-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add some regression tests #77741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add some regression tests #77741
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
07627a3
Add a regression test for issue-52843
JohnTitor 32bc245
Add a regression test for issue-53448
JohnTitor ebc1f89
Add a regression test for issue-54108
JohnTitor 3a4fe97
Add a regression test for issue-65581
JohnTitor 83370ef
Add a regression test for issue-65934
JohnTitor e4fa906
Add a regression test for issue-70292
JohnTitor fb4d627
Add a regression test for issue-71443
JohnTitor 9f7eab4
Use `ty::Binder::bind` to fix debug-assertions ICEs
JohnTitor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,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(()); | ||
} |
This file contains hidden or 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 @@ | ||
#![feature(associated_type_bounds)] | ||
|
||
struct Incorrect; | ||
|
||
fn hello<F: for<'a> Iterator<Item: 'a>>() { | ||
Incorrect //~ERROR: mismatched types | ||
} | ||
|
||
fn main() {} |
This file contains hidden or 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,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`. |
This file contains hidden or 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,11 @@ | ||
// check-pass | ||
|
||
#![feature(associated_type_bounds)] | ||
|
||
fn hello<'b, F>() | ||
where | ||
for<'a> F: Iterator<Item: 'a> + 'b, | ||
{ | ||
} | ||
|
||
fn main() {} |
This file contains hidden or 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,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 {}); | ||
} |
This file contains hidden or 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 @@ | ||
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`. |
This file contains hidden or 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,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() {} |
This file contains hidden or 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,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() {} |
This file contains hidden or 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,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(); | ||
} |
This file contains hidden or 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 @@ | ||
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`. |
This file contains hidden or 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,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); | ||
} |
This file contains hidden or 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,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`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.