diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2024-03-07 00:08:56 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2024-03-19 21:26:11 +0000 |
| commit | b1575b71d48a6452d2ff65b5fbb63858388b925b (patch) | |
| tree | 4834ac1fb33220b5c5aa5c14cb8322e85939a11a /tests/ui/sized | |
| parent | 3f2159fda5019f5b599dd3cdf53f430878e82ed2 (diff) | |
| download | rust-b1575b71d48a6452d2ff65b5fbb63858388b925b.tar.gz rust-b1575b71d48a6452d2ff65b5fbb63858388b925b.zip | |
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 #117846.
Diffstat (limited to 'tests/ui/sized')
| -rw-r--r-- | tests/ui/sized/expr-type-error-plus-sized-obligation.rs | 2 | ||||
| -rw-r--r-- | tests/ui/sized/expr-type-error-plus-sized-obligation.stderr | 15 |
2 files changed, 3 insertions, 14 deletions
diff --git a/tests/ui/sized/expr-type-error-plus-sized-obligation.rs b/tests/ui/sized/expr-type-error-plus-sized-obligation.rs index 4c76d2d2488..a96beeecab9 100644 --- a/tests/ui/sized/expr-type-error-plus-sized-obligation.rs +++ b/tests/ui/sized/expr-type-error-plus-sized-obligation.rs @@ -1,7 +1,7 @@ #![allow(warnings)] fn issue_117846_repro() { - let (a, _) = if true { //~ ERROR E0277 + let (a, _) = if true { produce() } else { (Vec::new(), &[]) //~ ERROR E0308 diff --git a/tests/ui/sized/expr-type-error-plus-sized-obligation.stderr b/tests/ui/sized/expr-type-error-plus-sized-obligation.stderr index 6a2810be107..9cf477fbd41 100644 --- a/tests/ui/sized/expr-type-error-plus-sized-obligation.stderr +++ b/tests/ui/sized/expr-type-error-plus-sized-obligation.stderr @@ -14,17 +14,6 @@ LL | | }; = note: expected tuple `(Vec<Foo>, &[Bar])` found tuple `(Vec<_>, &[_; 0])` -error[E0277]: the size for values of type `[Foo]` cannot be known at compilation time - --> $DIR/expr-type-error-plus-sized-obligation.rs:4:10 - | -LL | let (a, _) = if true { - | ^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[Foo]` - = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0277, E0308. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0308`. |
