aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src')
-rw-r--r--crates/ide/src/diagnostics/fixes.rs2
-rw-r--r--crates/ide/src/inlay_hints.rs2
-rw-r--r--crates/ide/src/runnables.rs8
-rw-r--r--crates/ide/src/syntax_highlighting/format.rs2
4 files changed, 10 insertions, 4 deletions
diff --git a/crates/ide/src/diagnostics/fixes.rs b/crates/ide/src/diagnostics/fixes.rs
index 2f840909c..5fb3e2d91 100644
--- a/crates/ide/src/diagnostics/fixes.rs
+++ b/crates/ide/src/diagnostics/fixes.rs
@@ -210,7 +210,7 @@ fn missing_record_expr_field_fix(
210 } 210 }
211 let new_field = make::record_field( 211 let new_field = make::record_field(
212 None, 212 None,
213 make::name(record_expr_field.field_name()?.text()), 213 make::name(&record_expr_field.field_name()?.text()),
214 make::ty(&new_field_type.display_source_code(sema.db, module.into()).ok()?), 214 make::ty(&new_field_type.display_source_code(sema.db, module.into()).ok()?),
215 ); 215 );
216 216
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs
index 16c04eeee..25f96222c 100644
--- a/crates/ide/src/inlay_hints.rs
+++ b/crates/ide/src/inlay_hints.rs
@@ -416,7 +416,7 @@ fn get_string_representation(expr: &ast::Expr) -> Option<String> {
416 match expr { 416 match expr {
417 ast::Expr::MethodCallExpr(method_call_expr) => { 417 ast::Expr::MethodCallExpr(method_call_expr) => {
418 let name_ref = method_call_expr.name_ref()?; 418 let name_ref = method_call_expr.name_ref()?;
419 match name_ref.text() { 419 match name_ref.text().as_str() {
420 "clone" => method_call_expr.receiver().map(|rec| rec.to_string()), 420 "clone" => method_call_expr.receiver().map(|rec| rec.to_string()),
421 name_ref => Some(name_ref.to_owned()), 421 name_ref => Some(name_ref.to_owned()),
422 } 422 }
diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs
index 5b488e2c5..7e4c5a078 100644
--- a/crates/ide/src/runnables.rs
+++ b/crates/ide/src/runnables.rs
@@ -226,7 +226,9 @@ pub(crate) fn runnable_fn(sema: &Semantics<RootDatabase>, def: hir::Function) ->
226 let func = def.source(sema.db)?; 226 let func = def.source(sema.db)?;
227 let name_string = def.name(sema.db).to_string(); 227 let name_string = def.name(sema.db).to_string();
228 228
229 let kind = if name_string == "main" { 229 let root = def.krate(sema.db)?.root_module(sema.db);
230
231 let kind = if name_string == "main" && def.module(sema.db) == root {
230 RunnableKind::Bin 232 RunnableKind::Bin
231 } else { 233 } else {
232 let canonical_path = { 234 let canonical_path = {
@@ -444,6 +446,10 @@ fn test_foo() {}
444 446
445#[bench] 447#[bench]
446fn bench() {} 448fn bench() {}
449
450mod not_a_root {
451 fn main() {}
452}
447"#, 453"#,
448 &[&BIN, &TEST, &TEST, &BENCH], 454 &[&BIN, &TEST, &TEST, &BENCH],
449 expect![[r#" 455 expect![[r#"
diff --git a/crates/ide/src/syntax_highlighting/format.rs b/crates/ide/src/syntax_highlighting/format.rs
index e503abc93..5bbadb0f4 100644
--- a/crates/ide/src/syntax_highlighting/format.rs
+++ b/crates/ide/src/syntax_highlighting/format.rs
@@ -31,7 +31,7 @@ fn is_format_string(string: &ast::String) -> Option<()> {
31 let parent = string.syntax().parent()?; 31 let parent = string.syntax().parent()?;
32 32
33 let name = parent.parent().and_then(ast::MacroCall::cast)?.path()?.segment()?.name_ref()?; 33 let name = parent.parent().and_then(ast::MacroCall::cast)?.path()?.segment()?.name_ref()?;
34 if !matches!(name.text(), "format_args" | "format_args_nl") { 34 if !matches!(name.text().as_str(), "format_args" | "format_args_nl") {
35 return None; 35 return None;
36 } 36 }
37 37