Skip to content
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

Spurious unsized error on resolution error #64088

Closed
oli-cosmian opened this issue Sep 2, 2019 · 1 comment
Closed

Spurious unsized error on resolution error #64088

oli-cosmian opened this issue Sep 2, 2019 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@oli-cosmian
Copy link

the bar function does not exist, so its return type is implicitly inferred to be whatever type is consumed further down. If the inferred type is unsized, we may get additional errors though. I think we should find a way to silence that additional error.

fn foo() {
    let x = bar();
    meh(&x);
}

fn meh(_: &[i32]) {}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
error[E0425]: cannot find function `bar` in this scope
 --> src/lib.rs:2:13
  |
2 |     let x = bar();
  |             ^^^ not found in this scope

error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
 --> src/lib.rs:2:9
  |
2 |     let x = bar();
  |         ^ doesn't have a size known at compile-time
  |
  = help: the trait `std::marker::Sized` is not implemented for `[i32]`
  = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
  = 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

Some errors have detailed explanations: E0277, E0425.
For more information about an error, try `rustc --explain E0277`.
error: Could not compile `playground`.

To learn more, run the command again with --verbose.

@Mark-Simulacrum Mark-Simulacrum added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 2, 2019
@Mark-Simulacrum
Copy link
Member

Closing as duplicate of #33575.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants