Skip to content

Commit

Permalink
Fix breakages
Browse files Browse the repository at this point in the history
  • Loading branch information
regexident committed Feb 18, 2025
1 parent 5a09fa8 commit 7a7aded
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ pub fn find_crate(

pub(crate) fn crate_name(krate: hir::Crate, db: &ide::RootDatabase) -> String {
// Obtain the crate's declaration name:
let display_name = &krate.display_name(db).unwrap();
let display_name = krate.display_name(db).unwrap().to_string();

// Since a crate's name may contain `-` we canonicalize it by replacing with `_`:
display_name.replace('-', "_")
Expand Down
7 changes: 6 additions & 1 deletion src/item/kind_display_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ impl ItemKindDisplayName {
if hir.is_async(db) {
keywords.push("async");
}
if hir.is_unsafe_to_call(db) {
let caller = None;
// Technically this should be the caller's edition,
// but for our purposes we should be fine with taking the
// callee's edition instead:
let edition = hir.module(db).krate().edition(db);
if hir.is_unsafe_to_call(db, caller, edition) {
keywords.push("unsafe");
}
keywords.push("fn");
Expand Down
17 changes: 12 additions & 5 deletions src/item/kind_ordering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,18 @@ impl ItemKindOrdering {
hir::ModuleDef::Module(module_def_hir) => Self::Module {
is_crate_root: module_def_hir.is_crate_root(),
},
hir::ModuleDef::Function(function_def) => Self::Function {
is_const: function_def.is_const(db),
is_async: function_def.is_async(db),
is_unsafe_to_call: function_def.is_unsafe_to_call(db),
},
hir::ModuleDef::Function(function_def) => {
let caller = None;
// Technically this should be the caller's edition,
// but for our purposes we should be fine with taking the
// callee's edition instead:
let edition = function_def.module(db).krate().edition(db);
Self::Function {
is_const: function_def.is_const(db),
is_async: function_def.is_async(db),
is_unsafe_to_call: function_def.is_unsafe_to_call(db, caller, edition),
}
}
hir::ModuleDef::Adt(adt_def) => match adt_def {
hir::Adt::Struct(_) => Self::Struct,
hir::Adt::Union(_) => Self::Union,
Expand Down

0 comments on commit 7a7aded

Please sign in to comment.