Skip to content

Commit b76d112

Browse files
committed
Conservatively report "not sure" in cfg_accessible
1 parent a4d03c6 commit b76d112

File tree

6 files changed

+59
-33
lines changed

6 files changed

+59
-33
lines changed

compiler/rustc_resolve/src/macros.rs

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

src/test/ui/conditional-compilation/cfg_accessible-bugs.rs

-12
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,8 @@
55
#![feature(cfg_accessible)]
66
#![feature(trait_alias)]
77

8-
enum Enum {
9-
Existing { existing: u8 },
10-
}
11-
128
trait TraitAlias = std::fmt::Debug + Send;
139

14-
// FIXME: Currently returns `false` but should be "not sure"
15-
#[cfg_accessible(Enum::Existing::existing)]
16-
const A: bool = true;
17-
18-
// FIXME: Currently returns `false` but should be "not sure"
19-
#[cfg_accessible(Enum::Existing::unresolved)]
20-
const B: bool = true;
21-
2210
// FIXME: Currently shows "cannot determine" but should be `false`
2311
#[cfg_accessible(unresolved)] //~ ERROR cannot determine
2412
const C: bool = true;

src/test/ui/conditional-compilation/cfg_accessible-bugs.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: not sure whether the path is accessible or not
2-
--> $DIR/cfg_accessible-bugs.rs:28:18
2+
--> $DIR/cfg_accessible-bugs.rs:15:18
33
|
44
LL | #[cfg_accessible(TraitAlias::unresolved)]
55
| ^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: the type may have associated items, but we are currently not checking them
88

99
error: cannot determine whether the path is accessible or not
10-
--> $DIR/cfg_accessible-bugs.rs:24:1
10+
--> $DIR/cfg_accessible-bugs.rs:11:1
1111
|
1212
LL | #[cfg_accessible(unresolved)]
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/conditional-compilation/cfg_accessible-not_sure.edition2015.stderr

+25-9
Original file line numberDiff line numberDiff line change
@@ -33,74 +33,90 @@ LL | #[cfg_accessible(Union::unresolved)]
3333
error: not sure whether the path is accessible or not
3434
--> $DIR/cfg_accessible-not_sure.rs:36:18
3535
|
36+
LL | #[cfg_accessible(Enum::Existing::existing)]
37+
| ^^^^^^^^^^^^^^^^^^^^^^^^
38+
|
39+
= note: the type may have associated items, but we are currently not checking them
40+
41+
error: not sure whether the path is accessible or not
42+
--> $DIR/cfg_accessible-not_sure.rs:38:18
43+
|
44+
LL | #[cfg_accessible(Enum::Existing::unresolved)]
45+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
46+
|
47+
= note: the type may have associated items, but we are currently not checking them
48+
49+
error: not sure whether the path is accessible or not
50+
--> $DIR/cfg_accessible-not_sure.rs:40:18
51+
|
3652
LL | #[cfg_accessible(Enum::unresolved)]
3753
| ^^^^^^^^^^^^^^^^
3854
|
3955
= note: the type may have associated items, but we are currently not checking them
4056

4157
error: not sure whether the path is accessible or not
42-
--> $DIR/cfg_accessible-not_sure.rs:46:18
58+
--> $DIR/cfg_accessible-not_sure.rs:50:18
4359
|
4460
LL | #[cfg_accessible(Trait::existing)]
4561
| ^^^^^^^^^^^^^^^
4662
|
4763
= note: the type may have associated items, but we are currently not checking them
4864

4965
error: not sure whether the path is accessible or not
50-
--> $DIR/cfg_accessible-not_sure.rs:48:18
66+
--> $DIR/cfg_accessible-not_sure.rs:52:18
5167
|
5268
LL | #[cfg_accessible(Trait::unresolved)]
5369
| ^^^^^^^^^^^^^^^^^
5470
|
5571
= note: the type may have associated items, but we are currently not checking them
5672

5773
error: not sure whether the path is accessible or not
58-
--> $DIR/cfg_accessible-not_sure.rs:55:18
74+
--> $DIR/cfg_accessible-not_sure.rs:59:18
5975
|
6076
LL | #[cfg_accessible(TypeAlias::existing)]
6177
| ^^^^^^^^^^^^^^^^^^^
6278
|
6379
= note: the type may have associated items, but we are currently not checking them
6480

6581
error: not sure whether the path is accessible or not
66-
--> $DIR/cfg_accessible-not_sure.rs:57:18
82+
--> $DIR/cfg_accessible-not_sure.rs:61:18
6783
|
6884
LL | #[cfg_accessible(TypeAlias::unresolved)]
6985
| ^^^^^^^^^^^^^^^^^^^^^
7086
|
7187
= note: the type may have associated items, but we are currently not checking them
7288

7389
error: not sure whether the path is accessible or not
74-
--> $DIR/cfg_accessible-not_sure.rs:66:18
90+
--> $DIR/cfg_accessible-not_sure.rs:70:18
7591
|
7692
LL | #[cfg_accessible(ForeignType::unresolved)]
7793
| ^^^^^^^^^^^^^^^^^^^^^^^
7894
|
7995
= note: the type may have associated items, but we are currently not checking them
8096

8197
error: not sure whether the path is accessible or not
82-
--> $DIR/cfg_accessible-not_sure.rs:75:18
98+
--> $DIR/cfg_accessible-not_sure.rs:79:18
8399
|
84100
LL | #[cfg_accessible(AssocType::AssocType::unresolved)]
85101
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
86102
|
87103
= note: the type may have associated items, but we are currently not checking them
88104

89105
error: not sure whether the path is accessible or not
90-
--> $DIR/cfg_accessible-not_sure.rs:80:18
106+
--> $DIR/cfg_accessible-not_sure.rs:84:18
91107
|
92108
LL | #[cfg_accessible(u8::unresolved)]
93109
| ^^^^^^^^^^^^^^
94110
|
95111
= note: the type may have associated items, but we are currently not checking them
96112

97113
error: not sure whether the path is accessible or not
98-
--> $DIR/cfg_accessible-not_sure.rs:82:18
114+
--> $DIR/cfg_accessible-not_sure.rs:86:18
99115
|
100116
LL | #[cfg_accessible(u8::is_ascii)]
101117
| ^^^^^^^^^^^^
102118
|
103119
= note: the type may have associated items, but we are currently not checking them
104120

105-
error: aborting due to 13 previous errors
121+
error: aborting due to 15 previous errors
106122

src/test/ui/conditional-compilation/cfg_accessible-not_sure.edition2021.stderr

+25-9
Original file line numberDiff line numberDiff line change
@@ -33,74 +33,90 @@ LL | #[cfg_accessible(Union::unresolved)]
3333
error: not sure whether the path is accessible or not
3434
--> $DIR/cfg_accessible-not_sure.rs:36:18
3535
|
36+
LL | #[cfg_accessible(Enum::Existing::existing)]
37+
| ^^^^^^^^^^^^^^^^^^^^^^^^
38+
|
39+
= note: the type may have associated items, but we are currently not checking them
40+
41+
error: not sure whether the path is accessible or not
42+
--> $DIR/cfg_accessible-not_sure.rs:38:18
43+
|
44+
LL | #[cfg_accessible(Enum::Existing::unresolved)]
45+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
46+
|
47+
= note: the type may have associated items, but we are currently not checking them
48+
49+
error: not sure whether the path is accessible or not
50+
--> $DIR/cfg_accessible-not_sure.rs:40:18
51+
|
3652
LL | #[cfg_accessible(Enum::unresolved)]
3753
| ^^^^^^^^^^^^^^^^
3854
|
3955
= note: the type may have associated items, but we are currently not checking them
4056

4157
error: not sure whether the path is accessible or not
42-
--> $DIR/cfg_accessible-not_sure.rs:46:18
58+
--> $DIR/cfg_accessible-not_sure.rs:50:18
4359
|
4460
LL | #[cfg_accessible(Trait::existing)]
4561
| ^^^^^^^^^^^^^^^
4662
|
4763
= note: the type may have associated items, but we are currently not checking them
4864

4965
error: not sure whether the path is accessible or not
50-
--> $DIR/cfg_accessible-not_sure.rs:48:18
66+
--> $DIR/cfg_accessible-not_sure.rs:52:18
5167
|
5268
LL | #[cfg_accessible(Trait::unresolved)]
5369
| ^^^^^^^^^^^^^^^^^
5470
|
5571
= note: the type may have associated items, but we are currently not checking them
5672

5773
error: not sure whether the path is accessible or not
58-
--> $DIR/cfg_accessible-not_sure.rs:55:18
74+
--> $DIR/cfg_accessible-not_sure.rs:59:18
5975
|
6076
LL | #[cfg_accessible(TypeAlias::existing)]
6177
| ^^^^^^^^^^^^^^^^^^^
6278
|
6379
= note: the type may have associated items, but we are currently not checking them
6480

6581
error: not sure whether the path is accessible or not
66-
--> $DIR/cfg_accessible-not_sure.rs:57:18
82+
--> $DIR/cfg_accessible-not_sure.rs:61:18
6783
|
6884
LL | #[cfg_accessible(TypeAlias::unresolved)]
6985
| ^^^^^^^^^^^^^^^^^^^^^
7086
|
7187
= note: the type may have associated items, but we are currently not checking them
7288

7389
error: not sure whether the path is accessible or not
74-
--> $DIR/cfg_accessible-not_sure.rs:66:18
90+
--> $DIR/cfg_accessible-not_sure.rs:70:18
7591
|
7692
LL | #[cfg_accessible(ForeignType::unresolved)]
7793
| ^^^^^^^^^^^^^^^^^^^^^^^
7894
|
7995
= note: the type may have associated items, but we are currently not checking them
8096

8197
error: not sure whether the path is accessible or not
82-
--> $DIR/cfg_accessible-not_sure.rs:75:18
98+
--> $DIR/cfg_accessible-not_sure.rs:79:18
8399
|
84100
LL | #[cfg_accessible(AssocType::AssocType::unresolved)]
85101
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
86102
|
87103
= note: the type may have associated items, but we are currently not checking them
88104

89105
error: not sure whether the path is accessible or not
90-
--> $DIR/cfg_accessible-not_sure.rs:80:18
106+
--> $DIR/cfg_accessible-not_sure.rs:84:18
91107
|
92108
LL | #[cfg_accessible(u8::unresolved)]
93109
| ^^^^^^^^^^^^^^
94110
|
95111
= note: the type may have associated items, but we are currently not checking them
96112

97113
error: not sure whether the path is accessible or not
98-
--> $DIR/cfg_accessible-not_sure.rs:82:18
114+
--> $DIR/cfg_accessible-not_sure.rs:86:18
99115
|
100116
LL | #[cfg_accessible(u8::is_ascii)]
101117
| ^^^^^^^^^^^^
102118
|
103119
= note: the type may have associated items, but we are currently not checking them
104120

105-
error: aborting due to 13 previous errors
121+
error: aborting due to 15 previous errors
106122

src/test/ui/conditional-compilation/cfg_accessible-not_sure.rs

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ enum Enum {
3333
Existing { existing: u8 },
3434
}
3535

36+
#[cfg_accessible(Enum::Existing::existing)] //~ ERROR not sure
37+
const A: bool = true;
38+
#[cfg_accessible(Enum::Existing::unresolved)] //~ ERROR not sure
39+
const B: bool = true;
3640
#[cfg_accessible(Enum::unresolved)] //~ ERROR not sure
3741
const C: bool = true;
3842

0 commit comments

Comments
 (0)