summaryrefslogtreecommitdiffstats
path: root/src/tools/rust-analyzer/crates/ide-diagnostics
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /src/tools/rust-analyzer/crates/ide-diagnostics
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/rust-analyzer/crates/ide-diagnostics')
-rw-r--r--src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/break_outside_of_loop.rs40
-rw-r--r--src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs2
-rw-r--r--src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/mismatched_arg_count.rs2
-rw-r--r--src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/missing_fields.rs4
-rw-r--r--src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/missing_unsafe.rs1
-rw-r--r--src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/no_such_field.rs8
-rw-r--r--src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/private_assoc_item.rs124
-rw-r--r--src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/private_field.rs68
-rw-r--r--src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/type_mismatch.rs4
-rw-r--r--src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unlinked_file.rs22
-rw-r--r--src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_macro_call.rs2
-rw-r--r--src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_module.rs2
-rw-r--r--src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_proc_macro.rs2
-rw-r--r--src/tools/rust-analyzer/crates/ide-diagnostics/src/lib.rs8
-rw-r--r--src/tools/rust-analyzer/crates/ide-diagnostics/src/tests.rs4
-rw-r--r--src/tools/rust-analyzer/crates/ide-diagnostics/src/tests/sourcegen.rs4
16 files changed, 245 insertions, 52 deletions
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/break_outside_of_loop.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/break_outside_of_loop.rs
index 0c92e706b..10e637979 100644
--- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/break_outside_of_loop.rs
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/break_outside_of_loop.rs
@@ -38,12 +38,12 @@ fn foo() {
}
#[test]
- fn try_blocks_are_borders() {
+ fn async_blocks_are_borders() {
check_diagnostics(
r#"
fn foo() {
'a: loop {
- try {
+ async {
break;
//^^^^^ error: break outside of loop
break 'a;
@@ -60,12 +60,12 @@ fn foo() {
}
#[test]
- fn async_blocks_are_borders() {
+ fn closures_are_borders() {
check_diagnostics(
r#"
fn foo() {
'a: loop {
- try {
+ || {
break;
//^^^^^ error: break outside of loop
break 'a;
@@ -82,21 +82,17 @@ fn foo() {
}
#[test]
- fn closures_are_borders() {
+ fn blocks_pass_through() {
check_diagnostics(
r#"
fn foo() {
'a: loop {
- try {
- break;
- //^^^^^ error: break outside of loop
- break 'a;
- //^^^^^^^^ error: break outside of loop
- continue;
- //^^^^^^^^ error: continue outside of loop
- continue 'a;
- //^^^^^^^^^^^ error: continue outside of loop
- };
+ {
+ break;
+ break 'a;
+ continue;
+ continue 'a;
+ }
}
}
"#,
@@ -104,17 +100,17 @@ fn foo() {
}
#[test]
- fn blocks_pass_through() {
+ fn try_blocks_pass_through() {
check_diagnostics(
r#"
fn foo() {
'a: loop {
- {
- break;
- break 'a;
- continue;
- continue 'a;
- }
+ try {
+ break;
+ break 'a;
+ continue;
+ continue 'a;
+ };
}
}
"#,
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs
index 303429519..e8df6dcf2 100644
--- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs
@@ -125,7 +125,7 @@ pub(crate) fn json_in_items(
.severity(Severity::WeakWarning)
.with_fixes(Some(vec![{
let mut scb = SourceChangeBuilder::new(file_id);
- let scope = match import_scope.clone() {
+ let scope = match import_scope {
ImportScope::File(it) => ImportScope::File(scb.make_mut(it)),
ImportScope::Module(it) => ImportScope::Module(scb.make_mut(it)),
ImportScope::Block(it) => ImportScope::Block(scb.make_mut(it)),
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/mismatched_arg_count.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/mismatched_arg_count.rs
index 5f8b3e543..c5db8c374 100644
--- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/mismatched_arg_count.rs
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/mismatched_arg_count.rs
@@ -13,7 +13,7 @@ pub(crate) fn mismatched_arg_count(
d: &hir::MismatchedArgCount,
) -> Diagnostic {
let s = if d.expected == 1 { "" } else { "s" };
- let message = format!("expected {} argument{}, found {}", d.expected, s, d.found);
+ let message = format!("expected {} argument{s}, found {}", d.expected, d.found);
Diagnostic::new("mismatched-arg-count", message, invalid_args_range(ctx, d))
}
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/missing_fields.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/missing_fields.rs
index 7f140eb6a..43af4d4f1 100644
--- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/missing_fields.rs
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/missing_fields.rs
@@ -128,9 +128,9 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::MissingFields) -> Option<Vec<Ass
)?;
use_trivial_constructor(
- &ctx.sema.db,
+ ctx.sema.db,
ide_db::helpers::mod_path_to_ast(&type_path),
- &ty,
+ ty,
)
})();
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/missing_unsafe.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/missing_unsafe.rs
index 7acd9228a..ea1ea5a21 100644
--- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/missing_unsafe.rs
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/missing_unsafe.rs
@@ -86,6 +86,7 @@ fn main() {
check_diagnostics(
r#"
extern "rust-intrinsic" {
+ #[rustc_safe_intrinsic]
pub fn bitreverse(x: u32) -> u32; // Safe intrinsic
pub fn floorf32(x: f32) -> f32; // Unsafe intrinsic
}
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/no_such_field.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/no_such_field.rs
index d8f2a9de9..8da04e628 100644
--- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/no_such_field.rs
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/no_such_field.rs
@@ -68,7 +68,7 @@ fn missing_record_expr_field_fixes(
}
let new_field = make::record_field(
None,
- make::name(&record_expr_field.field_name()?.ident_token()?.text()),
+ make::name(record_expr_field.field_name()?.ident_token()?.text()),
make::ty(&new_field_type.display_source_code(sema.db, module.into()).ok()?),
);
@@ -78,13 +78,13 @@ fn missing_record_expr_field_fixes(
let mut new_field = new_field.to_string();
if usage_file_id != def_file_id {
- new_field = format!("pub(crate) {}", new_field);
+ new_field = format!("pub(crate) {new_field}");
}
- new_field = format!("\n{}{}", indent, new_field);
+ new_field = format!("\n{indent}{new_field}");
let needs_comma = !last_field_syntax.to_string().ends_with(',');
if needs_comma {
- new_field = format!(",{}", new_field);
+ new_field = format!(",{new_field}");
}
let source_change = SourceChange::from_text_edit(
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/private_assoc_item.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/private_assoc_item.rs
new file mode 100644
index 000000000..b363a516d
--- /dev/null
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/private_assoc_item.rs
@@ -0,0 +1,124 @@
+use either::Either;
+
+use crate::{Diagnostic, DiagnosticsContext};
+
+// Diagnostic: private-assoc-item
+//
+// This diagnostic is triggered if the referenced associated item is not visible from the current
+// module.
+pub(crate) fn private_assoc_item(
+ ctx: &DiagnosticsContext<'_>,
+ d: &hir::PrivateAssocItem,
+) -> Diagnostic {
+ // FIXME: add quickfix
+ let name = match d.item.name(ctx.sema.db) {
+ Some(name) => format!("`{}` ", name),
+ None => String::new(),
+ };
+ Diagnostic::new(
+ "private-assoc-item",
+ format!(
+ "{} {}is private",
+ match d.item {
+ hir::AssocItem::Function(_) => "function",
+ hir::AssocItem::Const(_) => "const",
+ hir::AssocItem::TypeAlias(_) => "type alias",
+ },
+ name,
+ ),
+ ctx.sema
+ .diagnostics_display_range(d.expr_or_pat.clone().map(|it| match it {
+ Either::Left(it) => it.into(),
+ Either::Right(it) => match it {
+ Either::Left(it) => it.into(),
+ Either::Right(it) => it.into(),
+ },
+ }))
+ .range,
+ )
+}
+
+#[cfg(test)]
+mod tests {
+ use crate::tests::check_diagnostics;
+
+ #[test]
+ fn private_method() {
+ check_diagnostics(
+ r#"
+mod module {
+ pub struct Struct;
+ impl Struct {
+ fn method(&self) {}
+ }
+}
+fn main(s: module::Struct) {
+ s.method();
+ //^^^^^^^^^^ error: function `method` is private
+}
+"#,
+ );
+ }
+
+ #[test]
+ fn private_func() {
+ check_diagnostics(
+ r#"
+mod module {
+ pub struct Struct;
+ impl Struct {
+ fn func() {}
+ }
+}
+fn main() {
+ module::Struct::func();
+ //^^^^^^^^^^^^^^^^^^^^ error: function `func` is private
+}
+"#,
+ );
+ }
+
+ #[test]
+ fn private_const() {
+ check_diagnostics(
+ r#"
+mod module {
+ pub struct Struct;
+ impl Struct {
+ const CONST: u32 = 0;
+ }
+}
+fn main() {
+ module::Struct::CONST;
+ //^^^^^^^^^^^^^^^^^^^^^ error: const `CONST` is private
+}
+"#,
+ );
+ }
+
+ #[test]
+ fn private_but_shadowed_in_deref() {
+ check_diagnostics(
+ r#"
+//- minicore: deref
+mod module {
+ pub struct Struct { field: Inner }
+ pub struct Inner;
+ impl core::ops::Deref for Struct {
+ type Target = Inner;
+ fn deref(&self) -> &Inner { &self.field }
+ }
+ impl Struct {
+ fn method(&self) {}
+ }
+ impl Inner {
+ pub fn method(&self) {}
+ }
+}
+fn main(s: module::Struct) {
+ s.method();
+}
+"#,
+ );
+ }
+}
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/private_field.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/private_field.rs
new file mode 100644
index 000000000..e630ae368
--- /dev/null
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/private_field.rs
@@ -0,0 +1,68 @@
+use crate::{Diagnostic, DiagnosticsContext};
+
+// Diagnostic: private-field
+//
+// This diagnostic is triggered if the accessed field is not visible from the current module.
+pub(crate) fn private_field(ctx: &DiagnosticsContext<'_>, d: &hir::PrivateField) -> Diagnostic {
+ // FIXME: add quickfix
+ Diagnostic::new(
+ "private-field",
+ format!(
+ "field `{}` of `{}` is private",
+ d.field.name(ctx.sema.db),
+ d.field.parent_def(ctx.sema.db).name(ctx.sema.db)
+ ),
+ ctx.sema.diagnostics_display_range(d.expr.clone().map(|it| it.into())).range,
+ )
+}
+
+#[cfg(test)]
+mod tests {
+ use crate::tests::check_diagnostics;
+
+ #[test]
+ fn private_field() {
+ check_diagnostics(
+ r#"
+mod module { pub struct Struct { field: u32 } }
+fn main(s: module::Struct) {
+ s.field;
+ //^^^^^^^ error: field `field` of `Struct` is private
+}
+"#,
+ );
+ }
+
+ #[test]
+ fn private_tuple_field() {
+ check_diagnostics(
+ r#"
+mod module { pub struct Struct(u32); }
+fn main(s: module::Struct) {
+ s.0;
+ //^^^ error: field `0` of `Struct` is private
+}
+"#,
+ );
+ }
+
+ #[test]
+ fn private_but_shadowed_in_deref() {
+ check_diagnostics(
+ r#"
+//- minicore: deref
+mod module {
+ pub struct Struct { field: Inner }
+ pub struct Inner { pub field: u32 }
+ impl core::ops::Deref for Struct {
+ type Target = Inner;
+ fn deref(&self) -> &Inner { &self.field }
+ }
+}
+fn main(s: module::Struct) {
+ s.field;
+}
+"#,
+ );
+ }
+}
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/type_mismatch.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/type_mismatch.rs
index 62c69f90b..2adae165e 100644
--- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/type_mismatch.rs
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/type_mismatch.rs
@@ -106,11 +106,11 @@ fn add_missing_ok_or_some(
}
let mut builder = TextEdit::builder();
- builder.insert(expr.syntax().text_range().start(), format!("{}(", variant_name));
+ builder.insert(expr.syntax().text_range().start(), format!("{variant_name}("));
builder.insert(expr.syntax().text_range().end(), ")".to_string());
let source_change =
SourceChange::from_text_edit(d.expr.file_id.original_file(ctx.sema.db), builder.finish());
- let name = format!("Wrap in {}", variant_name);
+ let name = format!("Wrap in {variant_name}");
acc.push(fix("wrap_in_constructor", &name, source_change, expr_range));
Some(())
}
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unlinked_file.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unlinked_file.rs
index c626932f1..be70f0ac4 100644
--- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unlinked_file.rs
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unlinked_file.rs
@@ -64,7 +64,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, file_id: FileId) -> Option<Vec<Assist>> {
// `submod/bla.rs` -> `submod.rs`
let parent_mod = (|| {
let (name, _) = parent.name_and_extension()?;
- parent.parent()?.join(&format!("{}.rs", name))
+ parent.parent()?.join(&format!("{name}.rs"))
})();
paths.extend(parent_mod);
paths
@@ -99,8 +99,8 @@ fn make_fixes(
matches!(item, ast::Item::Module(m) if m.item_list().is_none())
}
- let mod_decl = format!("mod {};", new_mod_name);
- let pub_mod_decl = format!("pub mod {};", new_mod_name);
+ let mod_decl = format!("mod {new_mod_name};");
+ let pub_mod_decl = format!("pub mod {new_mod_name};");
let ast: ast::SourceFile = db.parse(parent_file_id).tree();
@@ -125,8 +125,8 @@ fn make_fixes(
Some(last) => {
cov_mark::hit!(unlinked_file_append_to_existing_mods);
let offset = last.syntax().text_range().end();
- mod_decl_builder.insert(offset, format!("\n{}", mod_decl));
- pub_mod_decl_builder.insert(offset, format!("\n{}", pub_mod_decl));
+ mod_decl_builder.insert(offset, format!("\n{mod_decl}"));
+ pub_mod_decl_builder.insert(offset, format!("\n{pub_mod_decl}"));
}
None => {
// Prepend before the first item in the file.
@@ -134,15 +134,15 @@ fn make_fixes(
Some(item) => {
cov_mark::hit!(unlinked_file_prepend_before_first_item);
let offset = item.syntax().text_range().start();
- mod_decl_builder.insert(offset, format!("{}\n\n", mod_decl));
- pub_mod_decl_builder.insert(offset, format!("{}\n\n", pub_mod_decl));
+ mod_decl_builder.insert(offset, format!("{mod_decl}\n\n"));
+ pub_mod_decl_builder.insert(offset, format!("{pub_mod_decl}\n\n"));
}
None => {
// No items in the file, so just append at the end.
cov_mark::hit!(unlinked_file_empty_file);
let offset = ast.syntax().text_range().end();
- mod_decl_builder.insert(offset, format!("{}\n", mod_decl));
- pub_mod_decl_builder.insert(offset, format!("{}\n", pub_mod_decl));
+ mod_decl_builder.insert(offset, format!("{mod_decl}\n"));
+ pub_mod_decl_builder.insert(offset, format!("{pub_mod_decl}\n"));
}
}
}
@@ -152,13 +152,13 @@ fn make_fixes(
Some(vec![
fix(
"add_mod_declaration",
- &format!("Insert `{}`", mod_decl),
+ &format!("Insert `{mod_decl}`"),
SourceChange::from_text_edit(parent_file_id, mod_decl_builder.finish()),
trigger_range,
),
fix(
"add_pub_mod_declaration",
- &format!("Insert `{}`", pub_mod_decl),
+ &format!("Insert `{pub_mod_decl}`"),
SourceChange::from_text_edit(parent_file_id, pub_mod_decl_builder.finish()),
trigger_range,
),
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_macro_call.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_macro_call.rs
index 87531f4ac..1a5efff2c 100644
--- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_macro_call.rs
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_macro_call.rs
@@ -13,7 +13,7 @@ pub(crate) fn unresolved_macro_call(
let bang = if d.is_bang { "!" } else { "" };
Diagnostic::new(
"unresolved-macro-call",
- format!("unresolved macro `{}{}`", d.path, bang),
+ format!("unresolved macro `{}{bang}`", d.path),
display_range,
)
.experimental()
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_module.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_module.rs
index b8f2a9e94..91395f1d8 100644
--- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_module.rs
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_module.rs
@@ -16,7 +16,7 @@ pub(crate) fn unresolved_module(
"unresolved-module",
match &*d.candidates {
[] => "unresolved module".to_string(),
- [candidate] => format!("unresolved module, can't find module file: {}", candidate),
+ [candidate] => format!("unresolved module, can't find module file: {candidate}"),
[candidates @ .., last] => {
format!(
"unresolved module, can't find module file: {}, or {}",
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_proc_macro.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_proc_macro.rs
index 23818d883..b2ed19104 100644
--- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_proc_macro.rs
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_proc_macro.rs
@@ -26,7 +26,7 @@ pub(crate) fn unresolved_proc_macro(
};
let message = match &d.macro_name {
- Some(name) => format!("proc macro `{}` not expanded", name),
+ Some(name) => format!("proc macro `{name}` not expanded"),
None => "proc macro not expanded".to_string(),
};
let severity = if config_enabled { Severity::Error } else { Severity::WeakWarning };
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/lib.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/lib.rs
index d81e36a1f..64ba08ac8 100644
--- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/lib.rs
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/lib.rs
@@ -37,6 +37,8 @@ mod handlers {
pub(crate) mod missing_match_arms;
pub(crate) mod missing_unsafe;
pub(crate) mod no_such_field;
+ pub(crate) mod private_assoc_item;
+ pub(crate) mod private_field;
pub(crate) mod replace_filter_map_next_with_find_map;
pub(crate) mod type_mismatch;
pub(crate) mod unimplemented_builtin_macro;
@@ -218,7 +220,7 @@ pub fn diagnostics(
// [#34344] Only take first 128 errors to prevent slowing down editor/ide, the number 128 is chosen arbitrarily.
res.extend(
parse.errors().iter().take(128).map(|err| {
- Diagnostic::new("syntax-error", format!("Syntax Error: {}", err), err.range())
+ Diagnostic::new("syntax-error", format!("Syntax Error: {err}"), err.range())
}),
);
@@ -227,7 +229,7 @@ pub fn diagnostics(
for node in parse.syntax().descendants() {
handlers::useless_braces::useless_braces(&mut res, file_id, &node);
handlers::field_shorthand::field_shorthand(&mut res, file_id, &node);
- handlers::json_is_not_rust::json_in_items(&sema, &mut res, file_id, &node, &config);
+ handlers::json_is_not_rust::json_in_items(&sema, &mut res, file_id, &node, config);
}
let module = sema.to_module_def(file_id);
@@ -254,6 +256,8 @@ pub fn diagnostics(
AnyDiagnostic::MissingMatchArms(d) => handlers::missing_match_arms::missing_match_arms(&ctx, &d),
AnyDiagnostic::MissingUnsafe(d) => handlers::missing_unsafe::missing_unsafe(&ctx, &d),
AnyDiagnostic::NoSuchField(d) => handlers::no_such_field::no_such_field(&ctx, &d),
+ AnyDiagnostic::PrivateAssocItem(d) => handlers::private_assoc_item::private_assoc_item(&ctx, &d),
+ AnyDiagnostic::PrivateField(d) => handlers::private_field::private_field(&ctx, &d),
AnyDiagnostic::ReplaceFilterMapNextWithFindMap(d) => handlers::replace_filter_map_next_with_find_map::replace_filter_map_next_with_find_map(&ctx, &d),
AnyDiagnostic::TypeMismatch(d) => handlers::type_mismatch::type_mismatch(&ctx, &d),
AnyDiagnostic::UnimplementedBuiltinMacro(d) => handlers::unimplemented_builtin_macro::unimplemented_builtin_macro(&ctx, &d),
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/tests.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/tests.rs
index 729619cfd..afa641c73 100644
--- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/tests.rs
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/tests.rs
@@ -75,7 +75,7 @@ pub(crate) fn check_no_fix(ra_fixture: &str) {
)
.pop()
.unwrap();
- assert!(diagnostic.fixes.is_none(), "got a fix when none was expected: {:?}", diagnostic);
+ assert!(diagnostic.fixes.is_none(), "got a fix when none was expected: {diagnostic:?}");
}
pub(crate) fn check_expect(ra_fixture: &str, expect: Expect) {
@@ -102,7 +102,7 @@ pub(crate) fn check_diagnostics_with_config(config: DiagnosticsConfig, ra_fixtur
for file_id in files {
let diagnostics = super::diagnostics(&db, &config, &AssistResolveStrategy::All, file_id);
- let expected = extract_annotations(&*db.file_text(file_id));
+ let expected = extract_annotations(&db.file_text(file_id));
let mut actual = diagnostics
.into_iter()
.map(|d| {
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/tests/sourcegen.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/tests/sourcegen.rs
index ec6558a46..9e7fcfc59 100644
--- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/tests/sourcegen.rs
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/tests/sourcegen.rs
@@ -11,7 +11,7 @@ fn sourcegen_diagnostic_docs() {
diagnostics.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n");
let contents = sourcegen::add_preamble("sourcegen_diagnostic_docs", contents);
let dst = project_root().join("docs/user/generated_diagnostic.adoc");
- fs::write(&dst, &contents).unwrap();
+ fs::write(dst, contents).unwrap();
}
#[derive(Debug)]
@@ -39,7 +39,7 @@ impl Diagnostic {
for block in comment_blocks {
let id = block.id;
if let Err(msg) = is_valid_diagnostic_name(&id) {
- panic!("invalid diagnostic name: {:?}:\n {}", id, msg)
+ panic!("invalid diagnostic name: {id:?}:\n {msg}")
}
let doc = block.contents.join("\n");
let location = sourcegen::Location { file: path.clone(), line: block.line };