diff options
| author | Jack Huey <31162821+jackh726@users.noreply.github.com> | 2021-04-28 22:59:29 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-28 22:59:29 -0400 |
| commit | 96c2316ed99c836e02eddca3f8849caa0cc85e16 (patch) | |
| tree | c29e02bba4e82a6604184baacdb9c711f15c574b | |
| parent | 43068063c041c7f62762fc52536e2b3e497b1789 (diff) | |
| parent | de92dfb3b604cfb6316ba7d5a3dea2bd36b6072d (diff) | |
| download | rust-96c2316ed99c836e02eddca3f8849caa0cc85e16.tar.gz rust-96c2316ed99c836e02eddca3f8849caa0cc85e16.zip | |
Rollup merge of #84646 - JohnTitor:add-some-bad-placeholder-tests, r=Dylan-DPC
Add some regression tests related to #82494 Closes #75883, closes #80779 r? ````@estebank````
| -rw-r--r-- | src/test/ui/typeck/issue-75883.rs | 22 | ||||
| -rw-r--r-- | src/test/ui/typeck/issue-75883.stderr | 52 | ||||
| -rw-r--r-- | src/test/ui/typeck/issue-80779.rs | 13 | ||||
| -rw-r--r-- | src/test/ui/typeck/issue-80779.stderr | 21 |
4 files changed, 108 insertions, 0 deletions
diff --git a/src/test/ui/typeck/issue-75883.rs b/src/test/ui/typeck/issue-75883.rs new file mode 100644 index 00000000000..3a59ca049ba --- /dev/null +++ b/src/test/ui/typeck/issue-75883.rs @@ -0,0 +1,22 @@ +// Regression test for #75883. + +pub struct UI {} + +impl UI { + pub fn run() -> Result<_> { + //~^ ERROR: this enum takes 2 type arguments but only 1 type argument was supplied + //~| ERROR: the type placeholder `_` is not allowed within types on item signatures + let mut ui = UI {}; + ui.interact(); + + unimplemented!(); + } + + pub fn interact(&mut self) -> Result<_> { + //~^ ERROR: this enum takes 2 type arguments but only 1 type argument was supplied + //~| ERROR: the type placeholder `_` is not allowed within types on item signatures + unimplemented!(); + } +} + +fn main() {} diff --git a/src/test/ui/typeck/issue-75883.stderr b/src/test/ui/typeck/issue-75883.stderr new file mode 100644 index 00000000000..a6b2eb8f972 --- /dev/null +++ b/src/test/ui/typeck/issue-75883.stderr @@ -0,0 +1,52 @@ +error[E0107]: this enum takes 2 type arguments but only 1 type argument was supplied + --> $DIR/issue-75883.rs:6:21 + | +LL | pub fn run() -> Result<_> { + | ^^^^^^ - supplied 1 type argument + | | + | expected 2 type arguments + | +note: enum defined here, with 2 type parameters: `T`, `E` + --> $SRC_DIR/core/src/result.rs:LL:COL + | +LL | pub enum Result<T, E> { + | ^^^^^^ - - +help: add missing type argument + | +LL | pub fn run() -> Result<_, E> { + | ^^^ + +error[E0107]: this enum takes 2 type arguments but only 1 type argument was supplied + --> $DIR/issue-75883.rs:15:35 + | +LL | pub fn interact(&mut self) -> Result<_> { + | ^^^^^^ - supplied 1 type argument + | | + | expected 2 type arguments + | +note: enum defined here, with 2 type parameters: `T`, `E` + --> $SRC_DIR/core/src/result.rs:LL:COL + | +LL | pub enum Result<T, E> { + | ^^^^^^ - - +help: add missing type argument + | +LL | pub fn interact(&mut self) -> Result<_, E> { + | ^^^ + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/issue-75883.rs:15:42 + | +LL | pub fn interact(&mut self) -> Result<_> { + | ^ not allowed in type signatures + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/issue-75883.rs:6:28 + | +LL | pub fn run() -> Result<_> { + | ^ not allowed in type signatures + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0107, E0121. +For more information about an error, try `rustc --explain E0107`. diff --git a/src/test/ui/typeck/issue-80779.rs b/src/test/ui/typeck/issue-80779.rs new file mode 100644 index 00000000000..6791976196f --- /dev/null +++ b/src/test/ui/typeck/issue-80779.rs @@ -0,0 +1,13 @@ +// Regression test for #80779. + +pub struct T<'a>(&'a str); + +pub fn f<'a>(val: T<'a>) -> _ { + //~^ ERROR: the type placeholder `_` is not allowed within types on item signatures + g(val) +} + +pub fn g(_: T<'static>) -> _ {} +//~^ ERROR: the type placeholder `_` is not allowed within types on item signatures + +fn main() {} diff --git a/src/test/ui/typeck/issue-80779.stderr b/src/test/ui/typeck/issue-80779.stderr new file mode 100644 index 00000000000..aca494520f8 --- /dev/null +++ b/src/test/ui/typeck/issue-80779.stderr @@ -0,0 +1,21 @@ +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/issue-80779.rs:10:28 + | +LL | pub fn g(_: T<'static>) -> _ {} + | ^ + | | + | not allowed in type signatures + | help: replace with the correct return type: `()` + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/issue-80779.rs:5:29 + | +LL | pub fn f<'a>(val: T<'a>) -> _ { + | ^ + | | + | not allowed in type signatures + | help: replace with the correct return type: `()` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0121`. |
