mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Handle auto traits & negative impls
We don't pass field types to Chalk yet though, so the auto trait inference won't be correct.
This commit is contained in:
parent
7744cd41e2
commit
d6dc75f9f2
5 changed files with 48 additions and 8 deletions
|
@ -11,6 +11,7 @@ use crate::{Function, Const, TypeAlias, Name, DefDatabase, Trait, ids::LocationC
|
|||
pub struct TraitData {
|
||||
name: Option<Name>,
|
||||
items: Vec<TraitItem>,
|
||||
auto: bool,
|
||||
}
|
||||
|
||||
impl TraitData {
|
||||
|
@ -19,6 +20,7 @@ impl TraitData {
|
|||
let name = node.name().map(|n| n.as_name());
|
||||
let module = tr.module(db);
|
||||
let ctx = LocationCtx::new(db, module, file_id);
|
||||
let auto = node.is_auto();
|
||||
let items = if let Some(item_list) = node.item_list() {
|
||||
item_list
|
||||
.impl_items()
|
||||
|
@ -31,7 +33,7 @@ impl TraitData {
|
|||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
Arc::new(TraitData { name, items })
|
||||
Arc::new(TraitData { name, items, auto })
|
||||
}
|
||||
|
||||
pub(crate) fn name(&self) -> &Option<Name> {
|
||||
|
@ -41,6 +43,10 @@ impl TraitData {
|
|||
pub(crate) fn items(&self) -> &[TraitItem] {
|
||||
&self.items
|
||||
}
|
||||
|
||||
pub(crate) fn is_auto(&self) -> bool {
|
||||
self.auto
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue