mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Replace emit_span_lint with emit_span_diag_lint in rustc_lint
This commit is contained in:
@@ -109,7 +109,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||
}
|
||||
&& method_did.map(|did| find_attr!(cx.tcx, did, RustcNoImplicitAutorefs)).unwrap_or(true)
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
DANGEROUS_IMPLICIT_AUTOREFS,
|
||||
expr.span.source_callsite(),
|
||||
ImplicitUnsafeAutorefsDiag {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
use rustc_ast::{self as ast, *};
|
||||
use rustc_ast_pretty::pprust::expr_to_string;
|
||||
use rustc_attr_parsing::AttributeParser;
|
||||
use rustc_errors::{Applicability, LintDiagnostic, msg};
|
||||
use rustc_errors::{Applicability, Diagnostic, msg};
|
||||
use rustc_feature::GateIssue;
|
||||
use rustc_hir::attrs::{AttributeKind, DocAttribute};
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
@@ -99,7 +99,7 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
|
||||
"{}loop",
|
||||
label.map_or_else(String::new, |label| format!("{}: ", label.ident,))
|
||||
);
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
WHILE_TRUE,
|
||||
condition_span,
|
||||
BuiltinWhileTrue { suggestion: condition_span, replace },
|
||||
@@ -172,7 +172,7 @@ fn check_pat(&mut self, cx: &LateContext<'_>, pat: &hir::Pat<'_>) {
|
||||
if cx.tcx.find_field_index(ident, variant)
|
||||
== Some(cx.typeck_results().field_index(fieldpat.hir_id))
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
NON_SHORTHAND_FIELD_PATTERNS,
|
||||
fieldpat.span,
|
||||
BuiltinNonShorthandFieldPatterns {
|
||||
@@ -235,14 +235,14 @@ fn report_unsafe(
|
||||
&self,
|
||||
cx: &EarlyContext<'_>,
|
||||
span: Span,
|
||||
decorate: impl for<'a> LintDiagnostic<'a, ()>,
|
||||
decorate: impl for<'a> Diagnostic<'a, ()>,
|
||||
) {
|
||||
// This comes from a macro that has `#[allow_internal_unsafe]`.
|
||||
if span.allows_unsafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
cx.emit_span_lint(UNSAFE_CODE, span, decorate);
|
||||
cx.emit_span_diag_lint(UNSAFE_CODE, span, decorate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,7 +423,7 @@ fn check_missing_docs_attrs(
|
||||
let attrs = cx.tcx.hir_attrs(cx.tcx.local_def_id_to_hir_id(def_id));
|
||||
let has_doc = attrs.iter().any(has_doc);
|
||||
if !has_doc {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
MISSING_DOCS,
|
||||
cx.tcx.def_span(def_id),
|
||||
BuiltinMissingDoc { article, desc },
|
||||
@@ -624,7 +624,7 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
|
||||
)
|
||||
.is_ok()
|
||||
{
|
||||
cx.emit_span_lint(MISSING_COPY_IMPLEMENTATIONS, item.span, BuiltinMissingCopyImpl);
|
||||
cx.emit_span_diag_lint(MISSING_COPY_IMPLEMENTATIONS, item.span, BuiltinMissingCopyImpl);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -711,7 +711,7 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
|
||||
.next()
|
||||
.is_some();
|
||||
if !has_impl {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
MISSING_DEBUG_IMPLEMENTATIONS,
|
||||
item.span,
|
||||
BuiltinMissingDebugImpl { tcx: cx.tcx, def_id: debug },
|
||||
@@ -788,7 +788,7 @@ fn check_trait_item(&mut self, cx: &EarlyContext<'_>, it: &ast::AssocItem) {
|
||||
} else {
|
||||
("<type>", Applicability::HasPlaceholders)
|
||||
};
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
ANONYMOUS_PARAMETERS,
|
||||
arg.pat.span,
|
||||
BuiltinAnonymousParams { suggestion: (arg.pat.span, appl), ty_snip },
|
||||
@@ -833,7 +833,7 @@ fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: &
|
||||
BuiltinUnusedDocCommentSub::BlockHelp
|
||||
}
|
||||
};
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
UNUSED_DOC_COMMENTS,
|
||||
span,
|
||||
BuiltinUnusedDocComment { kind: node_kind, label: node_span, sub },
|
||||
@@ -965,7 +965,7 @@ fn check_no_mangle_on_generic_fn(
|
||||
) {
|
||||
let generics = cx.tcx.generics_of(def_id);
|
||||
if generics.requires_monomorphization(cx.tcx) {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
NO_MANGLE_GENERIC_ITEMS,
|
||||
cx.tcx.def_span(def_id),
|
||||
BuiltinNoMangleGeneric { suggestion: attr_span },
|
||||
@@ -997,7 +997,7 @@ fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
|
||||
|
||||
// Const items do not refer to a particular location in memory, and therefore
|
||||
// don't have anything to attach a symbol to
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
NO_MANGLE_CONST_ITEMS,
|
||||
it.span,
|
||||
BuiltinConstNoMangle { suggestion },
|
||||
@@ -1058,7 +1058,7 @@ fn check_expr(&mut self, cx: &LateContext<'_>, expr: &hir::Expr<'_>) {
|
||||
get_transmute_from_to(cx, expr).map(|(ty1, ty2)| (ty1.kind(), ty2.kind()))
|
||||
{
|
||||
if from_mutbl < to_mutbl {
|
||||
cx.emit_span_lint(MUTABLE_TRANSMUTES, expr.span, BuiltinMutablesTransmutes);
|
||||
cx.emit_span_diag_lint(MUTABLE_TRANSMUTES, expr.span, BuiltinMutablesTransmutes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1122,7 +1122,7 @@ impl<'tcx> LateLintPass<'tcx> for UnstableFeatures {
|
||||
fn check_attributes(&mut self, cx: &LateContext<'_>, attrs: &[hir::Attribute]) {
|
||||
if let Some(features) = find_attr!(attrs, Feature(features, _) => features) {
|
||||
for feature in features {
|
||||
cx.emit_span_lint(UNSTABLE_FEATURES, feature.span, BuiltinUnstableFeatures);
|
||||
cx.emit_span_diag_lint(UNSTABLE_FEATURES, feature.span, BuiltinUnstableFeatures);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1175,7 +1175,7 @@ fn check_fn(
|
||||
// Now, check if the function has the `#[track_caller]` attribute
|
||||
&& let Some(attr_span) = find_attr!(cx.tcx, def_id, TrackCaller(span) => *span)
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
UNGATED_ASYNC_FN_TRACK_CALLER,
|
||||
attr_span,
|
||||
BuiltinUngatedAsyncFnTrackCaller { label: span, session: &cx.tcx.sess },
|
||||
@@ -1260,7 +1260,7 @@ fn perform_lint(
|
||||
applicability = Applicability::MaybeIncorrect;
|
||||
}
|
||||
let def_span = cx.tcx.def_span(def_id);
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
UNREACHABLE_PUB,
|
||||
def_span,
|
||||
BuiltinUnreachablePub {
|
||||
@@ -1412,7 +1412,7 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
|
||||
let enable_feat_help = cx.tcx.sess.is_nightly_build();
|
||||
|
||||
if let [.., label_sp] = *where_spans {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
TYPE_ALIAS_BOUNDS,
|
||||
where_spans,
|
||||
BuiltinTypeAliasBounds {
|
||||
@@ -1426,7 +1426,7 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
|
||||
);
|
||||
}
|
||||
if let [.., label_sp] = *inline_spans {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
TYPE_ALIAS_BOUNDS,
|
||||
inline_spans,
|
||||
BuiltinTypeAliasBounds {
|
||||
@@ -1526,7 +1526,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
||||
| ty::ClauseKind::HostEffect(..) => continue,
|
||||
};
|
||||
if predicate.is_global() {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
TRIVIAL_BOUNDS,
|
||||
span,
|
||||
BuiltinTrivialBounds { predicate_kind_name, predicate },
|
||||
@@ -1581,7 +1581,7 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) {
|
||||
// Don't lint if this jumps macro expansion boundary (Issue #143980)
|
||||
&& expr.span.eq_ctxt(inner.span)
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
DOUBLE_NEGATIONS,
|
||||
expr.span,
|
||||
BuiltinDoubleNegations {
|
||||
@@ -1702,7 +1702,7 @@ fn matches_ellipsis_pat(pat: &ast::Pat) -> Option<(Option<&Expr>, &Expr, Span)>
|
||||
replace,
|
||||
});
|
||||
} else {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
ELLIPSIS_INCLUSIVE_RANGE_PATTERNS,
|
||||
pat.span,
|
||||
BuiltinEllipsisInclusiveRangePatternsLint::Parenthesise {
|
||||
@@ -1720,7 +1720,7 @@ fn matches_ellipsis_pat(pat: &ast::Pat) -> Option<(Option<&Expr>, &Expr, Span)>
|
||||
replace: replace.to_string(),
|
||||
});
|
||||
} else {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
ELLIPSIS_INCLUSIVE_RANGE_PATTERNS,
|
||||
join,
|
||||
BuiltinEllipsisInclusiveRangePatternsLint::NonParenthesise {
|
||||
@@ -1902,7 +1902,7 @@ fn check_ident_token(
|
||||
return;
|
||||
}
|
||||
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
lint,
|
||||
ident.span,
|
||||
BuiltinKeywordIdents { kw: ident, next: edition, suggestion: ident.span, prefix },
|
||||
@@ -2238,7 +2238,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
|
||||
lint_spans.sort_unstable();
|
||||
lint_spans.dedup();
|
||||
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
EXPLICIT_OUTLIVES_REQUIREMENTS,
|
||||
lint_spans.clone(),
|
||||
BuiltinExplicitOutlives {
|
||||
@@ -2323,13 +2323,17 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
|
||||
let help =
|
||||
HAS_MIN_FEATURES.contains(&name).then_some(BuiltinIncompleteFeaturesHelp);
|
||||
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
INCOMPLETE_FEATURES,
|
||||
span,
|
||||
BuiltinIncompleteFeatures { name, note, help },
|
||||
);
|
||||
} else {
|
||||
cx.emit_span_lint(INTERNAL_FEATURES, span, BuiltinInternalFeatures { name });
|
||||
cx.emit_span_diag_lint(
|
||||
INTERNAL_FEATURES,
|
||||
span,
|
||||
BuiltinInternalFeatures { name },
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2655,7 +2659,7 @@ fn ty_find_init_error<'tcx>(
|
||||
}
|
||||
};
|
||||
let sub = BuiltinUnpermittedTypeInitSub { err };
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
INVALID_VALUE,
|
||||
expr.span,
|
||||
BuiltinUnpermittedTypeInit {
|
||||
@@ -2761,7 +2765,7 @@ fn is_zero(expr: &hir::Expr<'_>) -> bool {
|
||||
{
|
||||
// `&raw *NULL` is ok.
|
||||
} else {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
DEREF_NULLPTR,
|
||||
expr.span,
|
||||
BuiltinDerefNullptr { label: expr.span },
|
||||
@@ -3070,14 +3074,14 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) {
|
||||
let span = span.unwrap_or(*template_span);
|
||||
match label_kind {
|
||||
AsmLabelKind::Named => {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
NAMED_ASM_LABELS,
|
||||
span,
|
||||
InvalidAsmLabel::Named { missing_precise_span },
|
||||
);
|
||||
}
|
||||
AsmLabelKind::FormatArg => {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
NAMED_ASM_LABELS,
|
||||
span,
|
||||
InvalidAsmLabel::FormatArg { missing_precise_span },
|
||||
@@ -3091,7 +3095,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) {
|
||||
Some(InlineAsmArch::X86 | InlineAsmArch::X86_64) | None
|
||||
) =>
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
BINARY_ASM_LABELS,
|
||||
span,
|
||||
InvalidAsmLabel::Binary { missing_precise_span, span },
|
||||
@@ -3167,12 +3171,12 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, krate: &ast::Crate) {
|
||||
}
|
||||
|
||||
match ident.name.as_str() {
|
||||
"lib" => cx.emit_span_lint(
|
||||
"lib" => cx.emit_span_diag_lint(
|
||||
SPECIAL_MODULE_NAME,
|
||||
item.span,
|
||||
BuiltinSpecialModuleNameUsed::Lib,
|
||||
),
|
||||
"main" => cx.emit_span_lint(
|
||||
"main" => cx.emit_span_diag_lint(
|
||||
SPECIAL_MODULE_NAME,
|
||||
item.span,
|
||||
BuiltinSpecialModuleNameUsed::Main,
|
||||
|
||||
@@ -548,6 +548,17 @@ fn emit_span_lint<S: Into<MultiSpan>>(
|
||||
});
|
||||
}
|
||||
|
||||
/// Emit a lint at `span` from a lint struct (some type that implements `LintDiagnostic`,
|
||||
/// typically generated by `#[derive(LintDiagnostic)]`).
|
||||
fn emit_span_diag_lint<S: Into<MultiSpan>>(
|
||||
&self,
|
||||
lint: &'static Lint,
|
||||
span: S,
|
||||
decorator: impl for<'a> Diagnostic<'a, ()>,
|
||||
) {
|
||||
self.opt_span_diag_lint(lint, Some(span), decorator);
|
||||
}
|
||||
|
||||
/// Emit a lint at `span` from a lazily-constructed lint struct (some type that implements
|
||||
/// `LintDiagnostic`, typically generated by `#[derive(LintDiagnostic)]`).
|
||||
fn emit_span_lint_lazy<S: Into<MultiSpan>, L: for<'a> LintDiagnostic<'a, ()>>(
|
||||
|
||||
@@ -89,7 +89,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
||||
)
|
||||
.map(|label| SupertraitAsDerefTargetLabel { label: tcx.def_span(label.def_id) });
|
||||
let span = tcx.def_span(item.owner_id.def_id);
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
DEREF_INTO_DYN_SUPERTRAIT,
|
||||
span,
|
||||
SupertraitAsDerefTarget {
|
||||
|
||||
@@ -26,8 +26,8 @@ fn check_ty(&mut self, cx: &LateContext<'_>, ty: &'tcx hir::Ty<'tcx, AmbigArg>)
|
||||
if cx.tcx.trait_impl_of_assoc(ty.hir_id.owner.to_def_id()).is_some() {
|
||||
return;
|
||||
}
|
||||
if let Some(t) = path_for_rustc_pass_by_value(cx, inner_ty) {
|
||||
cx.emit_span_lint(
|
||||
if let Some(t) = path_for_pass_by_value(cx, inner_ty) {
|
||||
cx.emit_span_diag_lint(
|
||||
DISALLOWED_PASS_BY_REF,
|
||||
ty.span,
|
||||
DisallowedPassByRefDiag { ty: t, suggestion: ty.span },
|
||||
|
||||
@@ -163,14 +163,14 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
|
||||
};
|
||||
match fn_name {
|
||||
sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
DROPPING_REFERENCES,
|
||||
expr.span,
|
||||
DropRefDiag { arg_ty, label: arg.span, sugg: let_underscore_ignore_sugg() },
|
||||
);
|
||||
}
|
||||
sym::mem_forget if arg_ty.is_ref() => {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
FORGETTING_REFERENCES,
|
||||
expr.span,
|
||||
ForgetRefDiag {
|
||||
@@ -181,7 +181,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
|
||||
);
|
||||
}
|
||||
sym::mem_drop if is_copy && !drop_is_single_call_in_arm => {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
DROPPING_COPY_TYPES,
|
||||
expr.span,
|
||||
DropCopyDiag {
|
||||
@@ -192,7 +192,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
|
||||
);
|
||||
}
|
||||
sym::mem_forget if is_copy => {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
FORGETTING_COPY_TYPES,
|
||||
expr.span,
|
||||
ForgetCopyDiag {
|
||||
@@ -206,7 +206,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
|
||||
if let ty::Adt(adt, _) = arg_ty.kind()
|
||||
&& adt.is_manually_drop() =>
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
UNDROPPED_MANUALLY_DROPS,
|
||||
expr.span,
|
||||
UndroppedManuallyDropsDiag {
|
||||
|
||||
@@ -53,7 +53,7 @@ fn enforce_mem_discriminant(
|
||||
) {
|
||||
let ty_param = cx.typeck_results().node_args(func_expr.hir_id).type_at(0);
|
||||
if is_non_enum(ty_param) {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
ENUM_INTRINSICS_NON_ENUMS,
|
||||
expr_span,
|
||||
EnumIntrinsicsMemDiscriminate { ty_param, note: args_span },
|
||||
@@ -64,7 +64,11 @@ fn enforce_mem_discriminant(
|
||||
fn enforce_mem_variant_count(cx: &LateContext<'_>, func_expr: &hir::Expr<'_>, span: Span) {
|
||||
let ty_param = cx.typeck_results().node_args(func_expr.hir_id).type_at(0);
|
||||
if is_non_enum(ty_param) {
|
||||
cx.emit_span_lint(ENUM_INTRINSICS_NON_ENUMS, span, EnumIntrinsicsMemVariant { ty_param });
|
||||
cx.emit_span_diag_lint(
|
||||
ENUM_INTRINSICS_NON_ENUMS,
|
||||
span,
|
||||
EnumIntrinsicsMemVariant { ty_param },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||
end_span: pat.span.between(arg_span),
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
FOR_LOOPS_OVER_FALLIBLES,
|
||||
arg_span,
|
||||
ForLoopsOverFalliblesDiag { article, ref_prefix, ty, sub, question_mark, suggestion },
|
||||
|
||||
@@ -184,7 +184,11 @@ fn check_fn(
|
||||
|
||||
// Check for no_mangle/export_name, so the kernel can be found when querying the compiled object for the kernel function by name
|
||||
if !find_attr!(cx.tcx, id, NoMangle(..) | ExportName { .. }) {
|
||||
cx.emit_span_lint(MISSING_GPU_KERNEL_EXPORT_NAME, span, MissingGpuKernelExportName);
|
||||
cx.emit_span_diag_lint(
|
||||
MISSING_GPU_KERNEL_EXPORT_NAME,
|
||||
span,
|
||||
MissingGpuKernelExportName,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
|
||||
None
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
CONST_ITEM_INTERIOR_MUTATIONS,
|
||||
expr.span,
|
||||
ConstItemInteriorMutationsDiag {
|
||||
|
||||
@@ -48,7 +48,7 @@ fn check_path(&mut self, cx: &LateContext<'_>, path: &hir::Path<'_>, hir_id: Hir
|
||||
Some(sym::HashSet) => "FxHashSet",
|
||||
_ => return,
|
||||
};
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
DEFAULT_HASH_TYPES,
|
||||
path.span,
|
||||
DefaultHashTypesDiag { preferred, used: cx.tcx.item_name(def_id) },
|
||||
@@ -91,14 +91,14 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
|
||||
{
|
||||
let def_id = instance.def_id();
|
||||
if find_attr!(cx.tcx, def_id, RustcLintQueryInstability) {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
POTENTIAL_QUERY_INSTABILITY,
|
||||
span,
|
||||
QueryInstability { query: cx.tcx.item_name(def_id) },
|
||||
);
|
||||
} else if has_unstable_into_iter_predicate(cx, callee_def_id, generic_args) {
|
||||
let call_span = span.with_hi(expr.span.hi());
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
POTENTIAL_QUERY_INSTABILITY,
|
||||
call_span,
|
||||
QueryInstability { query: sym::into_iter },
|
||||
@@ -106,7 +106,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
|
||||
}
|
||||
|
||||
if find_attr!(cx.tcx, def_id, RustcLintUntrackedQueryInformation) {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
UNTRACKED_QUERY_INFORMATION,
|
||||
span,
|
||||
QueryUntracked { method: cx.tcx.item_name(def_id) },
|
||||
@@ -214,7 +214,7 @@ fn check_path(
|
||||
{
|
||||
let span =
|
||||
path.span.with_hi(segment.args.map_or(segment.ident.span, |a| a.span_ext).hi());
|
||||
cx.emit_span_lint(USAGE_OF_TY_TYKIND, path.span, TykindKind { suggestion: span });
|
||||
cx.emit_span_diag_lint(USAGE_OF_TY_TYKIND, path.span, TykindKind { suggestion: span });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,19 +249,19 @@ fn check_ty(&mut self, cx: &LateContext<'_>, ty: &'tcx hir::Ty<'tcx, hir::AmbigA
|
||||
|
||||
match span {
|
||||
Some(span) => {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
USAGE_OF_TY_TYKIND,
|
||||
path.span,
|
||||
TykindKind { suggestion: span },
|
||||
);
|
||||
}
|
||||
None => cx.emit_span_lint(USAGE_OF_TY_TYKIND, path.span, TykindDiag),
|
||||
None => cx.emit_span_diag_lint(USAGE_OF_TY_TYKIND, path.span, TykindDiag),
|
||||
}
|
||||
} else if !ty.span.from_expansion()
|
||||
&& path.segments.len() > 1
|
||||
&& let Some(ty) = is_ty_or_ty_ctxt(cx, path)
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
USAGE_OF_QUALIFIED_TY,
|
||||
path.span,
|
||||
TyQualified { ty, suggestion: path.span },
|
||||
@@ -385,7 +385,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) {
|
||||
&& (cx.tcx.is_diagnostic_item(sym::type_ir_interner, trait_def_id)
|
||||
| cx.tcx.is_diagnostic_item(sym::type_ir_infer_ctxt_like, trait_def_id))
|
||||
{
|
||||
cx.emit_span_lint(USAGE_OF_TYPE_IR_TRAITS, expr.span, TypeIrTraitUsage);
|
||||
cx.emit_span_diag_lint(USAGE_OF_TYPE_IR_TRAITS, expr.span, TypeIrTraitUsage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,13 +399,13 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
||||
|
||||
// Path segments except for the final.
|
||||
if let Some(seg) = path.segments.iter().find(|seg| is_mod_inherent(seg.res)) {
|
||||
cx.emit_span_lint(USAGE_OF_TYPE_IR_INHERENT, seg.ident.span, TypeIrInherentUsage);
|
||||
cx.emit_span_diag_lint(USAGE_OF_TYPE_IR_INHERENT, seg.ident.span, TypeIrInherentUsage);
|
||||
}
|
||||
// Final path resolutions, like `use rustc_type_ir::inherent`
|
||||
else if let Some(type_ns) = path.res.type_ns
|
||||
&& is_mod_inherent(type_ns)
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
USAGE_OF_TYPE_IR_INHERENT,
|
||||
path.segments.last().unwrap().ident.span,
|
||||
TypeIrInherentUsage,
|
||||
@@ -430,7 +430,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
||||
}
|
||||
_ => return,
|
||||
};
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
NON_GLOB_IMPORT_OF_TYPE_IR_INHERENT,
|
||||
path.span,
|
||||
NonGlobImportTypeIrInherent { suggestion: lo.eq_ctxt(hi).then(|| lo.to(hi)), snippet },
|
||||
@@ -448,7 +448,7 @@ fn check_path(
|
||||
.opt_def_id()
|
||||
.is_some_and(|def_id| cx.tcx.is_diagnostic_item(sym::type_ir, def_id))
|
||||
}) {
|
||||
cx.emit_span_lint(DIRECT_USE_OF_RUSTC_TYPE_IR, seg.ident.span, TypeIrDirectUse);
|
||||
cx.emit_span_diag_lint(DIRECT_USE_OF_RUSTC_TYPE_IR, seg.ident.span, TypeIrDirectUse);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -475,7 +475,7 @@ fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) {
|
||||
&& call_site.ctxt().outer_expn_data().kind
|
||||
!= ExpnKind::Macro(MacroKind::Bang, sym::declare_lint_pass)
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
LINT_PASS_IMPL_WITHOUT_MACRO,
|
||||
of_trait.trait_ref.path.span,
|
||||
LintPassByHand,
|
||||
@@ -510,7 +510,7 @@ fn check_expr(&mut self, cx: &LateContext<'_>, expr: &hir::Expr<'_>) {
|
||||
if field.name == target.name
|
||||
&& let Some(lint_message) = find_attr!(cx.tcx, field.did, RustcLintOptDenyFieldAccess { lint_message, } => lint_message)
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
BAD_OPT_ACCESS,
|
||||
expr.span,
|
||||
BadOptAccessDiag { msg: lint_message.as_str() },
|
||||
@@ -538,7 +538,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &hir::Expr<'_>) {
|
||||
) = expr.kind
|
||||
{
|
||||
if is_span_ctxt_call(cx, lhs) && is_span_ctxt_call(cx, rhs) {
|
||||
cx.emit_span_lint(SPAN_USE_EQ_CTXT, expr.span, SpanUseEqCtxtDiag);
|
||||
cx.emit_span_diag_lint(SPAN_USE_EQ_CTXT, expr.span, SpanUseEqCtxtDiag);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -576,7 +576,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx rustc_hir::Expr<'tc
|
||||
&& let hir::ExprKind::Lit(kind) = arg.kind
|
||||
&& let rustc_ast::LitKind::Str(_, _) = kind.node
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
SYMBOL_INTERN_STRING_LITERAL,
|
||||
kind.span,
|
||||
SymbolInternStringLiteralDiag,
|
||||
@@ -612,7 +612,7 @@ fn is_whitelisted(crate_name: &str) -> bool {
|
||||
let name = original_name.as_ref().unwrap_or(&imported_name.name).as_str();
|
||||
let externs = &cx.builder.sess().opts.externs;
|
||||
if externs.get(name).is_none() && !is_whitelisted(name) {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
IMPLICIT_SYSROOT_CRATE_IMPORT,
|
||||
item.span,
|
||||
ImplicitSysrootCrateImportDiag { name },
|
||||
@@ -635,10 +635,10 @@ fn check_arm(&mut self, cx: &EarlyContext<'_>, arm: &rustc_ast::Arm) {
|
||||
fn path_contains_attribute_kind(cx: &EarlyContext<'_>, path: &Path) {
|
||||
for segment in &path.segments {
|
||||
if segment.ident.as_str() == "AttributeKind" {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
BAD_USE_OF_FIND_ATTR,
|
||||
segment.span(),
|
||||
AttributeKindInFindAttr {},
|
||||
AttributeKindInFindAttr,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
|
||||
let valid_up_to = utf8_error.valid_up_to();
|
||||
let is_unchecked_variant = diag_item.as_str().contains("unchecked");
|
||||
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
if is_unchecked_variant {
|
||||
INVALID_FROM_UTF8_UNCHECKED
|
||||
} else {
|
||||
|
||||
@@ -156,14 +156,18 @@ fn check_local(&mut self, cx: &LateContext<'_>, local: &hir::LetStmt<'_>) {
|
||||
};
|
||||
if is_sync_lock {
|
||||
let span = MultiSpan::from_span(pat.span);
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
LET_UNDERSCORE_LOCK,
|
||||
span,
|
||||
NonBindingLet::SyncLock { sub, pat: pat.span },
|
||||
);
|
||||
// Only emit let_underscore_drop for top-level `_` patterns.
|
||||
} else if can_use_init.is_some() {
|
||||
cx.emit_span_lint(LET_UNDERSCORE_DROP, local.span, NonBindingLet::DropType { sub });
|
||||
cx.emit_span_diag_lint(
|
||||
LET_UNDERSCORE_DROP,
|
||||
local.span,
|
||||
NonBindingLet::DropType { sub },
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
|
||||
use rustc_data_structures::unord::UnordSet;
|
||||
use rustc_errors::{Diag, Diagnostic, LintDiagnostic, MultiSpan, msg};
|
||||
use rustc_errors::{Diag, Diagnostic, MultiSpan, msg};
|
||||
use rustc_feature::{Features, GateIssue};
|
||||
use rustc_hir::HirId;
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
@@ -593,7 +593,7 @@ fn insert_spec(&mut self, id: LintId, LevelAndSource { level, lint_id, src }: Le
|
||||
sub,
|
||||
});
|
||||
} else {
|
||||
self.emit_span_lint(
|
||||
self.emit_span_diag_lint(
|
||||
FORBIDDEN_LINT_GROUPS,
|
||||
src.span().into(),
|
||||
OverruledAttributeLint {
|
||||
@@ -783,7 +783,7 @@ fn add(
|
||||
Symbol::intern(complete_name)
|
||||
}
|
||||
Some(new_lint_name) => {
|
||||
self.emit_span_lint(
|
||||
self.emit_span_diag_lint(
|
||||
builtin::RENAMED_AND_REMOVED_LINTS,
|
||||
sp.into(),
|
||||
DeprecatedLintName {
|
||||
@@ -822,8 +822,11 @@ fn add(
|
||||
RenamedLintSuggestion::WithSpan { suggestion: sp, replace };
|
||||
let name =
|
||||
tool_ident.map(|tool| format!("{tool}::{name}")).unwrap_or(name);
|
||||
let lint = RenamedLint { name: name.as_str(), replace, suggestion };
|
||||
self.emit_span_lint(RENAMED_AND_REMOVED_LINTS, sp.into(), lint);
|
||||
self.emit_span_diag_lint(
|
||||
RENAMED_AND_REMOVED_LINTS,
|
||||
sp.into(),
|
||||
RenamedLint { name: name.as_str(), replace, suggestion },
|
||||
);
|
||||
}
|
||||
|
||||
// If this lint was renamed, apply the new lint instead of ignoring the
|
||||
@@ -844,8 +847,11 @@ fn add(
|
||||
if self.lint_added_lints {
|
||||
let name =
|
||||
tool_ident.map(|tool| format!("{tool}::{name}")).unwrap_or(name);
|
||||
let lint = RemovedLint { name: name.as_str(), reason };
|
||||
self.emit_span_lint(RENAMED_AND_REMOVED_LINTS, sp.into(), lint);
|
||||
self.emit_span_diag_lint(
|
||||
RENAMED_AND_REMOVED_LINTS,
|
||||
sp.into(),
|
||||
RemovedLint { name: name.as_str(), reason },
|
||||
);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -861,8 +867,11 @@ fn add(
|
||||
from_rustc,
|
||||
}
|
||||
});
|
||||
let lint = UnknownLint { name, suggestion };
|
||||
self.emit_span_lint(UNKNOWN_LINTS, sp.into(), lint);
|
||||
self.emit_span_diag_lint(
|
||||
UNKNOWN_LINTS,
|
||||
sp.into(),
|
||||
UnknownLint { name, suggestion },
|
||||
);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -912,7 +921,7 @@ fn add(
|
||||
continue;
|
||||
};
|
||||
|
||||
self.emit_span_lint(
|
||||
self.emit_span_diag_lint(
|
||||
UNUSED_ATTRIBUTES,
|
||||
lint_attr_span.into(),
|
||||
IgnoredUnlessCrateSpecified { level: level.as_str(), name: lint_attr_name },
|
||||
@@ -992,24 +1001,20 @@ pub(crate) fn opt_span_diag_lint(
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn emit_span_lint(
|
||||
pub fn emit_span_diag_lint(
|
||||
&self,
|
||||
lint: &'static Lint,
|
||||
span: MultiSpan,
|
||||
decorate: impl for<'a> LintDiagnostic<'a, ()>,
|
||||
decorator: impl for<'a> Diagnostic<'a, ()>,
|
||||
) {
|
||||
let level = self.lint_level(lint);
|
||||
lint_level(self.sess, lint, level, Some(span), |lint| {
|
||||
decorate.decorate_lint(lint);
|
||||
});
|
||||
diag_lint_level(self.sess, lint, level, Some(span), decorator);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn emit_lint(&self, lint: &'static Lint, decorate: impl for<'a> LintDiagnostic<'a, ()>) {
|
||||
pub fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> Diagnostic<'a, ()>) {
|
||||
let level = self.lint_level(lint);
|
||||
lint_level(self.sess, lint, level, None, |lint| {
|
||||
decorate.decorate_lint(lint);
|
||||
});
|
||||
diag_lint_level(self.sess, lint, level, None, decorator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -470,7 +470,7 @@ fn emit_mismatch_diagnostic<'tcx>(
|
||||
suggestions.extend(implicit_suggestion);
|
||||
suggestions.extend(explicit_anonymous_suggestion);
|
||||
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
MISMATCHED_LIFETIME_SYNTAXES,
|
||||
inputs.iter_unnamed().chain(outputs.iter_unnamed()).copied().collect::<Vec<_>>(),
|
||||
lints::MismatchedLifetimeSyntaxes { inputs, outputs, suggestions },
|
||||
|
||||
+191
-173
@@ -5,8 +5,8 @@
|
||||
use rustc_errors::codes::*;
|
||||
use rustc_errors::{
|
||||
Applicability, Diag, DiagArgValue, DiagCtxtHandle, DiagMessage, DiagStyledString, Diagnostic,
|
||||
ElidedLifetimeInPathSubdiag, EmissionGuarantee, Level, LintDiagnostic, MultiSpan,
|
||||
Subdiagnostic, SuggestionStyle, msg,
|
||||
ElidedLifetimeInPathSubdiag, EmissionGuarantee, Level, MultiSpan, Subdiagnostic,
|
||||
SuggestionStyle, msg,
|
||||
};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
@@ -24,7 +24,7 @@
|
||||
use crate::lifetime_syntax::LifetimeSyntaxCategories;
|
||||
|
||||
// array_into_iter.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"this method call resolves to `<&{$target} as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to `<{$target} as IntoIterator>::into_iter` in Rust {$edition}"
|
||||
)]
|
||||
@@ -65,7 +65,7 @@ pub(crate) enum ShadowedIntoIterDiagSub {
|
||||
}
|
||||
|
||||
// autorefs.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("implicit autoref creates a reference to the dereference of a raw pointer")]
|
||||
#[note(
|
||||
"creating a reference requires the pointer target to be valid and imposes aliasing requirements"
|
||||
@@ -119,7 +119,7 @@ pub(crate) struct ImplicitUnsafeAutorefsSuggestion {
|
||||
}
|
||||
|
||||
// builtin.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("denote infinite loops with `loop {\"{\"} ... {\"}\"}`")]
|
||||
pub(crate) struct BuiltinWhileTrue {
|
||||
#[suggestion(
|
||||
@@ -132,7 +132,7 @@ pub(crate) struct BuiltinWhileTrue {
|
||||
pub replace: String,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("the `{$ident}:` in this pattern is redundant")]
|
||||
pub(crate) struct BuiltinNonShorthandFieldPatterns {
|
||||
pub ident: Ident,
|
||||
@@ -145,7 +145,7 @@ pub(crate) struct BuiltinNonShorthandFieldPatterns {
|
||||
pub prefix: &'static str,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
pub(crate) enum BuiltinUnsafe {
|
||||
#[diag(
|
||||
"`allow_internal_unsafe` allows defining macros using unsafe without triggering the `unsafe_code` lint at their call site"
|
||||
@@ -210,14 +210,14 @@ pub(crate) enum BuiltinUnsafe {
|
||||
GlobalAsm,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("missing documentation for {$article} {$desc}")]
|
||||
pub(crate) struct BuiltinMissingDoc<'a> {
|
||||
pub article: &'a str,
|
||||
pub desc: &'a str,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("type could implement `Copy`; consider adding `impl Copy`")]
|
||||
pub(crate) struct BuiltinMissingCopyImpl;
|
||||
|
||||
@@ -227,14 +227,18 @@ pub(crate) struct BuiltinMissingDebugImpl<'a> {
|
||||
}
|
||||
|
||||
// Needed for def_path_str
|
||||
impl<'a> LintDiagnostic<'a, ()> for BuiltinMissingDebugImpl<'_> {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) {
|
||||
diag.primary_message(msg!("type does not implement `{$debug}`; consider adding `#[derive(Debug)]` or a manual implementation"));
|
||||
diag.arg("debug", self.tcx.def_path_str(self.def_id));
|
||||
impl<'a> Diagnostic<'a, ()> for BuiltinMissingDebugImpl<'_> {
|
||||
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
|
||||
let Self { tcx, def_id } = self;
|
||||
Diag::new(
|
||||
dcx,
|
||||
level,
|
||||
msg!("type does not implement `{$debug}`; consider adding `#[derive(Debug)]` or a manual implementation"),
|
||||
).with_arg("debug", tcx.def_path_str(def_id))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("anonymous parameters are deprecated and will be removed in the next edition")]
|
||||
pub(crate) struct BuiltinAnonymousParams<'a> {
|
||||
#[suggestion("try naming the parameter or explicitly ignoring it", code = "_: {ty_snip}")]
|
||||
@@ -242,7 +246,7 @@ pub(crate) struct BuiltinAnonymousParams<'a> {
|
||||
pub ty_snip: &'a str,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unused doc comment")]
|
||||
pub(crate) struct BuiltinUnusedDocComment<'a> {
|
||||
pub kind: &'a str,
|
||||
@@ -260,7 +264,7 @@ pub(crate) enum BuiltinUnusedDocCommentSub {
|
||||
BlockHelp,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("functions generic over types or consts must be mangled")]
|
||||
pub(crate) struct BuiltinNoMangleGeneric {
|
||||
// Use of `#[no_mangle]` suggests FFI intent; correct
|
||||
@@ -274,20 +278,20 @@ pub(crate) struct BuiltinNoMangleGeneric {
|
||||
pub suggestion: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("const items should never be `#[no_mangle]`")]
|
||||
pub(crate) struct BuiltinConstNoMangle {
|
||||
#[suggestion("try a static value", code = "pub static ", applicability = "machine-applicable")]
|
||||
pub suggestion: Option<Span>,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"transmuting &T to &mut T is undefined behavior, even if the reference is unused, consider instead using an UnsafeCell"
|
||||
)]
|
||||
pub(crate) struct BuiltinMutablesTransmutes;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("use of an unstable feature")]
|
||||
pub(crate) struct BuiltinUnstableFeatures;
|
||||
|
||||
@@ -297,19 +301,20 @@ pub(crate) struct BuiltinUngatedAsyncFnTrackCaller<'a> {
|
||||
pub session: &'a Session,
|
||||
}
|
||||
|
||||
impl<'a> LintDiagnostic<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.primary_message(msg!("`#[track_caller]` on async functions is a no-op"));
|
||||
diag.span_label(self.label, msg!("this function will not propagate the caller location"));
|
||||
impl<'a> Diagnostic<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> {
|
||||
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
|
||||
let mut diag = Diag::new(dcx, level, "`#[track_caller]` on async functions is a no-op")
|
||||
.with_span_label(self.label, "this function will not propagate the caller location");
|
||||
rustc_session::parse::add_feature_diagnostics(
|
||||
diag,
|
||||
&mut diag,
|
||||
self.session,
|
||||
sym::async_fn_track_caller,
|
||||
);
|
||||
diag
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unreachable `pub` {$what}")]
|
||||
pub(crate) struct BuiltinUnreachablePub<'a> {
|
||||
pub what: &'a str,
|
||||
@@ -320,7 +325,7 @@ pub(crate) struct BuiltinUnreachablePub<'a> {
|
||||
pub help: bool,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("the `expr` fragment specifier will accept more expressions in the 2024 edition")]
|
||||
pub(crate) struct MacroExprFragment2024 {
|
||||
#[suggestion(
|
||||
@@ -340,18 +345,18 @@ pub(crate) struct BuiltinTypeAliasBounds<'hir> {
|
||||
pub ty: Option<&'hir hir::Ty<'hir>>,
|
||||
}
|
||||
|
||||
impl<'a> LintDiagnostic<'a, ()> for BuiltinTypeAliasBounds<'_> {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.primary_message(if self.in_where_clause {
|
||||
impl<'a> Diagnostic<'a, ()> for BuiltinTypeAliasBounds<'_> {
|
||||
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
|
||||
let mut diag = Diag::new(dcx, level, if self.in_where_clause {
|
||||
msg!("where clauses on type aliases are not enforced")
|
||||
} else {
|
||||
msg!("bounds on generic parameters in type aliases are not enforced")
|
||||
});
|
||||
diag.span_label(self.label, msg!("will not be checked at usage sites of the type alias"));
|
||||
diag.note(msg!(
|
||||
"this is a known limitation of the type checker that may be lifted in a future edition.
|
||||
see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information"
|
||||
));
|
||||
})
|
||||
.with_span_label(self.label, msg!("will not be checked at usage sites of the type alias"))
|
||||
.with_note(msg!(
|
||||
"this is a known limitation of the type checker that may be lifted in a future edition.
|
||||
see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information"
|
||||
));
|
||||
if self.enable_feat_help {
|
||||
diag.help(msg!("add `#![feature(lazy_type_alias)]` to the crate attributes to enable the desired semantics"));
|
||||
}
|
||||
@@ -413,10 +418,11 @@ fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
Applicability::HasPlaceholders,
|
||||
);
|
||||
}
|
||||
diag
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"{$predicate_kind_name} bound {$predicate} does not depend on any type or lifetime parameters"
|
||||
)]
|
||||
@@ -425,7 +431,7 @@ pub(crate) struct BuiltinTrivialBounds<'a> {
|
||||
pub predicate: Clause<'a>,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("use of a double negation")]
|
||||
#[note(
|
||||
"the prefix `--` could be misinterpreted as a decrement operator which exists in other languages"
|
||||
@@ -445,7 +451,7 @@ pub(crate) struct BuiltinDoubleNegationsAddParens {
|
||||
pub end_span: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
pub(crate) enum BuiltinEllipsisInclusiveRangePatternsLint {
|
||||
#[diag("`...` range patterns are deprecated")]
|
||||
Parenthesise {
|
||||
@@ -469,7 +475,7 @@ pub(crate) enum BuiltinEllipsisInclusiveRangePatternsLint {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("`{$kw}` is a keyword in the {$next} edition")]
|
||||
pub(crate) struct BuiltinKeywordIdents {
|
||||
pub kw: Ident,
|
||||
@@ -483,7 +489,7 @@ pub(crate) struct BuiltinKeywordIdents {
|
||||
pub prefix: &'static str,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("outlives requirements can be inferred")]
|
||||
pub(crate) struct BuiltinExplicitOutlives {
|
||||
pub count: usize,
|
||||
@@ -505,7 +511,7 @@ pub(crate) struct BuiltinExplicitOutlivesSuggestion {
|
||||
pub applicability: Applicability,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"the feature `{$name}` is incomplete and may not be safe to use and/or cause compiler crashes"
|
||||
)]
|
||||
@@ -517,7 +523,7 @@ pub(crate) struct BuiltinIncompleteFeatures {
|
||||
pub help: Option<BuiltinIncompleteFeaturesHelp>,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("the feature `{$name}` is internal to the compiler or standard library")]
|
||||
#[note("using it is strongly discouraged")]
|
||||
pub(crate) struct BuiltinInternalFeatures {
|
||||
@@ -542,11 +548,11 @@ pub(crate) struct BuiltinUnpermittedTypeInit<'a> {
|
||||
pub tcx: TyCtxt<'a>,
|
||||
}
|
||||
|
||||
impl<'a> LintDiagnostic<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.primary_message(self.msg);
|
||||
diag.arg("ty", self.ty);
|
||||
diag.span_label(self.label, msg!("this code causes undefined behavior when executed"));
|
||||
impl<'a> Diagnostic<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
|
||||
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
|
||||
let mut diag = Diag::new(dcx, level, self.msg)
|
||||
.with_arg("ty", self.ty)
|
||||
.with_span_label(self.label, msg!("this code causes undefined behavior when executed"));
|
||||
if let InhabitedPredicate::True = self.ty.inhabited_predicate(self.tcx) {
|
||||
// Only suggest late `MaybeUninit::assume_init` initialization if the type is inhabited.
|
||||
diag.span_label(
|
||||
@@ -554,7 +560,8 @@ fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
msg!("help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done"),
|
||||
);
|
||||
}
|
||||
self.sub.add_to_diag(diag);
|
||||
self.sub.add_to_diag(&mut diag);
|
||||
diag
|
||||
}
|
||||
}
|
||||
|
||||
@@ -624,7 +631,7 @@ fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("dereferencing a null pointer")]
|
||||
pub(crate) struct BuiltinDerefNullptr {
|
||||
#[label("this code causes undefined behavior when executed")]
|
||||
@@ -633,7 +640,7 @@ pub(crate) struct BuiltinDerefNullptr {
|
||||
|
||||
// FIXME: migrate fluent::lint::builtin_asm_labels
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
pub(crate) enum BuiltinSpecialModuleNameUsed {
|
||||
#[diag("found module declaration for lib.rs")]
|
||||
#[note("lib.rs is the root of this crate's library target")]
|
||||
@@ -645,7 +652,7 @@ pub(crate) enum BuiltinSpecialModuleNameUsed {
|
||||
}
|
||||
|
||||
// deref_into_dyn_supertrait.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("this `Deref` implementation is covered by an implicit supertrait coercion")]
|
||||
pub(crate) struct SupertraitAsDerefTarget<'a> {
|
||||
pub self_ty: Ty<'a>,
|
||||
@@ -667,7 +674,7 @@ pub(crate) struct SupertraitAsDerefTargetLabel {
|
||||
}
|
||||
|
||||
// enum_intrinsics_non_enums.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("the return value of `mem::discriminant` is unspecified when called with a non-enum type")]
|
||||
pub(crate) struct EnumIntrinsicsMemDiscriminate<'a> {
|
||||
pub ty_param: Ty<'a>,
|
||||
@@ -677,7 +684,7 @@ pub(crate) struct EnumIntrinsicsMemDiscriminate<'a> {
|
||||
pub note: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("the return value of `mem::variant_count` is unspecified when called with a non-enum type")]
|
||||
#[note(
|
||||
"the type parameter of `variant_count` should be an enum, but it was instantiated with the type `{$ty_param}`, which is not an enum"
|
||||
@@ -705,7 +712,7 @@ pub(crate) struct ExpectationNote {
|
||||
}
|
||||
|
||||
// ptr_nulls.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
pub(crate) enum UselessPtrNullChecksDiag<'a> {
|
||||
#[diag(
|
||||
"function pointers are not nullable, so checking them for null will always return false"
|
||||
@@ -730,7 +737,7 @@ pub(crate) enum UselessPtrNullChecksDiag<'a> {
|
||||
FnRet { fn_name: Ident },
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
pub(crate) enum InvalidNullArgumentsDiag {
|
||||
#[diag(
|
||||
"calling this function with a null pointer is undefined behavior, even if the result of the function is unused"
|
||||
@@ -755,7 +762,7 @@ pub(crate) enum InvalidNullArgumentsDiag {
|
||||
}
|
||||
|
||||
// for_loops_over_fallibles.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"for loop over {$article} `{$ref_prefix}{$ty}`. This is more readably written as an `if let` statement"
|
||||
)]
|
||||
@@ -838,7 +845,7 @@ pub(crate) enum UseLetUnderscoreIgnoreSuggestion {
|
||||
}
|
||||
|
||||
// drop_forget_useless.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("calls to `std::mem::drop` with a reference instead of an owned value does nothing")]
|
||||
pub(crate) struct DropRefDiag<'a> {
|
||||
pub arg_ty: Ty<'a>,
|
||||
@@ -848,7 +855,7 @@ pub(crate) struct DropRefDiag<'a> {
|
||||
pub sugg: UseLetUnderscoreIgnoreSuggestion,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("calls to `std::mem::drop` with a value that implements `Copy` does nothing")]
|
||||
pub(crate) struct DropCopyDiag<'a> {
|
||||
pub arg_ty: Ty<'a>,
|
||||
@@ -858,7 +865,7 @@ pub(crate) struct DropCopyDiag<'a> {
|
||||
pub sugg: UseLetUnderscoreIgnoreSuggestion,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("calls to `std::mem::forget` with a reference instead of an owned value does nothing")]
|
||||
pub(crate) struct ForgetRefDiag<'a> {
|
||||
pub arg_ty: Ty<'a>,
|
||||
@@ -868,7 +875,7 @@ pub(crate) struct ForgetRefDiag<'a> {
|
||||
pub sugg: UseLetUnderscoreIgnoreSuggestion,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("calls to `std::mem::forget` with a value that implements `Copy` does nothing")]
|
||||
pub(crate) struct ForgetCopyDiag<'a> {
|
||||
pub arg_ty: Ty<'a>,
|
||||
@@ -878,7 +885,7 @@ pub(crate) struct ForgetCopyDiag<'a> {
|
||||
pub sugg: UseLetUnderscoreIgnoreSuggestion,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"calls to `std::mem::drop` with `std::mem::ManuallyDrop` instead of the inner value does nothing"
|
||||
)]
|
||||
@@ -903,7 +910,7 @@ pub(crate) struct UndroppedManuallyDropsSuggestion {
|
||||
}
|
||||
|
||||
// invalid_from_utf8.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
pub(crate) enum InvalidFromUtf8Diag {
|
||||
#[diag("calls to `{$method}` with an invalid literal are undefined behavior")]
|
||||
Unchecked {
|
||||
@@ -922,7 +929,7 @@ pub(crate) enum InvalidFromUtf8Diag {
|
||||
}
|
||||
|
||||
// interior_mutable_consts.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("mutation of an interior mutable `const` item with call to `{$method_name}`")]
|
||||
#[note("each usage of a `const` item creates a new temporary")]
|
||||
#[note("only the temporaries and never the original `const {$const_name}` will be modified")]
|
||||
@@ -957,7 +964,7 @@ pub(crate) enum ConstItemInteriorMutationsSuggestionStatic {
|
||||
}
|
||||
|
||||
// reference_casting.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
pub(crate) enum InvalidReferenceCastingDiag<'tcx> {
|
||||
#[diag(
|
||||
"casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`"
|
||||
@@ -1002,7 +1009,7 @@ pub(crate) enum InvalidReferenceCastingDiag<'tcx> {
|
||||
}
|
||||
|
||||
// map_unit_fn.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("`Iterator::map` call that discard the iterator's values")]
|
||||
#[note(
|
||||
"`Iterator::map`, like many of the methods on `Iterator`, gets executed lazily, meaning that its effects won't be visible until it is iterated"
|
||||
@@ -1026,7 +1033,7 @@ pub(crate) struct MappingToUnit {
|
||||
}
|
||||
|
||||
// internal.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("prefer `{$preferred}` over `{$used}`, it has better performance")]
|
||||
#[note("a `use rustc_data_structures::fx::{$preferred}` may be necessary")]
|
||||
pub(crate) struct DefaultHashTypesDiag<'a> {
|
||||
@@ -1034,7 +1041,7 @@ pub(crate) struct DefaultHashTypesDiag<'a> {
|
||||
pub used: Symbol,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("using `{$query}` can result in unstable query results")]
|
||||
#[note(
|
||||
"if you believe this case to be fine, allow this lint and add a comment explaining your rationale"
|
||||
@@ -1043,7 +1050,7 @@ pub(crate) struct QueryInstability {
|
||||
pub query: Symbol,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("`{$method}` accesses information that is not tracked by the query system")]
|
||||
#[note(
|
||||
"if you believe this case to be fine, allow this lint and add a comment explaining your rationale"
|
||||
@@ -1052,16 +1059,16 @@ pub(crate) struct QueryUntracked {
|
||||
pub method: Symbol,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("use `.eq_ctxt()` instead of `.ctxt() == .ctxt()`")]
|
||||
pub(crate) struct SpanUseEqCtxtDiag;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("using `Symbol::intern` on a string literal")]
|
||||
#[help("consider adding the symbol to `compiler/rustc_span/src/symbol.rs`")]
|
||||
pub(crate) struct SymbolInternStringLiteralDiag;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("usage of `ty::TyKind::<kind>`")]
|
||||
pub(crate) struct TykindKind {
|
||||
#[suggestion(
|
||||
@@ -1072,12 +1079,12 @@ pub(crate) struct TykindKind {
|
||||
pub suggestion: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("usage of `ty::TyKind`")]
|
||||
#[help("try using `Ty` instead")]
|
||||
pub(crate) struct TykindDiag;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("usage of qualified `ty::{$ty}`")]
|
||||
pub(crate) struct TyQualified {
|
||||
pub ty: String,
|
||||
@@ -1089,14 +1096,14 @@ pub(crate) struct TyQualified {
|
||||
pub suggestion: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("do not use `rustc_type_ir::inherent` unless you're inside of the trait solver")]
|
||||
#[note(
|
||||
"the method or struct you're looking for is likely defined somewhere else downstream in the compiler"
|
||||
)]
|
||||
pub(crate) struct TypeIrInherentUsage;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"do not use `rustc_type_ir::Interner` or `rustc_type_ir::InferCtxtLike` unless you're inside of the trait solver"
|
||||
)]
|
||||
@@ -1105,12 +1112,12 @@ pub(crate) struct TyQualified {
|
||||
)]
|
||||
pub(crate) struct TypeIrTraitUsage;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("do not use `rustc_type_ir` unless you are implementing type system internals")]
|
||||
#[note("use `rustc_middle::ty` instead")]
|
||||
pub(crate) struct TypeIrDirectUse;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("non-glob import of `rustc_type_ir::inherent`")]
|
||||
pub(crate) struct NonGlobImportTypeIrInherent {
|
||||
#[suggestion(
|
||||
@@ -1122,18 +1129,18 @@ pub(crate) struct NonGlobImportTypeIrInherent {
|
||||
pub snippet: &'static str,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("implementing `LintPass` by hand")]
|
||||
#[help("try using `declare_lint_pass!` or `impl_lint_pass!` instead")]
|
||||
pub(crate) struct LintPassByHand;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("{$msg}")]
|
||||
pub(crate) struct BadOptAccessDiag<'a> {
|
||||
pub msg: &'a str,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"dangerous use of `extern crate {$name}` which is not guaranteed to exist exactly once in the sysroot"
|
||||
)]
|
||||
@@ -1144,14 +1151,14 @@ pub(crate) struct ImplicitSysrootCrateImportDiag<'a> {
|
||||
pub name: &'a str,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("use of `AttributeKind` in `find_attr!(...)` invocation")]
|
||||
#[note("`find_attr!(...)` already imports `AttributeKind::*`")]
|
||||
#[help("remove `AttributeKind`")]
|
||||
pub(crate) struct AttributeKindInFindAttr {}
|
||||
pub(crate) struct AttributeKindInFindAttr;
|
||||
|
||||
// let_underscore.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
pub(crate) enum NonBindingLet {
|
||||
#[diag("non-binding let on a synchronization lock")]
|
||||
SyncLock {
|
||||
@@ -1213,7 +1220,7 @@ fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
|
||||
}
|
||||
|
||||
// levels.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("{$lint_level}({$lint_source}) incompatible with previous forbid")]
|
||||
pub(crate) struct OverruledAttributeLint<'a> {
|
||||
#[label("overruled by previous forbid")]
|
||||
@@ -1224,7 +1231,7 @@ pub(crate) struct OverruledAttributeLint<'a> {
|
||||
pub sub: OverruledAttributeSub,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("lint name `{$name}` is deprecated and may not have an effect in the future")]
|
||||
pub(crate) struct DeprecatedLintName<'a> {
|
||||
pub name: String,
|
||||
@@ -1233,7 +1240,7 @@ pub(crate) struct DeprecatedLintName<'a> {
|
||||
pub replace: &'a str,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("lint name `{$name}` is deprecated and may not have an effect in the future")]
|
||||
#[help("change it to {$replace}")]
|
||||
pub(crate) struct DeprecatedLintNameFromCommandLine<'a> {
|
||||
@@ -1243,7 +1250,7 @@ pub(crate) struct DeprecatedLintNameFromCommandLine<'a> {
|
||||
pub requested_level: RequestedLevel<'a>,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("lint `{$name}` has been renamed to `{$replace}`")]
|
||||
pub(crate) struct RenamedLint<'a> {
|
||||
pub name: &'a str,
|
||||
@@ -1264,7 +1271,7 @@ pub(crate) enum RenamedLintSuggestion<'a> {
|
||||
WithoutSpan { replace: &'a str },
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("lint `{$name}` has been renamed to `{$replace}`")]
|
||||
pub(crate) struct RenamedLintFromCommandLine<'a> {
|
||||
pub name: &'a str,
|
||||
@@ -1275,14 +1282,14 @@ pub(crate) struct RenamedLintFromCommandLine<'a> {
|
||||
pub requested_level: RequestedLevel<'a>,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("lint `{$name}` has been removed: {$reason}")]
|
||||
pub(crate) struct RemovedLint<'a> {
|
||||
pub name: &'a str,
|
||||
pub reason: &'a str,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("lint `{$name}` has been removed: {$reason}")]
|
||||
pub(crate) struct RemovedLintFromCommandLine<'a> {
|
||||
pub name: &'a str,
|
||||
@@ -1291,7 +1298,7 @@ pub(crate) struct RemovedLintFromCommandLine<'a> {
|
||||
pub requested_level: RequestedLevel<'a>,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unknown lint: `{$name}`")]
|
||||
pub(crate) struct UnknownLint {
|
||||
pub name: String,
|
||||
@@ -1324,7 +1331,7 @@ pub(crate) enum UnknownLintSuggestion {
|
||||
WithoutSpan { replace: Symbol, from_rustc: bool },
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unknown lint: `{$name}`", code = E0602)]
|
||||
pub(crate) struct UnknownLintFromCommandLine<'a> {
|
||||
pub name: String,
|
||||
@@ -1334,7 +1341,7 @@ pub(crate) struct UnknownLintFromCommandLine<'a> {
|
||||
pub requested_level: RequestedLevel<'a>,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("{$level}({$name}) is ignored unless specified at crate level")]
|
||||
pub(crate) struct IgnoredUnlessCrateSpecified<'a> {
|
||||
pub level: &'a str,
|
||||
@@ -1376,18 +1383,18 @@ pub(crate) struct DanglingPointersFromLocals<'tcx> {
|
||||
}
|
||||
|
||||
// multiple_supertrait_upcastable.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("`{$ident}` is dyn-compatible and has multiple supertraits")]
|
||||
pub(crate) struct MultipleSupertraitUpcastable {
|
||||
pub ident: Ident,
|
||||
}
|
||||
|
||||
// non_ascii_idents.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("identifier contains non-ASCII characters")]
|
||||
pub(crate) struct IdentifierNonAsciiChar;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"identifier contains {$codepoints_len ->
|
||||
[one] { $identifier_type ->
|
||||
@@ -1421,7 +1428,7 @@ pub(crate) struct IdentifierUncommonCodepoints {
|
||||
pub identifier_type: &'static str,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("found both `{$existing_sym}` and `{$sym}` as identifiers, which look alike")]
|
||||
pub(crate) struct ConfusableIdentifierPair {
|
||||
pub existing_sym: Symbol,
|
||||
@@ -1432,7 +1439,7 @@ pub(crate) struct ConfusableIdentifierPair {
|
||||
pub main_label: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"the usage of Script Group `{$set}` in this crate consists solely of mixed script confusables"
|
||||
)]
|
||||
@@ -1450,9 +1457,9 @@ pub(crate) struct NonFmtPanicUnused {
|
||||
}
|
||||
|
||||
// Used because of two suggestions based on one Option<Span>
|
||||
impl<'a> LintDiagnostic<'a, ()> for NonFmtPanicUnused {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.primary_message(msg!(
|
||||
impl<'a> Diagnostic<'a, ()> for NonFmtPanicUnused {
|
||||
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
|
||||
let mut diag = Diag::new(dcx, level, msg!(
|
||||
"panic message contains {$count ->
|
||||
[one] an unused
|
||||
*[other] unused
|
||||
@@ -1460,9 +1467,9 @@ fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
[one] placeholder
|
||||
*[other] placeholders
|
||||
}"
|
||||
));
|
||||
diag.arg("count", self.count);
|
||||
diag.note(msg!("this message is not used as a format string when given without arguments, but will be in Rust 2021"));
|
||||
))
|
||||
.with_arg("count", self.count)
|
||||
.with_note(msg!("this message is not used as a format string when given without arguments, but will be in Rust 2021"));
|
||||
if let Some(span) = self.suggestion {
|
||||
diag.span_suggestion(
|
||||
span.shrink_to_hi(),
|
||||
@@ -1482,10 +1489,11 @@ fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
diag
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"panic message contains {$count ->
|
||||
[one] a brace
|
||||
@@ -1504,7 +1512,7 @@ pub(crate) struct NonFmtPanicBraces {
|
||||
}
|
||||
|
||||
// nonstandard_style.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("{$sort} `{$name}` should have an upper camel case name")]
|
||||
pub(crate) struct NonCamelCaseType<'a> {
|
||||
pub sort: &'a str,
|
||||
@@ -1532,7 +1540,7 @@ pub(crate) enum NonCamelCaseTypeSub {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("{$sort} `{$name}` should have a snake case name")]
|
||||
pub(crate) struct NonSnakeCaseDiag<'a> {
|
||||
pub sort: &'a str,
|
||||
@@ -1630,7 +1638,7 @@ pub(crate) struct NonUpperCaseGlobalSubTool {
|
||||
}
|
||||
|
||||
// noop_method_call.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("call to `.{$method}()` on a reference in this situation does nothing")]
|
||||
#[note(
|
||||
"the type `{$orig_ty}` does not implement `{$trait_}`, so calling `{$method}` on `&{$orig_ty}` copies the reference, which does not do anything and can be removed"
|
||||
@@ -1649,7 +1657,7 @@ pub(crate) struct NoopMethodCallDiag<'a> {
|
||||
pub suggest_derive: Option<Span>,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"using `.deref()` on a double reference, which returns `{$ty}` instead of dereferencing the inner type"
|
||||
)]
|
||||
@@ -1657,7 +1665,7 @@ pub(crate) struct SuspiciousDoubleRefDerefDiag<'a> {
|
||||
pub ty: Ty<'a>,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"using `.clone()` on a double reference, which returns `{$ty}` instead of cloning the inner type"
|
||||
)]
|
||||
@@ -1685,8 +1693,9 @@ pub(crate) enum NonLocalDefinitionsDiag {
|
||||
},
|
||||
}
|
||||
|
||||
impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
impl<'a> Diagnostic<'a, ()> for NonLocalDefinitionsDiag {
|
||||
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
|
||||
let mut diag = Diag::new(dcx, level, "");
|
||||
match self {
|
||||
NonLocalDefinitionsDiag::Impl {
|
||||
depth,
|
||||
@@ -1759,6 +1768,7 @@ fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
diag
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1773,7 +1783,7 @@ pub(crate) struct NonLocalDefinitionsCargoUpdateNote {
|
||||
}
|
||||
|
||||
// precedence.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("`-` has lower precedence than method calls, which might be unexpected")]
|
||||
#[note("e.g. `-4.abs()` equals `-4`; while `(-4).abs()` equals `4`")]
|
||||
pub(crate) struct AmbiguousNegativeLiteralsDiag {
|
||||
@@ -1808,7 +1818,7 @@ pub(crate) struct AmbiguousNegativeLiteralsCurrentBehaviorSuggestion {
|
||||
}
|
||||
|
||||
// disallowed_pass_by_ref.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("passing `{$ty}` by reference")]
|
||||
pub(crate) struct DisallowedPassByRefDiag {
|
||||
pub ty: String,
|
||||
@@ -1817,7 +1827,7 @@ pub(crate) struct DisallowedPassByRefDiag {
|
||||
}
|
||||
|
||||
// redundant_semicolon.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"unnecessary trailing {$multiple ->
|
||||
[true] semicolons
|
||||
@@ -1853,11 +1863,11 @@ pub(crate) struct DropTraitConstraintsDiag<'a> {
|
||||
}
|
||||
|
||||
// Needed for def_path_str
|
||||
impl<'a> LintDiagnostic<'a, ()> for DropTraitConstraintsDiag<'_> {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.primary_message(msg!("bounds on `{$predicate}` are most likely incorrect, consider instead using `{$needs_drop}` to detect whether a type can be trivially dropped"));
|
||||
diag.arg("predicate", self.predicate);
|
||||
diag.arg("needs_drop", self.tcx.def_path_str(self.def_id));
|
||||
impl<'a> Diagnostic<'a, ()> for DropTraitConstraintsDiag<'_> {
|
||||
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
|
||||
Diag::new(dcx, level, msg!("bounds on `{$predicate}` are most likely incorrect, consider instead using `{$needs_drop}` to detect whether a type can be trivially dropped"))
|
||||
.with_arg("predicate", self.predicate)
|
||||
.with_arg("needs_drop", self.tcx.def_path_str(self.def_id))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1867,10 +1877,10 @@ pub(crate) struct DropGlue<'a> {
|
||||
}
|
||||
|
||||
// Needed for def_path_str
|
||||
impl<'a> LintDiagnostic<'a, ()> for DropGlue<'_> {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.primary_message(msg!("types that do not implement `Drop` can still have drop glue, consider instead using `{$needs_drop}` to detect whether a type is trivially dropped"));
|
||||
diag.arg("needs_drop", self.tcx.def_path_str(self.def_id));
|
||||
impl<'a> Diagnostic<'a, ()> for DropGlue<'_> {
|
||||
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
|
||||
Diag::new(dcx, level, msg!("types that do not implement `Drop` can still have drop glue, consider instead using `{$needs_drop}` to detect whether a type is trivially dropped"))
|
||||
.with_arg("needs_drop", self.tcx.def_path_str(self.def_id))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1925,7 +1935,7 @@ pub(crate) enum IntegerToPtrTransmutesSuggestion<'tcx> {
|
||||
}
|
||||
|
||||
// types.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("range endpoint is out of range for `{$ty}`")]
|
||||
pub(crate) struct RangeEndpointOutOfRange<'a> {
|
||||
pub ty: &'a str,
|
||||
@@ -1958,7 +1968,7 @@ pub(crate) enum UseInclusiveRange<'a> {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("literal out of range for `{$ty}`")]
|
||||
pub(crate) struct OverflowingBinHex<'a> {
|
||||
pub ty: &'a str,
|
||||
@@ -2016,7 +2026,7 @@ pub(crate) struct OverflowingBinHexSignBitSub<'a> {
|
||||
pub int_ty: &'a str,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("literal out of range for `{$ty}`")]
|
||||
#[note("the literal `{$lit}` does not fit into the type `{$ty}` whose range is `{$min}..={$max}`")]
|
||||
pub(crate) struct OverflowingInt<'a> {
|
||||
@@ -2034,7 +2044,7 @@ pub(crate) struct OverflowingIntHelp<'a> {
|
||||
pub suggestion_ty: &'a str,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("only `u8` can be cast into `char`")]
|
||||
pub(crate) struct OnlyCastu8ToChar {
|
||||
#[suggestion(
|
||||
@@ -2046,7 +2056,7 @@ pub(crate) struct OnlyCastu8ToChar {
|
||||
pub literal: u128,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("literal out of range for `{$ty}`")]
|
||||
#[note("the literal `{$lit}` does not fit into the type `{$ty}` whose range is `{$min}..={$max}`")]
|
||||
pub(crate) struct OverflowingUInt<'a> {
|
||||
@@ -2056,7 +2066,7 @@ pub(crate) struct OverflowingUInt<'a> {
|
||||
pub max: u128,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("literal out of range for `{$ty}`")]
|
||||
#[note(
|
||||
"the literal `{$lit}` does not fit into the type `{$ty}` and will be converted to `{$ty}::INFINITY`"
|
||||
@@ -2066,31 +2076,31 @@ pub(crate) struct OverflowingLiteral<'a> {
|
||||
pub lit: String,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("surrogate values are not valid for `char`")]
|
||||
#[note("`0xD800..=0xDFFF` are reserved for Unicode surrogates and are not valid `char` values")]
|
||||
pub(crate) struct SurrogateCharCast {
|
||||
pub literal: u128,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("value exceeds maximum `char` value")]
|
||||
#[note("maximum valid `char` value is `0x10FFFF`")]
|
||||
pub(crate) struct TooLargeCharCast {
|
||||
pub literal: u128,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type"
|
||||
)]
|
||||
pub(crate) struct UsesPowerAlignment;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("comparison is useless due to type limits")]
|
||||
pub(crate) struct UnusedComparisons;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
pub(crate) enum InvalidNanComparisons {
|
||||
#[diag("incorrect NaN comparison, NaN cannot be directly compared to itself")]
|
||||
EqNe {
|
||||
@@ -2120,7 +2130,7 @@ pub(crate) enum InvalidNanComparisonsSuggestion {
|
||||
Spanless,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
pub(crate) enum AmbiguousWidePointerComparisons<'a> {
|
||||
#[diag(
|
||||
"ambiguous wide pointer comparison, the comparison includes metadata which may not be expected"
|
||||
@@ -2233,7 +2243,7 @@ pub(crate) struct AmbiguousWidePointerComparisonsExpectSuggestion<'a> {
|
||||
pub(crate) after: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
pub(crate) enum UnpredictableFunctionPointerComparisons<'a, 'tcx> {
|
||||
#[diag(
|
||||
"function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique"
|
||||
@@ -2309,12 +2319,16 @@ pub(crate) struct ImproperCTypes<'a> {
|
||||
}
|
||||
|
||||
// Used because of the complexity of Option<DiagMessage>, DiagMessage, and Option<Span>
|
||||
impl<'a> LintDiagnostic<'a, ()> for ImproperCTypes<'_> {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.primary_message(msg!("`extern` {$desc} uses type `{$ty}`, which is not FFI-safe"));
|
||||
diag.arg("ty", self.ty);
|
||||
diag.arg("desc", self.desc);
|
||||
diag.span_label(self.label, msg!("not FFI-safe"));
|
||||
impl<'a> Diagnostic<'a, ()> for ImproperCTypes<'_> {
|
||||
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
|
||||
let mut diag = Diag::new(
|
||||
dcx,
|
||||
level,
|
||||
msg!("`extern` {$desc} uses type `{$ty}`, which is not FFI-safe"),
|
||||
)
|
||||
.with_arg("ty", self.ty)
|
||||
.with_arg("desc", self.desc)
|
||||
.with_span_label(self.label, msg!("not FFI-safe"));
|
||||
if let Some(help) = self.help {
|
||||
diag.help(help);
|
||||
}
|
||||
@@ -2322,6 +2336,7 @@ fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
if let Some(note) = self.span_note {
|
||||
diag.span_note(note, msg!("the type is defined here"));
|
||||
}
|
||||
diag
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2332,34 +2347,34 @@ pub(crate) struct ImproperGpuKernelArg<'a> {
|
||||
pub ty: Ty<'a>,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("function with the \"gpu-kernel\" ABI has a mangled name")]
|
||||
#[help("use `unsafe(no_mangle)` or `unsafe(export_name = \"<name>\")`")]
|
||||
#[note("mangled names make it hard to find the kernel, this is usually not intended")]
|
||||
pub(crate) struct MissingGpuKernelExportName;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("enum variant is more than three times larger ({$largest} bytes) than the next largest")]
|
||||
pub(crate) struct VariantSizeDifferencesDiag {
|
||||
pub largest: u64,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("atomic loads cannot have `Release` or `AcqRel` ordering")]
|
||||
#[help("consider using ordering modes `Acquire`, `SeqCst` or `Relaxed`")]
|
||||
pub(crate) struct AtomicOrderingLoad;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("atomic stores cannot have `Acquire` or `AcqRel` ordering")]
|
||||
#[help("consider using ordering modes `Release`, `SeqCst` or `Relaxed`")]
|
||||
pub(crate) struct AtomicOrderingStore;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("memory fences cannot have `Relaxed` ordering")]
|
||||
#[help("consider using ordering modes `Acquire`, `Release`, `AcqRel` or `SeqCst`")]
|
||||
pub(crate) struct AtomicOrderingFence;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"`{$method}`'s failure ordering may not be `Release` or `AcqRel`, since a failed `{$method}` does not result in a write"
|
||||
)]
|
||||
@@ -2371,7 +2386,7 @@ pub(crate) struct InvalidAtomicOrderingDiag {
|
||||
}
|
||||
|
||||
// unused.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unused {$op} that must be used")]
|
||||
pub(crate) struct UnusedOp<'a> {
|
||||
pub op: &'a str,
|
||||
@@ -2406,7 +2421,7 @@ pub(crate) enum UnusedOpSuggestion {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unused result of type `{$ty}`")]
|
||||
pub(crate) struct UnusedResult<'a> {
|
||||
pub ty: Ty<'a>,
|
||||
@@ -2414,7 +2429,7 @@ pub(crate) struct UnusedResult<'a> {
|
||||
|
||||
// FIXME(davidtwco): this isn't properly translatable because of the
|
||||
// pre/post strings
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"unused {$pre}{$count ->
|
||||
[one] closure
|
||||
@@ -2430,7 +2445,7 @@ pub(crate) struct UnusedClosure<'a> {
|
||||
|
||||
// FIXME(davidtwco): this isn't properly translatable because of the
|
||||
// pre/post strings
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"unused {$pre}{$count ->
|
||||
[one] coroutine
|
||||
@@ -2481,12 +2496,13 @@ pub(crate) enum UnusedDefSuggestion {
|
||||
}
|
||||
|
||||
// Needed because of def_path_str
|
||||
impl<'a> LintDiagnostic<'a, ()> for UnusedDef<'_, '_> {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
diag.primary_message(msg!("unused {$pre}`{$def}`{$post} that must be used"));
|
||||
diag.arg("pre", self.pre);
|
||||
diag.arg("post", self.post);
|
||||
diag.arg("def", self.cx.tcx.def_path_str(self.def_id));
|
||||
impl<'a> Diagnostic<'a, ()> for UnusedDef<'_, '_> {
|
||||
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
|
||||
let mut diag =
|
||||
Diag::new(dcx, level, msg!("unused {$pre}`{$def}`{$post} that must be used"))
|
||||
.with_arg("pre", self.pre)
|
||||
.with_arg("post", self.post)
|
||||
.with_arg("def", self.cx.tcx.def_path_str(self.def_id));
|
||||
// check for #[must_use = "..."]
|
||||
if let Some(note) = self.note {
|
||||
diag.note(note.to_string());
|
||||
@@ -2494,10 +2510,11 @@ fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||
if let Some(sugg) = self.suggestion {
|
||||
diag.subdiagnostic(sugg);
|
||||
}
|
||||
diag
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("path statement drops value")]
|
||||
pub(crate) struct PathStatementDrop {
|
||||
#[subdiagnostic]
|
||||
@@ -2523,11 +2540,11 @@ pub(crate) enum PathStatementDropSub {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("path statement with no effect")]
|
||||
pub(crate) struct PathStatementNoEffect;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unnecessary {$delim} around {$item}")]
|
||||
pub(crate) struct UnusedDelim<'a> {
|
||||
pub delim: &'static str,
|
||||
@@ -2547,17 +2564,17 @@ pub(crate) struct UnusedDelimSuggestion {
|
||||
pub end_replace: &'static str,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("braces around {$node} is unnecessary")]
|
||||
pub(crate) struct UnusedImportBracesDiag {
|
||||
pub node: Symbol,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unnecessary allocation, use `&` instead")]
|
||||
pub(crate) struct UnusedAllocationDiag;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unnecessary allocation, use `&mut` instead")]
|
||||
pub(crate) struct UnusedAllocationMutDiag;
|
||||
|
||||
@@ -2580,14 +2597,14 @@ fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("binding has unit type `()`")]
|
||||
pub(crate) struct UnitBindingsDiag {
|
||||
#[label("this pattern is inferred to be the unit type `()`")]
|
||||
pub label: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
pub(crate) enum InvalidAsmLabel {
|
||||
#[diag("avoid using named labels in inline assembly")]
|
||||
#[help("only local labels of the form `<number>:` should be used in inline asm")]
|
||||
@@ -3344,7 +3361,7 @@ pub(crate) struct AssociatedConstElidedLifetime {
|
||||
pub lifetimes_in_scope: MultiSpan,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("creating a {$shared_label}reference to mutable static")]
|
||||
pub(crate) struct RefOfMutStatic<'a> {
|
||||
#[label("{$shared_label}reference to mutable static")]
|
||||
@@ -3384,9 +3401,9 @@ pub(crate) enum MutRefSugg {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("`use` of a local item without leading `self::`, `super::`, or `crate::`")]
|
||||
pub(crate) struct UnqualifiedLocalImportsDiag {}
|
||||
pub(crate) struct UnqualifiedLocalImportsDiag;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag("will be parsed as a guarded string in Rust 2024")]
|
||||
@@ -3438,8 +3455,8 @@ pub(crate) struct MismatchedLifetimeSyntaxes {
|
||||
pub suggestions: Vec<MismatchedLifetimeSyntaxesSuggestion>,
|
||||
}
|
||||
|
||||
impl<'a, G: EmissionGuarantee> LintDiagnostic<'a, G> for MismatchedLifetimeSyntaxes {
|
||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>) {
|
||||
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for MismatchedLifetimeSyntaxes {
|
||||
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
|
||||
let counts = self.inputs.len() + self.outputs.len();
|
||||
let message = match counts {
|
||||
LifetimeSyntaxCategories { hidden: 0, elided: 0, named: 0 } => {
|
||||
@@ -3462,7 +3479,7 @@ fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>) {
|
||||
msg!("hiding or eliding a lifetime that's named elsewhere is confusing")
|
||||
}
|
||||
};
|
||||
diag.primary_message(message);
|
||||
let mut diag = Diag::new(dcx, level, message);
|
||||
|
||||
for s in self.inputs.hidden {
|
||||
diag.span_label(s, msg!("the lifetime is hidden here"));
|
||||
@@ -3497,6 +3514,7 @@ fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>) {
|
||||
diag.subdiagnostic(s);
|
||||
}
|
||||
}
|
||||
diag
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ fn check_ident_token(&mut self, cx: &crate::EarlyContext<'_>, token: &Token) {
|
||||
}
|
||||
|
||||
debug!("emitting lint");
|
||||
cx.builder.emit_span_lint(
|
||||
cx.builder.emit_span_diag_lint(
|
||||
&EDITION_2024_EXPR_FRAGMENT_SPECIFIER,
|
||||
token.span.into(),
|
||||
MacroExprFragment2024 { suggestion: token.span },
|
||||
|
||||
@@ -67,7 +67,7 @@ fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &Stmt<'_>) {
|
||||
if !(ret_ty.is_unit() || ret_ty.is_never()) {
|
||||
return;
|
||||
}
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
MAP_UNIT_FN,
|
||||
span,
|
||||
MappingToUnit {
|
||||
|
||||
@@ -50,7 +50,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
||||
.filter(|pred| !cx.tcx.is_lang_item(pred.def_id(), hir::LangItem::MetaSized))
|
||||
.filter(|pred| !cx.tcx.is_default_trait(pred.def_id()));
|
||||
if direct_super_traits_iter.count() > 1 {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
MULTIPLE_SUPERTRAIT_UPCASTABLE,
|
||||
cx.tcx.def_span(def_id),
|
||||
crate::lints::MultipleSupertraitUpcastable { ident },
|
||||
|
||||
@@ -190,7 +190,7 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
|
||||
continue;
|
||||
}
|
||||
has_non_ascii_idents = true;
|
||||
cx.emit_span_lint(NON_ASCII_IDENTS, sp, IdentifierNonAsciiChar);
|
||||
cx.emit_span_diag_lint(NON_ASCII_IDENTS, sp, IdentifierNonAsciiChar);
|
||||
if check_uncommon_codepoints
|
||||
&& !symbol_str.chars().all(GeneralSecurityProfile::identifier_allowed)
|
||||
{
|
||||
@@ -210,7 +210,7 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
|
||||
if codepoints.is_empty() {
|
||||
continue;
|
||||
}
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
UNCOMMON_CODEPOINTS,
|
||||
sp,
|
||||
IdentifierUncommonCodepoints {
|
||||
@@ -225,7 +225,7 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
|
||||
.extract_if(.., |(c, _)| !GeneralSecurityProfile::identifier_allowed(*c))
|
||||
.collect::<Vec<_>>();
|
||||
if !remaining.is_empty() {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
UNCOMMON_CODEPOINTS,
|
||||
sp,
|
||||
IdentifierUncommonCodepoints {
|
||||
@@ -262,7 +262,7 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
|
||||
.entry(skeleton_sym)
|
||||
.and_modify(|(existing_symbol, existing_span, existing_is_ascii)| {
|
||||
if !*existing_is_ascii || !is_ascii {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
CONFUSABLE_IDENTS,
|
||||
sp,
|
||||
ConfusableIdentifierPair {
|
||||
@@ -383,7 +383,7 @@ enum ScriptSetUsage {
|
||||
let char_info = format!("'{}' (U+{:04X})", ch, ch as u32);
|
||||
includes += &char_info;
|
||||
}
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
MIXED_SCRIPT_CONFUSABLES,
|
||||
sp,
|
||||
MixedScriptConfusables { set: script_set.to_string(), includes },
|
||||
|
||||
@@ -259,7 +259,7 @@ fn check_panic_str<'tcx>(
|
||||
.map(|span| fmt_span.from_inner(InnerSpan::new(span.start, span.end)))
|
||||
.collect(),
|
||||
};
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
NON_FMT_PANICS,
|
||||
arg_spans,
|
||||
NonFmtPanicUnused {
|
||||
@@ -276,7 +276,7 @@ fn check_panic_str<'tcx>(
|
||||
.collect()
|
||||
});
|
||||
let count = brace_spans.as_ref().map(|v| v.len()).unwrap_or(/* any number >1 */ 2);
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
NON_FMT_PANICS,
|
||||
brace_spans.unwrap_or_else(|| vec![span]),
|
||||
NonFmtPanicBraces {
|
||||
|
||||
@@ -225,7 +225,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
|
||||
None
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
NON_LOCAL_DEFINITIONS,
|
||||
ms,
|
||||
NonLocalDefinitionsDiag::Impl {
|
||||
@@ -244,7 +244,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
|
||||
ItemKind::Macro(_, _macro, _kinds)
|
||||
if find_attr!(cx.tcx, item.owner_id.def_id, MacroExport { .. }) =>
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
NON_LOCAL_DEFINITIONS,
|
||||
item.span,
|
||||
NonLocalDefinitionsDiag::MacroRules {
|
||||
|
||||
@@ -132,7 +132,7 @@ fn check_case(&self, cx: &EarlyContext<'_>, sort: &str, ident: &Ident) {
|
||||
} else {
|
||||
NonCamelCaseTypeSub::Label { span: ident.span }
|
||||
};
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
NON_CAMEL_CASE_TYPES,
|
||||
ident.span,
|
||||
NonCamelCaseType { sort, name, sub },
|
||||
@@ -301,7 +301,7 @@ fn is_snake_case(ident: &str) -> bool {
|
||||
} else {
|
||||
NonSnakeCaseDiagSub::Label { span }
|
||||
};
|
||||
cx.emit_span_lint(NON_SNAKE_CASE, span, NonSnakeCaseDiag { sort, name, sc, sub });
|
||||
cx.emit_span_diag_lint(NON_SNAKE_CASE, span, NonSnakeCaseDiag { sort, name, sc, sub });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||
ty::Adt(def, _) => Some(cx.tcx.def_span(def.did()).shrink_to_lo()),
|
||||
_ => None,
|
||||
};
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
NOOP_METHOD_CALL,
|
||||
span,
|
||||
NoopMethodCallDiag {
|
||||
@@ -147,12 +147,12 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||
// If `type_of(x) == T` and `x.borrow()` is used to get `&T`,
|
||||
// then that should be allowed
|
||||
sym::noop_method_borrow => return,
|
||||
sym::noop_method_clone => cx.emit_span_lint(
|
||||
sym::noop_method_clone => cx.emit_span_diag_lint(
|
||||
SUSPICIOUS_DOUBLE_REF_OP,
|
||||
span,
|
||||
SuspiciousDoubleRefCloneDiag { ty: expr_ty },
|
||||
),
|
||||
sym::noop_method_deref => cx.emit_span_lint(
|
||||
sym::noop_method_deref => cx.emit_span_diag_lint(
|
||||
SUSPICIOUS_DOUBLE_REF_OP,
|
||||
span,
|
||||
SuspiciousDoubleRefDerefDiag { ty: expr_ty },
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use rustc_hir::{self as hir, AmbigArg};
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_macros::{LintDiagnostic, Subdiagnostic};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_middle::ty::print::{PrintTraitPredicateExt as _, TraitPredPrintModifiersAndPath};
|
||||
use rustc_middle::ty::{self, BottomUpFolder, Ty, TypeFoldable};
|
||||
use rustc_session::{declare_lint, declare_lint_pass};
|
||||
@@ -180,7 +180,7 @@ fn check_ty(&mut self, cx: &LateContext<'tcx>, ty: &'tcx hir::Ty<'tcx, AmbigArg>
|
||||
_ => None,
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
OPAQUE_HIDDEN_INFERRED_BOUND,
|
||||
pred_span,
|
||||
OpaqueHiddenInferredBoundLint {
|
||||
@@ -201,7 +201,7 @@ fn check_ty(&mut self, cx: &LateContext<'tcx>, ty: &'tcx hir::Ty<'tcx, AmbigArg>
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("opaque type `{$ty}` does not satisfy its associated type bounds")]
|
||||
struct OpaqueHiddenInferredBoundLint<'tcx> {
|
||||
ty: Ty<'tcx>,
|
||||
|
||||
@@ -52,7 +52,7 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
|
||||
&& let ExprKind::Lit(lit) = &arg.kind
|
||||
&& let LitKind::Integer | LitKind::Float = &lit.kind
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
AMBIGUOUS_NEGATIVE_LITERALS,
|
||||
expr.span,
|
||||
AmbiguousNegativeLiteralsDiag {
|
||||
|
||||
@@ -143,7 +143,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||
)
|
||||
&& let Some(diag) = useless_check(cx, arg) =>
|
||||
{
|
||||
cx.emit_span_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
|
||||
cx.emit_span_diag_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
|
||||
}
|
||||
|
||||
// Catching:
|
||||
@@ -195,7 +195,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||
InvalidNullArgumentsDiag::NullPtrThroughBinding { null_span }
|
||||
};
|
||||
|
||||
cx.emit_span_lint(INVALID_NULL_ARGUMENTS, expr.span, diag)
|
||||
cx.emit_span_diag_lint(INVALID_NULL_ARGUMENTS, expr.span, diag)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,7 +210,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||
)
|
||||
&& let Some(diag) = useless_check(cx, receiver) =>
|
||||
{
|
||||
cx.emit_span_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
|
||||
cx.emit_span_diag_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
|
||||
}
|
||||
|
||||
ExprKind::Binary(op, left, right) if matches!(op.node, BinOpKind::Eq) => {
|
||||
@@ -234,7 +234,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||
&& let LitKind::Int(v, _) = spanned.node
|
||||
&& v == 0 =>
|
||||
{
|
||||
cx.emit_span_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
|
||||
cx.emit_span_diag_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
|
||||
}
|
||||
|
||||
// Catching:
|
||||
@@ -245,7 +245,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||
&& let Some(diag_item) = cx.tcx.get_diagnostic_name(def_id)
|
||||
&& (diag_item == sym::ptr_null || diag_item == sym::ptr_null_mut) =>
|
||||
{
|
||||
cx.emit_span_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
|
||||
cx.emit_span_diag_lint(USELESS_PTR_NULL_CHECKS, expr.span, diag)
|
||||
}
|
||||
|
||||
_ => {}
|
||||
|
||||
@@ -55,7 +55,7 @@ fn maybe_lint_redundant_semis(cx: &EarlyContext<'_>, seq: &mut Option<(Span, boo
|
||||
Some(RedundantSemicolonsSuggestion { multiple_semicolons: multiple, span })
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
REDUNDANT_SEMICOLONS,
|
||||
span,
|
||||
RedundantSemicolonsDiag { multiple, suggestion },
|
||||
|
||||
@@ -55,7 +55,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
|
||||
&& let Some(ty_has_interior_mutability) =
|
||||
is_cast_from_ref_to_mut_ptr(cx, init, &mut peel_casts)
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
INVALID_REFERENCE_CASTING,
|
||||
expr.span,
|
||||
if pat == PatternKind::Assign {
|
||||
@@ -75,7 +75,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
|
||||
if let Some((from_ty_layout, to_ty_layout, e_alloc)) =
|
||||
is_cast_to_bigger_memory_layout(cx, init, &mut peel_casts)
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
INVALID_REFERENCE_CASTING,
|
||||
expr.span,
|
||||
InvalidReferenceCastingDiag::BiggerLayout {
|
||||
|
||||
@@ -150,7 +150,7 @@ fn is_ref_to_boxed_slice(ty: Ty<'_>) -> bool {
|
||||
None
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
lint,
|
||||
call.ident.span,
|
||||
ShadowedIntoIterDiag { target, edition, suggestion: call.ident.span, sub },
|
||||
|
||||
@@ -155,7 +155,7 @@ fn emit_static_mut_refs(
|
||||
}
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
STATIC_MUT_REFS,
|
||||
span,
|
||||
RefOfMutStatic { span, sugg, shared_label, shared_note, mut_note },
|
||||
|
||||
@@ -101,7 +101,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
||||
continue;
|
||||
}
|
||||
let Some(def_id) = cx.tcx.get_diagnostic_item(sym::needs_drop) else { return };
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
DROP_BOUNDS,
|
||||
span,
|
||||
DropTraitConstraintsDiag { predicate, tcx: cx.tcx, def_id },
|
||||
@@ -118,7 +118,7 @@ fn check_ty(&mut self, cx: &LateContext<'_>, ty: &'tcx hir::Ty<'tcx, AmbigArg>)
|
||||
let def_id = bound.trait_ref.trait_def_id();
|
||||
if def_id.is_some_and(|def_id| cx.tcx.is_lang_item(def_id, LangItem::Drop)) {
|
||||
let Some(def_id) = cx.tcx.get_diagnostic_item(sym::needs_drop) else { return };
|
||||
cx.emit_span_lint(DYN_DROP, bound.span, DropGlue { tcx: cx.tcx, def_id });
|
||||
cx.emit_span_diag_lint(DYN_DROP, bound.span, DropGlue { tcx: cx.tcx, def_id });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ fn eq_ne(
|
||||
_ => return,
|
||||
};
|
||||
|
||||
cx.emit_span_lint(INVALID_NAN_COMPARISONS, e.span, lint);
|
||||
cx.emit_span_diag_lint(INVALID_NAN_COMPARISONS, e.span, lint);
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Copy, Clone)]
|
||||
@@ -343,7 +343,7 @@ fn lint_wide_pointer<'tcx>(
|
||||
let (Some(l_span), Some(r_span)) =
|
||||
(l.span.find_ancestor_inside(e.span), r.span.find_ancestor_inside(e.span))
|
||||
else {
|
||||
return cx.emit_span_lint(
|
||||
return cx.emit_span_diag_lint(
|
||||
AMBIGUOUS_WIDE_POINTER_COMPARISONS,
|
||||
e.span,
|
||||
AmbiguousWidePointerComparisons::Spanless,
|
||||
@@ -365,7 +365,7 @@ fn lint_wide_pointer<'tcx>(
|
||||
let l_modifiers = &*l_modifiers;
|
||||
let r_modifiers = &*r_modifiers;
|
||||
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
AMBIGUOUS_WIDE_POINTER_COMPARISONS,
|
||||
e.span,
|
||||
if is_eq_ne {
|
||||
@@ -460,7 +460,7 @@ fn lint_fn_pointer<'tcx>(
|
||||
&& r_some_arg.expect_ty().is_fn()
|
||||
{
|
||||
// both operands are `Option<{function ptr}>`
|
||||
return cx.emit_span_lint(
|
||||
return cx.emit_span_diag_lint(
|
||||
UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS,
|
||||
e.span,
|
||||
UnpredictableFunctionPointerComparisons::Warn,
|
||||
@@ -476,7 +476,7 @@ fn lint_fn_pointer<'tcx>(
|
||||
|
||||
if !is_eq_ne {
|
||||
// Neither `==` nor `!=`, we can't suggest `ptr::fn_addr_eq`, just show the warning.
|
||||
return cx.emit_span_lint(
|
||||
return cx.emit_span_diag_lint(
|
||||
UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS,
|
||||
e.span,
|
||||
UnpredictableFunctionPointerComparisons::Warn,
|
||||
@@ -487,7 +487,7 @@ fn lint_fn_pointer<'tcx>(
|
||||
(l.span.find_ancestor_inside(e.span), r.span.find_ancestor_inside(e.span))
|
||||
else {
|
||||
// No appropriate spans for the left and right operands, just show the warning.
|
||||
return cx.emit_span_lint(
|
||||
return cx.emit_span_diag_lint(
|
||||
UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS,
|
||||
e.span,
|
||||
UnpredictableFunctionPointerComparisons::Warn,
|
||||
@@ -530,7 +530,7 @@ fn lint_fn_pointer<'tcx>(
|
||||
}
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS,
|
||||
e.span,
|
||||
UnpredictableFunctionPointerComparisons::Suggestion { sugg },
|
||||
@@ -558,7 +558,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx hir::Expr<'tcx>) {
|
||||
hir::ExprKind::Binary(binop, ref l, ref r) => {
|
||||
if is_comparison(binop.node) {
|
||||
if !check_limits(cx, binop.node, l, r) {
|
||||
cx.emit_span_lint(UNUSED_COMPARISONS, e.span, UnusedComparisons);
|
||||
cx.emit_span_diag_lint(UNUSED_COMPARISONS, e.span, UnusedComparisons);
|
||||
} else {
|
||||
lint_nan(cx, e, binop.node, l, r);
|
||||
let cmpop = ComparisonOp::BinOp(binop.node);
|
||||
@@ -975,7 +975,7 @@ fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
|
||||
// We only warn if the largest variant is at least thrice as large as
|
||||
// the second-largest.
|
||||
if largest > slargest * 3 && slargest > 0 {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
VARIANT_SIZE_DIFFERENCES,
|
||||
enum_definition.variants[largest_index].span,
|
||||
VariantSizeDifferencesDiag { largest },
|
||||
@@ -1096,9 +1096,17 @@ fn check_atomic_load_store(cx: &LateContext<'_>, expr: &Expr<'_>) {
|
||||
&& (ordering == invalid_ordering || ordering == sym::AcqRel)
|
||||
{
|
||||
if method == sym::load {
|
||||
cx.emit_span_lint(INVALID_ATOMIC_ORDERING, ordering_arg.span, AtomicOrderingLoad);
|
||||
cx.emit_span_diag_lint(
|
||||
INVALID_ATOMIC_ORDERING,
|
||||
ordering_arg.span,
|
||||
AtomicOrderingLoad,
|
||||
);
|
||||
} else {
|
||||
cx.emit_span_lint(INVALID_ATOMIC_ORDERING, ordering_arg.span, AtomicOrderingStore);
|
||||
cx.emit_span_diag_lint(
|
||||
INVALID_ATOMIC_ORDERING,
|
||||
ordering_arg.span,
|
||||
AtomicOrderingStore,
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1110,7 +1118,7 @@ fn check_memory_fence(cx: &LateContext<'_>, expr: &Expr<'_>) {
|
||||
&& matches!(cx.tcx.get_diagnostic_name(def_id), Some(sym::fence | sym::compiler_fence))
|
||||
&& Self::match_ordering(cx, &args[0]) == Some(sym::Relaxed)
|
||||
{
|
||||
cx.emit_span_lint(INVALID_ATOMIC_ORDERING, args[0].span, AtomicOrderingFence);
|
||||
cx.emit_span_diag_lint(INVALID_ATOMIC_ORDERING, args[0].span, AtomicOrderingFence);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1138,7 +1146,7 @@ fn check_atomic_compare_exchange(cx: &LateContext<'_>, expr: &Expr<'_>) {
|
||||
let Some(fail_ordering) = Self::match_ordering(cx, fail_order_arg) else { return };
|
||||
|
||||
if matches!(fail_ordering, sym::Release | sym::AcqRel) {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
INVALID_ATOMIC_ORDERING,
|
||||
fail_order_arg.span,
|
||||
InvalidAtomicOrderingDiag { method, fail_order_arg_span: fail_order_arg.span },
|
||||
|
||||
@@ -237,7 +237,7 @@ fn check_struct_for_power_alignment<'tcx>(
|
||||
// to be the fields that are misaligned.
|
||||
let ty = tcx.type_of(field_def.def_id).instantiate_identity();
|
||||
if check_arg_for_power_alignment(cx, ty) {
|
||||
cx.emit_span_lint(USES_POWER_ALIGNMENT, field_def.span, UsesPowerAlignment);
|
||||
cx.emit_span_diag_lint(USES_POWER_ALIGNMENT, field_def.span, UsesPowerAlignment);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -959,7 +959,11 @@ fn emit_ffi_unsafe_type_lint(
|
||||
} else {
|
||||
None
|
||||
};
|
||||
cx.emit_span_lint(lint, sp, ImproperCTypes { ty, desc, label: sp, help, note, span_note });
|
||||
cx.emit_span_diag_lint(
|
||||
lint,
|
||||
sp,
|
||||
ImproperCTypes { ty, desc, label: sp, help, note, span_note },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ fn lint_overflowing_range_endpoint<'tcx>(
|
||||
}
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
OVERFLOWING_LITERALS,
|
||||
range_span,
|
||||
RangeEndpointOutOfRange { ty, sub: sub_sugg },
|
||||
@@ -201,7 +201,7 @@ fn report_bin_hex_error(
|
||||
})
|
||||
.flatten();
|
||||
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
OVERFLOWING_LITERALS,
|
||||
span,
|
||||
OverflowingBinHex {
|
||||
@@ -297,7 +297,7 @@ fn lint_int_literal<'tcx>(
|
||||
let help = get_type_suggestion(cx.typeck_results().node_type(hir_id), v, negative)
|
||||
.map(|suggestion_ty| OverflowingIntHelp { suggestion_ty });
|
||||
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
OVERFLOWING_LITERALS,
|
||||
span,
|
||||
OverflowingInt { ty: t.name_str(), lit, min, max, help },
|
||||
@@ -327,19 +327,19 @@ fn lint_uint_literal<'tcx>(
|
||||
hir::ExprKind::Cast(..) => {
|
||||
if let ty::Char = cx.typeck_results().expr_ty(par_e).kind() {
|
||||
if lit_val > 0x10FFFF {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
OVERFLOWING_LITERALS,
|
||||
par_e.span,
|
||||
TooLargeCharCast { literal: lit_val },
|
||||
);
|
||||
} else if (0xD800..=0xDFFF).contains(&lit_val) {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
OVERFLOWING_LITERALS,
|
||||
par_e.span,
|
||||
SurrogateCharCast { literal: lit_val },
|
||||
);
|
||||
} else {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
OVERFLOWING_LITERALS,
|
||||
par_e.span,
|
||||
OnlyCastu8ToChar { span: par_e.span, literal: lit_val },
|
||||
@@ -368,7 +368,7 @@ fn lint_uint_literal<'tcx>(
|
||||
);
|
||||
return;
|
||||
}
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
OVERFLOWING_LITERALS,
|
||||
span,
|
||||
OverflowingUInt {
|
||||
@@ -426,7 +426,7 @@ pub(crate) fn lint_literal<'tcx>(
|
||||
};
|
||||
|
||||
if is_infinite == Some(true) {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
OVERFLOWING_LITERALS,
|
||||
span,
|
||||
OverflowingLiteral {
|
||||
|
||||
@@ -63,7 +63,7 @@ fn check_local(&mut self, cx: &crate::LateContext<'tcx>, local: &'tcx hir::LetSt
|
||||
&& !matches!(init.kind, hir::ExprKind::Tup([]))
|
||||
&& !matches!(local.pat.kind, hir::PatKind::Tuple([], ..))
|
||||
{
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
UNIT_BINDINGS,
|
||||
local.span,
|
||||
UnitBindingsDiag { label: local.pat.span },
|
||||
|
||||
@@ -74,10 +74,10 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
||||
}
|
||||
|
||||
// This `use` qualifies for our lint!
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
UNQUALIFIED_LOCAL_IMPORTS,
|
||||
first_seg.ident.span,
|
||||
lints::UnqualifiedLocalImportsDiag {},
|
||||
lints::UnqualifiedLocalImportsDiag,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,9 +51,9 @@ fn check_stmt(&mut self, cx: &LateContext<'_>, s: &hir::Stmt<'_>) {
|
||||
} else {
|
||||
PathStatementDropSub::Help { span: s.span }
|
||||
};
|
||||
cx.emit_span_lint(PATH_STATEMENTS, s.span, PathStatementDrop { sub })
|
||||
cx.emit_span_diag_lint(PATH_STATEMENTS, s.span, PathStatementDrop { sub })
|
||||
} else {
|
||||
cx.emit_span_lint(PATH_STATEMENTS, s.span, PathStatementNoEffect);
|
||||
cx.emit_span_diag_lint(PATH_STATEMENTS, s.span, PathStatementNoEffect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -352,7 +352,7 @@ fn emit_unused_delims(
|
||||
end_replace: hi_replace,
|
||||
}
|
||||
});
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
self.lint(),
|
||||
primary_span,
|
||||
UnusedDelim { delim: Self::DELIM_STR, item: msg, suggestion },
|
||||
@@ -1181,7 +1181,7 @@ fn check_use_tree(&self, cx: &EarlyContext<'_>, use_tree: &ast::UseTree, item: &
|
||||
ast::UseTreeKind::Nested { .. } => return,
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
UNUSED_IMPORT_BRACES,
|
||||
item.span,
|
||||
UnusedImportBracesDiag { node: node_name },
|
||||
@@ -1244,10 +1244,10 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &hir::Expr<'_>) {
|
||||
}
|
||||
match m {
|
||||
adjustment::AutoBorrowMutability::Not => {
|
||||
cx.emit_span_lint(UNUSED_ALLOCATION, e.span, UnusedAllocationDiag);
|
||||
cx.emit_span_diag_lint(UNUSED_ALLOCATION, e.span, UnusedAllocationDiag);
|
||||
}
|
||||
adjustment::AutoBorrowMutability::Mut { .. } => {
|
||||
cx.emit_span_lint(UNUSED_ALLOCATION, e.span, UnusedAllocationMutDiag);
|
||||
cx.emit_span_diag_lint(UNUSED_ALLOCATION, e.span, UnusedAllocationMutDiag);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ fn check_stmt(&mut self, cx: &LateContext<'_>, s: &hir::Stmt<'_>) {
|
||||
let op_warned = match must_use_op {
|
||||
Some(must_use_op) => {
|
||||
let span = expr.span.find_ancestor_not_from_macro().unwrap_or(expr.span);
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
UNUSED_MUST_USE,
|
||||
expr.span,
|
||||
UnusedOp {
|
||||
@@ -423,7 +423,7 @@ fn check_stmt(&mut self, cx: &LateContext<'_>, s: &hir::Stmt<'_>) {
|
||||
|
||||
// Only emit unused results lint if we haven't emitted any of the more specific lints and the expression type is non trivial.
|
||||
if !(type_lint_emitted_or_trivial || fn_warned || op_warned) {
|
||||
cx.emit_span_lint(UNUSED_RESULTS, s.span, UnusedResult { ty });
|
||||
cx.emit_span_diag_lint(UNUSED_RESULTS, s.span, UnusedResult { ty });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -598,14 +598,14 @@ fn emit_must_use_untranslated(
|
||||
);
|
||||
}
|
||||
MustUsePath::Closure(span) => {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
UNUSED_MUST_USE,
|
||||
*span,
|
||||
UnusedClosure { count: plural_len, pre: descr_pre, post: descr_post },
|
||||
);
|
||||
}
|
||||
MustUsePath::Coroutine(span) => {
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
UNUSED_MUST_USE,
|
||||
*span,
|
||||
UnusedCoroutine { count: plural_len, pre: descr_pre, post: descr_post },
|
||||
@@ -621,7 +621,7 @@ fn emit_must_use_untranslated(
|
||||
.map(|prev| prev.trim_end().ends_with("let _ ="))
|
||||
.unwrap_or(false);
|
||||
let suggestion_span = if is_redundant_let_ignore { *span } else { ancenstor_span };
|
||||
cx.emit_span_lint(
|
||||
cx.emit_span_diag_lint(
|
||||
UNUSED_MUST_USE,
|
||||
ancenstor_span,
|
||||
UnusedDef {
|
||||
|
||||
@@ -4,8 +4,8 @@ warning: creating a mutable reference to mutable static
|
||||
LL | let sfoo: *mut Foo = &mut SFOO;
|
||||
| ^^^^^^^^^ mutable reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: `#[warn(static_mut_refs)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
|
||||
help: use `&raw mut` instead to create a raw pointer
|
||||
|
|
||||
|
||||
@@ -4,8 +4,8 @@ warning: creating a mutable reference to mutable static
|
||||
LL | let ptr = unsafe { &mut BB };
|
||||
| ^^^^^^^ mutable reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: `#[warn(static_mut_refs)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
|
||||
help: use `&raw mut` instead to create a raw pointer
|
||||
|
|
||||
|
||||
@@ -9,8 +9,8 @@ LL | | (Box::new(__static_ref_initialize()));
|
||||
LL | | });
|
||||
| |______________^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: `#[warn(static_mut_refs)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
||||
@@ -4,8 +4,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | let _y = &X;
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: `#[warn(static_mut_refs)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
|
||||
help: use `&raw const` instead to create a raw pointer
|
||||
|
|
||||
@@ -18,8 +18,8 @@ warning: creating a mutable reference to mutable static
|
||||
LL | let _y = &mut X;
|
||||
| ^^^^^^ mutable reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
help: use `&raw mut` instead to create a raw pointer
|
||||
|
|
||||
LL | let _y = &raw mut X;
|
||||
@@ -31,8 +31,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | let ref _a = X;
|
||||
| ^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
|
||||
warning: creating a shared reference to mutable static
|
||||
--> $DIR/static-mut-refs.rs:54:25
|
||||
@@ -40,8 +40,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | let (_b, _c) = (&X, &Y);
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
help: use `&raw const` instead to create a raw pointer
|
||||
|
|
||||
LL | let (_b, _c) = (&raw const X, &Y);
|
||||
@@ -53,8 +53,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | let (_b, _c) = (&X, &Y);
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
help: use `&raw const` instead to create a raw pointer
|
||||
|
|
||||
LL | let (_b, _c) = (&X, &raw const Y);
|
||||
@@ -66,8 +66,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | foo(&X);
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
help: use `&raw const` instead to create a raw pointer
|
||||
|
|
||||
LL | foo(&raw const X);
|
||||
@@ -79,8 +79,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | let _ = Z.len();
|
||||
| ^^^^^^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
|
||||
warning: creating a shared reference to mutable static
|
||||
--> $DIR/static-mut-refs.rs:72:33
|
||||
@@ -88,8 +88,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | let _ = format!("{:?}", Z);
|
||||
| ^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
|
||||
warning: creating a shared reference to mutable static
|
||||
--> $DIR/static-mut-refs.rs:76:18
|
||||
@@ -97,8 +97,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | let _v = &A.value;
|
||||
| ^^^^^^^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
help: use `&raw const` instead to create a raw pointer
|
||||
|
|
||||
LL | let _v = &raw const A.value;
|
||||
@@ -110,8 +110,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | let _s = &A.s.value;
|
||||
| ^^^^^^^^^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
help: use `&raw const` instead to create a raw pointer
|
||||
|
|
||||
LL | let _s = &raw const A.s.value;
|
||||
@@ -123,8 +123,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | let ref _v = A.value;
|
||||
| ^^^^^^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
|
||||
warning: creating a mutable reference to mutable static
|
||||
--> $DIR/static-mut-refs.rs:14:14
|
||||
@@ -135,8 +135,8 @@ LL | &mut ($x.0)
|
||||
LL | let _x = bar!(FOO);
|
||||
| --------- in this macro invocation
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: this warning originates in the macro `bar` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
warning: 12 warnings emitted
|
||||
|
||||
@@ -4,8 +4,8 @@ error: creating a shared reference to mutable static
|
||||
LL | let _y = &X;
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: `#[deny(static_mut_refs)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
|
||||
help: use `&raw const` instead to create a raw pointer
|
||||
|
|
||||
@@ -18,8 +18,8 @@ error: creating a mutable reference to mutable static
|
||||
LL | let _y = &mut X;
|
||||
| ^^^^^^ mutable reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
help: use `&raw mut` instead to create a raw pointer
|
||||
|
|
||||
LL | let _y = &raw mut X;
|
||||
@@ -31,8 +31,8 @@ error: creating a shared reference to mutable static
|
||||
LL | let ref _a = X;
|
||||
| ^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
|
||||
error: creating a shared reference to mutable static
|
||||
--> $DIR/static-mut-refs.rs:54:25
|
||||
@@ -40,8 +40,8 @@ error: creating a shared reference to mutable static
|
||||
LL | let (_b, _c) = (&X, &Y);
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
help: use `&raw const` instead to create a raw pointer
|
||||
|
|
||||
LL | let (_b, _c) = (&raw const X, &Y);
|
||||
@@ -53,8 +53,8 @@ error: creating a shared reference to mutable static
|
||||
LL | let (_b, _c) = (&X, &Y);
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
help: use `&raw const` instead to create a raw pointer
|
||||
|
|
||||
LL | let (_b, _c) = (&X, &raw const Y);
|
||||
@@ -66,8 +66,8 @@ error: creating a shared reference to mutable static
|
||||
LL | foo(&X);
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
help: use `&raw const` instead to create a raw pointer
|
||||
|
|
||||
LL | foo(&raw const X);
|
||||
@@ -79,8 +79,8 @@ error: creating a shared reference to mutable static
|
||||
LL | let _ = Z.len();
|
||||
| ^^^^^^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
|
||||
error: creating a shared reference to mutable static
|
||||
--> $DIR/static-mut-refs.rs:72:33
|
||||
@@ -88,8 +88,8 @@ error: creating a shared reference to mutable static
|
||||
LL | let _ = format!("{:?}", Z);
|
||||
| ^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
|
||||
error: creating a shared reference to mutable static
|
||||
--> $DIR/static-mut-refs.rs:76:18
|
||||
@@ -97,8 +97,8 @@ error: creating a shared reference to mutable static
|
||||
LL | let _v = &A.value;
|
||||
| ^^^^^^^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
help: use `&raw const` instead to create a raw pointer
|
||||
|
|
||||
LL | let _v = &raw const A.value;
|
||||
@@ -110,8 +110,8 @@ error: creating a shared reference to mutable static
|
||||
LL | let _s = &A.s.value;
|
||||
| ^^^^^^^^^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
help: use `&raw const` instead to create a raw pointer
|
||||
|
|
||||
LL | let _s = &raw const A.s.value;
|
||||
@@ -123,8 +123,8 @@ error: creating a shared reference to mutable static
|
||||
LL | let ref _v = A.value;
|
||||
| ^^^^^^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
|
||||
error: creating a mutable reference to mutable static
|
||||
--> $DIR/static-mut-refs.rs:14:14
|
||||
@@ -135,8 +135,8 @@ LL | &mut ($x.0)
|
||||
LL | let _x = bar!(FOO);
|
||||
| --------- in this macro invocation
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: this error originates in the macro `bar` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
@@ -4,8 +4,8 @@ warning: panic message contains a brace
|
||||
LL | panic!("here's a brace: {");
|
||||
| ^
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
= note: this message is not used as a format string, but will be in Rust 2021
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
= note: `#[warn(non_fmt_panics)]` (part of `#[warn(rust_2021_compatibility)]`) on by default
|
||||
help: add a "{}" format string to use the message literally
|
||||
|
|
||||
@@ -18,8 +18,8 @@ warning: panic message contains a brace
|
||||
LL | unreachable!("here's a brace: {");
|
||||
| ^
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
= note: this message is not used as a format string, but will be in Rust 2021
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
help: add a "{}" format string to use the message literally
|
||||
|
|
||||
LL | unreachable!("{}", "here's a brace: {");
|
||||
@@ -31,8 +31,8 @@ warning: panic message contains a brace
|
||||
LL | std::panic!("another one: }");
|
||||
| ^
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
= note: this message is not used as a format string, but will be in Rust 2021
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
help: add a "{}" format string to use the message literally
|
||||
|
|
||||
LL | std::panic!("{}", "another one: }");
|
||||
@@ -44,8 +44,8 @@ warning: panic message contains an unused formatting placeholder
|
||||
LL | core::panic!("Hello {}");
|
||||
| ^^
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
= note: this message is not used as a format string when given without arguments, but will be in Rust 2021
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
help: add the missing argument
|
||||
|
|
||||
LL | core::panic!("Hello {}", ...);
|
||||
@@ -61,8 +61,8 @@ warning: panic message contains unused formatting placeholders
|
||||
LL | assert!(false, "{:03x} {test} bla");
|
||||
| ^^^^^^ ^^^^^^
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
= note: this message is not used as a format string when given without arguments, but will be in Rust 2021
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
help: add the missing arguments
|
||||
|
|
||||
LL | assert!(false, "{:03x} {test} bla", ...);
|
||||
@@ -120,8 +120,8 @@ warning: panic message contains braces
|
||||
LL | debug_assert!(false, "{{}} bla");
|
||||
| ^^^^
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
= note: this message is not used as a format string, but will be in Rust 2021
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
help: add a "{}" format string to use the message literally
|
||||
|
|
||||
LL | debug_assert!(false, "{}", "{{}} bla");
|
||||
@@ -241,8 +241,8 @@ warning: panic message contains an unused formatting placeholder
|
||||
LL | panic!(concat!("{", "}"));
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
= note: this message is not used as a format string when given without arguments, but will be in Rust 2021
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
help: add the missing argument
|
||||
|
|
||||
LL | panic!(concat!("{", "}"), ...);
|
||||
@@ -258,8 +258,8 @@ warning: panic message contains braces
|
||||
LL | panic!(concat!("{", "{"));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
= note: this message is not used as a format string, but will be in Rust 2021
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
help: add a "{}" format string to use the message literally
|
||||
|
|
||||
LL | panic!("{}", concat!("{", "{"));
|
||||
@@ -271,8 +271,8 @@ warning: panic message contains an unused formatting placeholder
|
||||
LL | fancy_panic::fancy_panic!("test {} 123");
|
||||
| ^^
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
= note: this message is not used as a format string when given without arguments, but will be in Rust 2021
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
|
||||
warning: panic message is not a string literal
|
||||
--> $DIR/non-fmt-panic.rs:53:12
|
||||
|
||||
@@ -4,8 +4,8 @@ warning: creating a mutable reference to mutable static
|
||||
LL | S1 { a: unsafe { &mut X1 } }
|
||||
| ^^^^^^^ mutable reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: `#[warn(static_mut_refs)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
|
||||
help: use `&raw mut` instead to create a raw pointer
|
||||
|
|
||||
|
||||
@@ -4,8 +4,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | static n: &'static usize = unsafe { &n_mut };
|
||||
| ^^^^^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: `#[warn(static_mut_refs)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
|
||||
help: use `&raw const` instead to create a raw pointer
|
||||
|
|
||||
|
||||
@@ -4,8 +4,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | let _ = unsafe { (&TEST) as *const usize };
|
||||
| ^^^^^^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: `#[warn(static_mut_refs)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
|
||||
help: use `&raw const` instead to create a raw pointer
|
||||
|
|
||||
@@ -18,8 +18,8 @@ warning: creating a mutable reference to mutable static
|
||||
LL | let _ = unsafe { (&mut TEST) as *const usize };
|
||||
| ^^^^^^^^^^^ mutable reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
help: use `&raw mut` instead to create a raw pointer
|
||||
|
|
||||
LL | let _ = unsafe { (&raw mut TEST) as *const usize };
|
||||
|
||||
@@ -4,8 +4,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | assert_eq!(static_mut_xc::a, 3);
|
||||
| ^^^^^^^^^^^^^^^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: `#[warn(static_mut_refs)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
|
||||
|
||||
warning: creating a shared reference to mutable static
|
||||
@@ -14,8 +14,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | assert_eq!(static_mut_xc::a, 4);
|
||||
| ^^^^^^^^^^^^^^^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
|
||||
warning: creating a shared reference to mutable static
|
||||
--> $DIR/static-mut-xc.rs:25:16
|
||||
@@ -23,8 +23,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | assert_eq!(static_mut_xc::a, 5);
|
||||
| ^^^^^^^^^^^^^^^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
|
||||
warning: creating a shared reference to mutable static
|
||||
--> $DIR/static-mut-xc.rs:28:16
|
||||
@@ -32,8 +32,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | assert_eq!(static_mut_xc::a, 15);
|
||||
| ^^^^^^^^^^^^^^^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
|
||||
warning: creating a shared reference to mutable static
|
||||
--> $DIR/static-mut-xc.rs:31:16
|
||||
@@ -41,8 +41,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | assert_eq!(static_mut_xc::a, -3);
|
||||
| ^^^^^^^^^^^^^^^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
|
||||
warning: creating a shared reference to mutable static
|
||||
--> $DIR/static-mut-xc.rs:33:18
|
||||
@@ -50,8 +50,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | static_bound(&static_mut_xc::a);
|
||||
| ^^^^^^^^^^^^^^^^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
help: use `&raw const` instead to create a raw pointer
|
||||
|
|
||||
LL | static_bound(&raw const static_mut_xc::a);
|
||||
@@ -63,8 +63,8 @@ warning: creating a mutable reference to mutable static
|
||||
LL | static_bound_set(&mut static_mut_xc::a);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ mutable reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
help: use `&raw mut` instead to create a raw pointer
|
||||
|
|
||||
LL | static_bound_set(&raw mut static_mut_xc::a);
|
||||
|
||||
@@ -4,8 +4,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | static mut S: *const u8 = unsafe { &S as *const *const u8 as *const u8 };
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: `#[warn(static_mut_refs)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
|
||||
help: use `&raw const` instead to create a raw pointer
|
||||
|
|
||||
@@ -18,8 +18,8 @@ warning: creating a shared reference to mutable static
|
||||
LL | assert_eq!(S, *(S as *const *const u8));
|
||||
| ^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
|
||||
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html>
|
||||
|
||||
warning: 2 warnings emitted
|
||||
|
||||
|
||||
Reference in New Issue
Block a user