Commit Graph

226 Commits

Author SHA1 Message Date
Trevor Gross
a71dbcd679 Rollup merge of #143177 - xizheyin:143134, r=lcnr
Remove false label when `self` resolve failure does not relate to macro

Fixes rust-lang/rust#143134

In the first commit, I did some code-clean, moving `suggest*` to `suggestions/` dir.
In the second, commit, I added ui test.
In the third, I change the code, and present the test result.

r? compiler
2025-07-08 22:50:26 -05:00
Jonathan Brouwer
244d64e60b Port #[path] to the new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-06 22:19:16 +02:00
Jubilee
f10725218d Rollup merge of #143202 - Kivooeo:tf18, r=tgross35
`tests/ui`: A New Order [18/N]

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

Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895.

r? `@tgross35`
2025-07-04 23:26:21 -07:00
xizheyin
236b392904 Return early when self resolve failure because of let self = ...
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-03 23:47:19 +08:00
xizheyin
000f038e99 Add ui test resolve/false-self-in-macro-issue-143134.rs
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-03 23:11:57 +08:00
xizheyin
25ab022f29 move tests/ui/resolve/suggest* to tests/ui/resolve/suggestions/
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-03 23:11:57 +08:00
Kivooeo
f12120d2bd cleaned up some tests 2025-07-01 15:29:29 +05:00
Kivooeo
6ca9b43ea9 moved test files 2025-07-01 15:22:16 +05:00
Scott Schafer
c8fac7779e fix: Emit suggestion filename if primary diagnostic span is dummy 2025-06-30 19:24:22 -06:00
Kivooeo
580bc12844 cleaned up some tests 2025-06-30 11:16:18 +05:00
Trevor Gross
74657a4a1a Move some UI tests to more apropriate directories
Prepare for rework done in the rest of [PR143118].

[PR143118]: https://www.github.com/rust-lang/rust/pull/143118

Co-authored-by: Kivooeo <Kivooeo123@gmail.com>
2025-06-28 19:07:29 -05:00
Matthias Krüger
e2e201fd6b Rollup merge of #142219 - Kivooeo:tf11, r=wesleywiser
`tests/ui`: A New Order [11/N]

Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895.

r? `@jieyouxu`
2025-06-12 03:14:52 +02:00
Matthias Krüger
c557695fe1 Rollup merge of #142217 - Kivooeo:tf10, r=jieyouxu
`tests/ui`: A New Order [10/N]

Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895.

r? `@jieyouxu`
2025-06-12 03:14:51 +02:00
Kivooeo
c6c55cc0cb cleaned up some tests 2025-06-11 20:51:49 +05:00
Kivooeo
09940635d5 cleaned up some tests 2025-06-11 17:49:03 +05:00
Lukas Wirth
1d7c1b1b4f Add more missing 2015 edition directives 2025-06-05 09:20:19 +02:00
Lukas Wirth
46326e159f Use non-2015 edition paths in tests that do not test for their resolution 2025-06-05 09:19:31 +02:00
yukang
7167e7ce06 Fix false positive lint error from no_implicit_prelude attr 2025-06-02 17:49:01 +08:00
Guillaume Gomez
cd0adc9d7b Rollup merge of #140370 - WaffleLapkin:unqualified, r=jdonszelmann
Improve diagnostics for usage of qualified paths within tuple struct exprs/pats

For patterns the old diagnostic was just incorrect, but I also added machine applicable suggestions.

For context, this special cases errors for `<T as Trait>::Assoc(..)` patterns and expressions (latter is just a call). Tuple struct patterns and expressions both live in the value namespace, so they are not forwarded through associated *types*.

r? ``@jdonszelmann``

cc ``@petrochenkov`` in https://github.com/rust-lang/rust/pull/80080#issuecomment-800630582 you were wondering why it doesn't work for types, that's why — tuple patterns are resolved in the value namespace.
2025-06-01 19:35:41 +02:00
xizheyin
4ec991989a Add println! test for sugg-field-in-format-string-issue-141136
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-20 14:10:17 +08:00
xizheyin
9de7fff0d8 Suggest use "{}", self.x instead of {self.x} when resolve x as field of self
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-18 16:14:48 +08:00
xizheyin
fe0663c33d Add test sugg-field-in-format-string-issue-141136
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-18 15:53:03 +08:00
Vadim Petrochenkov
20faf8532b compiletest: Make diagnostic kind mandatory on line annotations 2025-04-30 10:44:24 +03:00
Waffle Lapkin
8f765fc7a1 bless tests 2025-04-27 18:14:55 +02:00
reddevilmidzy
db2a73e284 Cleaned up 5 tests in tests/ui 2025-04-25 20:50:57 +09:00
Matthias Krüger
a4adc005a1 Rollup merge of #139127 - compiler-errors:prim-ty-hack, r=oli-obk
Fix up partial res of segment in primitive resolution hack

There is a hack in the resolver:

```
// In `a(::assoc_item)*` `a` cannot be a module. If `a` does resolve to a module we
// don't report an error right away, but try to fallback to a primitive type.
```

This fixes up the resolution for primitives which would otherwise resolve to a module, but we weren't also updating the res of the path segment, leading to weird diagnostics.

We explicitly call `self.r.partial_res_map.insert` instead of `record_partial_res` b/c we have recorded a partial res already, and we specifically want to override it.

cc https://github.com/rust-lang/rust/issues/139095#issuecomment-2764371934
2025-04-14 18:15:30 +02:00
Matthias Krüger
79f357e63d Rollup merge of #139510 - nnethercote:name-to-ident, r=fee1-dead
Rename some `name` variables as `ident`.

It bugs me when variables of type `Ident` are called `name`. It leads to silly things like `name.name`. `Ident` variables should be called `ident`, and `name` should be used for variables of type `Symbol`.

This commit improves things by by doing `s/name/ident/` on a bunch of `Ident` variables. Not all of them, but a decent chunk.

r? `@fee1-dead`
2025-04-10 17:27:14 +02:00
Nicholas Nethercote
1b3fc585cb Rename some name variables as ident.
It bugs me when variables of type `Ident` are called `name`. It leads to
silly things like `name.name`. `Ident` variables should be called
`ident`, and `name` should be used for variables of type `Symbol`.

This commit improves things by by doing `s/name/ident/` on a bunch of
`Ident` variables. Not all of them, but a decent chunk.
2025-04-10 09:30:55 +10:00
bors
c1b8b7e86f Auto merge of #139555 - petrochenkov:errkind-ann, r=jieyouxu
UI tests: add missing diagnostic kinds where possible

The subset of https://github.com/rust-lang/rust/pull/139427 that only adds diagnostic kinds to line annotations, without changing any other things in annotations or compiletest.
After this only non-viral `NOTE`s and `HELP`s should be missing.

r? `@jieyouxu`
2025-04-09 02:19:37 +00:00
Vadim Petrochenkov
b3f75353a2 UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00
Vadim Petrochenkov
5c160f511e compiletest: Stricter parsing for diagnostic kinds 2025-04-07 19:13:31 +03:00
Vadim Petrochenkov
4d64990690 compiletest: Require //~ annotations even if error-pattern is specified 2025-04-03 11:08:55 +03:00
Matthias Krüger
068594e365 Rollup merge of #138790 - xizheyin:issue-138626, r=compiler-errors
Note potential but private items in show_candidates

Closes #138626 .
We should add potential private items to give ample hints.
And for the other seemingly false positive ` pub use crate:1️⃣:Foo;` should be kept because we don't know if the user wants to import other module's items or not, and therefore should be given the full option to do so.
r? compiler
2025-04-01 20:25:21 +02:00
Matthias Krüger
50485342a0 Rollup merge of #138840 - jyn514:precedence-order, r=wesleywiser
rustc_resolve: Test the order that preludes are resolved

This test is exhaustive. See attached truth table:
![image](https://github.com/user-attachments/assets/11fe703c-e114-48df-84f8-426b63395784)

Companion PR to https://github.com/rust-lang/reference/pull/1765.
2025-03-31 23:05:44 +02:00
Michael Goulet
18c787f48f Fix up partial res of segment in primitive resolution hack 2025-03-30 04:22:14 +00:00
jyn
41fdd280ff rustc_resolve: Test the order that preludes are resolved 2025-03-29 19:18:39 -04:00
Vadim Petrochenkov
8d5109aa6e compiletest: Support matching on diagnostics without a span 2025-03-25 17:33:09 +03:00
xizheyin
26cfa6f819 Note potential but private items in show_candidates
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-03-22 11:41:42 +08:00
Esteban Küber
f0b8e13b59 Do not suggest using -Zmacro-backtrace for builtin macros
For macros that are implemented on the compiler, we do *not* mention the `-Zmacro-backtrace` flag. This includes `derive`s and standard macros.
2025-03-14 19:50:03 +00:00
Michael Goulet
160905b625 Trim suggestion part before generating highlights 2025-02-21 00:54:01 +00:00
Michael Goulet
0a7ab1d6df More sophisticated span trimming 2025-02-21 00:41:17 +00:00
Zachary S
2c3725021e Update . -> :: tests for new diff suggestion format. 2025-02-18 13:28:35 -06:00
Zachary S
ae7b45a6d4 When giving a suggestion to use :: instead of . where the rhs is a macro giving a type,
make it also work when the rhs is a type alias, not just a struct.
2025-02-18 13:11:37 -06:00
Zachary S
bfde43c84b Suggest using :: instead of . for enums in some cases.
Suggest replacing `.` with `::` when encountering "expected value, found enum":
- in a method-call expression and the method has the same name as a tuple variant
- in a field-access expression and the field has the same name as a unit or tuple variant
2025-02-18 13:11:37 -06:00
Zachary S
fe37adab4b Suggest using :: instead of . in more cases.
When `Foo.field` or `Foo.method()` exprs are encountered, suggest `Foo::field` or `Foo::method()` when Foo is a type alias, not just
a struct, trait, or module.

Also rename test for this suggestion from issue-22692.rs to something more meaningful.
2025-02-18 13:11:37 -06:00
Michael Goulet
6d71251cf9 Trim suggestion parts to the subset that is purely additive 2025-02-14 00:44:10 -08:00
Michael Goulet
f6406dfd4e Consider add-prefix replacements too 2025-02-14 00:27:17 -08:00
Michael Goulet
b480a9214a Use underline suggestions for purely 'additive' replacements 2025-02-14 00:27:13 -08:00
Esteban Küber
f0845adb0c Show diff suggestion format on verbose replacement
```
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
  --> $DIR/attempted-access-non-fatal.rs:7:15
   |
LL |     let _ = 2.l;
   |               ^
   |
help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix
   |
LL -     let _ = 2.l;
LL +     let _ = 2.0f64;
   |
```
2025-02-10 20:21:39 +00:00
León Orell Valerian Liehr
57b5d3af62 Compiler: Finalize dyn compatibility renaming 2025-01-26 21:20:31 +01:00