Skip to content

Commit d852ffb

Browse files
committed
Auto merge of #158481 - JonathanBrouwer:rollup-KYHTTTs, r=<try>
Rollup of 10 pull requests try-job: dist-various-1 try-job: test-various try-job: x86_64-gnu-aux try-job: x86_64-gnu-llvm-21-3 try-job: x86_64-msvc-1 try-job: aarch64-apple try-job: x86_64-mingw-1 try-job: i686-msvc-2
2 parents 267c405 + b5267a1 commit d852ffb

36 files changed

Lines changed: 485 additions & 118 deletions

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2866,7 +2866,27 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
28662866
did,
28672867
path.segments.last().unwrap(),
28682868
);
2869-
ty::Const::zero_sized(tcx, Ty::new_fn_def(tcx, did, args))
2869+
2870+
if self.tcx().generics_of(did).own_synthetic_params_count() == 0 {
2871+
ty::Const::zero_sized(tcx, Ty::new_fn_def(tcx, did, args))
2872+
} else {
2873+
let tcx = self.tcx();
2874+
let generics = tcx.generics_of(did);
2875+
2876+
// Use infer tys for synthetic params; otherwise the impl header's trait ref may
2877+
// contain callee-owned synthetic params and fail when instantiated with impl args.
2878+
// See issue #155834
2879+
let args = args.iter().enumerate().map(|(index, arg)| {
2880+
let param = generics.param_at(index, tcx);
2881+
if param.kind.is_synthetic() {
2882+
self.ty_infer(Some(param), span).into()
2883+
} else {
2884+
arg
2885+
}
2886+
});
2887+
2888+
ty::Const::zero_sized(tcx, Ty::new_fn_def(tcx, did, args))
2889+
}
28702890
}
28712891

28722892
// Exhaustive match to be clear about what exactly we're considering to be

compiler/rustc_lint/src/context.rs

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,39 @@ type LateLintPassFactory =
4646
Box<dyn for<'tcx> Fn(TyCtxt<'tcx>) -> LateLintPassObject<'tcx> + sync::DynSend + sync::DynSync>;
4747

4848
/// Information about the registered lints.
49+
//
50+
// About the pass factories: these should only be called once, but since we
51+
// want to avoid locks or interior mutability, we don't enforce this. Lints
52+
// should, in theory, be compatible with being constructed more than once,
53+
// though not necessarily in a sane manner. This is safe though.
4954
pub struct LintStore {
5055
/// Registered lints.
5156
lints: Vec<&'static Lint>,
5257

53-
/// Constructor functions for each variety of lint pass.
58+
/// This lint pass kind is softly deprecated. It misses expanded code and has caused a few
59+
/// errors in the past. Currently, it is only used in Clippy. New implementations
60+
/// should avoid using this interface, as it might be removed in the future.
61+
///
62+
/// * See [rust#69838](https://github.com/rust-lang/rust/pull/69838)
63+
/// * See [rust-clippy#5518](https://github.com/rust-lang/rust-clippy/pull/5518)
64+
pub(crate) pre_expansion_lint_passes: Vec<EarlyLintPassFactory>,
65+
66+
/// These lint passes run on AST nodes.
67+
pub(crate) early_lint_passes: Vec<EarlyLintPassFactory>,
68+
69+
/// These lint passes run on HIR nodes. Each one processes an entire crate. They don't benefit
70+
/// from incremental compilation. `late_lint_mod_passes` should be used in preference where
71+
/// possible; only use `late_lint_passes` for lints that implement `check_crate` and/or
72+
/// `check_crate_post` and accumulate cross-module state.
5473
///
55-
/// These should only be called once, but since we want to avoid locks or
56-
/// interior mutability, we don't enforce this (and lints should, in theory,
57-
/// be compatible with being constructed more than once, though not
58-
/// necessarily in a sane manner. This is safe though.)
59-
pub pre_expansion_passes: Vec<EarlyLintPassFactory>,
60-
pub early_passes: Vec<EarlyLintPassFactory>,
61-
pub late_passes: Vec<LateLintPassFactory>,
62-
/// This is unique in that we construct them per-module, so not once.
63-
pub late_module_passes: Vec<LateLintPassFactory>,
74+
/// The exception is Clippy, which uses `late_lint_passes` for all late lint passes. It needs
75+
/// `check_crate`/`check_crate_post` for some of its lints and uses late lint passes throughout
76+
/// for consistency. This is ok because Clippy isn't wired for incremental compilation.
77+
pub(crate) late_lint_passes: Vec<LateLintPassFactory>,
78+
79+
/// These lint passes run on HIR nodes, and are constructed per-module (i.e. multiple times).
80+
/// They benefit from incremental compilation.
81+
pub(crate) late_lint_mod_passes: Vec<LateLintPassFactory>,
6482

6583
/// Lints indexed by name.
6684
by_name: UnordMap<String, TargetLint>,
@@ -136,10 +154,10 @@ impl LintStore {
136154
pub fn new() -> LintStore {
137155
LintStore {
138156
lints: vec![],
139-
pre_expansion_passes: vec![],
140-
early_passes: vec![],
141-
late_passes: vec![],
142-
late_module_passes: vec![],
157+
pre_expansion_lint_passes: vec![],
158+
early_lint_passes: vec![],
159+
late_lint_passes: vec![],
160+
late_lint_mod_passes: vec![],
143161
by_name: Default::default(),
144162
lint_groups: Default::default(),
145163
}
@@ -166,26 +184,24 @@ impl LintStore {
166184
self.lint_groups.keys().copied()
167185
}
168186

169-
pub fn register_early_pass(&mut self, pass: EarlyLintPassFactory) {
170-
self.early_passes.push(pass);
187+
/// See the comment on `LintStore::pre_expansion_lint_passes`.
188+
pub fn register_pre_expansion_lint_pass(&mut self, pass: EarlyLintPassFactory) {
189+
self.pre_expansion_lint_passes.push(pass);
171190
}
172191

173-
/// This lint pass is softly deprecated. It misses expanded code and has caused a few
174-
/// errors in the past. Currently, it is only used in Clippy. New implementations
175-
/// should avoid using this interface, as it might be removed in the future.
176-
///
177-
/// * See [rust#69838](https://github.com/rust-lang/rust/pull/69838)
178-
/// * See [rust-clippy#5518](https://github.com/rust-lang/rust-clippy/pull/5518)
179-
pub fn register_pre_expansion_pass(&mut self, pass: EarlyLintPassFactory) {
180-
self.pre_expansion_passes.push(pass);
192+
/// See the comment on `LintStore::early_lint_passes`.
193+
pub fn register_early_lint_pass(&mut self, pass: EarlyLintPassFactory) {
194+
self.early_lint_passes.push(pass);
181195
}
182196

183-
pub fn register_late_pass(&mut self, pass: LateLintPassFactory) {
184-
self.late_passes.push(pass);
197+
/// See the comment on `LintStore::late_lint_passes`.
198+
pub fn register_late_lint_pass(&mut self, pass: LateLintPassFactory) {
199+
self.late_lint_passes.push(pass);
185200
}
186201

187-
pub fn register_late_mod_pass(&mut self, pass: LateLintPassFactory) {
188-
self.late_module_passes.push(pass);
202+
/// See the comment on `LintStore::late_lint_mod_passes`.
203+
pub fn register_late_lint_mod_pass(&mut self, pass: LateLintPassFactory) {
204+
self.late_lint_mod_passes.push(pass);
189205
}
190206

191207
/// Helper method for register_early/late_pass

compiler/rustc_lint/src/early.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,11 @@ pub fn check_ast_node<'a>(
329329

330330
let context = if pre_expansion {
331331
let builtin_lints = crate::BuiltinCombinedPreExpansionLintPass::new();
332-
let passes = &lint_store.pre_expansion_passes;
332+
let passes = &lint_store.pre_expansion_lint_passes;
333333
run_passes(check_node, context, builtin_lints, passes)
334334
} else {
335335
let builtin_lints = crate::BuiltinCombinedEarlyLintPass::new();
336-
let passes = &lint_store.early_passes;
336+
let passes = &lint_store.early_lint_passes;
337337
run_passes(check_node, context, builtin_lints, passes)
338338
};
339339

compiler/rustc_lint/src/late.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>(
355355
// `builtin_lints` directly rather than bundling it up into the
356356
// `RuntimeCombinedLateLintPass`.
357357
let mut passes: Vec<_> = unerased_lint_store(tcx.sess)
358-
.late_module_passes
358+
.late_lint_mod_passes
359359
.iter()
360360
.map(|mk_pass| mk_pass(tcx))
361361
.filter(|pass| is_lint_pass_required(skippable_lints, &pass.get_lints()))
@@ -403,7 +403,7 @@ fn late_lint_crate<'tcx>(tcx: TyCtxt<'tcx>) {
403403

404404
// Note: `passes` is often empty after filtering.
405405
let passes: Vec<_> = unerased_lint_store(tcx.sess)
406-
.late_passes
406+
.late_lint_passes
407407
.iter()
408408
.map(|mk_pass| mk_pass(tcx))
409409
.filter(|pass| is_lint_pass_required(skippable_lints, &pass.get_lints()))

compiler/rustc_lint/src/lib.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pub fn provide(providers: &mut Providers) {
154154
}
155155

156156
fn lint_mod(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) {
157-
late_lint_mod(tcx, module_def_id, BuiltinCombinedModuleLateLintPass::new());
157+
late_lint_mod(tcx, module_def_id, BuiltinCombinedLateLintModPass::new());
158158
}
159159

160160
early_lint_methods!(
@@ -207,7 +207,7 @@ early_lint_methods!(
207207
late_lint_methods!(
208208
declare_combined_late_lint_pass,
209209
[
210-
BuiltinCombinedModuleLateLintPass,
210+
BuiltinCombinedLateLintModPass,
211211
[
212212
ForLoopsOverFallibles: ForLoopsOverFallibles,
213213
DefaultCouldBeDerived: DefaultCouldBeDerived,
@@ -279,7 +279,7 @@ late_lint_methods!(
279279
late_lint_methods!(
280280
declare_combined_late_lint_pass,
281281
[
282-
InternalCombinedModuleLateLintPass,
282+
InternalCombinedLateLintModPass,
283283
[
284284
DefaultHashTypes: DefaultHashTypes,
285285
QueryStability: QueryStability,
@@ -317,7 +317,7 @@ fn register_builtins(store: &mut LintStore) {
317317

318318
store.register_lints(&BuiltinCombinedPreExpansionLintPass::lint_vec());
319319
store.register_lints(&BuiltinCombinedEarlyLintPass::lint_vec());
320-
store.register_lints(&BuiltinCombinedModuleLateLintPass::lint_vec());
320+
store.register_lints(&BuiltinCombinedLateLintModPass::lint_vec());
321321
store.register_lints(&foreign_modules::lint_vec());
322322
store.register_lints(&hardwired::lint_vec());
323323

@@ -698,10 +698,12 @@ fn register_builtins(store: &mut LintStore) {
698698

699699
fn register_internals(store: &mut LintStore) {
700700
store.register_lints(&InternalCombinedEarlyLintPass::lint_vec());
701-
store.register_early_pass(Box::new(|| Box::new(InternalCombinedEarlyLintPass::new())));
701+
store.register_early_lint_pass(Box::new(|| Box::new(InternalCombinedEarlyLintPass::new())));
702702

703-
store.register_lints(&InternalCombinedModuleLateLintPass::lint_vec());
704-
store.register_late_mod_pass(Box::new(|_| Box::new(InternalCombinedModuleLateLintPass::new())));
703+
store.register_lints(&InternalCombinedLateLintModPass::lint_vec());
704+
store.register_late_lint_mod_pass(Box::new(|_| {
705+
Box::new(InternalCombinedLateLintModPass::new())
706+
}));
705707

706708
store.register_group(
707709
false,

compiler/rustc_lint/src/passes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ macro_rules! expand_combined_early_lint_pass_methods {
203203
/// Combines multiple lints passes into a single lint pass, at compile time,
204204
/// for maximum speed. Each `check_foo` method in `$methods` within this pass
205205
/// simply calls `check_foo` once per `$pass`. Compare with
206-
/// `EarlyLintPassObjects`, which is similar, but combines lint passes at
206+
/// `RuntimeCombinedEarlyLintPass`, which is similar, but combines lint passes at
207207
/// runtime.
208208
#[macro_export]
209209
macro_rules! declare_combined_early_lint_pass {

library/core/src/fmt/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,7 @@ mod flags {
332332
}
333333

334334
impl FormattingOptions {
335-
/// Construct a new `FormatterBuilder` with the supplied `Write` trait
336-
/// object for output that is equivalent to the `{}` formatting
337-
/// specifier:
335+
/// Construct a new `FormattingOptions` representing the plain `{}` formatting specifier:
338336
///
339337
/// - no flags,
340338
/// - filled with spaces,
@@ -518,7 +516,7 @@ impl FormattingOptions {
518516
pub const fn get_precision(&self) -> Option<u16> {
519517
if self.flags & flags::PRECISION_FLAG != 0 { Some(self.precision) } else { None }
520518
}
521-
/// Returns the current precision.
519+
/// Returns the current `x?` or `X?` flag.
522520
#[unstable(feature = "formatting_options", issue = "118117")]
523521
pub const fn get_debug_as_hex(&self) -> Option<DebugAsHex> {
524522
if self.flags & flags::DEBUG_LOWER_HEX_FLAG != 0 {

library/core/src/marker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ pub const trait Destruct: PointeeSized {}
10661066
///
10671067
/// The implementation of this trait is built-in and cannot be implemented
10681068
/// for any user type.
1069-
#[unstable(feature = "tuple_trait", issue = "none")]
1069+
#[unstable(feature = "tuple_trait", issue = "157987")]
10701070
#[lang = "tuple_trait"]
10711071
#[diagnostic::on_unimplemented(message = "`{Self}` is not a tuple")]
10721072
#[rustc_deny_explicit_impl]

0 commit comments

Comments
 (0)