This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
tests/ui/mismatched_types Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -12,3 +12,7 @@ pub fn bar(arg: Option<&Vec<i32>>) -> &[i32] {
1212pub fn barzz < ' a > ( arg : Option < & ' a Vec < i32 > > , v : & ' a [ i32 ] ) -> & ' a [ i32 ] {
1313 arg. unwrap_or ( v) //~ ERROR 13:19: 13:20: mismatched types [E0308]
1414}
15+
16+ pub fn convert_result ( arg : Result < & Vec < i32 > , ( ) > ) -> & [ i32 ] {
17+ arg. unwrap_or ( & [ ] ) //~ ERROR 17:19: 17:22: mismatched types [E0308]
18+ }
Original file line number Diff line number Diff line change @@ -61,6 +61,26 @@ help: use `Option::map_or` to deref inner value of `Option`
6161LL | arg.map_or(v, |v| v)
6262 | ~~~~~~~~~~~~~~~~
6363
64- error: aborting due to 3 previous errors
64+ error[E0308]: mismatched types
65+ --> $DIR/transforming-option-ref-issue-127545.rs:17:19
66+ |
67+ LL | arg.unwrap_or(&[])
68+ | --------- ^^^ expected `&Vec<i32>`, found `&[_; 0]`
69+ | |
70+ | arguments to this method are incorrect
71+ |
72+ = note: expected reference `&Vec<i32>`
73+ found reference `&[_; 0]`
74+ help: the return type of this call is `&[_; 0]` due to the type of the argument passed
75+ --> $DIR/transforming-option-ref-issue-127545.rs:17:5
76+ |
77+ LL | arg.unwrap_or(&[])
78+ | ^^^^^^^^^^^^^^---^
79+ | |
80+ | this argument influences the return type of `unwrap_or`
81+ note: method defined here
82+ --> $SRC_DIR/core/src/result.rs:LL:COL
83+
84+ error: aborting due to 4 previous errors
6585
6686For more information about this error, try `rustc --explain E0308`.
You can’t perform that action at this time.
0 commit comments