diff --git a/src/test/ui/suggestions/mut-ref-reassignment.rs b/src/test/ui/suggestions/mut-ref-reassignment.rs index b9deaa96dbf..1428324934d 100644 --- a/src/test/ui/suggestions/mut-ref-reassignment.rs +++ b/src/test/ui/suggestions/mut-ref-reassignment.rs @@ -1,5 +1,17 @@ -fn change_opt(opt: &mut Option){ +fn suggestion(opt: &mut Option) { + opt = None; //~ ERROR mismatched types +} + +fn no_suggestion(opt: &mut Result) { opt = None //~ ERROR mismatched types } +fn suggestion2(opt: &mut Option) { + opt = Some(String::new())//~ ERROR mismatched types +} + +fn no_suggestion2(opt: &mut Option) { + opt = Some(42)//~ ERROR mismatched types +} + fn main() {} diff --git a/src/test/ui/suggestions/mut-ref-reassignment.stderr b/src/test/ui/suggestions/mut-ref-reassignment.stderr index d90c13b3882..66b78a1b140 100644 --- a/src/test/ui/suggestions/mut-ref-reassignment.stderr +++ b/src/test/ui/suggestions/mut-ref-reassignment.stderr @@ -1,16 +1,47 @@ error[E0308]: mismatched types --> $DIR/mut-ref-reassignment.rs:2:11 | -LL | opt = None +LL | opt = None; | ^^^^ expected mutable reference, found enum `std::option::Option` | = note: expected type `&mut std::option::Option` found type `std::option::Option<_>` help: consider dereferencing here to assign to the mutable borrowed piece of memory | -LL | *opt = None +LL | *opt = None; | ^^^^ -error: aborting due to previous error +error[E0308]: mismatched types + --> $DIR/mut-ref-reassignment.rs:6:11 + | +LL | opt = None + | ^^^^ expected mutable reference, found enum `std::option::Option` + | + = note: expected type `&mut std::result::Result` + found type `std::option::Option<_>` + +error[E0308]: mismatched types + --> $DIR/mut-ref-reassignment.rs:10:11 + | +LL | opt = Some(String::new()) + | ^^^^^^^^^^^^^^^^^^^ expected mutable reference, found enum `std::option::Option` + | + = note: expected type `&mut std::option::Option` + found type `std::option::Option` +help: consider dereferencing here to assign to the mutable borrowed piece of memory + | +LL | *opt = Some(String::new()) + | ^^^^ + +error[E0308]: mismatched types + --> $DIR/mut-ref-reassignment.rs:14:11 + | +LL | opt = Some(42) + | ^^^^^^^^ expected mutable reference, found enum `std::option::Option` + | + = note: expected type `&mut std::option::Option` + found type `std::option::Option<{integer}>` + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0308`.