@@ -516,5 +516,119 @@ LL + (a, b) = x
516516LL + }
517517 |
518518
519- error: aborting due to 47 previous errors
519+ error: this `match` expression can be replaced with `?`
520+ --> tests/ui/question_mark.rs:741:9
521+ |
522+ LL | / match return_ref_option() {
523+ LL | |
524+ LL | | Some(it) => {
525+ LL | | dbg!(it);
526+ LL | | },
527+ LL | | None => return None,
528+ LL | | };
529+ | |_________^
530+ |
531+ help: try instead
532+ |
533+ LL ~ {
534+ LL + let it = return_ref_option().as_ref()?;
535+ LL + dbg!(it);
536+ LL ~ };
537+ |
538+
539+ error: this `match` expression can be replaced with `?`
540+ --> tests/ui/question_mark.rs:748:24
541+ |
542+ LL | let _x: &i32 = match return_ref_option() {
543+ | ________________________^
544+ LL | |
545+ LL | | Some(it) => it,
546+ LL | | None => return None,
547+ LL | | };
548+ | |_________^ help: try instead: `return_ref_option().as_ref()?`
549+
550+ error: this `match` expression can be replaced with `?`
551+ --> tests/ui/question_mark.rs:754:9
552+ |
553+ LL | / match return_ref_mut_option() {
554+ LL | |
555+ LL | | Some(it) => {
556+ LL | | *it += 1;
557+ LL | | },
558+ LL | | None => return None,
559+ LL | | };
560+ | |_________^
561+ |
562+ help: try instead
563+ |
564+ LL ~ {
565+ LL + let it = return_ref_mut_option().as_mut()?;
566+ LL + *it += 1;
567+ LL ~ };
568+ |
569+
570+ error: this `match` expression can be replaced with `?`
571+ --> tests/ui/question_mark.rs:761:28
572+ |
573+ LL | let _x: &mut i32 = match return_ref_mut_option() {
574+ | ____________________________^
575+ LL | |
576+ LL | | Some(it) => it,
577+ LL | | None => return None,
578+ LL | | };
579+ | |_________^ help: try instead: `return_ref_mut_option().as_mut()?`
580+
581+ error: this `match` expression can be replaced with `?`
582+ --> tests/ui/question_mark.rs:767:9
583+ |
584+ LL | / match &v {
585+ LL | |
586+ LL | | Some(n) => {
587+ LL | | println!("{n}");
588+ ... |
589+ LL | | None => return None,
590+ LL | | };
591+ | |_________^
592+ |
593+ help: try instead
594+ |
595+ LL ~ {
596+ LL + let n = &v?;
597+ LL + println!("{n}");
598+ LL + Some(42)
599+ LL ~ };
600+ |
601+
602+ error: this `match` expression can be replaced with `?`
603+ --> tests/ui/question_mark.rs:780:9
604+ |
605+ LL | / match return_ref_result() {
606+ LL | |
607+ LL | | Ok(val) => {
608+ LL | | dbg!(val);
609+ LL | | },
610+ LL | | Err(e) => return Err(e),
611+ LL | | };
612+ | |_________^
613+ |
614+ help: try instead
615+ |
616+ LL ~ {
617+ LL + let val = return_ref_result().as_ref()?;
618+ LL + dbg!(val);
619+ LL ~ };
620+ |
621+
622+ error: this `match` expression can be replaced with `?`
623+ --> tests/ui/question_mark.rs:787:24
624+ |
625+ LL | let _x: &i32 = match return_ref_result() {
626+ | ________________________^
627+ LL | |
628+ LL | | Ok(val) => val,
629+ LL | | Err(e) => return Err(e),
630+ LL | | };
631+ | |_________^ help: try instead: `return_ref_result().as_ref()?`
632+
633+ error: aborting due to 54 previous errors
520634
0 commit comments