Skip to content

Commit 22a86f8

Browse files
committed
Auto merge of #145644 - jhpratt:rollup-ypo3zcd, r=jhpratt
Rollup of 13 pull requests Successful merges: - #139357 (Fix parameter order for `_by()` variants of `min` / `max`/ `minmax` in `std::cmp`) - #140314 (Rustdoc: typecheck scrape-examples.js) - #140794 (mention lint group in default level lint note) - #145006 (Clarify EOF handling for `BufRead::skip_until`) - #145252 (Demote x86_64-apple-darwin to Tier 2 with host tools) - #145359 (Fix bug where `rustdoc-js` tester would not pick the right `search.js` file if there is more than one) - #145381 (Implement feature `int_lowest_highest_one` for integer and NonZero types) - #145417 (std_detect: RISC-V platform guide documentation) - #145531 (Add runtime detection for APX-F and AVX10) - #145619 (`std_detect`: Use `rustc-std-workspace-*` to pull in `compiler-builtins`) - #145622 (Remove the std workspace patch for `compiler-builtins`) - #145623 (Pretty print the name of an future from calling async closure) - #145626 (add a fallback implementation for the `prefetch_*` intrinsics ) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f605b57 + 816f098 commit 22a86f8

File tree

270 files changed

+1196
-577
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

270 files changed

+1196
-577
lines changed

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,16 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
330330
_ => bug!(),
331331
};
332332
let ptr = args[0].immediate();
333+
let locality = fn_args.const_at(1).to_value().valtree.unwrap_leaf().to_u32() as i32;
333334
self.call_intrinsic(
334335
"llvm.prefetch",
335336
&[self.val_ty(ptr)],
336-
&[ptr, self.const_i32(rw), args[1].immediate(), self.const_i32(cache_type)],
337+
&[
338+
ptr,
339+
self.const_i32(rw),
340+
self.const_i32(locality),
341+
self.const_i32(cache_type),
342+
],
337343
)
338344
}
339345
sym::carrying_mul_add => {

compiler/rustc_const_eval/src/util/type_name.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fmt::Write;
22

33
use rustc_data_structures::intern::Interned;
4-
use rustc_hir::def_id::CrateNum;
4+
use rustc_hir::def_id::{CrateNum, DefId};
55
use rustc_hir::definitions::DisambiguatedDefPathData;
66
use rustc_middle::bug;
77
use rustc_middle::ty::print::{PrettyPrinter, PrintError, Printer};
@@ -132,6 +132,35 @@ impl<'tcx> Printer<'tcx> for TypeNamePrinter<'tcx> {
132132
Ok(())
133133
}
134134
}
135+
136+
fn print_coroutine_with_kind(
137+
&mut self,
138+
def_id: DefId,
139+
parent_args: &'tcx [GenericArg<'tcx>],
140+
kind: Ty<'tcx>,
141+
) -> Result<(), PrintError> {
142+
self.print_def_path(def_id, parent_args)?;
143+
144+
let ty::Coroutine(_, args) = self.tcx.type_of(def_id).instantiate_identity().kind() else {
145+
// Could be `ty::Error`.
146+
return Ok(());
147+
};
148+
149+
let default_kind = args.as_coroutine().kind_ty();
150+
151+
match kind.to_opt_closure_kind() {
152+
_ if kind == default_kind => {
153+
// No need to mark the closure if it's the deduced coroutine kind.
154+
}
155+
Some(ty::ClosureKind::Fn) | None => {
156+
// Should never happen. Just don't mark anything rather than panicking.
157+
}
158+
Some(ty::ClosureKind::FnMut) => self.path.push_str("::{{call_mut}}"),
159+
Some(ty::ClosureKind::FnOnce) => self.path.push_str("::{{call_once}}"),
160+
}
161+
162+
Ok(())
163+
}
135164
}
136165

137166
impl<'tcx> PrettyPrinter<'tcx> for TypeNamePrinter<'tcx> {

compiler/rustc_hir_analysis/src/check/intrinsic.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -> hi
136136
| sym::round_ties_even_f64
137137
| sym::round_ties_even_f128
138138
| sym::autodiff
139+
| sym::prefetch_read_data
140+
| sym::prefetch_write_data
141+
| sym::prefetch_read_instruction
142+
| sym::prefetch_write_instruction
139143
| sym::const_eval_select => hir::Safety::Safe,
140144
_ => hir::Safety::Unsafe,
141145
};
@@ -218,7 +222,7 @@ pub(crate) fn check_intrinsic_type(
218222
| sym::prefetch_write_data
219223
| sym::prefetch_read_instruction
220224
| sym::prefetch_write_instruction => {
221-
(1, 0, vec![Ty::new_imm_ptr(tcx, param(0)), tcx.types.i32], tcx.types.unit)
225+
(1, 1, vec![Ty::new_imm_ptr(tcx, param(0))], tcx.types.unit)
222226
}
223227
sym::needs_drop => (1, 0, vec![], tcx.types.bool),
224228

compiler/rustc_lint/src/context.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use rustc_middle::ty::layout::{LayoutError, LayoutOfHelpers, TyAndLayout};
2424
use rustc_middle::ty::print::{PrintError, PrintTraitRefExt as _, Printer, with_no_trimmed_paths};
2525
use rustc_middle::ty::{self, GenericArg, RegisteredTools, Ty, TyCtxt, TypingEnv, TypingMode};
2626
use rustc_session::lint::{FutureIncompatibleInfo, Lint, LintBuffer, LintExpectationId, LintId};
27-
use rustc_session::{LintStoreMarker, Session};
27+
use rustc_session::{DynLintStore, Session};
2828
use rustc_span::edit_distance::find_best_match_for_names;
2929
use rustc_span::{Ident, Span, Symbol, sym};
3030
use tracing::debug;
@@ -62,7 +62,13 @@ pub struct LintStore {
6262
lint_groups: FxIndexMap<&'static str, LintGroup>,
6363
}
6464

65-
impl LintStoreMarker for LintStore {}
65+
impl DynLintStore for LintStore {
66+
fn lint_groups_iter(&self) -> Box<dyn Iterator<Item = rustc_session::LintGroup> + '_> {
67+
Box::new(self.get_lint_groups().map(|(name, lints, is_externally_loaded)| {
68+
rustc_session::LintGroup { name, lints, is_externally_loaded }
69+
}))
70+
}
71+
}
6672

6773
/// The target of the `by_name` map, which accounts for renaming/deprecation.
6874
#[derive(Debug)]

compiler/rustc_middle/src/lint.rs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,28 @@ impl LintExpectation {
211211
}
212212

213213
fn explain_lint_level_source(
214+
sess: &Session,
214215
lint: &'static Lint,
215216
level: Level,
216217
src: LintLevelSource,
217218
err: &mut Diag<'_, ()>,
218219
) {
220+
// Find the name of the lint group that contains the given lint.
221+
// Assumes the lint only belongs to one group.
222+
let lint_group_name = |lint| {
223+
let lint_groups_iter = sess.lint_groups_iter();
224+
let lint_id = LintId::of(lint);
225+
lint_groups_iter
226+
.filter(|lint_group| !lint_group.is_externally_loaded)
227+
.find(|lint_group| {
228+
lint_group
229+
.lints
230+
.iter()
231+
.find(|lint_group_lint| **lint_group_lint == lint_id)
232+
.is_some()
233+
})
234+
.map(|lint_group| lint_group.name)
235+
};
219236
let name = lint.name_lower();
220237
if let Level::Allow = level {
221238
// Do not point at `#[allow(compat_lint)]` as the reason for a compatibility lint
@@ -224,7 +241,15 @@ fn explain_lint_level_source(
224241
}
225242
match src {
226243
LintLevelSource::Default => {
227-
err.note_once(format!("`#[{}({})]` on by default", level.as_str(), name));
244+
let level_str = level.as_str();
245+
match lint_group_name(lint) {
246+
Some(group_name) => {
247+
err.note_once(format!("`#[{level_str}({name})]` (part of `#[{level_str}({group_name})]`) on by default"));
248+
}
249+
None => {
250+
err.note_once(format!("`#[{level_str}({name})]` on by default"));
251+
}
252+
}
228253
}
229254
LintLevelSource::CommandLine(lint_flag_val, orig_level) => {
230255
let flag = orig_level.to_cmd_flag();
@@ -427,7 +452,7 @@ pub fn lint_level(
427452
decorate(&mut err);
428453
}
429454

430-
explain_lint_level_source(lint, level, src, &mut err);
455+
explain_lint_level_source(sess, lint, level, src, &mut err);
431456
err.emit()
432457
}
433458
lint_level_impl(sess, lint, level, span, Box::new(decorate))

compiler/rustc_middle/src/ty/print/mod.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ pub trait Printer<'tcx>: Sized {
124124
trait_ref: Option<ty::TraitRef<'tcx>>,
125125
) -> Result<(), PrintError>;
126126

127+
fn print_coroutine_with_kind(
128+
&mut self,
129+
def_id: DefId,
130+
parent_args: &'tcx [GenericArg<'tcx>],
131+
kind: Ty<'tcx>,
132+
) -> Result<(), PrintError> {
133+
self.print_path_with_generic_args(|p| p.print_def_path(def_id, parent_args), &[kind.into()])
134+
}
135+
127136
// Defaults (should not be overridden):
128137

129138
#[instrument(skip(self), level = "debug")]
@@ -162,9 +171,10 @@ pub trait Printer<'tcx>: Sized {
162171
)) = self.tcx().coroutine_kind(def_id)
163172
&& args.len() > parent_args.len()
164173
{
165-
return self.print_path_with_generic_args(
166-
|p| p.print_def_path(def_id, parent_args),
167-
&args[..parent_args.len() + 1][..1],
174+
return self.print_coroutine_with_kind(
175+
def_id,
176+
parent_args,
177+
args[parent_args.len()].expect_ty(),
168178
);
169179
} else {
170180
// Closures' own generics are only captures, don't print them.

compiler/rustc_session/src/session.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ use crate::config::{
4444
SwitchWithOptPath,
4545
};
4646
use crate::filesearch::FileSearch;
47+
use crate::lint::LintId;
4748
use crate::parse::{ParseSess, add_feature_diagnostics};
4849
use crate::search_paths::SearchPath;
4950
use crate::{errors, filesearch, lint};
@@ -139,7 +140,10 @@ pub struct CompilerIO {
139140
pub temps_dir: Option<PathBuf>,
140141
}
141142

142-
pub trait LintStoreMarker: Any + DynSync + DynSend {}
143+
pub trait DynLintStore: Any + DynSync + DynSend {
144+
/// Provides a way to access lint groups without depending on `rustc_lint`
145+
fn lint_groups_iter(&self) -> Box<dyn Iterator<Item = LintGroup> + '_>;
146+
}
143147

144148
/// Represents the data associated with a compilation
145149
/// session for a single crate.
@@ -164,7 +168,7 @@ pub struct Session {
164168
pub code_stats: CodeStats,
165169

166170
/// This only ever stores a `LintStore` but we don't want a dependency on that type here.
167-
pub lint_store: Option<Arc<dyn LintStoreMarker>>,
171+
pub lint_store: Option<Arc<dyn DynLintStore>>,
168172

169173
/// Cap lint level specified by a driver specifically.
170174
pub driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
@@ -240,6 +244,12 @@ impl CodegenUnits {
240244
}
241245
}
242246

247+
pub struct LintGroup {
248+
pub name: &'static str,
249+
pub lints: Vec<LintId>,
250+
pub is_externally_loaded: bool,
251+
}
252+
243253
impl Session {
244254
pub fn miri_unleashed_feature(&self, span: Span, feature_gate: Option<Symbol>) {
245255
self.miri_unleashed_features.lock().push((span, feature_gate));
@@ -596,6 +606,13 @@ impl Session {
596606
(&*self.target.staticlib_prefix, &*self.target.staticlib_suffix)
597607
}
598608
}
609+
610+
pub fn lint_groups_iter(&self) -> Box<dyn Iterator<Item = LintGroup> + '_> {
611+
match self.lint_store {
612+
Some(ref lint_store) => lint_store.lint_groups_iter(),
613+
None => Box::new(std::iter::empty()),
614+
}
615+
}
599616
}
600617

601618
// JUSTIFICATION: defn of the suggested wrapper fns

compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub(crate) fn target() -> Target {
77
llvm_target,
88
metadata: TargetMetadata {
99
description: Some("x86_64 Apple macOS (10.12+, Sierra+)".into()),
10-
tier: Some(1),
10+
tier: Some(2),
1111
host_tools: Some(true),
1212
std: Some(true),
1313
},

library/Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,9 @@ dependencies = [
336336
name = "std_detect"
337337
version = "0.1.5"
338338
dependencies = [
339-
"alloc",
340-
"core",
341339
"libc",
340+
"rustc-std-workspace-alloc",
341+
"rustc-std-workspace-core",
342342
]
343343

344344
[[package]]

library/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,3 @@ rustflags = ["-Cpanic=abort"]
5959
rustc-std-workspace-core = { path = 'rustc-std-workspace-core' }
6060
rustc-std-workspace-alloc = { path = 'rustc-std-workspace-alloc' }
6161
rustc-std-workspace-std = { path = 'rustc-std-workspace-std' }
62-
compiler_builtins = { path = "compiler-builtins/compiler-builtins" }

0 commit comments

Comments
 (0)