Commit Graph

307 Commits

Author SHA1 Message Date
许杰友 Jieyou Xu (Joe) 76d07a61f3 Rollup merge of #156531 - Zalathar:no-pass-override, r=jieyouxu
compiletest: Rename `//@ ignore-pass` to `//@ no-pass-override`

By convention, compiletest directives starting with `ignore-*` normally cause the test itself to be skipped under certain conditions.

The `//@ ignore-pass` directive was the only exception to that convention. The new name should hopefully do a better job of communicating its effect, which is to cause the `--pass` flag to not override the test's `build-pass` or `run-pass` directive.

The `//@ no-pass-override` directive is mainly useful for tests that expect warnings produced during codegen.

---
r? jieyouxu
2026-05-14 13:24:34 +08:00
Zalathar 0a5216b52a Remove some //@ ignore-pass directives that do nothing
The compiletest `--pass` flag only affects tests with a `*-pass` directive,
i.e. `check-pass`, `build-pass`, or `run-pass`.

It has no effect in `*-fail` tests, or in auxiliary crates.
2026-05-13 17:15:51 +10:00
Zalathar 38d2c11584 Enforce that directives are consistently used with or without a colon 2026-05-13 15:52:33 +10:00
Jonathan Brouwer 29961709f1 Rollup merge of #155982 - cijiugechu:gio-ice-repro, r=chenyukang
Fix closure HIR span context mismatch

Ensure span has the closure expression's SyntaxContext.

Closes rust-lang/rust#155724
2026-05-10 19:05:44 +02:00
bors 44860d3e9e Auto merge of #152277 - gurry:114865-ice-format-args, r=chenyukang
Validate source snippet when format input is raw string



Fixes rust-lang/rust#114865

The issue occurred because the user's proc macro respanned the format arg to an unrelated multi-byte string and we ICE'd by landing in the middle of a multi-byte char.

This PR adds validation that prevents the parser from trying to walk such obviously wrong snippets. Such validation already existed for non-raw strings. This PR adds it for raw strings as well.
2026-05-03 03:24:52 +00:00
cijiugechu 06cb86d952 fix closure HIR span context mismatch 2026-04-30 14:19:21 +08:00
cyrgani 5f066e9467 delete unused auxillary test files 2026-04-28 12:22:02 +00:00
Gurinder Singh 43c78adea6 Refactored test code to remove duplication 2026-04-19 15:46:52 +05:30
Gurinder Singh 3f56fa931f Added another test 2026-04-19 15:40:44 +05:30
Gurinder Singh 8e94039fa5 Corrected a comment 2026-04-19 15:27:42 +05:30
Gurinder Singh 74971582c5 Added checks for the suffix 2026-04-19 15:17:26 +05:30
Esteban Küber b849e10d38 Make span_suggestions always verbose
`span_suggestions` is to provide mutually exclusive suggestions. When it was introduced, we made its behavior be that if a single suggestion is given to it, we present the suggestion inline, otherwise in patch format. Changing this to make all of its uses be verbose, as that is closer in intent of output.
2026-04-15 01:38:14 +00:00
Jonathan Brouwer 65745a1b95 Revert #152369 because of multiple regressions
The regressions are documented in the PR comments.
This reverts commit 2972b5e, reversing changes made to f908263.
2026-04-09 18:53:59 +02:00
bors 9004856428 Auto merge of #153838 - oli-obk:use-tree-span, r=davidtwco
Use fine grained component-wise span tracking in use trees

This often produces nicer spans and even doesn't need a Span field anymore (not that I expect the unused field to affect any perf, but still neat).
2026-04-08 20:09:27 +00:00
Oli Scherer 9017621ace Use fine grained component-wise span tracking in use trees 2026-04-08 12:37:25 +02:00
Scott Schafer 63ed113d84 chore: Update annotate-snippets to 0.12.15 2026-04-06 14:48:52 -06:00
Edvin Bryntesson bd864efa70 bless tests and tidy
also removes E0452 and splits
`tests/rustdoc-ui/lints/renamed-lint-still-applies` into 2 tests

this is because of delayed warn lint being lost on compiler aborting on
error
2026-04-03 11:08:11 +02:00
Sasha Pourcelot 5491c3529b check earlier for misused crate-level attributes 2026-03-22 07:51:23 +00:00
Jonathan Brouwer e103550588 Rollup merge of #153308 - aytey:macro_meta_hygiene, r=jdonszelmann
Add hygiene annotations for tokens in `macro_rules!` bodies

`-Zunpretty=expanded,hygiene` was not printing syntax context annotations for identifiers and lifetimes inside `macro_rules!` bodies. These tokens are printed via `print_tt()` → `token_to_string_ext()`, which converts tokens to strings without calling `ann_post()`. This meant that macro-generated `macro_rules!` definitions with hygienic metavar parameters (e.g. multiple `$marg` distinguished only by hygiene) were printed with no way to tell them apart.

This was fixed by adding a match on `token.kind` in `print_tt()` to call `ann_post()` for `Ident`, `NtIdent`, `Lifetime`, and `NtLifetime` tokens, matching how `print_ident()` and `print_lifetime()` already handle AST-level identifiers and lifetimes.
2026-03-19 13:42:34 +01:00
Esteban Küber 87d8f5885b Provide more context on type errors in const context
- On `const` and `static` point at the type (like we do for let bindings)
- On fn calls, point at const parameter in fn definition
- On type, point at const parameter in type definition
- On array type lengths, explain that array length is always `usize`
- On enum variant discriminant, mention `repr`
2026-03-14 20:13:43 +00:00
cyrgani 94acbebb08 add test for proc-macros with custom panic payloads 2026-03-09 09:00:58 +00:00
cyrgani 1ff7ed583f add test for closure precedence in TokenStreams 2026-03-07 21:02:10 +00:00
Andrew V. Teylu f5a2bb6263 Add hygiene annotations for tokens in macro_rules! bodies
`-Zunpretty=expanded,hygiene` was not printing syntax context annotations
for identifiers and lifetimes inside `macro_rules!` bodies. These tokens
are printed via `print_tt()` → `token_to_string_ext()`, which converts
tokens to strings without calling `ann_post()`. This meant that
macro-generated `macro_rules!` definitions with hygienic metavar
parameters (e.g. multiple `$marg` distinguished only by hygiene) were
printed with no way to tell them apart.

This was fixed by adding a match on `token.kind` in `print_tt()` to call
`ann_post()` for `Ident`, `NtIdent`, `Lifetime`, and `NtLifetime`
tokens, matching how `print_ident()` and `print_lifetime()` already
handle AST-level identifiers and lifetimes.

Signed-off-by: Andrew V. Teylu <andrew.teylu@vector.com>
2026-03-02 20:28:16 +00:00
Jonathan Brouwer 66cccfde99 Rollup merge of #147859 - cyrgani:nonfatal-tokenstream-parse, r=petrochenkov,JonathanBrouwer
reduce the amount of panics in `{TokenStream, Literal}::from_str` calls

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/147859)*

Before this PR, calling `TokenStream::from_str` or `Literal::from_str` with an invalid argument would always cause a compile error, even if the `TokenStream` is not used afterwards at all.
This PR changes this so it returns a `LexError` instead in some cases.

This is very theoretically a breaking change, but the doc comment on the impl already says
```
/// NOTE: some errors may cause panics instead of returning `LexError`. We reserve the right to
/// change these errors into `LexError`s later.
```

Fixes some cases of rust-lang/rust#58736.
2026-02-22 11:31:14 +01:00
Esteban Küber 37684bdfc5 Make all multipart suggestions verbose
The ShowAlways style of suggestions is usually easier to understand than the inline style.
2026-02-18 18:33:35 +00:00
Stuart Cook 64087bc8ec Rollup merge of #152753 - cyrgani:remove-hack, r=petrochenkov
remove the explicit error for old `rental` versions

This was converted to a hard error 20 months ago (in rust-lang/rust#125596). This seems like enough time for anyone still using it to notice, so remove the note entirely now.
In comparison, the explicit note for the more impactful `time` breakage was already removed after 6 months (rust-lang/rust#129343).

Closes rust-lang/rust#73933.
Closes rust-lang/rust#83125.

r? @petrochenkov
2026-02-18 17:29:43 +11:00
cyrgani 195b849ea7 remove the explicit error for old rental versions 2026-02-17 20:11:01 +00:00
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
Gurinder Singh 6b3d04e5f9 Validate source snippet when format input is raw string 2026-02-16 18:41:12 +05:30
cyrgani f1c80f5988 reduce the amount of panics in {TokenStream, Literal}::from_str calls 2026-02-11 20:09:30 +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