Commit graph

278 commits

Author SHA1 Message Date
Esteban Küber
c73b3d20c6 Unify wording of resolve error
Remove "failed to resolve" and use the same format we use in other resolution errors "cannot find `name`".

```
error[E0433]: cannot find `nonexistent` in `existent`
  --> $DIR/custom_attr_multisegment_error.rs:5:13
   |
LL | #[existent::nonexistent]
   |             ^^^^^^^^^^^ could not find `nonexistent` in `existent`
```
2026-02-17 16:51:44 +00:00
lcnr
7e14260fd1 probe_op silence ambiguity errors if tainted
see the `proc-macro/quote/not-repeatable.rs` test for a case where this is useful
2026-02-16 19:36:09 +00:00
Esteban Küber
6c8eee8297 reword span label 2026-02-01 18:20:31 +00:00
Esteban Küber
dd8148373f Tweak span labels 2026-02-01 18:20:30 +00:00
Esteban Küber
aebf1fdcf9 Keep span of type in builtin derive macros expansions 2026-02-01 18:20:30 +00:00
Esteban Küber
54fe73fd6d Tweak span labels caused by trait bound coming from derive expansion
```
note: required for `B<C>` to implement `Copy`
  --> $DIR/deriving-copyclone.rs:9:10
   |
LL | #[derive(Copy, Clone)]
   |          ^^^^ unsatisfied trait bound introduced in this `derive` macro
LL | struct B<T> {
   |          - would need to be `Copy`
```
2026-02-01 18:20:30 +00:00
Esteban Küber
679f38c125 On E0277 pointing at bound in derive, suggest manual impl
When encountering a bound coming from a derive macro, suggest manual impl of the trait.

Use the span for the specific param when adding bounds in builtin derive macros, so the diagnostic will point at them as well as the derive macro itself.

```
error[E0277]: can't compare `SomeNode` with `SomeNode`
  --> f29.rs:24:15
   |
24 |     accept_eq(&node);
   |     --------- ^^^^^ no implementation for `SomeNode == SomeNode`
   |     |
   |     required by a bound introduced by this call
   |
   = note: -Ztrack-diagnostics: created at compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs:279:39
   = help: the trait `PartialEq` is not implemented for `SomeNode`
note: required for `Id<SomeNode>` to implement `PartialEq`
  --> f29.rs:3:10
   |
 3 | #[derive(PartialEq, Eq)]
   |          ^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
 4 | pub struct Id<T>(PhantomData<T>);
   |               -
   = help: consider manually implementing `PartialEq` to avoid undesired bounds
note: required by a bound in `accept_eq`
  --> f29.rs:15:23
   |
15 | fn accept_eq(_: &impl PartialEq) { }
   |                       ^^^^^^^^^ required by this bound in `accept_eq`
help: consider annotating `SomeNode` with `#[derive(PartialEq)]`
   |
13 + #[derive(PartialEq)]
14 | struct SomeNode();
   |
```
2026-02-01 18:20:30 +00:00
Yuki Okushi
4b22ee9fc5 Tweak E0599 to consolidate unsatisfied trait bound messages 2026-01-29 17:26:32 +09:00
Vadim Petrochenkov
5726e37819 resolve: Replace Macros20NormalizedIdent with IdentKey 2026-01-27 18:11:52 +03:00
zedddie
2dbcc72d85
clean up some tests 2026-01-22 19:50:00 +01:00
zedddie
3815b05ccd
move some tests 2026-01-22 19:50:00 +01:00
Stuart Cook
8461682729
Rollup merge of #151384 - pm-tokenstream-tests, r=Kivooeo
add basic `TokenStream` api tests

There were none so far. Especially helpful for rust-lang/rust#130856.
2026-01-20 18:00:11 +11:00
cyrgani
60e488ec07 add basic TokenStream api tests 2026-01-19 21:46:52 +00:00
Zalathar
2df2c72d7a Ignore #[doc(hidden)] items when computing trimmed paths 2026-01-19 12:27:27 +11:00
Jonathan Brouwer
cbcd1c3eef
Rollup merge of #151036 - issue-151026, r=mati865
Better handle when trying to iterate on a `Range` of a type that isn't `Step`

Mention when a trait bound corresponds to an unstable trait.

Mention `Range` when `Step` bound is unment, and explain that only some std types impl `Iterator` for `Range`.

CC rust-lang/rust#151026
2026-01-14 11:05:40 +01:00
Lukas Bergdoll
506762f3ff Explicitly export core and std macros
Currently all core and std macros are automatically added to the prelude
via #[macro_use]. However a situation arose where we want to add a new macro
`assert_matches` but don't want to pull it into the standard prelude for
compatibility reasons. By explicitly exporting the macros found in the core and
std crates we get to decide on a per macro basis and can later add them via
the rust_20xx preludes.
2026-01-13 08:47:48 +01:00
Esteban Küber
cafe91749f On unmet trait bound, mention if trait is unstable 2026-01-13 01:16:58 +00:00
Vadim Petrochenkov
888e28b41b resolve: Pass a normalized ident to resolve_ident_in_scope
In practice it was already normalized because `visit_scopes` normalized it
2026-01-07 17:06:18 +03:00
Jonathan Brouwer
ed5a529df1
Rollup merge of #150504 - AprilNEA:fix-99173, r=JonathanBrouwer
Add regression test for issue #99173

Close rust-lang/rust#99173.

Adds a regression test for rust-lang/rust#99173, which was an ICE that occurred when a proc-macro generated code that invoked another proc-macro returning an empty `TokenStream`.
2026-01-02 00:04:08 +01:00
AprilNEA
b3c3604f62
Add regression test for issue 99173
Adds a test for nested proc-macro calls where the inner macro returns an
empty TokenStream.
This previously caused an ICE in rustc_resolve.
2025-12-30 17:59:40 +08:00
cyrgani
8fc2acadae test and document that proc_macro::Ident is NFC-normalized 2025-12-27 13:52:40 +00:00
Jonathan Brouwer
ae39d3d9ab
Improve spans of malformed attribute errors 2025-12-13 17:13:36 +01:00
Matthias Krüger
1553fcc240
Rollup merge of #149883 - cyrgani:sub-err-diag, r=Kivooeo
add regression test for `proc_macro` error subdiagnostics

The previous ICE was already fixed by rust-lang/rust#148188, but no test was added at that time.
Closes rust-lang/rust#145305.
2025-12-12 12:19:10 +01:00
Matthias Krüger
b826d06771
Rollup merge of #149791 - clubby789:cfg-bool-lints, r=jdonszelmann
Remove uses of `cfg({any()/all()})`

~~This implements the followup warning suggested in https://github.com/rust-lang/rfcs/pull/3695~~
~~Lint against an empty `cfg(any/all)`, suggest the boolean literal equivalents.~~
https://github.com/rust-lang/rust/pull/149791#issuecomment-3638624348

Tracking issue: https://github.com/rust-lang/rust/issues/131204
2025-12-12 12:19:09 +01:00
cyrgani
43fa2a95c9 add regression test for proc_macro error subdiagnostics 2025-12-11 18:15:15 +00:00
Jamie Hill-Daniel
c96ff2d429 Remove uses of cfg(any()/all()) 2025-12-10 23:41:19 +00:00
Esteban Küber
1bd7934d89 Point at span within local macros even when error happens in nested external macro
```
error[E0308]: mismatched types
  --> $DIR/macro-span-caller-replacement.rs:5:17
   |
LL |             s = format!("{arg}");
   |                 ^^^^^^^^^^^^^^^^ expected `&str`, found `String`
...
LL |     macro_with_format!();
   |     -------------------- in this macro invocation
   |
   = note: this error originates in the macro `format` which comes from the expansion of the macro `macro_with_format` (in Nightly builds, run with -Z macro-backtrace for more info)
```
2025-12-10 19:27:40 +00:00
Matthias Krüger
4da61b6d69
Rollup merge of #149816 - estebank:verbose-typo-suggestion, r=JonathanBrouwer,Kivooeo
Make typo in field and name suggestions verbose

Part of https://github.com/rust-lang/rust/issues/141973.
2025-12-10 07:54:21 +01:00
Esteban Küber
6cd44a472c Make typo in field and name suggestions verbose 2025-12-09 17:29:23 +00:00
Matthias Krüger
679ab9e061
Rollup merge of #149400 - Skgland:tracked_mod, r=Amanieu
unstable proc_macro tracked::* rename/restructure

Picking up what should be the uncontroversial part of rust-lang/rust#87173 (closed due to inactivity over two years ago).

Part of rust-lang/rust#99515.

- move `proc_macro::tracked_env::var` to `proc_macro::tracked::env_var`
- move `proc_macro::tracked_path::path` to `proc_macro::tracked::path`
- change the argument of `proc_macro::tracked::path` from `AsRef<str>` to `AsRef<Path>`.
2025-12-09 17:36:48 +01:00
Wafarm
e513ce3fb4
Check identifiers defined in macros when suggesting identifiers hidden by hygiene 2025-12-04 14:58:46 +08:00
xonx4l
4b000cfacd Merge E0412 into E0425 2025-12-02 18:25:13 +00:00
Christian Poveda
7ae2823bc6
Gate 2018 UI tests 2025-11-27 14:13:58 -05:00
Christian Poveda
b2ab7cf980
Gate 2015 UI tests 2025-11-27 11:19:00 -05:00
Skgland
72076c6b54
move and rename proc_macro::tracked_{env::var,path::path} 2025-11-26 22:44:25 +01:00
Jane Losare-Lusby
7537b0bc06 Update tests/ui/proc-macro/helper-attr-compat-collision.rs
Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2025-11-24 10:52:03 -08:00
Jane Losare-Lusby
30c2e26506 Add test for derive helper compat collisions 2025-11-24 10:52:03 -08:00
cyrgani
7194c921ca add larger test for proc_macro FromStr implementations 2025-11-16 23:14:51 +01:00
yukang
12cde3091a Add note for identifier with attempted hygiene violation 2025-11-07 08:27:23 +08:00
Matthias Krüger
2d59f53b88
Rollup merge of #147813 - JonathanBrouwer:unused_attributes, r=jdonszelmann
Warn on unused_attributes in uitests

r? ```@jdonszelmann```

Because:
- unused_attributes warnings are usually actual mistakes, rather than just unused code, and we want to notify test writers they may be accidentally making a mistake
- Because the lint was allowed by default previously, we missed real bugs, because the test coverage is worse
  1. https://github.com/rust-lang/rust/issues/147417
  2. https://github.com/rust-lang/rust/issues/147411
2025-10-18 23:54:46 +02:00
Matthias Krüger
48db5270a0
Rollup merge of #147438 - reddevilmidzy:rename-non-inline-module-in-msg, r=fee1-dead
Rename "non-inline module" to "file module" in proc macro diagnostics

This PR updates diagnostic messages to use "file module" instead of "non-inline module". because the term "non-inline module" can be confusing, especially for non-native English speakers.

follow up PR rust-lang/rust#147395
related of rust-lang/rust#147314, [#general > Rename "non-inline modules" to "external modules"](https://rust-lang.zulipchat.com/#narrow/channel/122651-general/topic/.E2.9C.94.20Rename.20.22non-inline.20modules.22.20to.20.22external.20modules.22/near/543361244)

cc ```@Kivooeo```
2025-10-18 23:54:44 +02:00
Jonathan Brouwer
66b8a9db1f
Update uitests with new unused_attributes warnings
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-10-18 21:17:48 +02:00
reddevilmidzy
a1a9113aa8 Rename "non-inline module" to "file module" in proc macro diagnostics 2025-10-18 11:54:57 +09:00
James Barford-Evans
43f7eaa0ba Fix; correct placement of type inference error for method calls 2025-10-07 09:51:16 +01:00
Stuart Cook
f50c76f2fa
Rollup merge of #147209 - jieyouxu:remove-no-remap-src-base, r=Zalathar
Remove `no-remap-src-base` from tests

Previously in the `//`-compiletest-directive times, `no-remap-src-base` was implemented as a special `no-*` directive parsing. In the migration from `//` -> `//`@`,` the `// no-remap-src-base` directive was lost, most likely because it had no effect -- the default is not remapping `src-base`.

So remove occurrences of `no-remap-src-base`, as these are not valid directives.

r? `@Zalathar` (since we discussed this on discord, or compiler)
2025-10-01 22:15:02 +10:00
Jieyou Xu
ec893d1a64
tests: remove no-remap-src-base
Previously in the `//`-compiletest-directive times, this was implemented
as a special `no-*` directive parsing. In the migration from `//` ->
`//@`, the `// no-remap-src-base` directive was lost, most likely
because it had no effect -- the default is not remapping `src-base`.

So remove occurrences of `no-remap-src-base`, as these are not valid
directives.
2025-10-01 13:31:42 +08:00
Matthias Krüger
014e0af149
Rollup merge of #146617 - Jules-Bertholet:E0277-NOFORN, r=SparrowLii
Don’t suggest foreign `doc(hidden)` types in "the following other types implement trait" diagnostics

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

``@rustbot`` label A-diagnostics T-compiler
2025-09-30 21:53:34 +02:00
bors
e131842222 Auto merge of #147074 - matthiaskrgr:rollup-sm3owsd, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#145113 (resolve: Do not finalize shadowed bindings)
 - rust-lang/rust#146523 (Demote both armebv7r-none-* targets.)
 - rust-lang/rust#146704 (port `#[debugger_visualizer]` to the new attribute system)
 - rust-lang/rust#146758 (Stop linking rs{begin,end} objects on x86_64-*-windows-gnu)
 - rust-lang/rust#146778 (Use standard attribute logic for allocator shim)
 - rust-lang/rust#146849 (Reduce some uses of `LegacyBang`)
 - rust-lang/rust#147016 (fix doc comments to be more standard)
 - rust-lang/rust#147027 (Add new `tyalias` intra-doc link disambiguator)
 - rust-lang/rust#147031 (mbe: Simplify check_redundant_vis_repetition)
 - rust-lang/rust#147058 (Ignore more failing ui tests for GCC backend)

Failed merges:

 - rust-lang/rust#147046 (Rename `rust.use-lld` to `rust.bootstrap-override-lld`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-27 00:44:47 +00:00
lcnr
6b379b560d use try_structurally_resolve_type for method receiver
We'll still error due to the `opt_bad_ty` of `method_autoderef_steps`.
This slightly worsens the span of `infer_var.method()` which is now the
same as for `Box::new(infer_var).method()`.

Unlike `structurally_resolve_type`, `probe_op` does not check whether
the infcx is already tainted, so this results in 2 previously not emitted
errors.
2025-09-26 16:33:15 +02:00
Guillaume Gomez
a535c7be54 Ignore more failing ui tests for GCC backend 2025-09-26 15:33:48 +02:00