diff options
| author | Michael Goulet <michael@errs.io> | 2025-01-04 00:13:49 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2025-01-06 18:04:33 +0000 |
| commit | 304ccf45d15153b29c413a84334a9b4aaee23d53 (patch) | |
| tree | e687819e1dc44220d3bd221377bfd572349c8e43 /tests | |
| parent | 243d2ca4db6f96d2d18aaf3a2381251d38eb6b0b (diff) | |
| download | rust-304ccf45d15153b29c413a84334a9b4aaee23d53.tar.gz rust-304ccf45d15153b29c413a84334a9b4aaee23d53.zip | |
Suggest to replace tuple constructor through projection
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/associated-types/invalid-ctor.fixed | 22 | ||||
| -rw-r--r-- | tests/ui/associated-types/invalid-ctor.rs | 22 | ||||
| -rw-r--r-- | tests/ui/associated-types/invalid-ctor.stderr | 14 |
3 files changed, 58 insertions, 0 deletions
diff --git a/tests/ui/associated-types/invalid-ctor.fixed b/tests/ui/associated-types/invalid-ctor.fixed new file mode 100644 index 00000000000..eba3820de0c --- /dev/null +++ b/tests/ui/associated-types/invalid-ctor.fixed @@ -0,0 +1,22 @@ +//@ run-rustfix + +#![allow(unused)] + +struct Constructor(i32); + +trait Trait { + type Out; + + fn mk() -> Self::Out; +} + +impl Trait for () { + type Out = Constructor; + + fn mk() -> Self::Out { + Constructor(1) + //~^ ERROR no associated item named `Out` found for unit type `()` + } +} + +fn main() {} diff --git a/tests/ui/associated-types/invalid-ctor.rs b/tests/ui/associated-types/invalid-ctor.rs new file mode 100644 index 00000000000..73335c065c2 --- /dev/null +++ b/tests/ui/associated-types/invalid-ctor.rs @@ -0,0 +1,22 @@ +//@ run-rustfix + +#![allow(unused)] + +struct Constructor(i32); + +trait Trait { + type Out; + + fn mk() -> Self::Out; +} + +impl Trait for () { + type Out = Constructor; + + fn mk() -> Self::Out { + Self::Out(1) + //~^ ERROR no associated item named `Out` found for unit type `()` + } +} + +fn main() {} diff --git a/tests/ui/associated-types/invalid-ctor.stderr b/tests/ui/associated-types/invalid-ctor.stderr new file mode 100644 index 00000000000..b545c95a768 --- /dev/null +++ b/tests/ui/associated-types/invalid-ctor.stderr @@ -0,0 +1,14 @@ +error[E0599]: no associated item named `Out` found for unit type `()` in the current scope + --> $DIR/invalid-ctor.rs:17:15 + | +LL | Self::Out(1) + | ^^^ associated item not found in `()` + | +help: to construct a value of type `Constructor`, use the explicit path + | +LL | Constructor(1) + | ~~~~~~~~~~~ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0599`. |
