forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
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#123348 - fmease:add-synth-auto-trait-impls-tests, r=GuillaumeGomez rustdoc: add a couple of regression tests Fixes rust-lang#114657. Fixes rust-lang#112828. Fixes rust-lang#107715. r? rustdoc
- Loading branch information
Showing
5 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
tests/rustdoc-ui/synthetic-auto-trait-impls/const-in-super-trait-and-item-bound.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,23 @@ | ||
// We used to ICE here while trying to synthesize auto trait impls. | ||
// issue: 107715 | ||
//@ check-pass | ||
|
||
pub const N: usize = 1; | ||
|
||
pub struct MapType<K: Supertrait<V>, V> { | ||
_array: K::Array, | ||
} | ||
|
||
pub trait Subtrait: Supertrait<[u8; N]> {} | ||
|
||
pub trait Supertrait<V> { | ||
type Array: AnotherTrait<V>; | ||
} | ||
|
||
pub trait AnotherTrait<V> { | ||
const LENGTH: usize; | ||
} | ||
|
||
pub struct Container<S: Subtrait> { | ||
_x: MapType<S, [u8; N]>, | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/rustdoc-ui/synthetic-auto-trait-impls/projections-in-super-trait-bound-unsatisfied.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,18 @@ | ||
// We used to ICE here while trying to synthesize auto trait impls. | ||
// issue: 114657 | ||
|
||
pub trait Foo { | ||
type FooType; | ||
} | ||
|
||
pub trait Bar<const A: usize>: Foo<FooType = <Self as Bar<A>>::BarType> { | ||
type BarType; | ||
} | ||
|
||
pub(crate) const B: usize = 5; | ||
|
||
pub trait Tec: Bar<B> {} | ||
|
||
pub struct Structure<C: Tec> { //~ ERROR the trait bound `C: Bar<5>` is not satisfied | ||
_field: C::BarType, //~ ERROR the trait bound `C: Bar<5>` is not satisfied | ||
} |
25 changes: 25 additions & 0 deletions
25
...rustdoc-ui/synthetic-auto-trait-impls/projections-in-super-trait-bound-unsatisfied.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,25 @@ | ||
error[E0277]: the trait bound `C: Bar<5>` is not satisfied | ||
--> $DIR/projections-in-super-trait-bound-unsatisfied.rs:16:1 | ||
| | ||
LL | pub struct Structure<C: Tec> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar<5>` is not implemented for `C` | ||
| | ||
help: consider further restricting this bound | ||
| | ||
LL | pub struct Structure<C: Tec + Bar<5>> { | ||
| ++++++++ | ||
|
||
error[E0277]: the trait bound `C: Bar<5>` is not satisfied | ||
--> $DIR/projections-in-super-trait-bound-unsatisfied.rs:17:13 | ||
| | ||
LL | _field: C::BarType, | ||
| ^^^^^^^^^^ the trait `Bar<5>` is not implemented for `C` | ||
| | ||
help: consider further restricting this bound | ||
| | ||
LL | pub struct Structure<C: Tec + Bar<5>> { | ||
| ++++++++ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
10 changes: 10 additions & 0 deletions
10
tests/rustdoc-ui/synthetic-auto-trait-impls/unconstrained-param-in-impl-ambiguity.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,10 @@ | ||
// We used to ICE here while trying to synthesize auto trait impls. | ||
// issue: 112828 | ||
|
||
struct Outer(Inner); | ||
struct Inner; | ||
|
||
unsafe impl<Q: Trait> Send for Inner {} | ||
//~^ ERROR the type parameter `Q` is not constrained by the impl trait, self type, or predicates | ||
|
||
trait Trait {} |
9 changes: 9 additions & 0 deletions
9
tests/rustdoc-ui/synthetic-auto-trait-impls/unconstrained-param-in-impl-ambiguity.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,9 @@ | ||
error[E0207]: the type parameter `Q` is not constrained by the impl trait, self type, or predicates | ||
--> $DIR/unconstrained-param-in-impl-ambiguity.rs:7:13 | ||
| | ||
LL | unsafe impl<Q: Trait> Send for Inner {} | ||
| ^ unconstrained type parameter | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0207`. |