-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Wrong underlined argument in tuple returned by function #117846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm getting an entirely different and much more helpful error:
|
Are you sure you minimized the code correctly? Not sure how to repro the example you shared, @GuillaumeGomez. |
Arf, sorry about that... Also important to note, I'm using:
I pushed the code with this issue here. However it requires a mac to enter this code. Just running |
This should be re-minimized by someone who has a Mac then. @rustbot label +E-needs-mcve |
Minimization: fn issue_117846_repro() {
let (cmd, _) = if true {
produce() //
} else {
(Vec::new(), &[])
};
accept(&cmd);
}
fn produce() -> (Vec<String>, &'static [u8]) {
todo!()
}
fn accept(cmd: &[String]) {} Note that:
It seems like the type mismatch is causing the compiler to fail to properly perform the deref coercion of the error[E0308]: `if` and `else` have incompatible types
--> src/lib.rs:5:9
|
2 | let (cmd, _) = if true {
| ____________________-
3 | | produce() //
| | --------- expected because of this
4 | | } else {
5 | | (Vec::new(), &[])
| | ^^^^^^^^^^^^^^^^^ expected `(Vec<String>, &[u8])`, found `(Vec<_>, &[_; 0])`
6 | | };
| |_____- `if` and `else` have incompatible types
|
= note: expected tuple `(Vec<String>, &[u8])`
found tuple `(Vec<_>, &[_; 0])`
error[E0277]: the size for values of type `[String]` cannot be known at compilation time
--> src/lib.rs:2:10
|
2 | let (cmd, _) = if true {
| ^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[String]`
= note: all local variables must have a statically known size
= help: unsized locals are gated as an unstable feature Tested on versions:
|
@rustbot label -E-needs-mcve |
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
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
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.
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
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/rust#117846
Code
Current output
Desired output
Rationale and extra context
It's underlining the wrong argument.
Other cases
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: