Commit graph

515 commits

Author SHA1 Message Date
Rust timing bot
d060fad6ee
Unrolled build for #145399
Rollup merge of #145399 - estebank:resolve-error-wording-2, r=petrochenkov

Unify wording of resolve error

Remove "failed to resolve" from the main error message 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`
```

The intent behind this is to end up with all resolve errors eventually be on the form of

```
error[ECODE]: cannot find `{NAME}` in {SCOPE}
  --> $DIR/file.rs:5:13
   |
LL | #[existent::nonexistent]
   |             ^^^^^^^^^^^ {SPECIFIC LABEL}
```

A category of errors that is interest are those that involve keywords. For example:

```
error[E0433]: cannot find `Self` in this scope
  --> $DIR/issue-97194.rs:2:35
   |
LL |     fn bget(&self, index: [usize; Self::DIM]) -> bool {
   |                                   ^^^^ `Self` is only available in impls, traits, and type definitions
```
and

```
error[E0433]: cannot find `super` in this scope
  --> $DIR/keyword-super.rs:2:9
   |
LL |     let super: isize;
   |         ^^^^^ there are too many leading `super` keywords
```

For these the label provides the actual help, while the message is less informative beyond telling you "couldn't find `name`".

This is an off-shoot of https://github.com/rust-lang/rust/pull/126810 and https://github.com/rust-lang/rust/pull/128086, a subset of the intended changes there with review comments applied.

r? @petrochenkov
2026-02-18 18:17:37 +01: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
cyrgani
28fc413c8f remove #![allow(stable_features)] from most tests 2026-02-17 08:45:08 +00:00
Ralf Jung
5e65109f21 add write_box_via_move intrinsic and use it for vec!
This allows us to get rid of box_new entirely
2026-02-16 17:27:40 +01:00
Jacob Pratt
8075b89aa6
Rollup merge of #152508 - arferreira:improve-write-macro-diagnostic, r=Mark-Simulacrum
Improve write! and writeln! error when called without destination

Fixes rust-lang/rust#152493

Adds catch-all arms to `write!` and `writeln!` macros so that calling them without a destination (e.g., `write!("S")` instead of `write!(f, "S")`) gives a clear error instead of the cryptic "unexpected end of macro invocation" pointing at macro internals.

r? @estebank
2026-02-14 23:17:31 -05:00
Stuart Cook
9e0a05b481
Rollup merge of #152550 - Ozzy1423:rustc-attrs, r=JonathanBrouwer
Port #[prelude_import] to the attribute parser

Tracking issue: https://github.com/rust-lang/rust/issues/131229

r? @JonathanBrouwer

Didn't change any use-sites of it in the compiler
2026-02-13 15:19:15 +11:00
Oscar Bray
dd8a98a9bc Fix pretty print tests with #[prelude_import] 2026-02-12 17:43:58 +00:00
yukang
caf7cdf558 Improve code suggestion for incorrect macro_rules! usage 2026-02-12 15:30:41 +08:00
arferreira
0bcec37604 Improve write! and writeln! error when called without destination 2026-02-11 20:37:45 -05:00
Lukas Bergdoll
2f3b952349 Stabilize assert_matches 2026-02-11 14:13:44 +01:00
Jonathan Brouwer
78bd6abbe6
Rollup merge of #152341 - folkertdev:cfg-select-optional-comma, r=JonathanBrouwer
`cfg_select!`: allow optional comma after `{ /* ... */ }`
2026-02-08 19:15:28 +01:00
Jonathan Brouwer
d14c26f45a
Fix help on AmbiguousMissingKwForItemSub diagnostic 2026-02-08 17:02:40 +01:00
Folkert de Vries
053f76e9f0
cfg_select!: allow optional comma after { /* ... */ } 2026-02-08 13:46:29 +01:00
Folkert de Vries
bad1a450c0
use test instead of unix to be platform-independent 2026-02-07 13:33:25 +01:00
Folkert de Vries
a6bd7cc54e
make the lint more sophisticated 2026-02-07 02:19:43 +01:00
Folkert de Vries
8aea4b1775
add unreachable_cfg_select_predicates lint
This is emitted on branches of a `cfg_select!` that are statically known
to be unreachable.
2026-02-07 02:19:42 +01:00
yukang
2bab7a02f2 Handle unbalanced delimiters gracefully in make_attr_token_stream 2026-02-01 13:16:32 +00:00
Vadim Petrochenkov
ea0ee492bd resolve: Remove force parameter from resolve_ident_in_scope 2026-01-30 21:32:37 +03:00
Esteban Küber
4a27be6972 Do not mention -Zmacro-backtrace for std macros that are a wrapper around a compiler intrinsic 2026-01-26 17:34:31 +00:00
Matthias Krüger
0bb15457de
Rollup merge of #149174 - GrigorenkoPV:const_block_item, r=me,ytmimi
`const` blocks as a `mod` item

Tracking issue: rust-lang/rust#149226

This adds support for writing `const { ... }` as an item in a module. In the current implementation, this is a unique AST item that gets lowered to `const _: () = const { ... };` in HIR.

rustfmt support included.

TODO:
- `pub const { ... }` does not make sense (see rust-lang/rust#147136). Reject it. Should this be rejected by the parser or smth?
- Improve diagnostics (preferably they should not mention the fake `_` ident).
2026-01-24 15:35:08 +01:00
Lukas Bergdoll
58be5d6620 Move assert_matches to planned stable path 2026-01-21 23:17:24 +01:00
Pavel Grigorenko
61ac56209d separate ast item for const block items 2026-01-21 18:26:57 +03:00
Olivier Goffart
f3e73dced1 Supress some lookup errors if a module contains compile_error!
The problem is that when a macro expand to `compile_error!` because
its input is malformed, the actual error message from the
`compile_error!` might be hidden in a long list of other messages about
using items that should have otherwise been generated by the macro.

So suppress error about missing items in that module.

Fixes issue 68838
2026-01-18 14:37:57 +01:00
Jacob Pratt
8790d2640d
Rollup merge of #151159 - t15, r=Kivooeo
Tidying up `tests/ui/issues` 15 tests [8/N]

> [!NOTE]
> Intermediate commits are intended to help review, but will be squashed add comment commit prior to merge.

part of rust-lang/rust#133895

There are some tests named {xxx}-2, which are meant to be merged with {xxx}.

r? Kivooeo
2026-01-15 19:35:47 -05:00
reddevilmidzy
77b2a196fb cleaned up some tests
merge privacy/privacy-sanity-2 with privacy/privacy-sanity.rs

Add comment to generics/type-args-on-module-in-bound.rs

Add comment to array-slice-vec/closure-in-array-eln.rs

Add comment to array-slice-vec/return-in-array-len.rs

Merge for-loop-while/break-outside-loop-2.rs with
for-loop-while/break-outside-loop.rs

Add comment to macros/column-macro-collision.rs

Add comment to privacy/private-extern-fn-visibility.rs

Add comment to mismatched_types/vec-hashset-type-mismatch.rs

Merge std-sync-right-kind-impls-2.rs with std-sync-right-kind-impls.rs

Add comment to array-slice-vec/slice-of-multi-ref.rs

Add comment to mismatched_types\vec-hashset-type-mismatch.rs

Add comment to derives/derive-hygiene-struct-builder.rs

Add comment to label/undeclared-label-span.rs

Add comment to label\undeclared-label-span.rs

Add comment to mismatched_types/array-repeat-unit-struct.rs
2026-01-16 06:50:34 +09:00
reddevilmidzy
559e672489 move some tests 2026-01-16 06:50:21 +09: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
Matthias Krüger
8add20b77f
Rollup merge of #150026 - Delta17920:fix/150002-macro-concat-bug, r=jdonszelmann
Fix macro_metavar_expr_concat behavior with nested repetitions

**The Bug**: The `${concat(...)}` expression was using the wrong loop index when inside nested repetitions (like optional groups), causing it to get "stuck" on the first element and generate duplicate code.

**The Fix**: Updated `metavar_expr_concat` in `transcribe.rs` to correctly search the repetition stack (`tscx.repeats`) for the target variable instead of blindly using the last index.

**Tests**:
    Added `tests/ui/macros/concat-nested-repetition.rs.`

Fixes rust-lang/rust#150002
2026-01-06 18:43:28 +01:00
delta17920
3566b6775c Fix macro_metavar_expr_concat behavior with nested repetitions 2025-12-18 15:53:39 +00:00
Folkert de Vries
82ee8b21cb
cfg_select!: emit parse errors in unused branches 2025-12-17 22:42:42 +01:00
Jonathan Brouwer
f3fa567fdf
Rollup merge of #150032 - Kivooeo:annotate-snippets-stable, r=Muscraft
Use annotate-snippet as default emitter on stable

This is implementation of https://github.com/rust-lang/rust/issues/149932

Now, after MCP was accepted, we can use annotate-snippet as default emitter for errors, that means that we not longer need of previous emitter, so this PR removed previous emitter and makes annotate-snippet new default one both on stable and nightly

(this PR does not remove a code of previous emitter it just removes a `Default` option of `HumanReadableErrorType` enum, and keeping only `HumanReadableErrorType::AnnotateSnippet` as it now uses by default)
2025-12-16 20:21:10 +01:00
Jonathan Brouwer
f108cd7232
Rollup merge of #149767 - reddevilmidzy:t11, r=Kivooeo
Tidying up tests/ui/issues 33 tests [4/N]

> [!NOTE]
> Intermediate commits are intended to help review, but will be squashed add comment commit prior to merge.

part of rust-lang/rust#133895

`tests/ui/compile-flags` split it into `tests/ui/compile-flags/invalid/` and `tests/ui/compile-flags/run-pass/`

r? Kivooeo
2025-12-16 20:21:07 +01:00
Kivooeo
84f2854bc3 remove fixme & update stderr files 2025-12-16 13:23:48 +00:00
reddevilmidzy
1bd997a452 Cleaned up some tests
Split invalid-compile-flags into run-pass & invalid

Update tests/ui/README.md
2025-12-16 02:10:08 +09: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
Matthias Krüger
17940e27c8
Rollup merge of #149770 - GrigorenkoPV:tests/consts, r=WaffleLapkin
Rename some issue-* tests

Also fixes one incorrect issue number: https://github.com/rust-lang/rust/pull/100168#issuecomment-3622946835
2025-12-11 22:09:54 +01:00
Jamie Hill-Daniel
c96ff2d429 Remove uses of cfg(any()/all()) 2025-12-10 23:41:19 +00:00
Pavel Grigorenko
96a7000101 Rename some issue-* tests 2025-12-10 20:31:10 +03:00
Matthias Krüger
eab103688f
Rollup merge of #149846 - jdonszelmann:links-for-all-fcws, r=wafflelapkin
Statically require links to an issue or the edition guide for all FCWs

r? `@wafflelapkin`
2025-12-10 17:16:50 +01:00
Jana Dönszelmann
1ef1ec13d8
bless the tests 2025-12-10 15:15:56 +01: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
reddevilmidzy
92f21a806d moved tests 2025-12-10 09:23:50 +09:00
Esteban Küber
6cd44a472c Make typo in field and name suggestions verbose 2025-12-09 17:29:23 +00:00
Matthias Krüger
90dc2b6e2d
Rollup merge of #146579 - estebank:issue-146325, r=jdonszelmann
Handle macro invocation in attribute during parse

```
error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found macro `concat`
  --> $DIR/macro-in-attribute.rs:4:21
   |
LL | #[deprecated(note = concat!("a", "b"))]
   |                     ^^^^^^^^^^^^^^^^^ macros are not allowed here
```

Fix rust-lang/rust#146325.
2025-12-09 17:36:48 +01:00
Esteban Küber
761cb57aef fix test 2025-12-09 01:20:58 +00:00
Jonathan Brouwer
e7df90412c
Changes to uitests 2025-12-06 10:22:13 +01:00
Matthias Krüger
0c05bb5606
Rollup merge of #149630 - wafarm:fix-149604, r=JonathanBrouwer
Check identifiers defined in macros when suggesting identifiers hidden by hygiene

Fix rust-lang/rust#149604

r? `@JonathanBrouwer` (Since you reviewed the other one related to this)
2025-12-05 16:17:10 +01:00
Wafarm
e513ce3fb4
Check identifiers defined in macros when suggesting identifiers hidden by hygiene 2025-12-04 14:58:46 +08:00
Jana Dönszelmann
8f8247812e
address review comments 2025-12-03 17:01:49 +01:00
Jana Dönszelmann
97d4d2154f
fixup name in diagnostics 2025-12-03 16:38:24 +01:00