Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b11a76b
tests: modify s390x vector test to be robust to instruction scheduling
durin42 Jun 23, 2026
247e6e1
Add missing links in integer docs
GuillaumeGomez Jun 26, 2026
87f3254
Cross-referencing tuple_trait tracking issue, source and the Unstable…
peter-lyons-kehl Jun 22, 2026
e7da124
Improve documentation on lint passes
nnethercote Jun 15, 2026
e983dd7
Fix a comment
nnethercote Jun 16, 2026
969db62
Rename `*CombinedModuleLateLintPass`
nnethercote Jun 18, 2026
cd8d703
Rename some lint pass things
nnethercote Jun 18, 2026
879aba1
Make `LintStore::*_lint_passes` non-`pub`
nnethercote Jun 18, 2026
67f85db
Add proc macro for unused assignments and corresponding test
chenyukang Jun 27, 2026
480ddb0
Add regression test for unexpected pointer dereference issue
chenyukang Jun 27, 2026
4bbd8fc
Use infer tys for synthetic params when lowering const paths point to…
mu001999 Jun 8, 2026
1af87c1
Fix doc comment on get_debug_as_hex.
m-ou-se Jun 27, 2026
36cd136
Fix doc comment on FormattingOptions::new().
m-ou-se Jun 27, 2026
fc35c23
add crashtests
cyrgani Jun 23, 2026
f68986a
Rollup merge of #158234 - peter-lyons-kehl:unstable_book_tuple_trait,…
JonathanBrouwer Jun 27, 2026
6c65e85
Rollup merge of #157625 - mu001999:fix-155834, r=JohnTitor
JonathanBrouwer Jun 27, 2026
6db4f9f
Rollup merge of #158290 - cyrgani:tests-incoming, r=nnethercote
JonathanBrouwer Jun 27, 2026
0205d1b
Rollup merge of #158306 - durin42:llvm-23-s390x-vec, r=JohnTitor
JonathanBrouwer Jun 27, 2026
1340d86
Rollup merge of #158431 - nnethercote:more-lint-cleanups, r=Urgau
JonathanBrouwer Jun 27, 2026
42ab90a
Rollup merge of #158452 - GuillaumeGomez:missing-links, r=JohnTitor
JonathanBrouwer Jun 27, 2026
01f3d25
Rollup merge of #158467 - chenyukang:yukang-rework-on-fix-unused_assi…
JonathanBrouwer Jun 27, 2026
160968e
Rollup merge of #158472 - chenyukang:yukang-fix-154568-unexpected-poi…
JonathanBrouwer Jun 27, 2026
b8a8bce
Rollup merge of #158475 - m-ou-se:fix-doc-comment, r=JonathanBrouwer
JonathanBrouwer Jun 27, 2026
b5267a1
Rollup merge of #158476 - m-ou-se:doc-comment-fmt-options-new, r=Jona…
JonathanBrouwer Jun 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2866,7 +2866,27 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
did,
path.segments.last().unwrap(),
);
ty::Const::zero_sized(tcx, Ty::new_fn_def(tcx, did, args))

if self.tcx().generics_of(did).own_synthetic_params_count() == 0 {
ty::Const::zero_sized(tcx, Ty::new_fn_def(tcx, did, args))
} else {
let tcx = self.tcx();
let generics = tcx.generics_of(did);

// Use infer tys for synthetic params; otherwise the impl header's trait ref may
// contain callee-owned synthetic params and fail when instantiated with impl args.
// See issue #155834
let args = args.iter().enumerate().map(|(index, arg)| {
let param = generics.param_at(index, tcx);
if param.kind.is_synthetic() {
self.ty_infer(Some(param), span).into()
} else {
arg
}
});

ty::Const::zero_sized(tcx, Ty::new_fn_def(tcx, did, args))
}
}

// Exhaustive match to be clear about what exactly we're considering to be
Expand Down
72 changes: 44 additions & 28 deletions compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,39 @@ type LateLintPassFactory =
Box<dyn for<'tcx> Fn(TyCtxt<'tcx>) -> LateLintPassObject<'tcx> + sync::DynSend + sync::DynSync>;

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

/// Constructor functions for each variety of lint pass.
/// This lint pass kind is softly deprecated. It misses expanded code and has caused a few
/// errors in the past. Currently, it is only used in Clippy. New implementations
/// should avoid using this interface, as it might be removed in the future.
///
/// * See [rust#69838](https://github.com/rust-lang/rust/pull/69838)
/// * See [rust-clippy#5518](https://github.com/rust-lang/rust-clippy/pull/5518)
pub(crate) pre_expansion_lint_passes: Vec<EarlyLintPassFactory>,

/// These lint passes run on AST nodes.
pub(crate) early_lint_passes: Vec<EarlyLintPassFactory>,

/// These lint passes run on HIR nodes. Each one processes an entire crate. They don't benefit
/// from incremental compilation. `late_lint_mod_passes` should be used in preference where
/// possible; only use `late_lint_passes` for lints that implement `check_crate` and/or
/// `check_crate_post` and accumulate cross-module state.
///
/// These should only be called once, but since we want to avoid locks or
/// interior mutability, we don't enforce this (and lints should, in theory,
/// be compatible with being constructed more than once, though not
/// necessarily in a sane manner. This is safe though.)
pub pre_expansion_passes: Vec<EarlyLintPassFactory>,
pub early_passes: Vec<EarlyLintPassFactory>,
pub late_passes: Vec<LateLintPassFactory>,
/// This is unique in that we construct them per-module, so not once.
pub late_module_passes: Vec<LateLintPassFactory>,
/// The exception is Clippy, which uses `late_lint_passes` for all late lint passes. It needs
/// `check_crate`/`check_crate_post` for some of its lints and uses late lint passes throughout
/// for consistency. This is ok because Clippy isn't wired for incremental compilation.
pub(crate) late_lint_passes: Vec<LateLintPassFactory>,

/// These lint passes run on HIR nodes, and are constructed per-module (i.e. multiple times).
/// They benefit from incremental compilation.
pub(crate) late_lint_mod_passes: Vec<LateLintPassFactory>,

/// Lints indexed by name.
by_name: UnordMap<String, TargetLint>,
Expand Down Expand Up @@ -136,10 +154,10 @@ impl LintStore {
pub fn new() -> LintStore {
LintStore {
lints: vec![],
pre_expansion_passes: vec![],
early_passes: vec![],
late_passes: vec![],
late_module_passes: vec![],
pre_expansion_lint_passes: vec![],
early_lint_passes: vec![],
late_lint_passes: vec![],
late_lint_mod_passes: vec![],
by_name: Default::default(),
lint_groups: Default::default(),
}
Expand All @@ -166,26 +184,24 @@ impl LintStore {
self.lint_groups.keys().copied()
}

pub fn register_early_pass(&mut self, pass: EarlyLintPassFactory) {
self.early_passes.push(pass);
/// See the comment on `LintStore::pre_expansion_lint_passes`.
pub fn register_pre_expansion_lint_pass(&mut self, pass: EarlyLintPassFactory) {
self.pre_expansion_lint_passes.push(pass);
}

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

pub fn register_late_pass(&mut self, pass: LateLintPassFactory) {
self.late_passes.push(pass);
/// See the comment on `LintStore::late_lint_passes`.
pub fn register_late_lint_pass(&mut self, pass: LateLintPassFactory) {
self.late_lint_passes.push(pass);
}

pub fn register_late_mod_pass(&mut self, pass: LateLintPassFactory) {
self.late_module_passes.push(pass);
/// See the comment on `LintStore::late_lint_mod_passes`.
pub fn register_late_lint_mod_pass(&mut self, pass: LateLintPassFactory) {
self.late_lint_mod_passes.push(pass);
}

/// Helper method for register_early/late_pass
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/early.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,11 @@ pub fn check_ast_node<'a>(

let context = if pre_expansion {
let builtin_lints = crate::BuiltinCombinedPreExpansionLintPass::new();
let passes = &lint_store.pre_expansion_passes;
let passes = &lint_store.pre_expansion_lint_passes;
run_passes(check_node, context, builtin_lints, passes)
} else {
let builtin_lints = crate::BuiltinCombinedEarlyLintPass::new();
let passes = &lint_store.early_passes;
let passes = &lint_store.early_lint_passes;
run_passes(check_node, context, builtin_lints, passes)
};

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>(
// `builtin_lints` directly rather than bundling it up into the
// `RuntimeCombinedLateLintPass`.
let mut passes: Vec<_> = unerased_lint_store(tcx.sess)
.late_module_passes
.late_lint_mod_passes
.iter()
.map(|mk_pass| mk_pass(tcx))
.filter(|pass| is_lint_pass_required(skippable_lints, &pass.get_lints()))
Expand Down Expand Up @@ -403,7 +403,7 @@ fn late_lint_crate<'tcx>(tcx: TyCtxt<'tcx>) {

// Note: `passes` is often empty after filtering.
let passes: Vec<_> = unerased_lint_store(tcx.sess)
.late_passes
.late_lint_passes
.iter()
.map(|mk_pass| mk_pass(tcx))
.filter(|pass| is_lint_pass_required(skippable_lints, &pass.get_lints()))
Expand Down
16 changes: 9 additions & 7 deletions compiler/rustc_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ pub fn provide(providers: &mut Providers) {
}

fn lint_mod(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) {
late_lint_mod(tcx, module_def_id, BuiltinCombinedModuleLateLintPass::new());
late_lint_mod(tcx, module_def_id, BuiltinCombinedLateLintModPass::new());
}

early_lint_methods!(
Expand Down Expand Up @@ -207,7 +207,7 @@ early_lint_methods!(
late_lint_methods!(
declare_combined_late_lint_pass,
[
BuiltinCombinedModuleLateLintPass,
BuiltinCombinedLateLintModPass,
[
ForLoopsOverFallibles: ForLoopsOverFallibles,
DefaultCouldBeDerived: DefaultCouldBeDerived,
Expand Down Expand Up @@ -279,7 +279,7 @@ late_lint_methods!(
late_lint_methods!(
declare_combined_late_lint_pass,
[
InternalCombinedModuleLateLintPass,
InternalCombinedLateLintModPass,
[
DefaultHashTypes: DefaultHashTypes,
QueryStability: QueryStability,
Expand Down Expand Up @@ -317,7 +317,7 @@ fn register_builtins(store: &mut LintStore) {

store.register_lints(&BuiltinCombinedPreExpansionLintPass::lint_vec());
store.register_lints(&BuiltinCombinedEarlyLintPass::lint_vec());
store.register_lints(&BuiltinCombinedModuleLateLintPass::lint_vec());
store.register_lints(&BuiltinCombinedLateLintModPass::lint_vec());
store.register_lints(&foreign_modules::lint_vec());
store.register_lints(&hardwired::lint_vec());

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

fn register_internals(store: &mut LintStore) {
store.register_lints(&InternalCombinedEarlyLintPass::lint_vec());
store.register_early_pass(Box::new(|| Box::new(InternalCombinedEarlyLintPass::new())));
store.register_early_lint_pass(Box::new(|| Box::new(InternalCombinedEarlyLintPass::new())));

store.register_lints(&InternalCombinedModuleLateLintPass::lint_vec());
store.register_late_mod_pass(Box::new(|_| Box::new(InternalCombinedModuleLateLintPass::new())));
store.register_lints(&InternalCombinedLateLintModPass::lint_vec());
store.register_late_lint_mod_pass(Box::new(|_| {
Box::new(InternalCombinedLateLintModPass::new())
}));

store.register_group(
false,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ macro_rules! expand_combined_early_lint_pass_methods {
/// Combines multiple lints passes into a single lint pass, at compile time,
/// for maximum speed. Each `check_foo` method in `$methods` within this pass
/// simply calls `check_foo` once per `$pass`. Compare with
/// `EarlyLintPassObjects`, which is similar, but combines lint passes at
/// `RuntimeCombinedEarlyLintPass`, which is similar, but combines lint passes at
/// runtime.
#[macro_export]
macro_rules! declare_combined_early_lint_pass {
Expand Down
6 changes: 2 additions & 4 deletions library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,7 @@ mod flags {
}

impl FormattingOptions {
/// Construct a new `FormatterBuilder` with the supplied `Write` trait
/// object for output that is equivalent to the `{}` formatting
/// specifier:
/// Construct a new `FormattingOptions` representing the plain `{}` formatting specifier:
///
/// - no flags,
/// - filled with spaces,
Expand Down Expand Up @@ -518,7 +516,7 @@ impl FormattingOptions {
pub const fn get_precision(&self) -> Option<u16> {
if self.flags & flags::PRECISION_FLAG != 0 { Some(self.precision) } else { None }
}
/// Returns the current precision.
/// Returns the current `x?` or `X?` flag.
#[unstable(feature = "formatting_options", issue = "118117")]
pub const fn get_debug_as_hex(&self) -> Option<DebugAsHex> {
if self.flags & flags::DEBUG_LOWER_HEX_FLAG != 0 {
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ pub const trait Destruct: PointeeSized {}
///
/// The implementation of this trait is built-in and cannot be implemented
/// for any user type.
#[unstable(feature = "tuple_trait", issue = "none")]
#[unstable(feature = "tuple_trait", issue = "157987")]
#[lang = "tuple_trait"]
#[diagnostic::on_unimplemented(message = "`{Self}` is not a tuple")]
#[rustc_deny_explicit_impl]
Expand Down
Loading
Loading