mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
More symbol usage
This commit is contained in:
parent
c30bdfcc84
commit
df5f1777b8
50 changed files with 388 additions and 303 deletions
|
@ -82,8 +82,7 @@ impl HirDisplay for Function {
|
|||
f.write_str("unsafe ")?;
|
||||
}
|
||||
if let Some(abi) = &data.abi {
|
||||
// FIXME: String escape?
|
||||
write!(f, "extern \"{}\" ", &**abi)?;
|
||||
write!(f, "extern \"{}\" ", abi.as_str())?;
|
||||
}
|
||||
write!(f, "fn {}", data.name.display(f.db.upcast()))?;
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ impl Crate {
|
|||
pub fn get_html_root_url(self: &Crate, db: &dyn HirDatabase) -> Option<String> {
|
||||
// Look for #![doc(html_root_url = "...")]
|
||||
let attrs = db.attrs(AttrDefId::ModuleId(self.root_module().into()));
|
||||
let doc_url = attrs.by_key("doc").find_string_value_in_tt("html_root_url");
|
||||
let doc_url = attrs.by_key(&sym::doc).find_string_value_in_tt(&sym::html_root_url);
|
||||
doc_url.map(|s| s.trim_matches('"').trim_end_matches('/').to_owned() + "/")
|
||||
}
|
||||
|
||||
|
@ -677,9 +677,9 @@ impl Module {
|
|||
TypeOrConstParamId { parent, local_id },
|
||||
))
|
||||
});
|
||||
let res = type_params
|
||||
.chain(lifetime_params)
|
||||
.any(|p| db.attrs(AttrDefId::GenericParamId(p)).by_key("may_dangle").exists());
|
||||
let res = type_params.chain(lifetime_params).any(|p| {
|
||||
db.attrs(AttrDefId::GenericParamId(p)).by_key(&sym::may_dangle).exists()
|
||||
});
|
||||
Some(res)
|
||||
})()
|
||||
.unwrap_or(false);
|
||||
|
@ -2088,14 +2088,14 @@ impl Function {
|
|||
/// is this a `fn main` or a function with an `export_name` of `main`?
|
||||
pub fn is_main(self, db: &dyn HirDatabase) -> bool {
|
||||
let data = db.function_data(self.id);
|
||||
data.attrs.export_name() == Some("main")
|
||||
|| self.module(db).is_crate_root() && data.name.to_smol_str() == "main"
|
||||
data.attrs.export_name() == Some(&sym::main)
|
||||
|| self.module(db).is_crate_root() && data.name == sym::main
|
||||
}
|
||||
|
||||
/// Is this a function with an `export_name` of `main`?
|
||||
pub fn exported_main(self, db: &dyn HirDatabase) -> bool {
|
||||
let data = db.function_data(self.id);
|
||||
data.attrs.export_name() == Some("main")
|
||||
data.attrs.export_name() == Some(&sym::main)
|
||||
}
|
||||
|
||||
/// Does this function have the ignore attribute?
|
||||
|
|
|
@ -293,7 +293,7 @@ impl<'a> SymbolCollector<'a> {
|
|||
if let Some(attrs) = def.attrs(self.db) {
|
||||
for alias in attrs.doc_aliases() {
|
||||
self.symbols.push(FileSymbol {
|
||||
name: alias,
|
||||
name: alias.as_str().into(),
|
||||
def,
|
||||
loc: dec_loc.clone(),
|
||||
container_name: self.current_container_name.clone(),
|
||||
|
@ -330,7 +330,7 @@ impl<'a> SymbolCollector<'a> {
|
|||
if let Some(attrs) = def.attrs(self.db) {
|
||||
for alias in attrs.doc_aliases() {
|
||||
self.symbols.push(FileSymbol {
|
||||
name: alias,
|
||||
name: alias.as_str().into(),
|
||||
def,
|
||||
loc: dec_loc.clone(),
|
||||
container_name: self.current_container_name.clone(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue