about summary refs log tree commit diff
path: root/tests/ui/sized
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-03-07 00:08:56 +0000
committerEsteban Küber <esteban@kuber.com.ar>2024-03-19 21:26:11 +0000
commitb1575b71d48a6452d2ff65b5fbb63858388b925b (patch)
tree4834ac1fb33220b5c5aa5c14cb8322e85939a11a /tests/ui/sized
parent3f2159fda5019f5b599dd3cdf53f430878e82ed2 (diff)
downloadrust-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.rs2
-rw-r--r--tests/ui/sized/expr-type-error-plus-sized-obligation.stderr15
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`.