|
| 1 | +error[E0308]: mismatched types |
| 2 | + --> $DIR/issue-127545-option-of-ref.rs:5:5 |
| 3 | + | |
| 4 | +LL | pub fn foo(arg: Option<&Vec<i32>>) -> Option<&[i32]> { |
| 5 | + | -------------- expected `Option<&[i32]>` because of return type |
| 6 | +LL | arg |
| 7 | + | ^^^ expected `Option<&[i32]>`, found `Option<&Vec<i32>>` |
| 8 | + | |
| 9 | + = note: expected enum `Option<&[i32]>` |
| 10 | + found enum `Option<&Vec<i32>>` |
| 11 | + |
| 12 | +error[E0308]: mismatched types |
| 13 | + --> $DIR/issue-127545-option-of-ref.rs:9:19 |
| 14 | + | |
| 15 | +LL | arg.unwrap_or(&[]) |
| 16 | + | --------- ^^^ expected `&Vec<i32>`, found `&[_; 0]` |
| 17 | + | | |
| 18 | + | arguments to this method are incorrect |
| 19 | + | |
| 20 | + = note: expected reference `&Vec<i32>` |
| 21 | + found reference `&[_; 0]` |
| 22 | +help: the return type of this call is `&[_; 0]` due to the type of the argument passed |
| 23 | + --> $DIR/issue-127545-option-of-ref.rs:9:5 |
| 24 | + | |
| 25 | +LL | arg.unwrap_or(&[]) |
| 26 | + | ^^^^^^^^^^^^^^---^ |
| 27 | + | | |
| 28 | + | this argument influences the return type of `unwrap_or` |
| 29 | +note: method defined here |
| 30 | + --> $SRC_DIR/core/src/option.rs:LL:COL |
| 31 | + |
| 32 | +error[E0308]: mismatched types |
| 33 | + --> $DIR/issue-127545-option-of-ref.rs:13:19 |
| 34 | + | |
| 35 | +LL | arg.unwrap_or(v) |
| 36 | + | --------- ^ expected `&Vec<i32>`, found `&[i32]` |
| 37 | + | | |
| 38 | + | arguments to this method are incorrect |
| 39 | + | |
| 40 | + = note: expected reference `&Vec<i32>` |
| 41 | + found reference `&'a [i32]` |
| 42 | +help: the return type of this call is `&'a [i32]` due to the type of the argument passed |
| 43 | + --> $DIR/issue-127545-option-of-ref.rs:13:5 |
| 44 | + | |
| 45 | +LL | arg.unwrap_or(v) |
| 46 | + | ^^^^^^^^^^^^^^-^ |
| 47 | + | | |
| 48 | + | this argument influences the return type of `unwrap_or` |
| 49 | +note: method defined here |
| 50 | + --> $SRC_DIR/core/src/option.rs:LL:COL |
| 51 | + |
| 52 | +error: aborting due to 3 previous errors |
| 53 | + |
| 54 | +For more information about this error, try `rustc --explain E0308`. |
0 commit comments