about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2025-06-26Rollup merge of #142986 - JonathanBrouwer:export_name_parser, r=jdonszelmannMichael Goulet-125/+215
Port `#[export_name]` to the new attribute parsing infrastructure This PR contains two changes, in separate commits for reviewability: - Ports `export_name` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197 - Moves the check for mixing export_name/no_mangle to check_attr.rs and improve the error message, which previously had a mix of 2021/2024 edition syntax r? ``@jdonszelmann``
2025-06-26Rollup merge of #142967 - krikera:fix-rwlock-try-write-docs, r=jhprattMichael Goulet-1/+1
Fix RwLock::try_write documentation for WouldBlock condition Fix RwLock::try_write documentation for WouldBlock condition The documentation incorrectly stated that try_write only fails when 'already locked exclusively', but it actually fails when there are either shared (read) or exclusive (write) locks. Fixes rust-lang/rust#142852
2025-06-26Rollup merge of #142927 - compiler-errors:note-find-const, r=BoxyUwUMichael Goulet-48/+64
Add note to `find_const_ty_from_env` Add a note to `find_const_ty_from_env` to explain why it has an `unwrap` which "often" causes ICEs. Also, uplift it into the new trait solver. This avoids needing to go through the interner to call this method which is otherwise an inherent method in the compiler. I can remove this part if desired. r? `@boxyuwu`
2025-06-26Rollup merge of #142700 - theemathas:remove-weak-comment, r=ibraheemdevMichael Goulet-2/+0
Remove incorrect comments in `Weak` It is currently possible to create a dangling `Weak` to a DST by calling `Weak::new()` for a sized type, then doing an unsized coercion. Therefore, the comments are wrong. These comments were added in <https://github.com/rust-lang/rust/pull/73845>. As far as I can tell, the guarantee in the comment was only previously used in the `as_ptr` method. However, the current implementation of `as_ptr` no longer relies on this guarantee.
2025-06-26Rollup merge of #142647 - compiler-errors:less-work-in-coherence, r=lcnrMichael Goulet-24/+28
[perf] Compute hard errors without diagnostics in impl_intersection_has_impossible_obligation First compute hard errors without diagnostics, then ambiguities with diagnostics since we need to know if any of them overflowed.
2025-06-26Rollup merge of #142637 - compiler-errors:less-globs, r=lcnrMichael Goulet-208/+259
Remove some glob imports from the type system Namely, remove the glob imports for `BoundRegionConversionTime`, `RegionVariableOrigin`, `SubregionOrigin`, `TyOrConstInferVar`, `RegionResolutionError`, `SelectionError`, `ProjectionCandidate`, `ProjectionCandidateSet`, and some more specific scoped globs (like `Inserted` in the impl overlap graph construction. These glob imports are IMO very low value, since they're not used nearly as often as other globs (like `TyKind`).
2025-06-26Rollup merge of #142549 - the8472:intersperse-fold-tweak, r=tgross35Michael Goulet-1/+10
small iter.intersperse.fold() optimization No need to call into fold when the first item is already None, this avoids some redundant work for empty iterators. "But it uses Fuse" one might want to protest, but Fuse is specialized and may call into the inner iterator anyway.
2025-06-26Rollup merge of #140942 - RalfJung:const-ref-to-mut, r=oli-obkMichael Goulet-373/+448
const-eval: allow constants to refer to mutable/external memory, but reject such constants as patterns This fixes https://github.com/rust-lang/rust/issues/140653 by accepting code such as this: ```rust static FOO: AtomicU32 = AtomicU32::new(0); const C: &'static AtomicU32 = &FOO; ``` This can be written entirely in safe code, so there can't really be anything wrong with it. We also accept the much more questionable following code, since it looks very similar to the interpreter: ```rust static mut FOO2: u32 = 0; const C2: &'static u32 = unsafe { &mut FOO2 }; ``` Using this without causing UB is at least very hard (the details are unclear since it is related to how the aliasing model deals with the staging of const-eval vs runtime code). If a constant like `C2` is used as a pattern, we emit an error: ``` error: constant BAD_PATTERN cannot be used as pattern --> $DIR/const_refs_to_static_fail.rs:30:9 | LL | BAD_PATTERN => {}, | ^^^^^^^^^^^ | = note: constants that reference mutable or external memory cannot be used as pattern ``` (If you somehow manage to build a pattern with constant `C`, you'd get the same error, but that should be impossible: we don't have a type that can be used in patterns and that has interior mutability.) The same treatment is afforded for shared references to `extern static`, for the same reason: the const evaluation is entirely fine with it, we just can't build a pattern for it -- and when using interior mutability, this can be totally sound. We do still not accept anything where there is an `&mut` in the final value of the const, as that should always require unsafe code and it's hard to imagine a sound use-case that would require this.
2025-06-26Rollup merge of #137843 - Daniel-Aaron-Bloom:const_cell, r=oli-obkMichael Goulet-35/+138
make RefCell unstably const Now that we can do interior mutability in `const`, most of the `RefCell` API can be `const fn`. The main exceptions are APIs which use `FnOnce` (`RefCell::replace_with` and `Ref[Mut]::[filter_]map[_split]`) and `RefCell::take` which calls `Default::default`. Tracking issue: #137844
2025-06-26Fix some fixmes that were waiting for let chainsYotam Ofek-12/+11
2025-06-26mbe: Fold calls to `check_meta_variables` into the parser loopJosh Triplett-18/+8
2025-06-26Rewrite `macro_rules!` parser to not use the MBE engine itselfJosh Triplett-199/+65
The `macro_rules!` parser was written to match the series of rules using the macros-by-example (MBE) engine and a hand-written equivalent of the left-hand side of a MBE macro. This was complex to read, difficult to extend, and produced confusing error messages. Because it was using the MBE engine, any parse failure would be reported as if some macro was being applied to the `macro_rules!` invocation itself; for instance, errors would talk about "macro invocation", "macro arguments", and "macro call", when they were actually about the macro *definition*. And in practice, the `macro_rules!` parser only used the MBE engine to extract the left-hand side and right-hand side of each rule as a token tree, and then parsed the rest using a separate parser. Rewrite it to parse the series of rules using a simple loop, instead. This makes it more extensible in the future, and improves error messages. For instance, omitting a semicolon between rules will result in "expected `;`" and "unexpected token", rather than the confusing "no rules expected this token in macro call". This work was greatly aided by pair programming with Vincenzo Palazzo and Eric Holk.
2025-06-27Fix completion in when typing `integer.|`Chayim Refael Friedman-1/+50
It should show integer, not floating point methods.
2025-06-26`zero_ptr`: lint in `const` context as wellSamuel Tardieu-5/+30
The lint was extra restrictive, and didn't suggest using `core::ptr::null` and `core::ptr::null_mut` in `const` contexts although they have been const-stabilized since Rust 1.24.
2025-06-26Merge pull request #20100 from ShoyuVanilla/ignore-sized-hierarchyChayim Refael Friedman-65/+142
Backport new sized-hierarchy trait bounds in old ways
2025-06-26Auto merge of #143057 - matthiaskrgr:rollup-bulih8o, r=matthiaskrgrbors-569/+1204
Rollup of 8 pull requests Successful merges: - rust-lang/rust#124595 (Suggest cloning `Arc` moved into closure) - rust-lang/rust#139594 (Simplify `ObligationCauseCode::IfExpression`) - rust-lang/rust#141311 (make `tidy-alphabetical` use a natural sort) - rust-lang/rust#141648 ([rustdoc] Do not emit redundant_explicit_links lint if the doc comment comes from expansion) - rust-lang/rust#142285 (tests: Do not run afoul of asm.validity.non-exhaustive in input-stats) - rust-lang/rust#142393 (Don't give APITs names with macro expansion placeholder fragments in it) - rust-lang/rust#142884 (StableMIR: Add method to retrieve body of coroutine) - rust-lang/rust#142981 (Make missing lifetime suggestion verbose) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-26Lint docs: Sort versions, so that stable comes first (#15149)Samuel Tardieu-3/+3
I expect that most people use stable Clippy. So having `master` be the first documentation link in the list is weird. Now the versions are sorted stable->beta->master. changelog: none
2025-06-26Tracking issue number for `iter_macro`Pavel Grigorenko-3/+3
2025-06-26Better recoveryMichael Goulet-6/+27
2025-06-26Make recovery for enum with struct field a bit more accurateMichael Goulet-1/+18
2025-06-26Add Ident::is_non_reserved_identMichael Goulet-15/+14
2025-06-26Lint docs: Sort versions, so that stable comes firstPhilipp Krones-3/+3
I expect that most people use stable Clippy. So having `master` be the first documentation link in the list is weird. Now the versions are sorted stable->beta->master.
2025-06-26Ping notriddle when a clippy lint in `clippy_lints/doc` is modified (#15147)Philipp Krones-0/+3
Related to [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/257328-clippy/topic/Reviewing.20the.20.60doc.60.20lints/with/525943439). @notriddle Would you want that? changelog: none
2025-06-27generate new for tuple fieldHayashi Mikihiro-22/+337
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
2025-06-26Rustup (#15148)Philipp Krones-213/+277
r? @ghost changelog: none
2025-06-26rustdoc: show attributes on enum variantsbinarycat-0/+26
mostly for #[non_exhaustive]
2025-06-26Bump Clippy version -> 0.1.90Philipp Krones-5/+5
2025-06-26Bump nightly version -> 2025-06-26Philipp Krones-2/+2
2025-06-26Merge remote-tracking branch 'upstream/master' into rustupPhilipp Krones-855/+3168
2025-06-26rustdoc js: several typechecking improvmentsbinarycat-77/+43
non-exhaustive list of changes: * rustdoc.Results has a max_dist field * improve typechecking around pathDist and addIntoResults * give handleNameSearch a type signature * typecheck sortQ * currentCrate is string and not optional * searchState is referenced as a global, not through window
2025-06-26Auto merge of #142774 - lcnr:search_graph-2, r=oli-obkbors-163/+73
`evaluate_goal` avoid unnecessary step based on rust-lang/rust#142617. This does not mess with the debug logging for the trait solver and is a very nice cleanup for rust-lang/rust#142735. E.g. for ```rust #[derive(Clone)] struct Wrapper<T>(T); #[derive(Clone)] struct Nested; // using a separate type to avoid the fast paths fn is_clone<T: Clone>() {} fn main() { is_clone::<Wrapper<Nested>>(); } ``` We get the following proof tree with `RUSTC_LOG=rustc_type_ir::search_graph=debug,rustc_next_trait_solver=debug` ``` rustc_next_trait_solver::solve::eval_ctxt::evaluate_root_goal goal=Goal { param_env: ParamEnv { caller_bounds: [] }, predicate: Binder { value: TraitPredicate(<Wrapper<Nested> as std::clone::Clone>, polarity:Positive), bound_vars: [] } }, generate_proof_tree=No, span=src/main.rs:7:5: 7:34 (#0), stalled_on=None rustc_type_ir::search_graph::evaluate_goal input=CanonicalQueryInput { canonical: Canonical { value: QueryInput { goal: Goal { param_env: ParamEnv { caller_bounds: [] }, predicate: Binder { value: TraitPredicate(<Wrapper<Nested> as std::clone::Clone>, polarity:Positive), bound_vars: [] } }, predefined_opaques_in_body: PredefinedOpaques(PredefinedOpaquesData { opaque_types: [] }) }, max_universe: U0, variables: [] }, typing_mode: Analysis { defining_opaque_types_and_generators: [] } }, step_kind_from_parent=Unknown rustc_next_trait_solver::solve::eval_ctxt::probe::enter source=Impl(DefId(0:10 ~ main[21d2]::{impl#0})) rustc_next_trait_solver::solve::eval_ctxt::add_goal source=ImplWhereBound, goal=Goal { param_env: ParamEnv { caller_bounds: [] }, predicate: Binder { value: TraitPredicate(<_ as std::marker::Sized>, polarity:Positive), bound_vars: [] } } rustc_next_trait_solver::solve::eval_ctxt::add_goal source=ImplWhereBound, goal=Goal { param_env: ParamEnv { caller_bounds: [] }, predicate: Binder { value: TraitPredicate(<_ as std::clone::Clone>, polarity:Positive), bound_vars: [] } } rustc_type_ir::search_graph::evaluate_goal input=CanonicalQueryInput { canonical: Canonical { value: QueryInput { goal: Goal { param_env: ParamEnv { caller_bounds: [] }, predicate: Binder { value: TraitPredicate(<Nested as std::clone::Clone>, polarity:Positive), bound_vars: [] } }, predefined_opaques_in_body: PredefinedOpaques(PredefinedOpaquesData { opaque_types: [] }) }, max_universe: U0, variables: [] }, typing_mode: Analysis { defining_opaque_types_and_generators: [] } }, step_kind_from_parent=Unknown 0ms DEBUG rustc_type_ir::search_graph global cache hit, required_depth=0 0ms DEBUG rustc_type_ir::search_graph return=Ok(Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: [], opaque_types: [], normalization_nested_goals: NestedNormalizationGoals([]) }) }, max_universe: U0, variables: [] }) rustc_next_trait_solver::solve::eval_ctxt::probe::enter source=BuiltinImpl(Misc) rustc_next_trait_solver::solve::trait_goals::merge_trait_candidates candidates=[Candidate { source: Impl(DefId(0:10 ~ main[21d2]::{impl#0})), result: Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: [], opaque_types: [], normalization_nested_goals: NestedNormalizationGoals([]) }) }, max_universe: U0, variables: [] } }] 0ms DEBUG rustc_next_trait_solver::solve::trait_goals return=Ok((Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: [], opaque_types: [], normalization_nested_goals: NestedNormalizationGoals([]) }) }, max_universe: U0, variables: [] }, Some(Misc))) 0ms DEBUG rustc_type_ir::search_graph insert global cache, evaluation_result=EvaluationResult { encountered_overflow: false, required_depth: 1, heads: CycleHeads { heads: {} }, nested_goals: NestedGoals { nested_goals: {} }, result: Ok(Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: [], opaque_types: [], normalization_nested_goals: NestedNormalizationGoals([]) }) }, max_universe: U0, variables: [] }) } 0ms DEBUG rustc_type_ir::search_graph return=Ok(Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: [], opaque_types: [], normalization_nested_goals: NestedNormalizationGoals([]) }) }, max_universe: U0, variables: [] }) ```
2025-06-26Update book and templates with feature freeze (#14456)Philipp Krones-1/+95
This PR announces the feature freeze period talked about in https://github.com/rust-lang/rust-clippy/issues/14364 1. Add the page to the book 2. Modify the in-Github templates. 3. The third commit (to be squashed into the first) rolls the date mentioned 6 weeks (so, starting on May 9th and ending on August 20th). This gives us a comfortable buffer to make choices for this period. We have a pending discussion on the #14364. So having some more time to make choices is very nice. I'm also preparing a Github action for detecting new lints and posting a comment about the feature freeze (being worked on in another branch) Something I'd like comment on is the date formatting. I'm not sure if "May 9th to the first of August" is the correct way of writing this information in a book :sweat_smile:. changelog: Announce the feature freeze from May 9th to the first of August
2025-06-26Ping notriddle when a clippy lint in `clippy_lints/doc` is modifiedSamuel Tardieu-0/+3
2025-06-26Add link to the feature freeze tracking issue to the bookPhilipp Krones-1/+5
2025-06-26Add beta-accepted to CHANGELOG for 1.88 (#15130)Philipp Krones-0/+16
Add beta-accepted to CHANGELOG for 1.88 since it was missed at rust-lang/rust-clippy#5095 changelog: none r? flip1995
2025-06-26doc_nested_refdefs: do not falsely report checkboxes as refdefsMichael Howell-32/+6
2025-06-27Add more missing APIs, and minor fixesJieyou Xu-6/+8
Co-authored-by: Josh Stone <cuviper@gmail.com>
2025-06-26clarify and unify 'transient mutable borrow' errorsRalf Jung-112/+83
2025-06-26add more sensible mut-ref-to-immutable testRalf Jung-8/+21
2025-06-26const-eval: allow constants to refer to mutable/external memory, but reject ↵Ralf Jung-253/+344
such constants as patterns
2025-06-26Add a note and one more fast pathMichael Goulet-0/+23
2025-06-26Shallowly bail from coerce_unsized moreMichael Goulet-0/+25
2025-06-26Assert shallow resolved args in coerceMichael Goulet-19/+22
2025-06-26Only args in main diag are saved and restored without removing the newly ↵xizheyin-11/+5
added ones Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-26Add `arguments sharing and isolation` section in `diagnostic-struct` of rdgxizheyin-8/+39
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-26Add missing stabilized slice chunk methodsJieyou Xu-0/+6
2025-06-26Use stable std linksJieyou Xu-2/+2
2025-06-26Backport new sized-hierarchy trait bounds in old waysShoyu Vanilla-24/+78
2025-06-26Rollup merge of #142981 - compiler-errors:verbose-missing-suggestion, r=estebankMatthias Krüger-123/+247
Make missing lifetime suggestion verbose I keep seeing this suggestion when working on rustc, and it's annoying that it's inline. Part of https://github.com/rust-lang/rust/issues/141973. Feel free to close this if there's another PR already doing this. r? ``@estebank``
2025-06-26Rollup merge of #142884 - makai410:coroutine-body, r=celinvalMatthias Krüger-0/+111
StableMIR: Add method to retrieve body of coroutine It would be handy if we can retrieve body of a coroutine in StableMIR.