From 6ed4a42fcf2aee2197fbc9d3cd00f1a796ae53bd Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 11 Aug 2019 22:17:28 +0200 Subject: [PATCH 1/2] Add test for issue 53598 and 57700 --- src/test/ui/impl-trait/issue-53598.rs | 28 +++++++++++++++++++++++ src/test/ui/impl-trait/issue-53598.stderr | 12 ++++++++++ src/test/ui/impl-trait/issue-57700.rs | 22 ++++++++++++++++++ src/test/ui/impl-trait/issue-57700.stderr | 12 ++++++++++ 4 files changed, 74 insertions(+) create mode 100644 src/test/ui/impl-trait/issue-53598.rs create mode 100644 src/test/ui/impl-trait/issue-53598.stderr create mode 100644 src/test/ui/impl-trait/issue-57700.rs create mode 100644 src/test/ui/impl-trait/issue-57700.stderr diff --git a/src/test/ui/impl-trait/issue-53598.rs b/src/test/ui/impl-trait/issue-53598.rs new file mode 100644 index 0000000000000..61dff79d07bad --- /dev/null +++ b/src/test/ui/impl-trait/issue-53598.rs @@ -0,0 +1,28 @@ +// ignore-tidy-linelength +#![feature(type_alias_impl_trait)] + +use std::fmt::Debug; + +pub trait Foo { + type Item: Debug; + + fn foo(_: T) -> Self::Item; +} + +#[derive(Debug)] +pub struct S(std::marker::PhantomData); + +pub struct S2; + +impl Foo for S2 { + type Item = impl Debug; + + fn foo(_: T) -> Self::Item { + //~^ Error type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias + S::(Default::default()) + } +} + +fn main() { + S2::foo(123); +} diff --git a/src/test/ui/impl-trait/issue-53598.stderr b/src/test/ui/impl-trait/issue-53598.stderr new file mode 100644 index 0000000000000..4c8144a235930 --- /dev/null +++ b/src/test/ui/impl-trait/issue-53598.stderr @@ -0,0 +1,12 @@ +error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias + --> $DIR/issue-53598.rs:20:42 + | +LL | fn foo(_: T) -> Self::Item { + | __________________________________________^ +LL | | +LL | | S::(Default::default()) +LL | | } + | |_____^ + +error: aborting due to previous error + diff --git a/src/test/ui/impl-trait/issue-57700.rs b/src/test/ui/impl-trait/issue-57700.rs new file mode 100644 index 0000000000000..bfabef54724c8 --- /dev/null +++ b/src/test/ui/impl-trait/issue-57700.rs @@ -0,0 +1,22 @@ +// ignore-tidy-linelength +#![feature(arbitrary_self_types)] +#![feature(type_alias_impl_trait)] + +use std::ops::Deref; + +trait Foo { + type Bar: Foo; + + fn foo(self: impl Deref) -> Self::Bar; +} + +impl Foo for C { + type Bar = impl Foo; + + fn foo(self: impl Deref) -> Self::Bar { + //~^ Error type parameter `impl Deref` is part of concrete type but not used in parameter list for the `impl Trait` type alias + self + } +} + +fn main() {} diff --git a/src/test/ui/impl-trait/issue-57700.stderr b/src/test/ui/impl-trait/issue-57700.stderr new file mode 100644 index 0000000000000..c701e3e74ef59 --- /dev/null +++ b/src/test/ui/impl-trait/issue-57700.stderr @@ -0,0 +1,12 @@ +error: type parameter `impl Deref` is part of concrete type but not used in parameter list for the `impl Trait` type alias + --> $DIR/issue-57700.rs:16:58 + | +LL | fn foo(self: impl Deref) -> Self::Bar { + | __________________________________________________________^ +LL | | +LL | | self +LL | | } + | |_____^ + +error: aborting due to previous error + From 5981dfffbae081df0281de2cbe0da79fa1ceb7e6 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 11 Aug 2019 22:30:21 +0200 Subject: [PATCH 2/2] Move tests into type-alias-impl-trait --- src/test/ui/{impl-trait => type-alias-impl-trait}/issue-53598.rs | 0 .../ui/{impl-trait => type-alias-impl-trait}/issue-53598.stderr | 0 src/test/ui/{impl-trait => type-alias-impl-trait}/issue-57700.rs | 0 .../ui/{impl-trait => type-alias-impl-trait}/issue-57700.stderr | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename src/test/ui/{impl-trait => type-alias-impl-trait}/issue-53598.rs (100%) rename src/test/ui/{impl-trait => type-alias-impl-trait}/issue-53598.stderr (100%) rename src/test/ui/{impl-trait => type-alias-impl-trait}/issue-57700.rs (100%) rename src/test/ui/{impl-trait => type-alias-impl-trait}/issue-57700.stderr (100%) diff --git a/src/test/ui/impl-trait/issue-53598.rs b/src/test/ui/type-alias-impl-trait/issue-53598.rs similarity index 100% rename from src/test/ui/impl-trait/issue-53598.rs rename to src/test/ui/type-alias-impl-trait/issue-53598.rs diff --git a/src/test/ui/impl-trait/issue-53598.stderr b/src/test/ui/type-alias-impl-trait/issue-53598.stderr similarity index 100% rename from src/test/ui/impl-trait/issue-53598.stderr rename to src/test/ui/type-alias-impl-trait/issue-53598.stderr diff --git a/src/test/ui/impl-trait/issue-57700.rs b/src/test/ui/type-alias-impl-trait/issue-57700.rs similarity index 100% rename from src/test/ui/impl-trait/issue-57700.rs rename to src/test/ui/type-alias-impl-trait/issue-57700.rs diff --git a/src/test/ui/impl-trait/issue-57700.stderr b/src/test/ui/type-alias-impl-trait/issue-57700.stderr similarity index 100% rename from src/test/ui/impl-trait/issue-57700.stderr rename to src/test/ui/type-alias-impl-trait/issue-57700.stderr