-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #53427 - eddyb:uniform-paths-diagnostics, r=varkor
rustc_resolve: overhaul `#![feature(uniform_paths)]` error reporting. Fixes #53408 by only considering external crates to conflict within their (type/module) namespace, *not* with the value or macro namespaces, and also by adding a special-cased error for redundant `use crate_name;` imports (without actually allowing them). Also, all canaries for a given import are grouped into one diagnostic per namespace, in order to make block-scoped ambiguities clearer. See changed/added tests for more details. r? @petrochenkov cc @aturon @joshtriplett
- Loading branch information
Showing
14 changed files
with
195 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/test/ui/rust-2018/uniform-paths/ambiguity-macros-nested.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 36 additions & 4 deletions
40
src/test/ui/rust-2018/uniform-paths/block-scoped-shadow.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,45 @@ | ||
error: import from `Foo` is ambiguous | ||
--> $DIR/block-scoped-shadow.rs:19:9 | ||
error: `Foo` import is ambiguous | ||
--> $DIR/block-scoped-shadow.rs:21:9 | ||
| | ||
LL | enum Foo { A, B } | ||
| ----------------- can refer to `self::Foo` | ||
... | ||
LL | enum Foo {} | ||
| ----------- shadowed by block-scoped `Foo` | ||
LL | use Foo::*; | ||
| ^^^ | ||
| | ||
= help: write `::Foo` or `self::Foo` explicitly instead | ||
= help: write `self::Foo` explicitly instead | ||
= note: relative `use` paths enabled by `#![feature(uniform_paths)]` | ||
|
||
error: aborting due to previous error | ||
error: `std` import is ambiguous | ||
--> $DIR/block-scoped-shadow.rs:28:9 | ||
| | ||
LL | struct std; | ||
| ----------- can refer to `self::std` | ||
... | ||
LL | enum std {} | ||
| ----------- shadowed by block-scoped `std` | ||
LL | use std as foo; | ||
| ^^^ can refer to external crate `::std` | ||
| | ||
= help: write `::std` or `self::std` explicitly instead | ||
= note: relative `use` paths enabled by `#![feature(uniform_paths)]` | ||
|
||
error: `std` import is ambiguous | ||
--> $DIR/block-scoped-shadow.rs:28:9 | ||
| | ||
LL | struct std; | ||
| ----------- can refer to `self::std` | ||
... | ||
LL | fn std() {} | ||
| ----------- shadowed by block-scoped `std` | ||
LL | enum std {} | ||
LL | use std as foo; | ||
| ^^^ | ||
| | ||
= help: write `self::std` explicitly instead | ||
= note: relative `use` paths enabled by `#![feature(uniform_paths)]` | ||
|
||
error: aborting due to 3 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// edition:2018 | ||
|
||
#![feature(uniform_paths)] | ||
|
||
use std; | ||
|
||
fn main() {} |
Oops, something went wrong.