Add regression test for issue 127545

This commit is contained in:
Lzu Tao 2024-07-11 22:20:53 +00:00
parent 0ca92de473
commit d9170dc666
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,6 @@
// Regression test for <https://github.com/rust-lang/rust/issues/127545>.
#![crate_type = "lib"]
pub fn foo(arg: Option<&Vec<i32>>) -> Option<&[i32]> {
arg //~ ERROR 5:5: 5:8: mismatched types [E0308]
}

View File

@ -0,0 +1,14 @@
error[E0308]: mismatched types
--> $DIR/transforming-option-ref-issue-127545.rs:5:5
|
LL | pub fn foo(arg: Option<&Vec<i32>>) -> Option<&[i32]> {
| -------------- expected `Option<&[i32]>` because of return type
LL | arg
| ^^^ expected `Option<&[i32]>`, found `Option<&Vec<i32>>`
|
= note: expected enum `Option<&[i32]>`
found enum `Option<&Vec<i32>>`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.