mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Auto merge of #16039 - WaffleLapkin:don't-emit-missing-assoc-items-diagnostic-for-negative-impls, r=Veykril
fix: Don't emit "missing items" diagnostic for negative impls Negative impls can't have items, so there is no reason for this diagnostic. LMK if I should add a test somewhere. Also LMK if that's not how we usually check multiple things in an if in r-a.
This commit is contained in:
commit
457b966b17
2 changed files with 16 additions and 1 deletions
|
@ -671,7 +671,8 @@ impl Module {
|
||||||
_ => (),
|
_ => (),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(trait_) = trait_ {
|
// Negative impls can't have items, don't emit missing items diagnostic for them
|
||||||
|
if let (false, Some(trait_)) = (impl_is_negative, trait_) {
|
||||||
let items = &db.trait_data(trait_.into()).items;
|
let items = &db.trait_data(trait_.into()).items;
|
||||||
let required_items = items.iter().filter(|&(_, assoc)| match *assoc {
|
let required_items = items.iter().filter(|&(_, assoc)| match *assoc {
|
||||||
AssocItemId::FunctionId(it) => !db.function_data(it).has_body(),
|
AssocItemId::FunctionId(it) => !db.function_data(it).has_body(),
|
||||||
|
|
|
@ -112,4 +112,18 @@ impl Trait for () {
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn negative_impl() {
|
||||||
|
check_diagnostics(
|
||||||
|
r#"
|
||||||
|
trait Trait {
|
||||||
|
fn item();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Negative impls don't require any items (in fact, the forbid providing any)
|
||||||
|
impl !Trait for () {}
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue