forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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#117416 - compiler-errors:tait-in-bad-body, …
…r=oli-obk Also consider TAIT to be uncomputable if the MIR body is tainted Not totally sure if this is the best solution. We could, alternatively, look at the hir typeck results and try to take a type from there instead of just falling back to type error, inferring `u8` instead of `{type error}`. Not certain it really matters, though. Happy to iterate on this. Fixes rust-lang#117413 r? `@oli-obk` cc `@Nadrieril`
- Loading branch information
Showing
3 changed files
with
42 additions
and
3 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
14 changes: 14 additions & 0 deletions
14
tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.rs
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 @@ | ||
#![feature(type_alias_impl_trait)] | ||
|
||
type Tait = impl Copy; | ||
// Make sure that this TAIT isn't considered unconstrained... | ||
|
||
fn empty_opaque() -> Tait { | ||
if false { | ||
match empty_opaque() {} | ||
//~^ ERROR non-empty | ||
} | ||
0u8 | ||
} | ||
|
||
fn main() {} |
17 changes: 17 additions & 0 deletions
17
tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.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,17 @@ | ||
error[E0004]: non-exhaustive patterns: type `Tait` is non-empty | ||
--> $DIR/unconstrained-due-to-bad-pattern.rs:8:15 | ||
| | ||
LL | match empty_opaque() {} | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: the matched value is of type `Tait` | ||
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown | ||
| | ||
LL ~ match empty_opaque() { | ||
LL + _ => todo!(), | ||
LL + } | ||
| | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0004`. |