forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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#108063 - compiler-errors:associated-type-bo…
…unds-in-bad-position, r=cjgillot Ban associated type bounds in bad positions We should not try to lower associated type bounds into TAITs in positions where `impl Trait` is not allowed (except for in `where` clauses, like `where T: Trait<Assoc: Bound>`). This is achieved by using the same `rustc_ast_lowering` machinery as impl-trait does to characterize positions as universal/existential/disallowed. Fixes rust-lang#106077 Split out the first commit into rust-lang#108066, since it's not really related.
- Loading branch information
Showing
33 changed files
with
221 additions
and
276 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
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
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
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
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
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
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
14 changes: 14 additions & 0 deletions
14
tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.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,14 @@ | ||
#![feature(associated_type_bounds)] | ||
|
||
trait B { | ||
type AssocType; | ||
} | ||
|
||
fn f() | ||
where | ||
dyn for<'j> B<AssocType: 'j>:, | ||
//~^ ERROR associated type bounds are only allowed in where clauses and function signatures | ||
{ | ||
} | ||
|
||
fn main() {} |
8 changes: 8 additions & 0 deletions
8
tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.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,8 @@ | ||
error: associated type bounds are only allowed in where clauses and function signatures, not in bounds | ||
--> $DIR/bad-universal-in-dyn-in-where-clause.rs:9:19 | ||
| | ||
LL | dyn for<'j> B<AssocType: 'j>:, | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
13 changes: 13 additions & 0 deletions
13
tests/ui/associated-type-bounds/bad-universal-in-impl-sig.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,13 @@ | ||
#![feature(associated_type_bounds)] | ||
|
||
trait Trait { | ||
type Item; | ||
} | ||
|
||
trait Trait2 {} | ||
|
||
// It's not possible to insert a universal `impl Trait` here! | ||
impl dyn Trait<Item: Trait2> {} | ||
//~^ ERROR associated type bounds are only allowed in where clauses and function signatures | ||
|
||
fn main() {} |
8 changes: 8 additions & 0 deletions
8
tests/ui/associated-type-bounds/bad-universal-in-impl-sig.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,8 @@ | ||
error: associated type bounds are only allowed in where clauses and function signatures, not in impl headers | ||
--> $DIR/bad-universal-in-impl-sig.rs:10:16 | ||
| | ||
LL | impl dyn Trait<Item: Trait2> {} | ||
| ^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
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
Oops, something went wrong.