Skip to content

internal: Make diagnostics experimental by default #19772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub(crate) fn await_outside_of_async(
format!("`await` is used inside {}, which is not an `async` context", d.location),
display_range,
)
.stable()
}

#[cfg(test)]
Expand Down
1 change: 1 addition & 0 deletions crates/ide-diagnostics/src/handlers/bad_rtn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub(crate) fn bad_rtn(ctx: &DiagnosticsContext<'_>, d: &hir::BadRtn) -> Diagnost
"return type notation not allowed in this position yet",
d.rtn.map(Into::into),
)
.stable()
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub(crate) fn break_outside_of_loop(
message,
d.expr.map(|it| it.into()),
)
.stable()
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ pub(crate) fn elided_lifetimes_in_path(
"implicit elided lifetime not allowed here",
d.generics_or_segment.map(Into::into),
)
.experimental()
} else {
Diagnostic::new_with_syntax_node_ptr(
ctx,
DiagnosticCode::RustcLint("elided_lifetimes_in_paths"),
"hidden lifetime parameters in types are deprecated",
d.generics_or_segment.map(Into::into),
)
.experimental()
}
}

Expand Down
1 change: 0 additions & 1 deletion crates/ide-diagnostics/src/handlers/expected_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub(crate) fn expected_function(
format!("expected function, found {}", d.found.display(ctx.sema.db, ctx.display_target)),
d.call.map(|it| it.into()),
)
.experimental()
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub(crate) fn generic_args_prohibited(
describe_reason(d.reason),
d.args.map(Into::into),
)
.stable()
.with_fixes(fixes(ctx, d))
}

Expand Down
1 change: 1 addition & 0 deletions crates/ide-diagnostics/src/handlers/inactive_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub(crate) fn inactive_code(
message,
ctx.sema.diagnostics_display_range(d.node),
)
.stable()
.with_unused(true);
Some(res)
}
Expand Down
1 change: 1 addition & 0 deletions crates/ide-diagnostics/src/handlers/incoherent_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub(crate) fn incoherent_impl(ctx: &DiagnosticsContext<'_>, d: &hir::IncoherentI
"cannot define inherent `impl` for foreign type".to_owned(),
display_range,
)
.stable()
}

#[cfg(test)]
Expand Down
1 change: 1 addition & 0 deletions crates/ide-diagnostics/src/handlers/incorrect_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub(crate) fn incorrect_case(ctx: &DiagnosticsContext<'_>, d: &hir::IncorrectCas
),
InFile::new(d.file, d.ident.into()),
)
.stable()
.with_fixes(fixes(ctx, d))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pub(crate) fn incorrect_generics_len(
message,
d.generics_or_segment.map(Into::into),
)
.experimental()
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub(crate) fn incorrect_generics_order(
message,
d.provided_arg.map(Into::into),
)
.stable()
}

#[cfg(test)]
Expand Down
3 changes: 2 additions & 1 deletion crates/ide-diagnostics/src/handlers/invalid_cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub(crate) fn invalid_cast(ctx: &DiagnosticsContext<'_>, d: &hir::InvalidCast) -
// "cannot cast to a pointer of an unknown kind".to_owned(),
// ),
};
Diagnostic::new(code, message, display_range)
Diagnostic::new(code, message, display_range).stable()
}

// Diagnostic: cast-to-unsized
Expand All @@ -113,6 +113,7 @@ pub(crate) fn cast_to_unsized(ctx: &DiagnosticsContext<'_>, d: &hir::CastToUnsiz
format_ty!(ctx, "cast to unsized type: `{}`", d.cast_ty),
display_range,
)
.stable()
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub(crate) fn invalid_derive_target(
"`derive` may only be applied to `struct`s, `enum`s and `union`s",
display_range,
)
.stable()
}

#[cfg(test)]
Expand Down
2 changes: 2 additions & 0 deletions crates/ide-diagnostics/src/handlers/macro_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub(crate) fn macro_error(ctx: &DiagnosticsContext<'_>, d: &hir::MacroError) ->
d.message.clone(),
display_range,
)
.stable()
}

// Diagnostic: macro-def-error
Expand All @@ -33,6 +34,7 @@ pub(crate) fn macro_def_error(ctx: &DiagnosticsContext<'_>, d: &hir::MacroDefErr
d.message.clone(),
display_range,
)
.stable()
}

#[cfg(test)]
Expand Down
1 change: 1 addition & 0 deletions crates/ide-diagnostics/src/handlers/malformed_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub(crate) fn malformed_derive(
"malformed derive input, derive attributes are of the form `#[derive(Derive1, Derive2, ...)]`",
display_range,
)
.stable()
}

#[cfg(test)]
Expand Down
2 changes: 2 additions & 0 deletions crates/ide-diagnostics/src/handlers/mismatched_arg_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub(crate) fn mismatched_tuple_struct_pat_arg_count(
message,
invalid_args_range(ctx, d.expr_or_pat, d.expected, d.found),
)
.stable()
}

// Diagnostic: mismatched-arg-count
Expand All @@ -42,6 +43,7 @@ pub(crate) fn mismatched_arg_count(
message,
invalid_args_range(ctx, d.call_expr, d.expected, d.found),
)
.stable()
}

fn invalid_args_range(
Expand Down
1 change: 1 addition & 0 deletions crates/ide-diagnostics/src/handlers/missing_fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub(crate) fn missing_fields(ctx: &DiagnosticsContext<'_>, d: &hir::MissingField
);

Diagnostic::new_with_syntax_node_ptr(ctx, DiagnosticCode::RustcHardError("E0063"), message, ptr)
.stable()
.with_fixes(fixes(ctx, d))
}

Expand Down
1 change: 0 additions & 1 deletion crates/ide-diagnostics/src/handlers/missing_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub(crate) fn missing_lifetime(
"missing lifetime specifier",
d.generics_or_segment.map(Into::into),
)
.experimental()
}

#[cfg(test)]
Expand Down
1 change: 1 addition & 0 deletions crates/ide-diagnostics/src/handlers/missing_match_arms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub(crate) fn missing_match_arms(
format!("missing match arm: {}", d.uncovered_patterns),
d.scrutinee_expr.map(Into::into),
)
.stable()
}

#[cfg(test)]
Expand Down
1 change: 1 addition & 0 deletions crates/ide-diagnostics/src/handlers/missing_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub(crate) fn missing_unsafe(ctx: &DiagnosticsContext<'_>, d: &hir::MissingUnsaf
format!("{operation} is unsafe and requires an unsafe function or block"),
d.node.map(|it| it.into()),
)
.stable()
.with_fixes(fixes(ctx, d))
}

Expand Down
2 changes: 1 addition & 1 deletion crates/ide-diagnostics/src/handlers/moved_out_of_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub(crate) fn moved_out_of_ref(ctx: &DiagnosticsContext<'_>, d: &hir::MovedOutOf
format!("cannot move `{}` out of reference", d.ty.display(ctx.sema.db, ctx.display_target)),
d.span,
)
.experimental() // spans are broken, and I'm not sure how precise we can detect copy types
// spans are broken, and I'm not sure how precise we can detect copy types
}

#[cfg(test)]
Expand Down
3 changes: 2 additions & 1 deletion crates/ide-diagnostics/src/handlers/mutability_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub(crate) fn need_mut(ctx: &DiagnosticsContext<'_>, d: &hir::NeedMut) -> Option
),
span,
)
.stable()
.with_fixes(fixes),
)
}
Expand Down Expand Up @@ -94,7 +95,7 @@ pub(crate) fn unused_mut(ctx: &DiagnosticsContext<'_>, d: &hir::UnusedMut) -> Op
"variable does not need to be mutable",
ast,
)
.experimental() // Not supporting `#[allow(unused_mut)]` in proc macros leads to false positive.
// Not supporting `#[allow(unused_mut)]` in proc macros leads to false positive, hence not stable.
.with_fixes(fixes),
)
}
Expand Down
2 changes: 2 additions & 0 deletions crates/ide-diagnostics/src/handlers/no_such_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub(crate) fn no_such_field(ctx: &DiagnosticsContext<'_>, d: &hir::NoSuchField)
"field is private",
node,
)
.stable()
} else {
Diagnostic::new_with_syntax_node_ptr(
ctx,
Expand All @@ -32,6 +33,7 @@ pub(crate) fn no_such_field(ctx: &DiagnosticsContext<'_>, d: &hir::NoSuchField)
"no such field",
node,
)
.stable()
.with_fixes(fixes(ctx, d))
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub(crate) fn non_exhaustive_let(
format!("non-exhaustive pattern: {}", d.uncovered_patterns),
d.pat.map(Into::into),
)
.stable()
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub(crate) fn parenthesized_generic_args_without_fn_trait(
"parenthesized type parameters may only be used with a `Fn` trait",
d.args.map(Into::into),
)
.stable()
}

#[cfg(test)]
Expand Down
1 change: 1 addition & 0 deletions crates/ide-diagnostics/src/handlers/private_assoc_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub(crate) fn private_assoc_item(
),
d.expr_or_pat.map(Into::into),
)
.stable()
}

#[cfg(test)]
Expand Down
1 change: 1 addition & 0 deletions crates/ide-diagnostics/src/handlers/private_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub(crate) fn private_field(ctx: &DiagnosticsContext<'_>, d: &hir::PrivateField)
),
d.expr.map(|it| it.into()),
)
.stable()
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub(crate) fn remove_trailing_return(
"replace return <expr>; with <expr>",
display_range,
)
.stable()
.with_fixes(fixes(ctx, d)),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ pub(crate) fn remove_unnecessary_else(
"remove unnecessary else block",
display_range,
)
.experimental()
.with_fixes(fixes(ctx, d)),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub(crate) fn replace_filter_map_next_with_find_map(
"replace filter_map(..).next() with find_map(..)",
InFile::new(d.file, d.next_expr.into()),
)
.stable()
.with_fixes(fixes(ctx, d))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub(crate) fn trait_impl_incorrect_safety(
},
),
)
.stable()
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub(crate) fn trait_impl_missing_assoc_item(
&|impl_| impl_.trait_().map(|t| t.syntax().text_range()),
),
)
.stable()
}

#[cfg(test)]
Expand Down
2 changes: 0 additions & 2 deletions crates/ide-diagnostics/src/handlers/trait_impl_orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ pub(crate) fn trait_impl_orphan(
.to_owned(),
InFile::new(d.file_id, d.impl_.into()),
)
// Not yet checked for false positives
.experimental()
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub(crate) fn trait_impl_redundant_assoc_item(
format!("{redundant_item_name} is not a member of trait `{trait_name}`"),
ide_db::FileRange { file_id: file_id.file_id(ctx.sema.db), range },
)
.stable()
.with_fixes(quickfix_for_redundant_assoc_item(
ctx,
d,
Expand Down
4 changes: 2 additions & 2 deletions crates/ide-diagnostics/src/handlers/type_mismatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ pub(crate) fn type_mismatch(ctx: &DiagnosticsContext<'_>, d: &hir::TypeMismatch)
display_range,
)
.with_fixes(fixes(ctx, d));
if diag.fixes.is_none() {
diag.experimental = true;
if diag.fixes.is_some() {
diag.experimental = false;
}
diag
}
Expand Down
1 change: 1 addition & 0 deletions crates/ide-diagnostics/src/handlers/typed_hole.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub(crate) fn typed_hole(ctx: &DiagnosticsContext<'_>, d: &hir::TypedHole) -> Di
};

Diagnostic::new(DiagnosticCode::RustcHardError("typed-hole"), message, display_range)
.stable()
.with_fixes(fixes)
}

Expand Down
1 change: 1 addition & 0 deletions crates/ide-diagnostics/src/handlers/undeclared_label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub(crate) fn undeclared_label(
format!("use of undeclared label `{}`", name.display(ctx.sema.db, ctx.edition)),
d.node.map(|it| it.into()),
)
.stable()
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ pub(crate) fn unimplemented_builtin_macro(
"unimplemented built-in macro".to_owned(),
d.node,
)
.stable()
}
1 change: 1 addition & 0 deletions crates/ide-diagnostics/src/handlers/unreachable_label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub(crate) fn unreachable_label(
format!("use of unreachable label `{}`", name.display(ctx.sema.db, ctx.edition)),
d.node.map(|it| it.into()),
)
.stable()
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub(crate) fn unresolved_assoc_item(
"no such associated item",
d.expr_or_pat.map(Into::into),
)
.experimental()
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub(crate) fn unresolved_extern_crate(
"unresolved extern crate",
d.decl.map(|it| it.into()),
)
.stable()
}

#[cfg(test)]
Expand Down
1 change: 0 additions & 1 deletion crates/ide-diagnostics/src/handlers/unresolved_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ pub(crate) fn unresolved_field(
}),
)
.with_fixes(fixes(ctx, d))
.experimental()
}

fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedField) -> Option<Vec<Assist>> {
Expand Down
1 change: 0 additions & 1 deletion crates/ide-diagnostics/src/handlers/unresolved_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub(crate) fn unresolved_ident(
range.range = in_node_range + range.range.start();
}
Diagnostic::new(DiagnosticCode::RustcHardError("E0425"), "no such value in this scope", range)
.experimental()
}

#[cfg(test)]
Expand Down
Loading