forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#121406 - compiler-errors:tests, r=Nilstrieb Add a couple tests Fixes rust-lang#119857 Fixes rust-lang#115497
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#![feature(associated_type_bounds)] | ||
|
||
// Test for <https://github.com/rust-lang/rust/issues/119857>. | ||
|
||
pub trait Iter { | ||
type Item<'a>: 'a where Self: 'a; | ||
|
||
fn next<'a>(&'a mut self) -> Option<Self::Item<'a, As1: Copy>>; | ||
//~^ ERROR associated type bindings are not allowed here | ||
} | ||
|
||
impl Iter for () { | ||
type Item<'a> = &'a mut [()]; | ||
|
||
fn next<'a>(&'a mut self) -> Option<Self::Item<'a>> { None } | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Self::Item<'a, As1: Copy>>; | ||
| ^^^^^^^^^ associated type not allowed here | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0229`. |
26 changes: 26 additions & 0 deletions
26
tests/ui/traits/non_lifetime_binders/bad-suggestion-on-missing-assoc.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://github.com/rust-lang/rust/issues/115497>, | ||
// 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<T>() | ||
where | ||
for<const N: u8 = { T::A }> T: TraitA<AsA = impl TraitB<AsB = impl TraitC>>, | ||
//~^ ERROR defaults for generic parameters are not allowed in `for<...>` binders | ||
//~| ERROR `impl Trait` is not allowed in bounds | ||
{ | ||
} | ||
|
||
fn main() {} |
34 changes: 34 additions & 0 deletions
34
tests/ui/traits/non_lifetime_binders/bad-suggestion-on-missing-assoc.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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<const N: u8 = { T::A }> T: TraitA<AsA = impl TraitB<AsB = impl TraitC>>, | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0562]: `impl Trait` is not allowed in bounds | ||
--> $DIR/bad-suggestion-on-missing-assoc.rs:20:49 | ||
| | ||
LL | for<const N: u8 = { T::A }> T: TraitA<AsA = impl TraitB<AsB = impl TraitC>>, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= 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`. |