Files
rust/tests/ui/borrowck/array-slice-coercion-mismatch-15783.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
503 B
Rust
Raw Normal View History

2025-07-24 19:07:20 +05:00
//! Regression test for https://github.com/rust-lang/rust/issues/15783
//@ dont-require-annotations: NOTE
pub fn foo(params: Option<&[&str]>) -> usize {
params.unwrap().first().unwrap().len()
}
fn main() {
let name = "Foo";
let x = Some(&[name]);
let msg = foo(x);
2019-09-06 19:21:26 +01:00
//~^ ERROR mismatched types
//~| NOTE expected enum `Option<&[&str]>`
//~| NOTE found enum `Option<&[&str; 1]>`
//~| NOTE expected `Option<&[&str]>`, found `Option<&[&str; 1]>`
assert_eq!(msg, 3);
}