forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
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#132933 - compiler-errors:never-lint-arg-bug…
…, r=WaffleLapkin Make sure that we suggest turbofishing the right type arg for never suggestion I had a bug where rust would suggest the wrong arg to turbofish `()` if there were any early-bound lifetimes... r? WaffleLapkin
- Loading branch information
Showing
5 changed files
with
122 additions
and
10 deletions.
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
52 changes: 52 additions & 0 deletions
52
tests/ui/editions/never-type-fallback-breaking.e2021.fixed
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,52 @@ | ||
//@ revisions: e2021 e2024 | ||
// | ||
//@[e2021] edition: 2021 | ||
//@[e2024] edition: 2024 | ||
//@[e2024] compile-flags: -Zunstable-options | ||
// | ||
//@[e2021] run-pass | ||
//@[e2021] run-rustfix | ||
//@[e2024] check-fail | ||
|
||
fn main() { | ||
m(); | ||
q(); | ||
let _ = meow(); | ||
} | ||
|
||
fn m() { | ||
//[e2021]~^ this function depends on never type fallback being `()` | ||
//[e2021]~| this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
let x: () = match true { | ||
true => Default::default(), | ||
//[e2024]~^ error: the trait bound `!: Default` is not satisfied | ||
false => panic!("..."), | ||
}; | ||
|
||
dbg!(x); | ||
} | ||
|
||
fn q() -> Option<()> { | ||
//[e2021]~^ this function depends on never type fallback being `()` | ||
//[e2021]~| this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
fn deserialize<T: Default>() -> Option<T> { | ||
Some(T::default()) | ||
} | ||
|
||
deserialize::<()>()?; | ||
//[e2024]~^ error: the trait bound `!: Default` is not satisfied | ||
|
||
None | ||
} | ||
|
||
// Make sure we turbofish the right argument | ||
fn help<'a: 'a, T: Into<()>, U>(_: U) -> Result<T, ()> { | ||
Err(()) | ||
} | ||
fn meow() -> Result<(), ()> { | ||
//[e2021]~^ this function depends on never type fallback being `()` | ||
//[e2021]~| this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
help::<(), _>(1)?; | ||
//[e2024]~^ error: the trait bound `(): From<!>` is not satisfied | ||
Ok(()) | ||
} |
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