self.def_map(db).containing_module(self.local_id)
}
- /// Returns `true` if this module represents a block expression.
- ///
- /// Returns `false` if this module is a submodule *inside* a block expression
- /// (eg. `m` in `{ mod m {} }`).
- pub fn is_block_root(&self, db: &dyn db::DefDatabase) -> bool {
- if self.block.is_none() {
- return false;
- }
-
- self.def_map(db)[self.local_id].parent.is_none()
+ pub fn containing_block(&self) -> Option<BlockId> {
+ self.block
}
}
}
}
+impl HasModule for TypeAliasId {
+ fn module(&self, db: &dyn db::DefDatabase) -> ModuleId {
+ self.lookup(db).module(db)
+ }
+}
+
+impl HasModule for TraitId {
+ fn module(&self, db: &dyn db::DefDatabase) -> ModuleId {
+ self.lookup(db).container
+ }
+}
+
impl HasModule for StaticLoc {
fn module(&self, _db: &dyn db::DefDatabase) -> ModuleId {
self.container
.ok_or_else(|| UnresolvedMacro { path: item_attr.path.clone() })?;
let mut arg = match ¯o_attr.input {
Some(input) => match &**input {
- attr::AttrInput::Literal(_) => tt::Subtree::default(),
+ attr::AttrInput::Literal(_) => Default::default(),
attr::AttrInput::TokenTree(tt) => tt.clone(),
},
- None => tt::Subtree::default(),
+ None => Default::default(),
};
// The parentheses are always disposed here.
- arg.delimiter = None;
+ arg.tree.delimiter = None;
let res = def.as_lazy_macro(
db.upcast(),