This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +35
-2
lines changed Expand file tree Collapse file tree 1 file changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -638,8 +638,12 @@ fn adjustment_hints(
638638 return None ;
639639 }
640640
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+ {
643647 return None ;
644648 }
645649
@@ -3083,6 +3087,33 @@ fn main() {
30833087 //^^^^^^^^^^^&
30843088 //^^^^^^^^^^^*
30853089 (&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+ //^^^^^^^*
30863117}
30873118
30883119#[derive(Copy, Clone)]
@@ -3092,6 +3123,8 @@ impl Struct {
30923123 fn by_ref(&self) {}
30933124 fn by_ref_mut(&mut self) {}
30943125}
3126+ trait Trait {}
3127+ impl Trait for Struct {}
30953128"# ,
30963129 )
30973130 }
You can’t perform that action at this time.
0 commit comments