Commit Graph

36 Commits

Author SHA1 Message Date
Esteban Küber beaf31581a Structured use suggestion on privacy error
When encoutering a privacy error on an item through a re-export that is
accessible in an alternative path, provide a structured suggestion with
that path.

```
error[E0603]: module import `mem` is private
  --> $DIR/private-std-reexport-suggest-public.rs:4:14
   |
LL |     use foo::mem;
   |              ^^^ private module import
   |
note: the module import `mem` is defined here...
  --> $DIR/private-std-reexport-suggest-public.rs:8:9
   |
LL |     use std::mem;
   |         ^^^^^^^^
note: ...and refers to the module `mem` which is defined here
  --> $SRC_DIR/std/src/lib.rs:LL:COL
   |
   = note: you could import this
help: import `mem` through the re-export
   |
LL |     use std::mem;
   |         ~~~~~~~~
```

Fix #42909.
2023-12-04 22:26:08 +00:00
bohan d0941f92d7 vis note for no pub reexports glob import 2023-12-01 12:10:07 +08:00
Nilstrieb 41e8d152dc Show number in error message even for one error
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
Esteban Küber 27919ceba7 Tweak suggestion spans for invalid crate-level inner attribute
CC #89566.
2023-10-26 18:35:09 +00:00
Matthias Krüger 2a027faf68 Rollup merge of #117009 - fmease:diag-disambig-sugg-crate, r=b-naber
On unresolved imports, suggest a disambiguated path if necessary to avoid collision with local items

Fixes #116970.
2023-10-25 23:37:10 +02:00
bohan 482275b194 use visibility to check unused imports and delete some stmts 2023-10-22 21:27:46 +08:00
León Orell Valerian Liehr 4aaf8e03e1 on unresolved import disambiguate suggested path if it would collide 2023-10-21 15:40:32 +02:00
Alex Macleod 5453a9f34d Add a note to duplicate diagnostics 2023-10-05 01:04:41 +00:00
bohan f1536507e1 resolve: determined binding after parent module macro expand 2023-09-13 16:38:05 +08:00
bohan 107152141b fix(resolve): update def if binding is warning ambiguity 2023-08-31 20:00:04 +08:00
Nilstrieb ddda3fa0b0 Rollup merge of #114166 - Enselic:libc-unavailable, r=Nilstrieb
Add regression test for resolving `--extern libc=test.rlib`

Closes #26043

I could not find a test for this particular use case. The closest I got was [`tests/ui/imports/issue-37887.rs`](https://github.com/rust-lang/rust/blob/master/tests/ui/imports/issue-37887.rs), but that is a regression test for a different use case (see https://github.com/rust-lang/rust/issues/37887).
2023-08-02 13:46:54 +02:00
Matthias Krüger 2de51cce90 Rollup merge of #113920 - bvanjoi:fix-81413, r=petrochenkov
fix(resolve): report unresolved imports firstly

Fixes #81413

An easy fix, r? ```@petrochenkov```
2023-07-31 22:49:50 +02:00
Martin Nordholts 7dd5e3c1cd Add regression test for resolving --extern libc=test.rlib
I could not find a test for this particular use case. The closest I got
was `tests/ui/imports/issue-37887.rs`, but that is a regression test
for a different use case.
2023-07-29 08:51:17 +02:00
bohan cac0bd0bef fix(resolve): update the ambiguity glob binding as warning recursively 2023-07-29 00:19:50 +08:00
bohan 1b18e2a176 fix(resolve): report unresolved imports firstly 2023-07-29 00:14:38 +08:00
bohan 02f1f6a8a8 fix(resolve): skip panic when resolution is dummy 2023-07-25 01:34:03 +08:00
bohan 549f48d0ed fix(resolve): skip assertion judgment when NonModule is dummy 2023-07-01 11:53:31 +08:00
Vadim Petrochenkov 4dcce38cda resolve: Remove artificial import ambiguity errors 2023-06-29 13:42:58 +03:00
许杰友 Jieyou Xu (Joe) b9606589c4 Add warn-by-default lint for local binding shadowing exported glob re-export item 2023-05-27 18:49:07 +08:00
bohan c41b2089c7 fix(resolve): not defined extern crate shadow_name 2023-05-23 13:14:34 +08:00
bohan f34678c097 fix(resolve): replace bindings to dummy for unresolved imports 2023-05-18 09:22:29 +08:00
Esteban Küber 9fadcc143a Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
Esteban Küber 5b40aa5eb4 Tweak output for 'add line' suggestion 2023-04-12 22:50:10 +00:00
Pietro Albini 64af509377 remove invalid ignore-pretty 2023-04-03 09:24:11 +02:00
Matthias Krüger 3961ef5bc8 Rollup merge of #109487 - GuillaumeGomez:move-useless-reexport-check, r=petrochenkov
Move useless_anynous_reexport lint into unused_imports

As mentioned in https://github.com/rust-lang/rust/pull/109003, this check should have been merged with `unused_imports` in the start.

r? `@petrochenkov`
2023-03-23 19:55:46 +01:00
Matthias Krüger bacf059f57 Rollup merge of #107880 - jieyouxu:issue-107563, r=petrochenkov
Lint ambiguous glob re-exports

Attempts to fix #107563.

We currently already emit errors for ambiguous re-exports when two names are re-exported *specifically*, i.e. not from glob exports. This PR attempts to emit deny-by-default lints for ambiguous glob re-exports.
2023-03-23 19:55:43 +01:00
Guillaume Gomez 825f0888cc Move useless_anynous_reexport lint into unused_imports 2023-03-22 16:05:20 +01:00
许杰友 Jieyou Xu (Joe) 1f67949f0e Lint ambiguous glob re-exports 2023-03-20 03:22:31 +08:00
Guillaume Gomez 7b0fa085b0 Update failing ui tests 2023-03-12 16:38:54 +01:00
bors d8da513668 Auto merge of #106916 - lukas-code:overlapping-substs, r=estebank
Remove overlapping parts of multipart suggestions

This PR adds a debug assertion that the parts of a single substitution cannot overlap, fixes a overlapping substitution from the testsuite, and fixes https://github.com/rust-lang/rust/issues/106870.

Note that a single suggestion can still have multiple overlapping substitutions / possible edits, we just don't suggest overlapping replacements in a single edit anymore.

I've also included a fix for an unrelated bug where rustfix for `explicit_outlives_requirements` would produce multiple trailing commas for a where clause.
2023-01-28 10:00:56 +00:00
Michael Howell e237690a28 diagnostics: add }; only if { was added too 2023-01-20 14:53:33 -07:00
Michael Howell e9d8d238ef diagnostics: suggest changing s@self::{macro}@::macro for exported
Fixes #99695
2023-01-20 14:52:24 -07:00
Lukas Markeffsky 31443c63b5 preserve delim spans during macro_rules! expansion if able 2023-01-20 20:16:37 +01:00
Michael Goulet 21725774a2 note -> help 2023-01-17 03:09:49 +00:00
Michael Goulet 716ea5f19c Fix use suggestion span 2023-01-17 03:06:38 +00:00
Albert Larsan cf2dff2b1e Move /src/test to /tests 2023-01-11 09:32:08 +00:00