Commit Graph

300570 Commits

Author SHA1 Message Date
Chayim Refael Friedman
59962413b6 Fix completion in when typing integer.|
It should show integer, not floating point methods.
2025-06-27 00:12:27 +03:00
Samuel Tardieu
9117cb0223 zero_ptr: lint in const context as well
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-26 23:09:37 +02:00
Chayim Refael Friedman
1a2e7aa3f7 Merge pull request #20100 from ShoyuVanilla/ignore-sized-hierarchy
Backport new sized-hierarchy trait bounds in old ways
2025-06-26 20:37:18 +00:00
bors
513999b936 Auto merge of #143057 - matthiaskrgr:rollup-bulih8o, r=matthiaskrgr
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-26 20:06:23 +00:00
Samuel Tardieu
c5dbd1de07 Lint docs: Sort versions, so that stable comes first (#15149)
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-26 19:13:14 +00:00
Pavel Grigorenko
8c15a69290 Tracking issue number for iter_macro 2025-06-26 21:30:02 +03:00
Michael Goulet
4e51e67a24 Better recovery 2025-06-26 18:11:14 +00:00
Michael Goulet
e63921262c Make recovery for enum with struct field a bit more accurate 2025-06-26 18:11:14 +00:00
Michael Goulet
94e9973b92 Add Ident::is_non_reserved_ident 2025-06-26 18:11:14 +00:00
Philipp Krones
22c0226aff Lint docs: Sort versions, so that stable comes first
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-26 19:59:04 +02:00
Philipp Krones
cd15aeb70b Ping notriddle when a clippy lint in clippy_lints/doc is modified (#15147)
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-26 17:48:02 +00:00
Hayashi Mikihiro
6240a2b5b9 generate new for tuple field
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
2025-06-27 02:39:04 +09:00
Philipp Krones
c950602c01 Rustup (#15148)
r? @ghost

changelog: none
2025-06-26 17:34:27 +00:00
binarycat
b2be01c815 rustdoc: show attributes on enum variants
mostly for #[non_exhaustive]
2025-06-26 12:33:30 -05:00
Philipp Krones
32fcff8aa8 Bump Clippy version -> 0.1.90 2025-06-26 19:30:02 +02:00
Philipp Krones
9b41d8fdb6 Bump nightly version -> 2025-06-26 2025-06-26 19:29:50 +02:00
Philipp Krones
90364dd178 Merge remote-tracking branch 'upstream/master' into rustup 2025-06-26 19:29:33 +02:00
binarycat
3b259ad33c rustdoc js: several typechecking improvments
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-26 12:16:35 -05:00
bors
b03b3a7ec9 Auto merge of #142774 - lcnr:search_graph-2, r=oli-obk
`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-26 17:04:47 +00:00
Philipp Krones
8050e591b6 Update book and templates with feature freeze (#14456)
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 😅.

changelog: Announce the feature freeze from May 9th to the first of
August
2025-06-26 16:45:13 +00:00
Samuel Tardieu
4116a72a08 Ping notriddle when a clippy lint in clippy_lints/doc is modified 2025-06-26 18:45:11 +02:00
Philipp Krones
b88d162d2a Add link to the feature freeze tracking issue to the book 2025-06-26 18:40:51 +02:00
Philipp Krones
40554ef4aa Add beta-accepted to CHANGELOG for 1.88 (#15130)
Add beta-accepted to CHANGELOG for 1.88 since it was missed at
rust-lang/rust-clippy#5095

changelog: none

r? flip1995
2025-06-26 16:30:45 +00:00
Michael Howell
664b143dac doc_nested_refdefs: do not falsely report checkboxes as refdefs 2025-06-26 09:19:59 -07:00
Jieyou Xu
0c1c648ea7 Add more missing APIs, and minor fixes
Co-authored-by: Josh Stone <cuviper@gmail.com>
2025-06-27 00:17:04 +08:00
Ralf Jung
bade3fd058 clarify and unify 'transient mutable borrow' errors 2025-06-26 18:11:24 +02:00
Ralf Jung
ff17a225e6 add more sensible mut-ref-to-immutable test 2025-06-26 18:09:48 +02:00
Ralf Jung
492526548d const-eval: allow constants to refer to mutable/external memory, but reject such constants as patterns 2025-06-26 18:09:47 +02:00
Michael Goulet
0d37587a30 Add a note and one more fast path 2025-06-26 15:56:36 +00:00
Michael Goulet
904458f27f Shallowly bail from coerce_unsized more 2025-06-26 15:53:06 +00:00
Michael Goulet
8242b55f50 Assert shallow resolved args in coerce 2025-06-26 15:52:48 +00:00
xizheyin
d1f313649c Only args in main diag are saved and restored without removing the newly added ones
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-26 23:06:38 +08:00
xizheyin
005dd432ed Add arguments sharing and isolation section in diagnostic-struct of rdg
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-26 22:34:44 +08:00
Jieyou Xu
fad27aa667 Add missing stabilized slice chunk methods 2025-06-26 22:24:08 +08:00
Jieyou Xu
bf9a5d4db2 Use stable std links 2025-06-26 22:23:45 +08:00
Shoyu Vanilla
1bd7565767 Backport new sized-hierarchy trait bounds in old ways 2025-06-26 23:22:26 +09:00
Matthias Krüger
2f8b715f10 Rollup merge of #142981 - compiler-errors:verbose-missing-suggestion, r=estebank
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-26 15:47:22 +02:00
Matthias Krüger
2fc94f119a Rollup merge of #142884 - makai410:coroutine-body, r=celinval
StableMIR: Add method to retrieve body of coroutine

It would be handy if we can retrieve body of a coroutine in StableMIR.
2025-06-26 15:47:21 +02:00
Matthias Krüger
a05f2cc44d Rollup merge of #142393 - compiler-errors:nofield, r=petrochenkov
Don't  give APITs names with macro expansion placeholder fragments in it

The `DefCollector` previously called `pprust::ty_to_string` to construct a name for APITs (arg-position impl traits). The `ast::Ty` that was being formatted however has already had its macro calls replaced with "placeholder fragments", which end up rendering like `!()` (or ICEing, in the case of rust-lang/rust#140333, since it led to a placeholder struct field with no name).

Instead, collect the name of the APIT *before* we visit its macros and replace them with placeholders in the macro expander. This makes the implementation a bit more involved, but AFAICT there's no better way to do this since we can't do a reverse mapping from placeholder fragment -> original macro call AST.

Fixes rust-lang/rust#140333
2025-06-26 15:47:20 +02:00
Matthias Krüger
d73bf103b9 Rollup merge of #142285 - workingjubilee:dont-use-bad-assembly, r=nnethercote
tests: Do not run afoul of asm.validity.non-exhaustive in input-stats

This addresses one of the three powerpc64-unknown-linux-musl test failures in https://github.com/rust-lang/rust/issues/142280

I was motivated to cover it myself because technically this is also compile-time UB if we compile a program that has `asm!` with x86-64-specific instructions on another platform. That'll only mean something if this is ever switched to build-pass, or if checking emits object code, but conveniently "nop" is valid assembly on all platforms anyone has implemented Rust codegen for. Even the weird ones LLVM doesn't support, like PA-RISC or Common Intermediate Language.

...except GPUs. Not sure about those.

r? ```@nnethercote```
2025-06-26 15:47:19 +02:00
Matthias Krüger
55d4f76c73 Rollup merge of #141648 - GuillaumeGomez:redundant_explicit_links-expansion, r=lolbinarycat
[rustdoc] Do not emit redundant_explicit_links lint if the doc comment comes from expansion

Fixes https://github.com/rust-lang/rust/issues/141553.

The problem was that we change the context for the attributes in some cases to get better error output, preventing us to detect if the attribute comes from expansion. Most of the changes are about keeping track of the "does this span comes from expansion" information.

r? ```@Manishearth```
2025-06-26 15:47:18 +02:00
Matthias Krüger
cbcf183711 Rollup merge of #141648 - GuillaumeGomez:redundant_explicit_links-expansion, r=lolbinarycat
[rustdoc] Do not emit redundant_explicit_links lint if the doc comment comes from expansion

Fixes https://github.com/rust-lang/rust/issues/141553.

The problem was that we change the context for the attributes in some cases to get better error output, preventing us to detect if the attribute comes from expansion. Most of the changes are about keeping track of the "does this span comes from expansion" information.

r? ```@Manishearth```
2025-06-26 15:47:18 +02:00
Matthias Krüger
158340f561 Rollup merge of #141311 - folkertdev:tidy-natural-sort, r=jieyouxu
make `tidy-alphabetical` use a natural sort

The idea here is that these lines should be correctly sorted, even though a naive string comparison would say they are not:

```
foo2
foo10
```

This is the ["natural sort order"](https://en.wikipedia.org/wiki/Natural_sort_order).

There is more discussion in [#t-compiler/help > tidy natural sort](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/tidy.20natural.20sort/with/519111079)

Unfortunately, no standard sorting tools are smart enough to to this automatically (casting some doubt on whether we should make this change). Here are some sort outputs:

```
> cat foo.txt | sort
foo
foo1
foo10
foo2
mp
mp1e2
np",
np1e2",
> cat foo.txt | sort -n
foo
foo1
foo10
foo2
mp
mp1e2
np",
np1e2",
> cat foo.txt | sort -V
foo
foo1
foo2
foo10
mp
mp1e2
np1e2",
np",
```

Disappointingly, "numeric" sort does not actually have the behavior we want. It only sorts by numeric value if the line starts with a number. The "version" sort looks promising, but does something very unintuitive if you look at the final 4 values. None of the other options seem to have the desired behavior in all cases:

```
  -b, --ignore-leading-blanks  ignore leading blanks
  -d, --dictionary-order      consider only blanks and alphanumeric characters
  -f, --ignore-case           fold lower case to upper case characters
  -g, --general-numeric-sort  compare according to general numerical value
  -i, --ignore-nonprinting    consider only printable characters
  -M, --month-sort            compare (unknown) < 'JAN' < ... < 'DEC'
  -h, --human-numeric-sort    compare human readable numbers (e.g., 2K 1G)
  -n, --numeric-sort          compare according to string numerical value
  -R, --random-sort           shuffle, but group identical keys.  See shuf(1)
      --random-source=FILE    get random bytes from FILE
  -r, --reverse               reverse the result of comparisons
      --sort=WORD             sort according to WORD:
                                general-numeric -g, human-numeric -h, month -M,
                                numeric -n, random -R, version -V
  -V, --version-sort          natural sort of (version) numbers within text
```

r? ```@Noratrieb``` (it sounded like you know this code?)
2025-06-26 15:47:17 +02:00
Matthias Krüger
d5d5eb471e Rollup merge of #139594 - compiler-errors:if-cause, r=oli-obk
Simplify `ObligationCauseCode::IfExpression`

This originally started out as an experiment to do less incremental invalidation by deferring the span operations that happen on the good path in `check_expr_if`, but it ended up not helping much (or at least not showing up in our incremental tests).

As a side-effect though, I think the code is a lot cleaner and there are modest diagnostics improvements with overlapping spans, so I think it's still worth landing.
2025-06-26 15:47:16 +02:00
Matthias Krüger
aa8ba54caf Rollup merge of #124595 - estebank:issue-104232, r=davidtwco
Suggest cloning `Arc` moved into closure

```
error[E0382]: borrow of moved value: `x`
  --> $DIR/moves-based-on-type-capture-clause-bad.rs:9:20
   |
LL |     let x = "Hello world!".to_string();
   |         - move occurs because `x` has type `String`, which does not implement the `Copy` trait
LL |     thread::spawn(move || {
   |                   ------- value moved into closure here
LL |         println!("{}", x);
   |                        - variable moved due to use in closure
LL |     });
LL |     println!("{}", x);
   |                    ^ value borrowed here after move
   |
   = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value before moving it into the closure
   |
LL ~     let value = x.clone();
LL ~     thread::spawn(move || {
LL ~         println!("{}", value);
   |
```

Fix rust-lang/rust#104232.
2025-06-26 15:47:16 +02:00
Oli Scherer
4f3c17486e Change const trait bound syntax from ~const to [const] 2025-06-26 13:46:45 +00:00
Oli Scherer
512ff95206 Rename tilde const test files to conditionally const 2025-06-26 13:46:45 +00:00
Oli Scherer
eb7245a864 Change const trait bound syntax from ~const to [const] 2025-06-26 13:46:45 +00:00
Ralf Jung
03901977c9 Merge pull request #4408 from Patrick-6/rework-thread-join
Only write join return value once join succeeds
2025-06-26 13:46:40 +00:00
León Orell Valerian Liehr
169e81cd59 Move an ACE test out of the GCI directory 2025-06-26 15:42:57 +02:00