Skip to content

Commit 5f294f0

Browse files
committed
Improve test for FQS tuple struct pat/expr
1. Better explain what the test tests 2. Test slightly more cases
1 parent 49e5e4e commit 5f294f0

4 files changed

+113
-43
lines changed

tests/ui/associated-types/associated-type-tuple-struct-construction.rs

-24
This file was deleted.

tests/ui/associated-types/associated-type-tuple-struct-construction.stderr

-19
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Check that fully qualified syntax can **not** be used in tuple struct expressions (calls) and
2+
// patterns. Both tuple struct expressions and patterns are resolved in value namespace and thus
3+
// can't be resolved through associated *types*.
4+
5+
#![feature(more_qualified_paths)]
6+
7+
fn main() {
8+
let <T<0> as Trait>::Assoc() = <T<0> as Trait>::Assoc();
9+
//~^ error: expected method or associated constant, found associated type
10+
//~| error: expected method or associated constant, found associated type
11+
let <T<1> as Trait>::Assoc(_a) = <T<1> as Trait>::Assoc(0);
12+
//~^ error: expected method or associated constant, found associated type
13+
//~| error: expected method or associated constant, found associated type
14+
let <T<2> as Trait>::Assoc(_a, _b) = <T<2> as Trait>::Assoc(0, 1);
15+
//~^ error: expected method or associated constant, found associated type
16+
//~| error: expected method or associated constant, found associated type
17+
let <T<3> as Trait>::Assoc(ref _a, ref mut _b, mut _c) = <T<3> as Trait>::Assoc(0, 1, 2);
18+
//~^ error: expected method or associated constant, found associated type
19+
//~| error: expected method or associated constant, found associated type
20+
}
21+
22+
23+
struct T<const N: usize>;
24+
25+
struct T0();
26+
struct T1(u8);
27+
struct T2(u8, u8);
28+
struct T3(u8, u8, u8);
29+
30+
trait Trait {
31+
type Assoc;
32+
}
33+
34+
impl Trait for T<0> {
35+
type Assoc = T0;
36+
}
37+
38+
impl Trait for T<1> {
39+
type Assoc = T1;
40+
}
41+
impl Trait for T<2> {
42+
type Assoc = T2;
43+
}
44+
impl Trait for T<3> {
45+
type Assoc = T3;
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
error[E0575]: expected method or associated constant, found associated type `Trait::Assoc`
2+
--> $DIR/tuple-struct-expr-pat.rs:8:36
3+
|
4+
LL | let <T<0> as Trait>::Assoc() = <T<0> as Trait>::Assoc();
5+
| ^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: can't use a type alias as a constructor
8+
9+
error[E0575]: expected method or associated constant, found associated type `Trait::Assoc`
10+
--> $DIR/tuple-struct-expr-pat.rs:8:9
11+
|
12+
LL | let <T<0> as Trait>::Assoc() = <T<0> as Trait>::Assoc();
13+
| ^^^^^^^^^^^^^^^^^^^^^^
14+
|
15+
= note: can't use a type alias as a constructor
16+
17+
error[E0575]: expected method or associated constant, found associated type `Trait::Assoc`
18+
--> $DIR/tuple-struct-expr-pat.rs:11:38
19+
|
20+
LL | let <T<1> as Trait>::Assoc(_a) = <T<1> as Trait>::Assoc(0);
21+
| ^^^^^^^^^^^^^^^^^^^^^^
22+
|
23+
= note: can't use a type alias as a constructor
24+
25+
error[E0575]: expected method or associated constant, found associated type `Trait::Assoc`
26+
--> $DIR/tuple-struct-expr-pat.rs:11:9
27+
|
28+
LL | let <T<1> as Trait>::Assoc(_a) = <T<1> as Trait>::Assoc(0);
29+
| ^^^^^^^^^^^^^^^^^^^^^^
30+
|
31+
= note: can't use a type alias as a constructor
32+
33+
error[E0575]: expected method or associated constant, found associated type `Trait::Assoc`
34+
--> $DIR/tuple-struct-expr-pat.rs:14:42
35+
|
36+
LL | let <T<2> as Trait>::Assoc(_a, _b) = <T<2> as Trait>::Assoc(0, 1);
37+
| ^^^^^^^^^^^^^^^^^^^^^^
38+
|
39+
= note: can't use a type alias as a constructor
40+
41+
error[E0575]: expected method or associated constant, found associated type `Trait::Assoc`
42+
--> $DIR/tuple-struct-expr-pat.rs:14:9
43+
|
44+
LL | let <T<2> as Trait>::Assoc(_a, _b) = <T<2> as Trait>::Assoc(0, 1);
45+
| ^^^^^^^^^^^^^^^^^^^^^^
46+
|
47+
= note: can't use a type alias as a constructor
48+
49+
error[E0575]: expected method or associated constant, found associated type `Trait::Assoc`
50+
--> $DIR/tuple-struct-expr-pat.rs:17:62
51+
|
52+
LL | let <T<3> as Trait>::Assoc(ref _a, ref mut _b, mut _c) = <T<3> as Trait>::Assoc(0, 1, 2);
53+
| ^^^^^^^^^^^^^^^^^^^^^^
54+
|
55+
= note: can't use a type alias as a constructor
56+
57+
error[E0575]: expected method or associated constant, found associated type `Trait::Assoc`
58+
--> $DIR/tuple-struct-expr-pat.rs:17:9
59+
|
60+
LL | let <T<3> as Trait>::Assoc(ref _a, ref mut _b, mut _c) = <T<3> as Trait>::Assoc(0, 1, 2);
61+
| ^^^^^^^^^^^^^^^^^^^^^^
62+
|
63+
= note: can't use a type alias as a constructor
64+
65+
error: aborting due to 8 previous errors
66+
67+
For more information about this error, try `rustc --explain E0575`.

0 commit comments

Comments
 (0)