diff options
| author | bors <bors@rust-lang.org> | 2020-10-14 06:43:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-10-14 06:43:10 +0000 |
| commit | 5565241f65cf402c3dbcb55dd492f172c473d4ce (patch) | |
| tree | 3e6c5a4f7d81f2f5bace2e183f851c5ee01d58e1 | |
| parent | 31e4087b9098c6174a22b294bea960d54013fe22 (diff) | |
| parent | 9f7eab4548388cc93fed635aacc1d59475bed89f (diff) | |
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
| -rw-r--r-- | compiler/rustc_typeck/src/bounds.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/associated-type-bounds/issue-70292.rs | 21 | ||||
| -rw-r--r-- | src/test/ui/associated-type-bounds/issue-71443-1.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/associated-type-bounds/issue-71443-1.stderr | 11 | ||||
| -rw-r--r-- | src/test/ui/associated-type-bounds/issue-71443-2.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/associated-types/issue-54108.rs | 41 | ||||
| -rw-r--r-- | src/test/ui/associated-types/issue-54108.stderr | 18 | ||||
| -rw-r--r-- | src/test/ui/associated-types/issue-65934.rs | 17 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/issues/issue-65581.rs | 33 | ||||
| -rw-r--r-- | src/test/ui/type-alias-impl-trait/issue-52843.rs | 15 | ||||
| -rw-r--r-- | src/test/ui/type-alias-impl-trait/issue-52843.stderr | 14 | ||||
| -rw-r--r-- | src/test/ui/unboxed-closures/issue-53448.rs | 15 | ||||
| -rw-r--r-- | src/test/ui/unboxed-closures/issue-53448.stderr | 20 |
13 files changed, 226 insertions, 1 deletions
diff --git a/compiler/rustc_typeck/src/bounds.rs b/compiler/rustc_typeck/src/bounds.rs index 80f39051c58..683707470f4 100644 --- a/compiler/rustc_typeck/src/bounds.rs +++ b/compiler/rustc_typeck/src/bounds.rs @@ -72,7 +72,7 @@ impl<'tcx> Bounds<'tcx> { .iter() .map(|&(region_bound, span)| { let outlives = ty::OutlivesPredicate(param_ty, region_bound); - (ty::Binder::dummy(outlives).to_predicate(tcx), span) + (ty::Binder::bind(outlives).to_predicate(tcx), span) }) .chain(self.trait_bounds.iter().map(|&(bound_trait_ref, span, constness)| { let predicate = bound_trait_ref.with_constness(constness).to_predicate(tcx); diff --git a/src/test/ui/associated-type-bounds/issue-70292.rs b/src/test/ui/associated-type-bounds/issue-70292.rs new file mode 100644 index 00000000000..945d7688ce6 --- /dev/null +++ b/src/test/ui/associated-type-bounds/issue-70292.rs @@ -0,0 +1,21 @@ +// check-pass + +#![feature(associated_type_bounds)] + +fn foo<F>(_: F) +where + F: for<'a> Trait<Output: 'a>, +{ +} + +trait Trait { + type Output; +} + +impl<T> Trait for T { + type Output = (); +} + +fn main() { + foo(()); +} diff --git a/src/test/ui/associated-type-bounds/issue-71443-1.rs b/src/test/ui/associated-type-bounds/issue-71443-1.rs new file mode 100644 index 00000000000..5d2a3e6cbad --- /dev/null +++ b/src/test/ui/associated-type-bounds/issue-71443-1.rs @@ -0,0 +1,9 @@ +#![feature(associated_type_bounds)] + +struct Incorrect; + +fn hello<F: for<'a> Iterator<Item: 'a>>() { + Incorrect //~ERROR: mismatched types +} + +fn main() {} diff --git a/src/test/ui/associated-type-bounds/issue-71443-1.stderr b/src/test/ui/associated-type-bounds/issue-71443-1.stderr new file mode 100644 index 00000000000..a9459ee7432 --- /dev/null +++ b/src/test/ui/associated-type-bounds/issue-71443-1.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/issue-71443-1.rs:6:5 + | +LL | fn hello<F: for<'a> Iterator<Item: 'a>>() { + | - help: try adding a return type: `-> Incorrect` +LL | Incorrect + | ^^^^^^^^^ expected `()`, found struct `Incorrect` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/associated-type-bounds/issue-71443-2.rs b/src/test/ui/associated-type-bounds/issue-71443-2.rs new file mode 100644 index 00000000000..813dcd60ad1 --- /dev/null +++ b/src/test/ui/associated-type-bounds/issue-71443-2.rs @@ -0,0 +1,11 @@ +// check-pass + +#![feature(associated_type_bounds)] + +fn hello<'b, F>() +where + for<'a> F: Iterator<Item: 'a> + 'b, +{ +} + +fn main() {} diff --git a/src/test/ui/associated-types/issue-54108.rs b/src/test/ui/associated-types/issue-54108.rs new file mode 100644 index 00000000000..87f67ce4b52 --- /dev/null +++ b/src/test/ui/associated-types/issue-54108.rs @@ -0,0 +1,41 @@ +use std::ops::Add; + +pub trait Encoder { + type Size: Add<Output = Self::Size>; + + fn foo(&self) -> Self::Size; +} + +pub trait SubEncoder: Encoder { + type ActualSize; + + fn bar(&self) -> Self::Size; +} + +impl<T> Encoder for T +where + T: SubEncoder, +{ + type Size = <Self as SubEncoder>::ActualSize; + //~^ ERROR: cannot add `<T as SubEncoder>::ActualSize` to `<T as SubEncoder>::ActualSize` + + fn foo(&self) -> Self::Size { + self.bar() + self.bar() + } +} + +pub struct UnitEncoder; + +impl SubEncoder for UnitEncoder { + type ActualSize = (); + + fn bar(&self) {} +} + +pub fn fun<R: Encoder>(encoder: &R) { + encoder.foo(); +} + +fn main() { + fun(&UnitEncoder {}); +} diff --git a/src/test/ui/associated-types/issue-54108.stderr b/src/test/ui/associated-types/issue-54108.stderr new file mode 100644 index 00000000000..927a2de9965 --- /dev/null +++ b/src/test/ui/associated-types/issue-54108.stderr @@ -0,0 +1,18 @@ +error[E0277]: cannot add `<T as SubEncoder>::ActualSize` to `<T as SubEncoder>::ActualSize` + --> $DIR/issue-54108.rs:19:5 + | +LL | type Size: Add<Output = Self::Size>; + | ------------------------ required by this bound in `Encoder::Size` +... +LL | type Size = <Self as SubEncoder>::ActualSize; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `<T as SubEncoder>::ActualSize + <T as SubEncoder>::ActualSize` + | + = help: the trait `Add` is not implemented for `<T as SubEncoder>::ActualSize` +help: consider further restricting the associated type + | +LL | T: SubEncoder, <T as SubEncoder>::ActualSize: Add + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-types/issue-65934.rs b/src/test/ui/associated-types/issue-65934.rs new file mode 100644 index 00000000000..e17b11c5eae --- /dev/null +++ b/src/test/ui/associated-types/issue-65934.rs @@ -0,0 +1,17 @@ +// check-pass + +trait Trait { + type Assoc; +} + +impl Trait for () { + type Assoc = (); +} + +fn unit() -> impl Into<<() as Trait>::Assoc> {} + +pub fn ice() { + Into::into(unit()); +} + +fn main() {} diff --git a/src/test/ui/impl-trait/issues/issue-65581.rs b/src/test/ui/impl-trait/issues/issue-65581.rs new file mode 100644 index 00000000000..af65b79d3e8 --- /dev/null +++ b/src/test/ui/impl-trait/issues/issue-65581.rs @@ -0,0 +1,33 @@ +// check-pass + +#![allow(dead_code)] + +trait Trait1<T, U> { + fn f1(self) -> U; +} + +trait Trait2 { + type T; + type U: Trait2<T = Self::T>; + fn f2(f: impl FnOnce(&Self::U)); +} + +fn f3<T: Trait2>() -> impl Trait1<T, T::T> { + Struct1 +} + +struct Struct1; + +impl<T: Trait2> Trait1<T, T::T> for Struct1 { + fn f1(self) -> T::T { + unimplemented!() + } +} + +fn f4<T: Trait2>() { + T::f2(|_| { + f3::<T::U>().f1(); + }); +} + +fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/issue-52843.rs b/src/test/ui/type-alias-impl-trait/issue-52843.rs new file mode 100644 index 00000000000..b24959d7207 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-52843.rs @@ -0,0 +1,15 @@ +#![feature(type_alias_impl_trait)] + +type Foo<T> = impl Default; +//~^ ERROR: the trait bound `T: Default` is not satisfied + +#[allow(unused)] +fn foo<T: Default>(t: T) -> Foo<T> { + t +} + +struct NotDefault; + +fn main() { + let _ = Foo::<NotDefault>::default(); +} diff --git a/src/test/ui/type-alias-impl-trait/issue-52843.stderr b/src/test/ui/type-alias-impl-trait/issue-52843.stderr new file mode 100644 index 00000000000..25db8dfabfc --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-52843.stderr @@ -0,0 +1,14 @@ +error[E0277]: the trait bound `T: Default` is not satisfied + --> $DIR/issue-52843.rs:3:15 + | +LL | type Foo<T> = impl Default; + | ^^^^^^^^^^^^ the trait `Default` is not implemented for `T` + | +help: consider restricting type parameter `T` + | +LL | type Foo<T: Default> = impl Default; + | ^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/unboxed-closures/issue-53448.rs b/src/test/ui/unboxed-closures/issue-53448.rs new file mode 100644 index 00000000000..5c82a56e77e --- /dev/null +++ b/src/test/ui/unboxed-closures/issue-53448.rs @@ -0,0 +1,15 @@ +#![feature(unboxed_closures)] + +trait Lt<'a> { + type T; +} +impl<'a> Lt<'a> for () { + type T = (); +} + +fn main() { + let v: <() as Lt<'_>>::T = (); + let f: &mut dyn FnMut<(_,), Output = ()> = &mut |_: <() as Lt<'_>>::T| {}; + //~^ ERROR: the size for values of type `<() as Lt<'_>>::T` cannot be known + f(v); +} diff --git a/src/test/ui/unboxed-closures/issue-53448.stderr b/src/test/ui/unboxed-closures/issue-53448.stderr new file mode 100644 index 00000000000..bece9eedc7f --- /dev/null +++ b/src/test/ui/unboxed-closures/issue-53448.stderr @@ -0,0 +1,20 @@ +error[E0277]: the size for values of type `<() as Lt<'_>>::T` cannot be known at compilation time + --> $DIR/issue-53448.rs:12:54 + | +LL | let f: &mut dyn FnMut<(_,), Output = ()> = &mut |_: <() as Lt<'_>>::T| {}; + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `<() as Lt<'_>>::T` + = help: unsized locals are gated as an unstable feature +help: consider further restricting the associated type + | +LL | fn main() where <() as Lt<'_>>::T: Sized { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: function arguments must have a statically known size, borrowed types always have a known size + | +LL | let f: &mut dyn FnMut<(_,), Output = ()> = &mut |_: &<() as Lt<'_>>::T| {}; + | ^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. |
