about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUrgau <urgau@numericable.fr>2022-05-25 20:08:27 +0200
committerUrgau <urgau@numericable.fr>2022-06-03 11:31:11 +0200
commitb76d1125d4f1596e4c4481064fa6342990f1a985 (patch)
tree511407df881b6878dc53fdf014c9f98c6f170274
parenta4d03c6c94b7c46a2d53a9412c447932d69316a4 (diff)
downloadrust-b76d1125d4f1596e4c4481064fa6342990f1a985.tar.gz
rust-b76d1125d4f1596e4c4481064fa6342990f1a985.zip
Conservatively report "not sure" in cfg_accessible
-rw-r--r--compiler/rustc_resolve/src/macros.rs4
-rw-r--r--src/test/ui/conditional-compilation/cfg_accessible-bugs.rs12
-rw-r--r--src/test/ui/conditional-compilation/cfg_accessible-bugs.stderr4
-rw-r--r--src/test/ui/conditional-compilation/cfg_accessible-not_sure.edition2015.stderr34
-rw-r--r--src/test/ui/conditional-compilation/cfg_accessible-not_sure.edition2021.stderr34
-rw-r--r--src/test/ui/conditional-compilation/cfg_accessible-not_sure.rs4
6 files changed, 59 insertions, 33 deletions
diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs
index 31d7bda5989..2e2d3674560 100644
--- a/compiler/rustc_resolve/src/macros.rs
+++ b/compiler/rustc_resolve/src/macros.rs
@@ -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")
diff --git a/src/test/ui/conditional-compilation/cfg_accessible-bugs.rs b/src/test/ui/conditional-compilation/cfg_accessible-bugs.rs
index a95d397d3d2..ae18bc55c4f 100644
--- a/src/test/ui/conditional-compilation/cfg_accessible-bugs.rs
+++ b/src/test/ui/conditional-compilation/cfg_accessible-bugs.rs
@@ -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;
diff --git a/src/test/ui/conditional-compilation/cfg_accessible-bugs.stderr b/src/test/ui/conditional-compilation/cfg_accessible-bugs.stderr
index 30db6063041..81f02387835 100644
--- a/src/test/ui/conditional-compilation/cfg_accessible-bugs.stderr
+++ b/src/test/ui/conditional-compilation/cfg_accessible-bugs.stderr
@@ -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)]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/src/test/ui/conditional-compilation/cfg_accessible-not_sure.edition2015.stderr b/src/test/ui/conditional-compilation/cfg_accessible-not_sure.edition2015.stderr
index f0a57def525..7d5dd589027 100644
--- a/src/test/ui/conditional-compilation/cfg_accessible-not_sure.edition2015.stderr
+++ b/src/test/ui/conditional-compilation/cfg_accessible-not_sure.edition2015.stderr
@@ -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
 
diff --git a/src/test/ui/conditional-compilation/cfg_accessible-not_sure.edition2021.stderr b/src/test/ui/conditional-compilation/cfg_accessible-not_sure.edition2021.stderr
index f0a57def525..7d5dd589027 100644
--- a/src/test/ui/conditional-compilation/cfg_accessible-not_sure.edition2021.stderr
+++ b/src/test/ui/conditional-compilation/cfg_accessible-not_sure.edition2021.stderr
@@ -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
 
diff --git a/src/test/ui/conditional-compilation/cfg_accessible-not_sure.rs b/src/test/ui/conditional-compilation/cfg_accessible-not_sure.rs
index 55b68ce0d63..d68acd2451f 100644
--- a/src/test/ui/conditional-compilation/cfg_accessible-not_sure.rs
+++ b/src/test/ui/conditional-compilation/cfg_accessible-not_sure.rs
@@ -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;