Skip to content

Commit f45eaf8

Browse files
committed
rustdoc: add a couple of regression tests
1 parent a3cfa03 commit f45eaf8

6 files changed

+102
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// We used to ICE here while trying to synthesize auto trait impls.
2+
// issue: 107715
3+
//@ check-pass
4+
5+
pub const N: usize = 1;
6+
7+
pub struct MapType<K: Supertrait<V>, V> {
8+
_array: K::Array,
9+
}
10+
11+
pub trait Subtrait: Supertrait<[u8; N]> {}
12+
13+
pub trait Supertrait<V> {
14+
type Array: AnotherTrait<V>;
15+
}
16+
17+
pub trait AnotherTrait<V> {
18+
const LENGTH: usize;
19+
}
20+
21+
pub struct Container<S: Subtrait> {
22+
_x: MapType<S, [u8; N]>,
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// We used to ICE here while trying to synthesize auto trait impls.
2+
// issue: 112242
3+
//@ check-pass
4+
//@ compile-flags: -Znormalize-docs
5+
6+
pub trait MyTrait<'a> {
7+
type MyItem;
8+
}
9+
pub struct Inner<Q>(Q);
10+
pub struct Outer<Q>(Inner<Q>);
11+
12+
impl<'a, Q> std::marker::Unpin for Inner<Q>
13+
where
14+
Q: MyTrait<'a>,
15+
<Q as MyTrait<'a>>::MyItem: Copy,
16+
{
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// We used to ICE here while trying to synthesize auto trait impls.
2+
// issue: 114657
3+
4+
pub trait Foo {
5+
type FooType;
6+
}
7+
8+
pub trait Bar<const A: usize>: Foo<FooType = <Self as Bar<A>>::BarType> {
9+
type BarType;
10+
}
11+
12+
pub(crate) const B: usize = 5;
13+
14+
pub trait Tec: Bar<B> {}
15+
16+
pub struct Structure<C: Tec> { //~ ERROR the trait bound `C: Bar<5>` is not satisfied
17+
_field: C::BarType, //~ ERROR the trait bound `C: Bar<5>` is not satisfied
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0277]: the trait bound `C: Bar<5>` is not satisfied
2+
--> $DIR/projections-in-super-trait-bound-unsatisfied.rs:16:1
3+
|
4+
LL | pub struct Structure<C: Tec> {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar<5>` is not implemented for `C`
6+
|
7+
help: consider further restricting this bound
8+
|
9+
LL | pub struct Structure<C: Tec + Bar<5>> {
10+
| ++++++++
11+
12+
error[E0277]: the trait bound `C: Bar<5>` is not satisfied
13+
--> $DIR/projections-in-super-trait-bound-unsatisfied.rs:17:13
14+
|
15+
LL | _field: C::BarType,
16+
| ^^^^^^^^^^ the trait `Bar<5>` is not implemented for `C`
17+
|
18+
help: consider further restricting this bound
19+
|
20+
LL | pub struct Structure<C: Tec + Bar<5>> {
21+
| ++++++++
22+
23+
error: aborting due to 2 previous errors
24+
25+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// We used to ICE here while trying to synthesize auto trait impls.
2+
// issue: 112828
3+
4+
struct Outer(Inner);
5+
struct Inner;
6+
7+
unsafe impl<Q: Trait> Send for Inner {}
8+
//~^ ERROR the type parameter `Q` is not constrained by the impl trait, self type, or predicates
9+
10+
trait Trait {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0207]: the type parameter `Q` is not constrained by the impl trait, self type, or predicates
2+
--> $DIR/unconstrained-param-in-impl-ambiguity.rs:7:13
3+
|
4+
LL | unsafe impl<Q: Trait> Send for Inner {}
5+
| ^ unconstrained type parameter
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0207`.

0 commit comments

Comments
 (0)