File tree 1 file changed +35
-2
lines changed
1 file changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -638,8 +638,12 @@ fn adjustment_hints(
638
638
return None ;
639
639
}
640
640
641
- if let ast:: Expr :: ParenExpr ( _) = expr {
642
- // These inherit from the inner expression which would result in duplicate hints
641
+ // These inherit from the inner expression which would result in duplicate hints
642
+ if let ast:: Expr :: ParenExpr ( _)
643
+ | ast:: Expr :: IfExpr ( _)
644
+ | ast:: Expr :: BlockExpr ( _)
645
+ | ast:: Expr :: MatchExpr ( _) = expr
646
+ {
643
647
return None ;
644
648
}
645
649
@@ -3083,6 +3087,33 @@ fn main() {
3083
3087
//^^^^^^^^^^^&
3084
3088
//^^^^^^^^^^^*
3085
3089
(&mut Struct).by_ref_mut();
3090
+
3091
+ // Check that block-like expressions don't duplicate hints
3092
+ let _: &mut [u32] = (&mut []);
3093
+ //^^^^^^^<unsize>
3094
+ //^^^^^^^&mut $
3095
+ //^^^^^^^*
3096
+ let _: &mut [u32] = { &mut [] };
3097
+ //^^^^^^^<unsize>
3098
+ //^^^^^^^&mut $
3099
+ //^^^^^^^*
3100
+ let _: &mut [u32] = unsafe { &mut [] };
3101
+ //^^^^^^^<unsize>
3102
+ //^^^^^^^&mut $
3103
+ //^^^^^^^*
3104
+ let _: &mut [u32] = if true {
3105
+ &mut []
3106
+ //^^^^^^^<unsize>
3107
+ //^^^^^^^&mut $
3108
+ //^^^^^^^*
3109
+ } else {
3110
+ loop {}
3111
+ //^^^^^^^<never-to-any>
3112
+ };
3113
+ let _: &mut [u32] = match () { () => &mut [] }
3114
+ //^^^^^^^<unsize>
3115
+ //^^^^^^^&mut $
3116
+ //^^^^^^^*
3086
3117
}
3087
3118
3088
3119
#[derive(Copy, Clone)]
@@ -3092,6 +3123,8 @@ impl Struct {
3092
3123
fn by_ref(&self) {}
3093
3124
fn by_ref_mut(&mut self) {}
3094
3125
}
3126
+ trait Trait {}
3127
+ impl Trait for Struct {}
3095
3128
"# ,
3096
3129
)
3097
3130
}
You can’t perform that action at this time.
0 commit comments