Skip to content

Commit

Permalink
Auto merge of #13749 - WaffleLapkin:remove_some_redudant_adjustment_h…
Browse files Browse the repository at this point in the history
…ints, r=Veykril

fix: Don't show duplicated adjustment hints for blocks, ifs and matches

Before:
![2022-12-09_21-10](https://user-images.githubusercontent.com/38225716/206761100-5511d91b-2543-4166-aa2c-abdb8bad3613.png)
After:
![2022-12-09_21-22](https://user-images.githubusercontent.com/38225716/206761113-c58dbb5a-8616-4287-a3b4-69c13703294d.png)

----

I want to improve adjustment hints, this is the first step :)
  • Loading branch information
bors committed Dec 9, 2022
2 parents a0296c2 + 7c9a85b commit 1449204
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions crates/ide/src/inlay_hints.rs
Expand Up @@ -638,8 +638,12 @@ fn adjustment_hints(
return None;
}

if let ast::Expr::ParenExpr(_) = expr {
// These inherit from the inner expression which would result in duplicate hints
// These inherit from the inner expression which would result in duplicate hints
if let ast::Expr::ParenExpr(_)
| ast::Expr::IfExpr(_)
| ast::Expr::BlockExpr(_)
| ast::Expr::MatchExpr(_) = expr
{
return None;
}

Expand Down Expand Up @@ -3083,6 +3087,33 @@ fn main() {
//^^^^^^^^^^^&
//^^^^^^^^^^^*
(&mut Struct).by_ref_mut();
// Check that block-like expressions don't duplicate hints
let _: &mut [u32] = (&mut []);
//^^^^^^^<unsize>
//^^^^^^^&mut $
//^^^^^^^*
let _: &mut [u32] = { &mut [] };
//^^^^^^^<unsize>
//^^^^^^^&mut $
//^^^^^^^*
let _: &mut [u32] = unsafe { &mut [] };
//^^^^^^^<unsize>
//^^^^^^^&mut $
//^^^^^^^*
let _: &mut [u32] = if true {
&mut []
//^^^^^^^<unsize>
//^^^^^^^&mut $
//^^^^^^^*
} else {
loop {}
//^^^^^^^<never-to-any>
};
let _: &mut [u32] = match () { () => &mut [] }
//^^^^^^^<unsize>
//^^^^^^^&mut $
//^^^^^^^*
}
#[derive(Copy, Clone)]
Expand All @@ -3092,6 +3123,8 @@ impl Struct {
fn by_ref(&self) {}
fn by_ref_mut(&mut self) {}
}
trait Trait {}
impl Trait for Struct {}
"#,
)
}
Expand Down

0 comments on commit 1449204

Please sign in to comment.