Improve diagnostics for inaccessible items

This commit is contained in:
Fabian Wolff 2021-09-18 00:07:41 +02:00
parent 65eb381dec
commit 750018e16e
10 changed files with 164 additions and 56 deletions

View file

@ -4,8 +4,11 @@ error[E0425]: cannot find function `fpriv` in this scope
LL | fpriv();
| ^^^^^ not found in this scope
|
= note: this function exists but is inaccessible:
bar::fpriv
note: function `bar::fpriv` exists but is inaccessible
--> $DIR/glob-resolve1.rs:7:5
|
LL | fn fpriv() {}
| ^^^^^^^^^^ not accessible
error[E0425]: cannot find function `epriv` in this scope
--> $DIR/glob-resolve1.rs:27:5
@ -13,8 +16,11 @@ error[E0425]: cannot find function `epriv` in this scope
LL | epriv();
| ^^^^^ not found in this scope
|
= note: this function exists but is inaccessible:
bar::epriv
note: function `bar::epriv` exists but is inaccessible
--> $DIR/glob-resolve1.rs:9:9
|
LL | fn epriv();
| ^^^^^^^^^^^ not accessible
error[E0423]: expected value, found enum `B`
--> $DIR/glob-resolve1.rs:28:5
@ -40,8 +46,11 @@ error[E0425]: cannot find value `C` in this scope
LL | C;
| ^ not found in this scope
|
= note: this unit struct exists but is inaccessible:
bar::C
note: unit struct `bar::C` exists but is inaccessible
--> $DIR/glob-resolve1.rs:18:5
|
LL | struct C;
| ^^^^^^^^^ not accessible
error[E0425]: cannot find function `import` in this scope
--> $DIR/glob-resolve1.rs:30:5
@ -63,8 +72,11 @@ LL | pub enum B {
LL | foo::<A>();
| ^ help: an enum with a similar name exists: `B`
|
= note: this enum exists but is inaccessible:
bar::A
note: enum `bar::A` exists but is inaccessible
--> $DIR/glob-resolve1.rs:11:5
|
LL | enum A {
| ^^^^^^ not accessible
error[E0412]: cannot find type `C` in this scope
--> $DIR/glob-resolve1.rs:33:11
@ -75,8 +87,11 @@ LL | pub enum B {
LL | foo::<C>();
| ^ help: an enum with a similar name exists: `B`
|
= note: this struct exists but is inaccessible:
bar::C
note: struct `bar::C` exists but is inaccessible
--> $DIR/glob-resolve1.rs:18:5
|
LL | struct C;
| ^^^^^^^^^ not accessible
error[E0412]: cannot find type `D` in this scope
--> $DIR/glob-resolve1.rs:34:11
@ -87,8 +102,11 @@ LL | pub enum B {
LL | foo::<D>();
| ^ help: an enum with a similar name exists: `B`
|
= note: this type alias exists but is inaccessible:
bar::D
note: type alias `bar::D` exists but is inaccessible
--> $DIR/glob-resolve1.rs:20:5
|
LL | type D = isize;
| ^^^^^^^^^^^^^^^ not accessible
error: aborting due to 8 previous errors

View file

@ -4,8 +4,11 @@ error[E0412]: cannot find type `Bar` in this scope
LL | fn sub() -> Bar { 1 }
| ^^^ not found in this scope
|
= note: this type alias exists but is inaccessible:
a::b::Bar
note: type alias `a::b::Bar` exists but is inaccessible
--> $DIR/issue-4366-2.rs:11:9
|
LL | type Bar = isize;
| ^^^^^^^^^^^^^^^^^ not accessible
error[E0423]: expected function, found module `foo`
--> $DIR/issue-4366-2.rs:25:5

View file

@ -16,8 +16,11 @@ error[E0425]: cannot find function, tuple struct or tuple variant `Bx` in this s
LL | Bx(());
| ^^ not found in this scope
|
= note: this tuple struct exists but is inaccessible:
foo::Bx
note: tuple struct `foo::Bx` exists but is inaccessible
--> $DIR/issue-42944.rs:2:5
|
LL | pub struct Bx(());
| ^^^^^^^^^^^^^^^^^^ not accessible
error: aborting due to 2 previous errors

View file

@ -6,6 +6,8 @@
mod a {
struct Foo;
//~^ NOTE: struct `a::Foo` exists but is inaccessible
//~| NOTE: not accessible
}
mod b {
@ -14,14 +16,16 @@ mod b {
type Bar = Foo;
//~^ ERROR: cannot find type `Foo` in this scope [E0412]
//~| NOTE: not found in this scope
//~| NOTE: this struct exists but is inaccessible
}
mod c {
enum Eee {}
//~^ NOTE: these enums exist but are inaccessible
//~| NOTE: `c::Eee`: not accessible
mod d {
enum Eee {}
//~^ NOTE: `c::d::Eee`: not accessible
}
}
@ -29,7 +33,6 @@ mod e {
type Baz = Eee;
//~^ ERROR: cannot find type `Eee` in this scope [E0412]
//~| NOTE: not found in this scope
//~| NOTE: these items exist but are inaccessible
}
fn main() {}

View file

@ -1,24 +1,32 @@
error[E0412]: cannot find type `Foo` in this scope
--> $DIR/issue-88472.rs:14:16
--> $DIR/issue-88472.rs:16:16
|
LL | type Bar = Foo;
| ^^^ not found in this scope
|
= note: this struct exists but is inaccessible:
a::Foo
note: struct `a::Foo` exists but is inaccessible
--> $DIR/issue-88472.rs:8:5
|
LL | struct Foo;
| ^^^^^^^^^^^ not accessible
error[E0412]: cannot find type `Eee` in this scope
--> $DIR/issue-88472.rs:29:16
--> $DIR/issue-88472.rs:33:16
|
LL | type Baz = Eee;
| ^^^ not found in this scope
|
= note: these items exist but are inaccessible:
c::Eee
c::d::Eee
note: these enums exist but are inaccessible
--> $DIR/issue-88472.rs:22:5
|
LL | enum Eee {}
| ^^^^^^^^ `c::Eee`: not accessible
...
LL | enum Eee {}
| ^^^^^^^^ `c::d::Eee`: not accessible
warning: unused import: `crate::a::*`
--> $DIR/issue-88472.rs:12:9
--> $DIR/issue-88472.rs:14:9
|
LL | use crate::a::*;
| ^^^^^^^^^^^

View file

@ -171,8 +171,11 @@ LL | pub enum E {
LL | let _: Z = m::n::Z;
| ^ help: an enum with a similar name exists: `E`
|
= note: this enum exists but is inaccessible:
m::Z
note: enum `m::Z` exists but is inaccessible
--> $DIR/privacy-enum-ctor.rs:11:9
|
LL | pub(in m) enum Z {
| ^^^^^^^^^^^^^^^^ not accessible
error[E0423]: expected value, found enum `m::n::Z`
--> $DIR/privacy-enum-ctor.rs:57:16
@ -211,8 +214,11 @@ LL | pub enum E {
LL | let _: Z = m::n::Z::Fn;
| ^ help: an enum with a similar name exists: `E`
|
= note: this enum exists but is inaccessible:
m::Z
note: enum `m::Z` exists but is inaccessible
--> $DIR/privacy-enum-ctor.rs:11:9
|
LL | pub(in m) enum Z {
| ^^^^^^^^^^^^^^^^ not accessible
error[E0412]: cannot find type `Z` in this scope
--> $DIR/privacy-enum-ctor.rs:64:12
@ -223,8 +229,11 @@ LL | pub enum E {
LL | let _: Z = m::n::Z::Struct;
| ^ help: an enum with a similar name exists: `E`
|
= note: this enum exists but is inaccessible:
m::Z
note: enum `m::Z` exists but is inaccessible
--> $DIR/privacy-enum-ctor.rs:11:9
|
LL | pub(in m) enum Z {
| ^^^^^^^^^^^^^^^^ not accessible
error[E0423]: expected value, found struct variant `m::n::Z::Struct`
--> $DIR/privacy-enum-ctor.rs:64:16
@ -246,8 +255,11 @@ LL | pub enum E {
LL | let _: Z = m::n::Z::Unit {};
| ^ help: an enum with a similar name exists: `E`
|
= note: this enum exists but is inaccessible:
m::Z
note: enum `m::Z` exists but is inaccessible
--> $DIR/privacy-enum-ctor.rs:11:9
|
LL | pub(in m) enum Z {
| ^^^^^^^^^^^^^^^^ not accessible
error[E0603]: enum `Z` is private
--> $DIR/privacy-enum-ctor.rs:57:22

View file

@ -33,8 +33,11 @@ error[E0423]: expected value, found struct `xcrate::S`
LL | xcrate::S;
| ^^^^^^^^^ constructor is not visible here due to private fields
|
= note: this tuple struct exists but is inaccessible:
m::S
note: tuple struct `m::S` exists but is inaccessible
--> $DIR/privacy-struct-ctor.rs:6:5
|
LL | pub struct S(u8);
| ^^^^^^^^^^^^^^^^^ not accessible
error[E0603]: tuple struct constructor `Z` is private
--> $DIR/privacy-struct-ctor.rs:18:12

View file

@ -66,8 +66,11 @@ error[E0531]: cannot find unit struct, unit variant or constant `Self` in this s
LL | mut Self => (),
| ^^^^ not found in this scope
|
= note: this unit struct exists but is inaccessible:
foo::Self
note: unit struct `foo::Self` exists but is inaccessible
--> $DIR/self_type_keyword.rs:2:3
|
LL | struct Self;
| ^^^^^^^^^^^^ not accessible
error[E0392]: parameter `'Self` is never used
--> $DIR/self_type_keyword.rs:6:12