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.
Auto merge of rust-lang#125289 - WaffleLapkin:never-obligations, r=co…
…mpiler-errors Implement lint for obligations broken by never type fallback change This is the second (and probably last major?) lint required for the never type fallback change. The idea is to check if the code errors with `fallback = ()` and if it errors with `fallback = !` and if it went from "ok" to "error", lint. I'm not happy with the diagnostic, ideally we'd highlight what bound is the problem. But I'm really unsure how to do that (cc `@jackh726,` iirc you had some ideas?) r? `@compiler-errors` Thanks `@BoxyUwU` with helping with trait solver stuff when I was implementing the initial version of this lint. Tracking: - rust-lang#123748
- Loading branch information
Showing
24 changed files
with
314 additions
and
26 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
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
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
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
13 changes: 13 additions & 0 deletions
13
tests/ui/never_type/defaulted-never-note.nofallback.stderr
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,13 @@ | ||
warning: this function depends on never type fallback being `()` | ||
--> $DIR/defaulted-never-note.rs:28:1 | ||
| | ||
LL | fn smeg() { | ||
| ^^^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748> | ||
= help: specify the types explicitly | ||
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
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,28 @@ | ||
//@ check-pass | ||
|
||
fn main() { | ||
def(); | ||
_ = question_mark(); | ||
} | ||
|
||
fn def() { | ||
//~^ warn: this function depends on never type fallback being `()` | ||
//~| warn: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
match true { | ||
false => <_>::default(), | ||
true => return, | ||
}; | ||
} | ||
|
||
// <https://github.com/rust-lang/rust/issues/51125> | ||
// <https://github.com/rust-lang/rust/issues/39216> | ||
fn question_mark() -> Result<(), ()> { | ||
//~^ warn: this function depends on never type fallback being `()` | ||
//~| warn: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
deserialize()?; | ||
Ok(()) | ||
} | ||
|
||
fn deserialize<T: Default>() -> Result<T, ()> { | ||
Ok(T::default()) | ||
} |
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,23 @@ | ||
warning: this function depends on never type fallback being `()` | ||
--> $DIR/dependency-on-fallback-to-unit.rs:8:1 | ||
| | ||
LL | fn def() { | ||
| ^^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748> | ||
= help: specify the types explicitly | ||
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default | ||
|
||
warning: this function depends on never type fallback being `()` | ||
--> $DIR/dependency-on-fallback-to-unit.rs:19:1 | ||
| | ||
LL | fn question_mark() -> Result<(), ()> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748> | ||
= help: specify the types explicitly | ||
|
||
warning: 2 warnings emitted | ||
|
Oops, something went wrong.