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.
Auto merge of rust-lang#122119 - estebank:issue-117846, r=Nadrieril
Silence unecessary !Sized binding error When gathering locals, we introduce a `Sized` obligation for each binding in the pattern. *After* doing so, we typecheck the init expression. If this has a type failure, we store `{type error}`, for both the expression and the pattern. But later we store an inference variable for the pattern. We now avoid any override of an existing type on a hir node when they've already been marked as `{type error}`, and on E0277, when it comes from `VariableType` we silence the error in support of the type error. Fix rust-lang#117846
- Loading branch information
Showing
6 changed files
with
94 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
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,22 @@ | ||
#![allow(warnings)] | ||
|
||
fn issue_117846_repro() { | ||
let (a, _) = if true { | ||
produce() | ||
} else { | ||
(Vec::new(), &[]) //~ ERROR E0308 | ||
}; | ||
|
||
accept(&a); | ||
} | ||
|
||
struct Foo; | ||
struct Bar; | ||
|
||
fn produce() -> (Vec<Foo>, &'static [Bar]) { | ||
todo!() | ||
} | ||
|
||
fn accept(c: &[Foo]) {} | ||
|
||
fn main() {} |
19 changes: 19 additions & 0 deletions
19
tests/ui/sized/expr-type-error-plus-sized-obligation.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,19 @@ | ||
error[E0308]: `if` and `else` have incompatible types | ||
--> $DIR/expr-type-error-plus-sized-obligation.rs:7:9 | ||
| | ||
LL | let (a, _) = if true { | ||
| __________________- | ||
LL | | produce() | ||
| | --------- expected because of this | ||
LL | | } else { | ||
LL | | (Vec::new(), &[]) | ||
| | ^^^^^^^^^^^^^^^^^ expected `(Vec<Foo>, &[Bar])`, found `(Vec<_>, &[_; 0])` | ||
LL | | }; | ||
| |_____- `if` and `else` have incompatible types | ||
| | ||
= note: expected tuple `(Vec<Foo>, &[Bar])` | ||
found tuple `(Vec<_>, &[_; 0])` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |