mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Merge #3520
3520: Omit unit struct hints r=matklad a=SomeoneToIgnore Closes https://github.com/rust-analyzer/rust-analyzer/issues/3488 Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
This commit is contained in:
commit
51a50e3f50
1 changed files with 32 additions and 0 deletions
|
@ -119,6 +119,12 @@ fn should_not_display_type_hint(db: &RootDatabase, bind_pat: &ast::BindPat, pat_
|
|||
return true;
|
||||
}
|
||||
|
||||
if let Some(Adt::Struct(s)) = pat_ty.as_adt() {
|
||||
if s.fields(db).is_empty() && s.name(db).to_string() == bind_pat.syntax().to_string() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for node in bind_pat.syntax().ancestors() {
|
||||
match_ast! {
|
||||
match node {
|
||||
|
@ -943,4 +949,30 @@ fn main() {
|
|||
"###
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unit_structs_have_no_type_hints() {
|
||||
let (analysis, file_id) = single_file(
|
||||
r#"
|
||||
enum CustomResult<T, E> {
|
||||
Ok(T),
|
||||
Err(E),
|
||||
}
|
||||
use CustomResult::*;
|
||||
|
||||
struct SyntheticSyntax;
|
||||
|
||||
fn main() {
|
||||
match Ok(()) {
|
||||
Ok(_) => (),
|
||||
Err(SyntheticSyntax) => (),
|
||||
}
|
||||
}"#,
|
||||
);
|
||||
|
||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, Some(8)).unwrap(), @r###"
|
||||
[]
|
||||
"###
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue