Conservatively report "not sure" in cfg_accessible

This commit is contained in:
Urgau 2022-05-25 20:08:27 +02:00
parent a4d03c6c94
commit b76d1125d4
6 changed files with 59 additions and 33 deletions

View file

@ -443,7 +443,9 @@ impl<'a> ResolverExpand for Resolver<'a> {
PathResult::NonModule(partial_res) if partial_res.unresolved_segments() == 0 => {
return Ok(true);
}
PathResult::NonModule(..) => {
PathResult::NonModule(..) |
// HACK(Urgau): This shouldn't be necessary
PathResult::Failed { is_error_from_last_segment: false, .. } => {
self.session
.struct_span_err(span, "not sure whether the path is accessible or not")
.note("the type may have associated items, but we are currently not checking them")

View file

@ -5,20 +5,8 @@
#![feature(cfg_accessible)]
#![feature(trait_alias)]
enum Enum {
Existing { existing: u8 },
}
trait TraitAlias = std::fmt::Debug + Send;
// FIXME: Currently returns `false` but should be "not sure"
#[cfg_accessible(Enum::Existing::existing)]
const A: bool = true;
// FIXME: Currently returns `false` but should be "not sure"
#[cfg_accessible(Enum::Existing::unresolved)]
const B: bool = true;
// FIXME: Currently shows "cannot determine" but should be `false`
#[cfg_accessible(unresolved)] //~ ERROR cannot determine
const C: bool = true;

View file

@ -1,5 +1,5 @@
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-bugs.rs:28:18
--> $DIR/cfg_accessible-bugs.rs:15:18
|
LL | #[cfg_accessible(TraitAlias::unresolved)]
| ^^^^^^^^^^^^^^^^^^^^^^
@ -7,7 +7,7 @@ LL | #[cfg_accessible(TraitAlias::unresolved)]
= note: the type may have associated items, but we are currently not checking them
error: cannot determine whether the path is accessible or not
--> $DIR/cfg_accessible-bugs.rs:24:1
--> $DIR/cfg_accessible-bugs.rs:11:1
|
LL | #[cfg_accessible(unresolved)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -33,13 +33,29 @@ LL | #[cfg_accessible(Union::unresolved)]
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:36:18
|
LL | #[cfg_accessible(Enum::Existing::existing)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:38:18
|
LL | #[cfg_accessible(Enum::Existing::unresolved)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:40:18
|
LL | #[cfg_accessible(Enum::unresolved)]
| ^^^^^^^^^^^^^^^^
|
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:46:18
--> $DIR/cfg_accessible-not_sure.rs:50:18
|
LL | #[cfg_accessible(Trait::existing)]
| ^^^^^^^^^^^^^^^
@ -47,7 +63,7 @@ LL | #[cfg_accessible(Trait::existing)]
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:48:18
--> $DIR/cfg_accessible-not_sure.rs:52:18
|
LL | #[cfg_accessible(Trait::unresolved)]
| ^^^^^^^^^^^^^^^^^
@ -55,7 +71,7 @@ LL | #[cfg_accessible(Trait::unresolved)]
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:55:18
--> $DIR/cfg_accessible-not_sure.rs:59:18
|
LL | #[cfg_accessible(TypeAlias::existing)]
| ^^^^^^^^^^^^^^^^^^^
@ -63,7 +79,7 @@ LL | #[cfg_accessible(TypeAlias::existing)]
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:57:18
--> $DIR/cfg_accessible-not_sure.rs:61:18
|
LL | #[cfg_accessible(TypeAlias::unresolved)]
| ^^^^^^^^^^^^^^^^^^^^^
@ -71,7 +87,7 @@ LL | #[cfg_accessible(TypeAlias::unresolved)]
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:66:18
--> $DIR/cfg_accessible-not_sure.rs:70:18
|
LL | #[cfg_accessible(ForeignType::unresolved)]
| ^^^^^^^^^^^^^^^^^^^^^^^
@ -79,7 +95,7 @@ LL | #[cfg_accessible(ForeignType::unresolved)]
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:75:18
--> $DIR/cfg_accessible-not_sure.rs:79:18
|
LL | #[cfg_accessible(AssocType::AssocType::unresolved)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -87,7 +103,7 @@ LL | #[cfg_accessible(AssocType::AssocType::unresolved)]
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:80:18
--> $DIR/cfg_accessible-not_sure.rs:84:18
|
LL | #[cfg_accessible(u8::unresolved)]
| ^^^^^^^^^^^^^^
@ -95,12 +111,12 @@ LL | #[cfg_accessible(u8::unresolved)]
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:82:18
--> $DIR/cfg_accessible-not_sure.rs:86:18
|
LL | #[cfg_accessible(u8::is_ascii)]
| ^^^^^^^^^^^^
|
= note: the type may have associated items, but we are currently not checking them
error: aborting due to 13 previous errors
error: aborting due to 15 previous errors

View file

@ -33,13 +33,29 @@ LL | #[cfg_accessible(Union::unresolved)]
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:36:18
|
LL | #[cfg_accessible(Enum::Existing::existing)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:38:18
|
LL | #[cfg_accessible(Enum::Existing::unresolved)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:40:18
|
LL | #[cfg_accessible(Enum::unresolved)]
| ^^^^^^^^^^^^^^^^
|
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:46:18
--> $DIR/cfg_accessible-not_sure.rs:50:18
|
LL | #[cfg_accessible(Trait::existing)]
| ^^^^^^^^^^^^^^^
@ -47,7 +63,7 @@ LL | #[cfg_accessible(Trait::existing)]
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:48:18
--> $DIR/cfg_accessible-not_sure.rs:52:18
|
LL | #[cfg_accessible(Trait::unresolved)]
| ^^^^^^^^^^^^^^^^^
@ -55,7 +71,7 @@ LL | #[cfg_accessible(Trait::unresolved)]
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:55:18
--> $DIR/cfg_accessible-not_sure.rs:59:18
|
LL | #[cfg_accessible(TypeAlias::existing)]
| ^^^^^^^^^^^^^^^^^^^
@ -63,7 +79,7 @@ LL | #[cfg_accessible(TypeAlias::existing)]
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:57:18
--> $DIR/cfg_accessible-not_sure.rs:61:18
|
LL | #[cfg_accessible(TypeAlias::unresolved)]
| ^^^^^^^^^^^^^^^^^^^^^
@ -71,7 +87,7 @@ LL | #[cfg_accessible(TypeAlias::unresolved)]
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:66:18
--> $DIR/cfg_accessible-not_sure.rs:70:18
|
LL | #[cfg_accessible(ForeignType::unresolved)]
| ^^^^^^^^^^^^^^^^^^^^^^^
@ -79,7 +95,7 @@ LL | #[cfg_accessible(ForeignType::unresolved)]
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:75:18
--> $DIR/cfg_accessible-not_sure.rs:79:18
|
LL | #[cfg_accessible(AssocType::AssocType::unresolved)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -87,7 +103,7 @@ LL | #[cfg_accessible(AssocType::AssocType::unresolved)]
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:80:18
--> $DIR/cfg_accessible-not_sure.rs:84:18
|
LL | #[cfg_accessible(u8::unresolved)]
| ^^^^^^^^^^^^^^
@ -95,12 +111,12 @@ LL | #[cfg_accessible(u8::unresolved)]
= note: the type may have associated items, but we are currently not checking them
error: not sure whether the path is accessible or not
--> $DIR/cfg_accessible-not_sure.rs:82:18
--> $DIR/cfg_accessible-not_sure.rs:86:18
|
LL | #[cfg_accessible(u8::is_ascii)]
| ^^^^^^^^^^^^
|
= note: the type may have associated items, but we are currently not checking them
error: aborting due to 13 previous errors
error: aborting due to 15 previous errors

View file

@ -33,6 +33,10 @@ enum Enum {
Existing { existing: u8 },
}
#[cfg_accessible(Enum::Existing::existing)] //~ ERROR not sure
const A: bool = true;
#[cfg_accessible(Enum::Existing::unresolved)] //~ ERROR not sure
const B: bool = true;
#[cfg_accessible(Enum::unresolved)] //~ ERROR not sure
const C: bool = true;