Skip to content

Commit eef85cf

Browse files
committed
Add tests checking taht "priority" of qpath recovery is higher than unary and binary operators
1 parent 9a68098 commit eef85cf

File tree

6 files changed

+97
-3
lines changed

6 files changed

+97
-3
lines changed

src/test/ui/did_you_mean/bad-assoc-expr.rs

+6
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,10 @@ fn main() {
2121

2222
(u8, u8)::clone(&(0, 0));
2323
//~^ ERROR missing angle brackets in associated item path
24+
25+
&(u8)::clone(&0);
26+
//~^ ERROR missing angle brackets in associated item path
27+
28+
10 + (u8)::clone(&0);
29+
//~^ ERROR missing angle brackets in associated item path
2430
}

src/test/ui/did_you_mean/bad-assoc-expr.stderr

+13-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,17 @@ error: missing angle brackets in associated item path
2222
22 | (u8, u8)::clone(&(0, 0));
2323
| ^^^^^^^^^^^^^^^ help: try: `<(u8, u8)>::clone`
2424

25-
error: aborting due to 4 previous errors
25+
error: missing angle brackets in associated item path
26+
--> $DIR/bad-assoc-expr.rs:25:6
27+
|
28+
25 | &(u8)::clone(&0);
29+
| ^^^^^^^^^^^ help: try: `<(u8)>::clone`
30+
31+
error: missing angle brackets in associated item path
32+
--> $DIR/bad-assoc-expr.rs:28:10
33+
|
34+
28 | 10 + (u8)::clone(&0);
35+
| ^^^^^^^^^^^ help: try: `<(u8)>::clone`
36+
37+
error: aborting due to 6 previous errors
2638

src/test/ui/did_you_mean/bad-assoc-pat.rs

+5
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@ fn main() {
2020
//~^ ERROR missing angle brackets in associated item path
2121
//~| ERROR no associated item named `AssocItem` found for type `_` in the current scope
2222
}
23+
match &0u8 {
24+
&(u8,)::AssocItem => {}
25+
//~^ ERROR missing angle brackets in associated item path
26+
//~| ERROR no associated item named `AssocItem` found for type `(u8,)` in the current scope
27+
}
2328
}

src/test/ui/did_you_mean/bad-assoc-pat.stderr

+13-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ error: missing angle brackets in associated item path
1616
19 | _::AssocItem => {}
1717
| ^^^^^^^^^^^^ help: try: `<_>::AssocItem`
1818

19+
error: missing angle brackets in associated item path
20+
--> $DIR/bad-assoc-pat.rs:24:10
21+
|
22+
24 | &(u8,)::AssocItem => {}
23+
| ^^^^^^^^^^^^^^^^ help: try: `<(u8,)>::AssocItem`
24+
1925
error[E0599]: no associated item named `AssocItem` found for type `[u8]` in the current scope
2026
--> $DIR/bad-assoc-pat.rs:13:9
2127
|
@@ -34,5 +40,11 @@ error[E0599]: no associated item named `AssocItem` found for type `_` in the cur
3440
19 | _::AssocItem => {}
3541
| ^^^^^^^^^^^^ associated item not found in `_`
3642

37-
error: aborting due to 6 previous errors
43+
error[E0599]: no associated item named `AssocItem` found for type `(u8,)` in the current scope
44+
--> $DIR/bad-assoc-pat.rs:24:10
45+
|
46+
24 | &(u8,)::AssocItem => {}
47+
| ^^^^^^^^^^^^^^^^ associated item not found in `(u8,)`
48+
49+
error: aborting due to 8 previous errors
3850

src/test/ui/did_you_mean/bad-assoc-ty.rs

+17
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,21 @@ type E = _::AssocTy;
2828
//~^ ERROR missing angle brackets in associated item path
2929
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
3030

31+
type F = &'static (u8)::AssocTy;
32+
//~^ ERROR missing angle brackets in associated item path
33+
//~| ERROR ambiguous associated type
34+
35+
// Qualified paths cannot appear in bounds, so the recovery
36+
// should apply to the whole sum and not `(Send)`.
37+
type G = 'static + (Send)::AssocTy;
38+
//~^ ERROR missing angle brackets in associated item path
39+
//~| ERROR ambiguous associated type
40+
41+
// FIXME
42+
// This is actually a legal path with fn-like generic arguments in the middle!
43+
// Recovery should not apply in this context.
44+
type H = Fn(u8) -> (u8)::Output;
45+
//~^ ERROR missing angle brackets in associated item path
46+
//~| ERROR ambiguous associated type
47+
3148
fn main() {}

src/test/ui/did_you_mean/bad-assoc-ty.stderr

+43-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@ error: missing angle brackets in associated item path
2828
27 | type E = _::AssocTy;
2929
| ^^^^^^^^^^ help: try: `<_>::AssocTy`
3030

31+
error: missing angle brackets in associated item path
32+
--> $DIR/bad-assoc-ty.rs:31:19
33+
|
34+
31 | type F = &'static (u8)::AssocTy;
35+
| ^^^^^^^^^^^^^ help: try: `<(u8)>::AssocTy`
36+
37+
error: missing angle brackets in associated item path
38+
--> $DIR/bad-assoc-ty.rs:37:10
39+
|
40+
37 | type G = 'static + (Send)::AssocTy;
41+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `< 'static + Send>::AssocTy`
42+
43+
error: missing angle brackets in associated item path
44+
--> $DIR/bad-assoc-ty.rs:44:20
45+
|
46+
44 | type H = Fn(u8) -> (u8)::Output;
47+
| ^^^^^^^^^^^^ help: try: `<(u8)>::Output`
48+
3149
error[E0223]: ambiguous associated type
3250
--> $DIR/bad-assoc-ty.rs:11:10
3351
|
@@ -66,5 +84,29 @@ error[E0121]: the type placeholder `_` is not allowed within types on item signa
6684
27 | type E = _::AssocTy;
6785
| ^ not allowed in type signatures
6886

69-
error: aborting due to 10 previous errors
87+
error[E0223]: ambiguous associated type
88+
--> $DIR/bad-assoc-ty.rs:31:19
89+
|
90+
31 | type F = &'static (u8)::AssocTy;
91+
| ^^^^^^^^^^^^^ ambiguous associated type
92+
|
93+
= note: specify the type using the syntax `<u8 as Trait>::AssocTy`
94+
95+
error[E0223]: ambiguous associated type
96+
--> $DIR/bad-assoc-ty.rs:37:10
97+
|
98+
37 | type G = 'static + (Send)::AssocTy;
99+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type
100+
|
101+
= note: specify the type using the syntax `<std::marker::Send + 'static as Trait>::AssocTy`
102+
103+
error[E0223]: ambiguous associated type
104+
--> $DIR/bad-assoc-ty.rs:44:20
105+
|
106+
44 | type H = Fn(u8) -> (u8)::Output;
107+
| ^^^^^^^^^^^^ ambiguous associated type
108+
|
109+
= note: specify the type using the syntax `<u8 as Trait>::Output`
110+
111+
error: aborting due to 16 previous errors
70112

0 commit comments

Comments
 (0)