Skip to content

Commit 5565241

Browse files
committed
Auto merge of #77741 - JohnTitor:add-tests, r=matthewjasper
Add some regression tests They're fixed since nightly-2020-10-07: Closes #52843 Closes #53448 Closes #54108 Closes #65581 Closes #65934 Closes #70292 Closes #71443
2 parents 31e4087 + 9f7eab4 commit 5565241

File tree

13 files changed

+226
-1
lines changed

13 files changed

+226
-1
lines changed

Diff for: compiler/rustc_typeck/src/bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<'tcx> Bounds<'tcx> {
7272
.iter()
7373
.map(|&(region_bound, span)| {
7474
let outlives = ty::OutlivesPredicate(param_ty, region_bound);
75-
(ty::Binder::dummy(outlives).to_predicate(tcx), span)
75+
(ty::Binder::bind(outlives).to_predicate(tcx), span)
7676
})
7777
.chain(self.trait_bounds.iter().map(|&(bound_trait_ref, span, constness)| {
7878
let predicate = bound_trait_ref.with_constness(constness).to_predicate(tcx);

Diff for: src/test/ui/associated-type-bounds/issue-70292.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// check-pass
2+
3+
#![feature(associated_type_bounds)]
4+
5+
fn foo<F>(_: F)
6+
where
7+
F: for<'a> Trait<Output: 'a>,
8+
{
9+
}
10+
11+
trait Trait {
12+
type Output;
13+
}
14+
15+
impl<T> Trait for T {
16+
type Output = ();
17+
}
18+
19+
fn main() {
20+
foo(());
21+
}

Diff for: src/test/ui/associated-type-bounds/issue-71443-1.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(associated_type_bounds)]
2+
3+
struct Incorrect;
4+
5+
fn hello<F: for<'a> Iterator<Item: 'a>>() {
6+
Incorrect //~ERROR: mismatched types
7+
}
8+
9+
fn main() {}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-71443-1.rs:6:5
3+
|
4+
LL | fn hello<F: for<'a> Iterator<Item: 'a>>() {
5+
| - help: try adding a return type: `-> Incorrect`
6+
LL | Incorrect
7+
| ^^^^^^^^^ expected `()`, found struct `Incorrect`
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0308`.

Diff for: src/test/ui/associated-type-bounds/issue-71443-2.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// check-pass
2+
3+
#![feature(associated_type_bounds)]
4+
5+
fn hello<'b, F>()
6+
where
7+
for<'a> F: Iterator<Item: 'a> + 'b,
8+
{
9+
}
10+
11+
fn main() {}

Diff for: src/test/ui/associated-types/issue-54108.rs

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
use std::ops::Add;
2+
3+
pub trait Encoder {
4+
type Size: Add<Output = Self::Size>;
5+
6+
fn foo(&self) -> Self::Size;
7+
}
8+
9+
pub trait SubEncoder: Encoder {
10+
type ActualSize;
11+
12+
fn bar(&self) -> Self::Size;
13+
}
14+
15+
impl<T> Encoder for T
16+
where
17+
T: SubEncoder,
18+
{
19+
type Size = <Self as SubEncoder>::ActualSize;
20+
//~^ ERROR: cannot add `<T as SubEncoder>::ActualSize` to `<T as SubEncoder>::ActualSize`
21+
22+
fn foo(&self) -> Self::Size {
23+
self.bar() + self.bar()
24+
}
25+
}
26+
27+
pub struct UnitEncoder;
28+
29+
impl SubEncoder for UnitEncoder {
30+
type ActualSize = ();
31+
32+
fn bar(&self) {}
33+
}
34+
35+
pub fn fun<R: Encoder>(encoder: &R) {
36+
encoder.foo();
37+
}
38+
39+
fn main() {
40+
fun(&UnitEncoder {});
41+
}

Diff for: src/test/ui/associated-types/issue-54108.stderr

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0277]: cannot add `<T as SubEncoder>::ActualSize` to `<T as SubEncoder>::ActualSize`
2+
--> $DIR/issue-54108.rs:19:5
3+
|
4+
LL | type Size: Add<Output = Self::Size>;
5+
| ------------------------ required by this bound in `Encoder::Size`
6+
...
7+
LL | type Size = <Self as SubEncoder>::ActualSize;
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `<T as SubEncoder>::ActualSize + <T as SubEncoder>::ActualSize`
9+
|
10+
= help: the trait `Add` is not implemented for `<T as SubEncoder>::ActualSize`
11+
help: consider further restricting the associated type
12+
|
13+
LL | T: SubEncoder, <T as SubEncoder>::ActualSize: Add
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
16+
error: aborting due to previous error
17+
18+
For more information about this error, try `rustc --explain E0277`.

Diff for: src/test/ui/associated-types/issue-65934.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// check-pass
2+
3+
trait Trait {
4+
type Assoc;
5+
}
6+
7+
impl Trait for () {
8+
type Assoc = ();
9+
}
10+
11+
fn unit() -> impl Into<<() as Trait>::Assoc> {}
12+
13+
pub fn ice() {
14+
Into::into(unit());
15+
}
16+
17+
fn main() {}

Diff for: src/test/ui/impl-trait/issues/issue-65581.rs

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// check-pass
2+
3+
#![allow(dead_code)]
4+
5+
trait Trait1<T, U> {
6+
fn f1(self) -> U;
7+
}
8+
9+
trait Trait2 {
10+
type T;
11+
type U: Trait2<T = Self::T>;
12+
fn f2(f: impl FnOnce(&Self::U));
13+
}
14+
15+
fn f3<T: Trait2>() -> impl Trait1<T, T::T> {
16+
Struct1
17+
}
18+
19+
struct Struct1;
20+
21+
impl<T: Trait2> Trait1<T, T::T> for Struct1 {
22+
fn f1(self) -> T::T {
23+
unimplemented!()
24+
}
25+
}
26+
27+
fn f4<T: Trait2>() {
28+
T::f2(|_| {
29+
f3::<T::U>().f1();
30+
});
31+
}
32+
33+
fn main() {}

Diff for: src/test/ui/type-alias-impl-trait/issue-52843.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#![feature(type_alias_impl_trait)]
2+
3+
type Foo<T> = impl Default;
4+
//~^ ERROR: the trait bound `T: Default` is not satisfied
5+
6+
#[allow(unused)]
7+
fn foo<T: Default>(t: T) -> Foo<T> {
8+
t
9+
}
10+
11+
struct NotDefault;
12+
13+
fn main() {
14+
let _ = Foo::<NotDefault>::default();
15+
}

Diff for: src/test/ui/type-alias-impl-trait/issue-52843.stderr

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0277]: the trait bound `T: Default` is not satisfied
2+
--> $DIR/issue-52843.rs:3:15
3+
|
4+
LL | type Foo<T> = impl Default;
5+
| ^^^^^^^^^^^^ the trait `Default` is not implemented for `T`
6+
|
7+
help: consider restricting type parameter `T`
8+
|
9+
LL | type Foo<T: Default> = impl Default;
10+
| ^^^^^^^^^
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0277`.

Diff for: src/test/ui/unboxed-closures/issue-53448.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#![feature(unboxed_closures)]
2+
3+
trait Lt<'a> {
4+
type T;
5+
}
6+
impl<'a> Lt<'a> for () {
7+
type T = ();
8+
}
9+
10+
fn main() {
11+
let v: <() as Lt<'_>>::T = ();
12+
let f: &mut dyn FnMut<(_,), Output = ()> = &mut |_: <() as Lt<'_>>::T| {};
13+
//~^ ERROR: the size for values of type `<() as Lt<'_>>::T` cannot be known
14+
f(v);
15+
}

Diff for: src/test/ui/unboxed-closures/issue-53448.stderr

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error[E0277]: the size for values of type `<() as Lt<'_>>::T` cannot be known at compilation time
2+
--> $DIR/issue-53448.rs:12:54
3+
|
4+
LL | let f: &mut dyn FnMut<(_,), Output = ()> = &mut |_: <() as Lt<'_>>::T| {};
5+
| ^ doesn't have a size known at compile-time
6+
|
7+
= help: the trait `Sized` is not implemented for `<() as Lt<'_>>::T`
8+
= help: unsized locals are gated as an unstable feature
9+
help: consider further restricting the associated type
10+
|
11+
LL | fn main() where <() as Lt<'_>>::T: Sized {
12+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13+
help: function arguments must have a statically known size, borrowed types always have a known size
14+
|
15+
LL | let f: &mut dyn FnMut<(_,), Output = ()> = &mut |_: &<() as Lt<'_>>::T| {};
16+
| ^
17+
18+
error: aborting due to previous error
19+
20+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)