forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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#99345 - compiler-errors:issue-99073-redux, …
…r=oli-obk Do not allow typeck children items to constrain outer RPITs Fixes rust-lang#99073 in a simpler and more conservative way than rust-lang#99079. Simply raise a mismatched types error if we try to constrain an RPIT in an item that isn't the RPIT's parent. r? `@oli-obk`
- Loading branch information
Showing
6 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
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
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
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,17 @@ | ||
use std::fmt::Display; | ||
|
||
fn main() { | ||
test("hi", true); | ||
} | ||
|
||
fn test<T: Display>(t: T, recurse: bool) -> impl Display { | ||
let f = || { | ||
let i: u32 = test::<i32>(-1, false); | ||
//~^ ERROR mismatched types | ||
println!("{i}"); | ||
}; | ||
if recurse { | ||
f(); | ||
} | ||
t | ||
} |
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,15 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/issue-99073-2.rs:9:22 | ||
| | ||
LL | fn test<T: Display>(t: T, recurse: bool) -> impl Display { | ||
| ------------ the expected opaque type | ||
LL | let f = || { | ||
LL | let i: u32 = test::<i32>(-1, false); | ||
| ^^^^^^^^^^^^^^^^^^^^^^ types differ | ||
| | ||
= note: expected opaque type `impl std::fmt::Display` | ||
found type `u32` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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,8 @@ | ||
fn main() { | ||
let _ = fix(|_: &dyn Fn()| {}); | ||
} | ||
|
||
fn fix<F: Fn(G), G: Fn()>(f: F) -> impl Fn() { | ||
move || f(fix(&f)) | ||
//~^ ERROR mismatched types | ||
} |
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,14 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/issue-99073.rs:6:13 | ||
| | ||
LL | fn fix<F: Fn(G), G: Fn()>(f: F) -> impl Fn() { | ||
| --------- the expected opaque type | ||
LL | move || f(fix(&f)) | ||
| ^^^^^^^^^^ types differ | ||
| | ||
= note: expected opaque type `impl Fn()` | ||
found type parameter `G` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |