mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 11:20:54 +00:00
Merge pull request #19772 from rust-lang/push-nxzlokoozypo
internal: Make diagnostics experimental by default
This commit is contained in:
commit
2bafe9d96c
@ -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)]
|
||||
|
@ -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)]
|
||||
|
@ -19,6 +19,7 @@ pub(crate) fn break_outside_of_loop(
|
||||
message,
|
||||
d.expr.map(|it| it.into()),
|
||||
)
|
||||
.stable()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -15,7 +15,6 @@ 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,
|
||||
@ -23,7 +22,6 @@ pub(crate) fn elided_lifetimes_in_path(
|
||||
"hidden lifetime parameters in types are deprecated",
|
||||
d.generics_or_segment.map(Into::into),
|
||||
)
|
||||
.experimental()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)]
|
||||
|
@ -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))
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ pub(crate) fn inactive_code(
|
||||
message,
|
||||
ctx.sema.diagnostics_display_range(d.node),
|
||||
)
|
||||
.stable()
|
||||
.with_unused(true);
|
||||
Some(res)
|
||||
}
|
||||
|
@ -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)]
|
||||
|
@ -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))
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@ pub(crate) fn incorrect_generics_len(
|
||||
message,
|
||||
d.generics_or_segment.map(Into::into),
|
||||
)
|
||||
.experimental()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -28,6 +28,7 @@ pub(crate) fn incorrect_generics_order(
|
||||
message,
|
||||
d.provided_arg.map(Into::into),
|
||||
)
|
||||
.stable()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -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
|
||||
@ -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)]
|
||||
|
@ -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)]
|
||||
|
@ -19,6 +19,7 @@ pub(crate) fn macro_error(ctx: &DiagnosticsContext<'_>, d: &hir::MacroError) ->
|
||||
d.message.clone(),
|
||||
display_range,
|
||||
)
|
||||
.stable()
|
||||
}
|
||||
|
||||
// Diagnostic: macro-def-error
|
||||
@ -33,6 +34,7 @@ pub(crate) fn macro_def_error(ctx: &DiagnosticsContext<'_>, d: &hir::MacroDefErr
|
||||
d.message.clone(),
|
||||
display_range,
|
||||
)
|
||||
.stable()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -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)]
|
||||
|
@ -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
|
||||
@ -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(
|
||||
|
@ -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))
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ pub(crate) fn missing_lifetime(
|
||||
"missing lifetime specifier",
|
||||
d.generics_or_segment.map(Into::into),
|
||||
)
|
||||
.experimental()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -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)]
|
||||
|
@ -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))
|
||||
}
|
||||
|
||||
|
@ -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)]
|
||||
|
@ -55,6 +55,7 @@ pub(crate) fn need_mut(ctx: &DiagnosticsContext<'_>, d: &hir::NeedMut) -> Option
|
||||
),
|
||||
span,
|
||||
)
|
||||
.stable()
|
||||
.with_fixes(fixes),
|
||||
)
|
||||
}
|
||||
@ -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),
|
||||
)
|
||||
}
|
||||
|
@ -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,
|
||||
@ -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))
|
||||
}
|
||||
}
|
||||
|
@ -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)]
|
||||
|
@ -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)]
|
||||
|
@ -28,6 +28,7 @@ pub(crate) fn private_assoc_item(
|
||||
),
|
||||
d.expr_or_pat.map(Into::into),
|
||||
)
|
||||
.stable()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -15,6 +15,7 @@ pub(crate) fn private_field(ctx: &DiagnosticsContext<'_>, d: &hir::PrivateField)
|
||||
),
|
||||
d.expr.map(|it| it.into()),
|
||||
)
|
||||
.stable()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -31,6 +31,7 @@ pub(crate) fn remove_trailing_return(
|
||||
"replace return <expr>; with <expr>",
|
||||
display_range,
|
||||
)
|
||||
.stable()
|
||||
.with_fixes(fixes(ctx, d)),
|
||||
)
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ pub(crate) fn remove_unnecessary_else(
|
||||
"remove unnecessary else block",
|
||||
display_range,
|
||||
)
|
||||
.experimental()
|
||||
.with_fixes(fixes(ctx, d)),
|
||||
)
|
||||
}
|
||||
|
@ -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))
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ pub(crate) fn trait_impl_incorrect_safety(
|
||||
},
|
||||
),
|
||||
)
|
||||
.stable()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -29,6 +29,7 @@ pub(crate) fn trait_impl_missing_assoc_item(
|
||||
&|impl_| impl_.trait_().map(|t| t.syntax().text_range()),
|
||||
),
|
||||
)
|
||||
.stable()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -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)]
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)]
|
||||
|
@ -13,4 +13,5 @@ pub(crate) fn unimplemented_builtin_macro(
|
||||
"unimplemented built-in macro".to_owned(),
|
||||
d.node,
|
||||
)
|
||||
.stable()
|
||||
}
|
||||
|
@ -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)]
|
||||
|
@ -13,7 +13,6 @@ pub(crate) fn unresolved_assoc_item(
|
||||
"no such associated item",
|
||||
d.expr_or_pat.map(Into::into),
|
||||
)
|
||||
.experimental()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -13,6 +13,7 @@ pub(crate) fn unresolved_extern_crate(
|
||||
"unresolved extern crate",
|
||||
d.decl.map(|it| it.into()),
|
||||
)
|
||||
.stable()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -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>> {
|
||||
|
@ -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)]
|
||||
|
@ -18,7 +18,6 @@ pub(crate) fn unresolved_import(
|
||||
// - `cfg_if!`-generated code in libstd (we don't load the sysroot correctly)
|
||||
// - `core::arch` (we don't handle `#[path = "../<path>"]` correctly)
|
||||
// - proc macros and/or proc macro generated code
|
||||
.experimental()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -16,7 +16,6 @@ pub(crate) fn unresolved_macro_call(
|
||||
format!("unresolved macro `{}{bang}`", d.path.display(ctx.sema.db, ctx.edition)),
|
||||
display_range,
|
||||
)
|
||||
.experimental()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -47,7 +47,6 @@ pub(crate) fn unresolved_method(
|
||||
}),
|
||||
)
|
||||
.with_fixes(fixes(ctx, d))
|
||||
.experimental()
|
||||
}
|
||||
|
||||
fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedMethodCall) -> Option<Vec<Assist>> {
|
||||
|
@ -28,6 +28,7 @@ pub(crate) fn unresolved_module(
|
||||
},
|
||||
d.decl.map(|it| it.into()),
|
||||
)
|
||||
.stable()
|
||||
.with_fixes(fixes(ctx, d))
|
||||
}
|
||||
|
||||
|
@ -50,8 +50,7 @@ pub(crate) fn unused_variables(
|
||||
ast.file_id.is_macro(),
|
||||
ctx.edition,
|
||||
)
|
||||
}))
|
||||
.experimental(),
|
||||
})),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ impl Diagnostic {
|
||||
DiagnosticCode::Ra(_, s) => s,
|
||||
},
|
||||
unused: false,
|
||||
experimental: false,
|
||||
experimental: true,
|
||||
fixes: None,
|
||||
main_node: None,
|
||||
}
|
||||
@ -198,8 +198,8 @@ impl Diagnostic {
|
||||
.with_main_node(node)
|
||||
}
|
||||
|
||||
fn experimental(mut self) -> Diagnostic {
|
||||
self.experimental = true;
|
||||
fn stable(mut self) -> Diagnostic {
|
||||
self.experimental = false;
|
||||
self
|
||||
}
|
||||
|
||||
@ -424,14 +424,11 @@ pub fn semantic_diagnostics(
|
||||
AnyDiagnostic::MacroExpansionParseError(d) => {
|
||||
// FIXME: Point to the correct error span here, not just the macro-call name
|
||||
res.extend(d.errors.iter().take(16).map(|err| {
|
||||
{
|
||||
Diagnostic::new(
|
||||
DiagnosticCode::SyntaxError,
|
||||
format!("Syntax Error in Expansion: {err}"),
|
||||
ctx.resolve_precise_location(&d.node.clone(), d.precise_location),
|
||||
)
|
||||
}
|
||||
.experimental()
|
||||
}));
|
||||
continue;
|
||||
},
|
||||
@ -485,12 +482,8 @@ pub fn semantic_diagnostics(
|
||||
Some(it) => it,
|
||||
None => continue,
|
||||
},
|
||||
AnyDiagnostic::GenericArgsProhibited(d) => {
|
||||
handlers::generic_args_prohibited::generic_args_prohibited(&ctx, &d)
|
||||
}
|
||||
AnyDiagnostic::ParenthesizedGenericArgsWithoutFnTrait(d) => {
|
||||
handlers::parenthesized_generic_args_without_fn_trait::parenthesized_generic_args_without_fn_trait(&ctx, &d)
|
||||
}
|
||||
AnyDiagnostic::GenericArgsProhibited(d) => handlers::generic_args_prohibited::generic_args_prohibited(&ctx, &d),
|
||||
AnyDiagnostic::ParenthesizedGenericArgsWithoutFnTrait(d) => handlers::parenthesized_generic_args_without_fn_trait::parenthesized_generic_args_without_fn_trait(&ctx, &d),
|
||||
AnyDiagnostic::BadRtn(d) => handlers::bad_rtn::bad_rtn(&ctx, &d),
|
||||
AnyDiagnostic::IncorrectGenericsLen(d) => handlers::incorrect_generics_len::incorrect_generics_len(&ctx, &d),
|
||||
AnyDiagnostic::IncorrectGenericsOrder(d) => handlers::incorrect_generics_order::incorrect_generics_order(&ctx, &d),
|
||||
|
Loading…
x
Reference in New Issue
Block a user