Open
Description
Code
fn func(x: &[u8]) {
std::hint::black_box(x);
}
fn test() {
if let Some(path) = None {
func(&path);
}
}
Current output
Compiling playground v0.0.1 (/playground)
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> src/lib.rs:6:17
|
6 | if let Some(path) = None {
| ^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[u8]`
= note: all local variables must have a statically known size
= help: unsized locals are gated as an unstable feature
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> src/lib.rs:6:12
|
6 | if let Some(path) = None {
| ^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[u8]`
note: required by a bound in `Some`
--> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:589:17
|
589 | pub enum Option<T> {
| ^ required by this bound in `Some`
...
597 | Some(#[stable(feature = "rust1", since = "1.0.0")] T),
| ---- required by a bound in this tuple variant
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> src/lib.rs:6:25
|
6 | if let Some(path) = None {
| ^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[u8]`
note: required by a bound in `None`
--> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:589:17
|
589 | pub enum Option<T> {
| ^ required by this bound in `None`
...
593 | None,
| ---- required by a bound in this unit variant
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` (lib) due to 3 previous errors
Desired output
I'm not sure; but the issue is not that path doesn't have a size known at compile time but more that we can't infer an appropriate type for path
Rationale and extra context
No response
Other cases
Rust Version
nightly: 2025-05-20 bc821528634632b4ff8d from rust playground