From a233b1656e0311e6a9842546d2f4273a95ebf6d6 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 21 Feb 2024 17:16:35 +0000 Subject: [PATCH 1/2] Add an ATB test --- .../associated-type-bounds/no-gat-position.rs | 18 ++++++++++++++++++ .../no-gat-position.stderr | 9 +++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/ui/associated-type-bounds/no-gat-position.rs create mode 100644 tests/ui/associated-type-bounds/no-gat-position.stderr diff --git a/tests/ui/associated-type-bounds/no-gat-position.rs b/tests/ui/associated-type-bounds/no-gat-position.rs new file mode 100644 index 0000000000000..01740e6242e98 --- /dev/null +++ b/tests/ui/associated-type-bounds/no-gat-position.rs @@ -0,0 +1,18 @@ +#![feature(associated_type_bounds)] + +// Test for . + +pub trait Iter { + type Item<'a>: 'a where Self: 'a; + + fn next<'a>(&'a mut self) -> Option>; + //~^ ERROR associated type bindings are not allowed here +} + +impl Iter for () { + type Item<'a> = &'a mut [()]; + + fn next<'a>(&'a mut self) -> Option> { None } +} + +fn main() {} diff --git a/tests/ui/associated-type-bounds/no-gat-position.stderr b/tests/ui/associated-type-bounds/no-gat-position.stderr new file mode 100644 index 0000000000000..5692b2c7d0902 --- /dev/null +++ b/tests/ui/associated-type-bounds/no-gat-position.stderr @@ -0,0 +1,9 @@ +error[E0229]: associated type bindings are not allowed here + --> $DIR/no-gat-position.rs:8:56 + | +LL | fn next<'a>(&'a mut self) -> Option>; + | ^^^^^^^^^ associated type not allowed here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0229`. From f8fbb7060c746cafc0d503b119e4ece019e1dcb5 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 21 Feb 2024 17:31:53 +0000 Subject: [PATCH 2/2] Add a non-lifetime-binders test --- .../bad-suggestion-on-missing-assoc.rs | 26 ++++++++++++++ .../bad-suggestion-on-missing-assoc.stderr | 34 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 tests/ui/traits/non_lifetime_binders/bad-suggestion-on-missing-assoc.rs create mode 100644 tests/ui/traits/non_lifetime_binders/bad-suggestion-on-missing-assoc.stderr diff --git a/tests/ui/traits/non_lifetime_binders/bad-suggestion-on-missing-assoc.rs b/tests/ui/traits/non_lifetime_binders/bad-suggestion-on-missing-assoc.rs new file mode 100644 index 0000000000000..fc64381b961d4 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/bad-suggestion-on-missing-assoc.rs @@ -0,0 +1,26 @@ +#![feature(generic_const_exprs)] +//~^ WARN the feature `generic_const_exprs` is incomplete +#![feature(non_lifetime_binders)] +//~^ WARN the feature `non_lifetime_binders` is incomplete + +// Test for , +// which originally relied on associated_type_bounds, but was +// minimized away from that. + +trait TraitA { + type AsA; +} +trait TraitB { + type AsB; +} +trait TraitC {} + +fn foo() +where + for T: TraitA>, + //~^ ERROR defaults for generic parameters are not allowed in `for<...>` binders + //~| ERROR `impl Trait` is not allowed in bounds +{ +} + +fn main() {} diff --git a/tests/ui/traits/non_lifetime_binders/bad-suggestion-on-missing-assoc.stderr b/tests/ui/traits/non_lifetime_binders/bad-suggestion-on-missing-assoc.stderr new file mode 100644 index 0000000000000..a4a79413a9be6 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/bad-suggestion-on-missing-assoc.stderr @@ -0,0 +1,34 @@ +warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/bad-suggestion-on-missing-assoc.rs:1:12 + | +LL | #![feature(generic_const_exprs)] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #76560 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/bad-suggestion-on-missing-assoc.rs:3:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 for more information + +error: defaults for generic parameters are not allowed in `for<...>` binders + --> $DIR/bad-suggestion-on-missing-assoc.rs:20:9 + | +LL | for T: TraitA>, + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0562]: `impl Trait` is not allowed in bounds + --> $DIR/bad-suggestion-on-missing-assoc.rs:20:49 + | +LL | for T: TraitA>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + +error: aborting due to 2 previous errors; 2 warnings emitted + +For more information about this error, try `rustc --explain E0562`.