mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 02:03:53 +00:00
Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercote
[perf] Delay the construction of early lint diag structs
Attacks some of the perf regressions from https://github.com/rust-lang/rust/pull/124417#issuecomment-2123700666.
See individual commits for details. The first three commits are not strictly necessary.
However, the 2nd one (06bc4fc671
, *Remove `LintDiagnostic::msg`*) makes the main change way nicer to implement.
It's also pretty sweet on its own if I may say so myself.
This commit is contained in:
commit
b582f807fa
@ -576,8 +576,8 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
|||||||
lint::builtin::INLINE_NO_SANITIZE,
|
lint::builtin::INLINE_NO_SANITIZE,
|
||||||
hir_id,
|
hir_id,
|
||||||
no_sanitize_span,
|
no_sanitize_span,
|
||||||
"`no_sanitize` will have no effect after inlining",
|
|
||||||
|lint| {
|
|lint| {
|
||||||
|
lint.primary_message("`no_sanitize` will have no effect after inlining");
|
||||||
lint.span_note(inline_span, "inlining requested here");
|
lint.span_note(inline_span, "inlining requested here");
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -364,17 +364,6 @@ impl From<Cow<'static, str>> for DiagMessage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A workaround for must_produce_diag ICEs when formatting types in disabled lints.
|
|
||||||
///
|
|
||||||
/// Delays formatting until `.into(): DiagMessage` is used.
|
|
||||||
pub struct DelayDm<F>(pub F);
|
|
||||||
|
|
||||||
impl<F: FnOnce() -> String> From<DelayDm<F>> for DiagMessage {
|
|
||||||
fn from(DelayDm(f): DelayDm<F>) -> Self {
|
|
||||||
DiagMessage::from(f())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Translating *into* a subdiagnostic message from a diagnostic message is a little strange - but
|
/// Translating *into* a subdiagnostic message from a diagnostic message is a little strange - but
|
||||||
/// the subdiagnostic functions (e.g. `span_label`) take a `SubdiagMessage` and the
|
/// the subdiagnostic functions (e.g. `span_label`) take a `SubdiagMessage` and the
|
||||||
/// subdiagnostic derive refers to typed identifiers that are `DiagMessage`s, so need to be
|
/// subdiagnostic derive refers to typed identifiers that are `DiagMessage`s, so need to be
|
||||||
|
@ -200,8 +200,6 @@ pub trait SubdiagMessageOp<G: EmissionGuarantee> =
|
|||||||
pub trait LintDiagnostic<'a, G: EmissionGuarantee> {
|
pub trait LintDiagnostic<'a, G: EmissionGuarantee> {
|
||||||
/// Decorate and emit a lint.
|
/// Decorate and emit a lint.
|
||||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>);
|
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>);
|
||||||
|
|
||||||
fn msg(&self) -> DiagMessage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Encodable, Decodable)]
|
#[derive(Clone, Debug, Encodable, Decodable)]
|
||||||
|
@ -39,7 +39,7 @@ pub use diagnostic_impls::{
|
|||||||
};
|
};
|
||||||
pub use emitter::ColorConfig;
|
pub use emitter::ColorConfig;
|
||||||
pub use rustc_error_messages::{
|
pub use rustc_error_messages::{
|
||||||
fallback_fluent_bundle, fluent_bundle, DelayDm, DiagMessage, FluentBundle, LanguageIdentifier,
|
fallback_fluent_bundle, fluent_bundle, DiagMessage, FluentBundle, LanguageIdentifier,
|
||||||
LazyFallbackBundle, MultiSpan, SpanLabel, SubdiagMessage,
|
LazyFallbackBundle, MultiSpan, SpanLabel, SubdiagMessage,
|
||||||
};
|
};
|
||||||
pub use rustc_lint_defs::{pluralize, Applicability};
|
pub use rustc_lint_defs::{pluralize, Applicability};
|
||||||
@ -572,8 +572,8 @@ impl Drop for DiagCtxtInner {
|
|||||||
if let Some(backtrace) = &self.must_produce_diag {
|
if let Some(backtrace) = &self.must_produce_diag {
|
||||||
panic!(
|
panic!(
|
||||||
"must_produce_diag: `trimmed_def_paths` called but no diagnostics emitted; \
|
"must_produce_diag: `trimmed_def_paths` called but no diagnostics emitted; \
|
||||||
use `DelayDm` for lints or `with_no_trimmed_paths` for debugging. \
|
`with_no_trimmed_paths` for debugging. \
|
||||||
called at: {backtrace}"
|
called at: {backtrace}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,13 +46,9 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) {
|
|||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
tcx.node_span_lint(
|
tcx.node_span_lint(UNSUPPORTED_CALLING_CONVENTIONS, hir_id, span, |lint| {
|
||||||
UNSUPPORTED_CALLING_CONVENTIONS,
|
lint.primary_message("use of calling convention not supported on this target");
|
||||||
hir_id,
|
});
|
||||||
span,
|
|
||||||
"use of calling convention not supported on this target",
|
|
||||||
|_| {},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,8 +239,8 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||||||
UNINHABITED_STATIC,
|
UNINHABITED_STATIC,
|
||||||
tcx.local_def_id_to_hir_id(def_id),
|
tcx.local_def_id_to_hir_id(def_id),
|
||||||
span,
|
span,
|
||||||
"static of uninhabited type",
|
|
||||||
|lint| {
|
|lint| {
|
||||||
|
lint.primary_message("static of uninhabited type");
|
||||||
lint
|
lint
|
||||||
.note("uninhabited statics cannot be initialized, and any access would be an immediate error");
|
.note("uninhabited statics cannot be initialized, and any access would be an immediate error");
|
||||||
},
|
},
|
||||||
@ -1310,9 +1306,11 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>)
|
|||||||
REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS,
|
REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS,
|
||||||
tcx.local_def_id_to_hir_id(adt.did().expect_local()),
|
tcx.local_def_id_to_hir_id(adt.did().expect_local()),
|
||||||
span,
|
span,
|
||||||
"zero-sized fields in `repr(transparent)` cannot \
|
|
||||||
contain external non-exhaustive types",
|
|
||||||
|lint| {
|
|lint| {
|
||||||
|
lint.primary_message(
|
||||||
|
"zero-sized fields in `repr(transparent)` cannot \
|
||||||
|
contain external non-exhaustive types",
|
||||||
|
);
|
||||||
let note = if non_exhaustive {
|
let note = if non_exhaustive {
|
||||||
"is marked with `#[non_exhaustive]`"
|
"is marked with `#[non_exhaustive]`"
|
||||||
} else {
|
} else {
|
||||||
|
@ -281,8 +281,8 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||||||
lint::builtin::ASM_SUB_REGISTER,
|
lint::builtin::ASM_SUB_REGISTER,
|
||||||
expr.hir_id,
|
expr.hir_id,
|
||||||
spans,
|
spans,
|
||||||
"formatting may not be suitable for sub-register argument",
|
|
||||||
|lint| {
|
|lint| {
|
||||||
|
lint.primary_message("formatting may not be suitable for sub-register argument");
|
||||||
lint.span_label(expr.span, "for this argument");
|
lint.span_label(expr.span, "for this argument");
|
||||||
lint.help(format!(
|
lint.help(format!(
|
||||||
"use `{{{idx}:{suggested_modifier}}}` to have the register formatted as `{suggested_result}` (for {suggested_size}-bit values)",
|
"use `{{{idx}:{suggested_modifier}}}` to have the register formatted as `{suggested_result}` (for {suggested_size}-bit values)",
|
||||||
|
@ -35,11 +35,12 @@ fn check_unused_traits(tcx: TyCtxt<'_>, (): ()) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let (path, _) = item.expect_use();
|
let (path, _) = item.expect_use();
|
||||||
let msg = if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(path.span) {
|
tcx.node_span_lint(lint::builtin::UNUSED_IMPORTS, item.hir_id(), path.span, |lint| {
|
||||||
format!("unused import: `{snippet}`")
|
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(path.span) {
|
||||||
} else {
|
lint.primary_message(format!("unused import: `{snippet}`"));
|
||||||
"unused import".to_owned()
|
} else {
|
||||||
};
|
lint.primary_message("unused import");
|
||||||
tcx.node_span_lint(lint::builtin::UNUSED_IMPORTS, item.hir_id(), path.span, msg, |_| {});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,8 +317,9 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
|
|||||||
lint::builtin::INVALID_TYPE_PARAM_DEFAULT,
|
lint::builtin::INVALID_TYPE_PARAM_DEFAULT,
|
||||||
param.hir_id,
|
param.hir_id,
|
||||||
param.span,
|
param.span,
|
||||||
TYPE_DEFAULT_NOT_ALLOWED,
|
|lint| {
|
||||||
|_| {},
|
lint.primary_message(TYPE_DEFAULT_NOT_ALLOWED);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Defaults::Deny => {
|
Defaults::Deny => {
|
||||||
|
@ -646,8 +646,9 @@ pub(crate) fn prohibit_explicit_late_bound_lifetimes(
|
|||||||
LATE_BOUND_LIFETIME_ARGUMENTS,
|
LATE_BOUND_LIFETIME_ARGUMENTS,
|
||||||
args.args[0].hir_id(),
|
args.args[0].hir_id(),
|
||||||
multispan,
|
multispan,
|
||||||
msg,
|
|lint| {
|
||||||
|_| {},
|
lint.primary_message(msg);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||||||
self.maybe_suggest_assoc_ty_bound(self_ty, &mut diag);
|
self.maybe_suggest_assoc_ty_bound(self_ty, &mut diag);
|
||||||
diag.stash(self_ty.span, StashKey::TraitMissingMethod);
|
diag.stash(self_ty.span, StashKey::TraitMissingMethod);
|
||||||
} else {
|
} else {
|
||||||
let msg = "trait objects without an explicit `dyn` are deprecated";
|
tcx.node_span_lint(BARE_TRAIT_OBJECTS, self_ty.hir_id, self_ty.span, |lint| {
|
||||||
tcx.node_span_lint(BARE_TRAIT_OBJECTS, self_ty.hir_id, self_ty.span, msg, |lint| {
|
lint.primary_message("trait objects without an explicit `dyn` are deprecated");
|
||||||
if self_ty.span.can_be_used_for_suggestions() {
|
if self_ty.span.can_be_used_for_suggestions() {
|
||||||
lint.multipart_suggestion_verbose(
|
lint.multipart_suggestion_verbose(
|
||||||
"if this is an object-safe trait, use `dyn`",
|
"if this is an object-safe trait, use `dyn`",
|
||||||
|
@ -1165,33 +1165,28 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||||||
let ty = self.lower_assoc_ty(span, assoc_ty_did, assoc_segment, bound);
|
let ty = self.lower_assoc_ty(span, assoc_ty_did, assoc_segment, bound);
|
||||||
|
|
||||||
if let Some(variant_def_id) = variant_resolution {
|
if let Some(variant_def_id) = variant_resolution {
|
||||||
tcx.node_span_lint(
|
tcx.node_span_lint(AMBIGUOUS_ASSOCIATED_ITEMS, hir_ref_id, span, |lint| {
|
||||||
AMBIGUOUS_ASSOCIATED_ITEMS,
|
lint.primary_message("ambiguous associated item");
|
||||||
hir_ref_id,
|
let mut could_refer_to = |kind: DefKind, def_id, also| {
|
||||||
span,
|
let note_msg = format!(
|
||||||
"ambiguous associated item",
|
"`{}` could{} refer to the {} defined here",
|
||||||
|lint| {
|
assoc_ident,
|
||||||
let mut could_refer_to = |kind: DefKind, def_id, also| {
|
also,
|
||||||
let note_msg = format!(
|
tcx.def_kind_descr(kind, def_id)
|
||||||
"`{}` could{} refer to the {} defined here",
|
|
||||||
assoc_ident,
|
|
||||||
also,
|
|
||||||
tcx.def_kind_descr(kind, def_id)
|
|
||||||
);
|
|
||||||
lint.span_note(tcx.def_span(def_id), note_msg);
|
|
||||||
};
|
|
||||||
|
|
||||||
could_refer_to(DefKind::Variant, variant_def_id, "");
|
|
||||||
could_refer_to(DefKind::AssocTy, assoc_ty_did, " also");
|
|
||||||
|
|
||||||
lint.span_suggestion(
|
|
||||||
span,
|
|
||||||
"use fully-qualified syntax",
|
|
||||||
format!("<{} as {}>::{}", qself_ty, tcx.item_name(trait_did), assoc_ident),
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
);
|
);
|
||||||
},
|
lint.span_note(tcx.def_span(def_id), note_msg);
|
||||||
);
|
};
|
||||||
|
|
||||||
|
could_refer_to(DefKind::Variant, variant_def_id, "");
|
||||||
|
could_refer_to(DefKind::AssocTy, assoc_ty_did, " also");
|
||||||
|
|
||||||
|
lint.span_suggestion(
|
||||||
|
span,
|
||||||
|
"use fully-qualified syntax",
|
||||||
|
format!("<{} as {}>::{}", qself_ty, tcx.item_name(trait_did), assoc_ident),
|
||||||
|
Applicability::MachineApplicable,
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
Ok((ty, DefKind::AssocTy, assoc_ty_did))
|
Ok((ty, DefKind::AssocTy, assoc_ty_did))
|
||||||
}
|
}
|
||||||
|
@ -64,19 +64,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
debug!("warn_if_unreachable: id={:?} span={:?} kind={}", id, span, kind);
|
debug!("warn_if_unreachable: id={:?} span={:?} kind={}", id, span, kind);
|
||||||
|
|
||||||
let msg = format!("unreachable {kind}");
|
let msg = format!("unreachable {kind}");
|
||||||
self.tcx().node_span_lint(
|
self.tcx().node_span_lint(lint::builtin::UNREACHABLE_CODE, id, span, |lint| {
|
||||||
lint::builtin::UNREACHABLE_CODE,
|
lint.primary_message(msg.clone());
|
||||||
id,
|
lint.span_label(span, msg).span_label(
|
||||||
span,
|
orig_span,
|
||||||
msg.clone(),
|
custom_note.unwrap_or("any code following this expression is unreachable"),
|
||||||
|lint| {
|
);
|
||||||
lint.span_label(span, msg).span_label(
|
})
|
||||||
orig_span,
|
|
||||||
custom_note
|
|
||||||
.unwrap_or("any code following this expression is unreachable"),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,11 +91,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
prelude_or_array_lint,
|
prelude_or_array_lint,
|
||||||
self_expr.hir_id,
|
self_expr.hir_id,
|
||||||
self_expr.span,
|
self_expr.span,
|
||||||
format!(
|
|
||||||
"trait method `{}` will become ambiguous in Rust {edition}",
|
|
||||||
segment.ident.name
|
|
||||||
),
|
|
||||||
|lint| {
|
|lint| {
|
||||||
|
lint.primary_message(format!(
|
||||||
|
"trait method `{}` will become ambiguous in Rust {edition}",
|
||||||
|
segment.ident.name
|
||||||
|
));
|
||||||
|
|
||||||
let sp = self_expr.span;
|
let sp = self_expr.span;
|
||||||
|
|
||||||
let derefs = "*".repeat(pick.autoderefs);
|
let derefs = "*".repeat(pick.autoderefs);
|
||||||
@ -144,11 +145,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
prelude_or_array_lint,
|
prelude_or_array_lint,
|
||||||
call_expr.hir_id,
|
call_expr.hir_id,
|
||||||
call_expr.span,
|
call_expr.span,
|
||||||
format!(
|
|
||||||
"trait method `{}` will become ambiguous in Rust {edition}",
|
|
||||||
segment.ident.name
|
|
||||||
),
|
|
||||||
|lint| {
|
|lint| {
|
||||||
|
lint.primary_message(format!(
|
||||||
|
"trait method `{}` will become ambiguous in Rust {edition}",
|
||||||
|
segment.ident.name
|
||||||
|
));
|
||||||
|
|
||||||
let sp = call_expr.span;
|
let sp = call_expr.span;
|
||||||
let trait_name = self.trait_path_or_bare_name(
|
let trait_name = self.trait_path_or_bare_name(
|
||||||
span,
|
span,
|
||||||
@ -251,73 +253,67 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.tcx.node_span_lint(
|
self.tcx.node_span_lint(RUST_2021_PRELUDE_COLLISIONS, expr_id, span, |lint| {
|
||||||
RUST_2021_PRELUDE_COLLISIONS,
|
lint.primary_message(format!(
|
||||||
expr_id,
|
|
||||||
span,
|
|
||||||
format!(
|
|
||||||
"trait-associated function `{}` will become ambiguous in Rust 2021",
|
"trait-associated function `{}` will become ambiguous in Rust 2021",
|
||||||
method_name.name
|
method_name.name
|
||||||
),
|
));
|
||||||
|lint| {
|
|
||||||
// "type" refers to either a type or, more likely, a trait from which
|
|
||||||
// the associated function or method is from.
|
|
||||||
let container_id = pick.item.container_id(self.tcx);
|
|
||||||
let trait_path = self.trait_path_or_bare_name(span, expr_id, container_id);
|
|
||||||
let trait_generics = self.tcx.generics_of(container_id);
|
|
||||||
|
|
||||||
let trait_name =
|
// "type" refers to either a type or, more likely, a trait from which
|
||||||
if trait_generics.own_params.len() <= trait_generics.has_self as usize {
|
// the associated function or method is from.
|
||||||
trait_path
|
let container_id = pick.item.container_id(self.tcx);
|
||||||
} else {
|
let trait_path = self.trait_path_or_bare_name(span, expr_id, container_id);
|
||||||
let counts = trait_generics.own_counts();
|
let trait_generics = self.tcx.generics_of(container_id);
|
||||||
format!(
|
|
||||||
"{}<{}>",
|
let trait_name =
|
||||||
trait_path,
|
if trait_generics.own_params.len() <= trait_generics.has_self as usize {
|
||||||
|
trait_path
|
||||||
|
} else {
|
||||||
|
let counts = trait_generics.own_counts();
|
||||||
|
format!(
|
||||||
|
"{}<{}>",
|
||||||
|
trait_path,
|
||||||
|
std::iter::repeat("'_")
|
||||||
|
.take(counts.lifetimes)
|
||||||
|
.chain(std::iter::repeat("_").take(
|
||||||
|
counts.types + counts.consts - trait_generics.has_self as usize
|
||||||
|
))
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join(", ")
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut self_ty_name = self_ty_span
|
||||||
|
.find_ancestor_inside(span)
|
||||||
|
.and_then(|span| self.sess().source_map().span_to_snippet(span).ok())
|
||||||
|
.unwrap_or_else(|| self_ty.to_string());
|
||||||
|
|
||||||
|
// Get the number of generics the self type has (if an Adt) unless we can determine that
|
||||||
|
// the user has written the self type with generics already which we (naively) do by looking
|
||||||
|
// for a "<" in `self_ty_name`.
|
||||||
|
if !self_ty_name.contains('<') {
|
||||||
|
if let ty::Adt(def, _) = self_ty.kind() {
|
||||||
|
let generics = self.tcx.generics_of(def.did());
|
||||||
|
if !generics.is_own_empty() {
|
||||||
|
let counts = generics.own_counts();
|
||||||
|
self_ty_name += &format!(
|
||||||
|
"<{}>",
|
||||||
std::iter::repeat("'_")
|
std::iter::repeat("'_")
|
||||||
.take(counts.lifetimes)
|
.take(counts.lifetimes)
|
||||||
.chain(std::iter::repeat("_").take(
|
.chain(std::iter::repeat("_").take(counts.types + counts.consts))
|
||||||
counts.types + counts.consts - trait_generics.has_self as usize
|
|
||||||
))
|
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(", ")
|
.join(", ")
|
||||||
)
|
);
|
||||||
};
|
|
||||||
|
|
||||||
let mut self_ty_name = self_ty_span
|
|
||||||
.find_ancestor_inside(span)
|
|
||||||
.and_then(|span| self.sess().source_map().span_to_snippet(span).ok())
|
|
||||||
.unwrap_or_else(|| self_ty.to_string());
|
|
||||||
|
|
||||||
// Get the number of generics the self type has (if an Adt) unless we can determine that
|
|
||||||
// the user has written the self type with generics already which we (naively) do by looking
|
|
||||||
// for a "<" in `self_ty_name`.
|
|
||||||
if !self_ty_name.contains('<') {
|
|
||||||
if let ty::Adt(def, _) = self_ty.kind() {
|
|
||||||
let generics = self.tcx.generics_of(def.did());
|
|
||||||
if !generics.is_own_empty() {
|
|
||||||
let counts = generics.own_counts();
|
|
||||||
self_ty_name += &format!(
|
|
||||||
"<{}>",
|
|
||||||
std::iter::repeat("'_")
|
|
||||||
.take(counts.lifetimes)
|
|
||||||
.chain(
|
|
||||||
std::iter::repeat("_").take(counts.types + counts.consts)
|
|
||||||
)
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.join(", ")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lint.span_suggestion(
|
}
|
||||||
span,
|
lint.span_suggestion(
|
||||||
"disambiguate the associated function",
|
span,
|
||||||
format!("<{} as {}>::{}", self_ty_name, trait_name, method_name.name,),
|
"disambiguate the associated function",
|
||||||
Applicability::MachineApplicable,
|
format!("<{} as {}>::{}", self_ty_name, trait_name, method_name.name,),
|
||||||
);
|
Applicability::MachineApplicable,
|
||||||
},
|
);
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn trait_path_or_bare_name(
|
fn trait_path_or_bare_name(
|
||||||
|
@ -415,8 +415,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
lint::builtin::TYVAR_BEHIND_RAW_POINTER,
|
lint::builtin::TYVAR_BEHIND_RAW_POINTER,
|
||||||
scope_expr_id,
|
scope_expr_id,
|
||||||
span,
|
span,
|
||||||
"type annotations needed",
|
|lint| {
|
||||||
|_| {},
|
lint.primary_message("type annotations needed");
|
||||||
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Ended up encountering a type variable when doing autoderef,
|
// Ended up encountering a type variable when doing autoderef,
|
||||||
@ -1286,53 +1287,49 @@ impl<'tcx> Pick<'tcx> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let def_kind = self.item.kind.as_def_kind();
|
let def_kind = self.item.kind.as_def_kind();
|
||||||
tcx.node_span_lint(
|
tcx.node_span_lint(lint::builtin::UNSTABLE_NAME_COLLISIONS, scope_expr_id, span, |lint| {
|
||||||
lint::builtin::UNSTABLE_NAME_COLLISIONS,
|
lint.primary_message(format!(
|
||||||
scope_expr_id,
|
|
||||||
span,
|
|
||||||
format!(
|
|
||||||
"{} {} with this name may be added to the standard library in the future",
|
"{} {} with this name may be added to the standard library in the future",
|
||||||
tcx.def_kind_descr_article(def_kind, self.item.def_id),
|
tcx.def_kind_descr_article(def_kind, self.item.def_id),
|
||||||
tcx.def_kind_descr(def_kind, self.item.def_id),
|
tcx.def_kind_descr(def_kind, self.item.def_id),
|
||||||
),
|
));
|
||||||
|lint| {
|
|
||||||
match (self.item.kind, self.item.container) {
|
match (self.item.kind, self.item.container) {
|
||||||
(ty::AssocKind::Fn, _) => {
|
(ty::AssocKind::Fn, _) => {
|
||||||
// FIXME: This should be a `span_suggestion` instead of `help`
|
// FIXME: This should be a `span_suggestion` instead of `help`
|
||||||
// However `self.span` only
|
// However `self.span` only
|
||||||
// highlights the method name, so we can't use it. Also consider reusing
|
// highlights the method name, so we can't use it. Also consider reusing
|
||||||
// the code from `report_method_error()`.
|
// the code from `report_method_error()`.
|
||||||
lint.help(format!(
|
lint.help(format!(
|
||||||
"call with fully qualified syntax `{}(...)` to keep using the current \
|
"call with fully qualified syntax `{}(...)` to keep using the current \
|
||||||
method",
|
method",
|
||||||
tcx.def_path_str(self.item.def_id),
|
tcx.def_path_str(self.item.def_id),
|
||||||
));
|
));
|
||||||
}
|
|
||||||
(ty::AssocKind::Const, ty::AssocItemContainer::TraitContainer) => {
|
|
||||||
let def_id = self.item.container_id(tcx);
|
|
||||||
lint.span_suggestion(
|
|
||||||
span,
|
|
||||||
"use the fully qualified path to the associated const",
|
|
||||||
format!(
|
|
||||||
"<{} as {}>::{}",
|
|
||||||
self.self_ty,
|
|
||||||
tcx.def_path_str(def_id),
|
|
||||||
self.item.name
|
|
||||||
),
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
tcx.disabled_nightly_features(
|
(ty::AssocKind::Const, ty::AssocItemContainer::TraitContainer) => {
|
||||||
lint,
|
let def_id = self.item.container_id(tcx);
|
||||||
Some(scope_expr_id),
|
lint.span_suggestion(
|
||||||
self.unstable_candidates.iter().map(|(candidate, feature)| {
|
span,
|
||||||
(format!(" `{}`", tcx.def_path_str(candidate.item.def_id)), *feature)
|
"use the fully qualified path to the associated const",
|
||||||
}),
|
format!(
|
||||||
);
|
"<{} as {}>::{}",
|
||||||
},
|
self.self_ty,
|
||||||
);
|
tcx.def_path_str(def_id),
|
||||||
|
self.item.name
|
||||||
|
),
|
||||||
|
Applicability::MachineApplicable,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
tcx.disabled_nightly_features(
|
||||||
|
lint,
|
||||||
|
Some(scope_expr_id),
|
||||||
|
self.unstable_candidates.iter().map(|(candidate, feature)| {
|
||||||
|
(format!(" `{}`", tcx.def_path_str(candidate.item.def_id)), *feature)
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1950,15 +1950,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
&unmentioned_fields.iter().map(|(_, i)| i).collect::<Vec<_>>(),
|
&unmentioned_fields.iter().map(|(_, i)| i).collect::<Vec<_>>(),
|
||||||
);
|
);
|
||||||
|
|
||||||
self.tcx.node_span_lint(NON_EXHAUSTIVE_OMITTED_PATTERNS, pat.hir_id, pat.span, "some fields are not explicitly listed", |lint| {
|
self.tcx.node_span_lint(NON_EXHAUSTIVE_OMITTED_PATTERNS, pat.hir_id, pat.span, |lint| {
|
||||||
lint.span_label(pat.span, format!("field{} {} not listed", rustc_errors::pluralize!(unmentioned_fields.len()), joined_patterns));
|
lint.primary_message("some fields are not explicitly listed");
|
||||||
lint.help(
|
lint.span_label(pat.span, format!("field{} {} not listed", rustc_errors::pluralize!(unmentioned_fields.len()), joined_patterns));
|
||||||
"ensure that all fields are mentioned explicitly by adding the suggested fields",
|
lint.help(
|
||||||
);
|
"ensure that all fields are mentioned explicitly by adding the suggested fields",
|
||||||
lint.note(format!(
|
);
|
||||||
"the pattern is of type `{ty}` and the `non_exhaustive_omitted_patterns` attribute was found",
|
lint.note(format!(
|
||||||
));
|
"the pattern is of type `{ty}` and the `non_exhaustive_omitted_patterns` attribute was found",
|
||||||
});
|
));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a diagnostic reporting a struct pattern which does not mention some fields.
|
/// Returns a diagnostic reporting a struct pattern which does not mention some fields.
|
||||||
|
@ -955,8 +955,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
|
lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
|
||||||
closure_hir_id,
|
closure_hir_id,
|
||||||
closure_head_span,
|
closure_head_span,
|
||||||
reasons.migration_message(),
|
|
||||||
|lint| {
|
|lint| {
|
||||||
|
lint.primary_message(reasons.migration_message());
|
||||||
|
|
||||||
for NeededMigration { var_hir_id, diagnostics_info } in &need_migrations {
|
for NeededMigration { var_hir_id, diagnostics_info } in &need_migrations {
|
||||||
// Labels all the usage of the captured variable and why they are responsible
|
// Labels all the usage of the captured variable and why they are responsible
|
||||||
// for migration being needed
|
// for migration being needed
|
||||||
|
@ -21,7 +21,7 @@ use crate::passes::{EarlyLintPassObject, LateLintPassObject};
|
|||||||
use rustc_data_structures::fx::FxIndexMap;
|
use rustc_data_structures::fx::FxIndexMap;
|
||||||
use rustc_data_structures::sync;
|
use rustc_data_structures::sync;
|
||||||
use rustc_data_structures::unord::UnordMap;
|
use rustc_data_structures::unord::UnordMap;
|
||||||
use rustc_errors::{Diag, DiagMessage, LintDiagnostic, MultiSpan};
|
use rustc_errors::{Diag, LintDiagnostic, MultiSpan};
|
||||||
use rustc_feature::Features;
|
use rustc_feature::Features;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::Res;
|
use rustc_hir::def::Res;
|
||||||
@ -539,7 +539,9 @@ impl EarlyContext<'_> {
|
|||||||
span: MultiSpan,
|
span: MultiSpan,
|
||||||
diagnostic: BuiltinLintDiag,
|
diagnostic: BuiltinLintDiag,
|
||||||
) {
|
) {
|
||||||
diagnostics::emit_buffered_lint(self, lint, span, diagnostic)
|
self.opt_span_lint(lint, Some(span), |diag| {
|
||||||
|
diagnostics::decorate_lint(self.sess(), diagnostic, diag);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,7 +558,6 @@ pub trait LintContext {
|
|||||||
&self,
|
&self,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
span: Option<S>,
|
span: Option<S>,
|
||||||
msg: impl Into<DiagMessage>,
|
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -568,8 +569,8 @@ pub trait LintContext {
|
|||||||
span: S,
|
span: S,
|
||||||
decorator: impl for<'a> LintDiagnostic<'a, ()>,
|
decorator: impl for<'a> LintDiagnostic<'a, ()>,
|
||||||
) {
|
) {
|
||||||
self.opt_span_lint(lint, Some(span), decorator.msg(), |diag| {
|
self.opt_span_lint(lint, Some(span), |lint| {
|
||||||
decorator.decorate_lint(diag);
|
decorator.decorate_lint(lint);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -581,17 +582,16 @@ pub trait LintContext {
|
|||||||
&self,
|
&self,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
span: S,
|
span: S,
|
||||||
msg: impl Into<DiagMessage>,
|
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
self.opt_span_lint(lint, Some(span), msg, decorate);
|
self.opt_span_lint(lint, Some(span), decorate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Emit a lint from a lint struct (some type that implements `LintDiagnostic`, typically
|
/// Emit a lint from a lint struct (some type that implements `LintDiagnostic`, typically
|
||||||
/// generated by `#[derive(LintDiagnostic)]`).
|
/// generated by `#[derive(LintDiagnostic)]`).
|
||||||
fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> LintDiagnostic<'a, ()>) {
|
fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> LintDiagnostic<'a, ()>) {
|
||||||
self.opt_span_lint(lint, None as Option<Span>, decorator.msg(), |diag| {
|
self.opt_span_lint(lint, None as Option<Span>, |lint| {
|
||||||
decorator.decorate_lint(diag);
|
decorator.decorate_lint(lint);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -599,13 +599,8 @@ pub trait LintContext {
|
|||||||
///
|
///
|
||||||
/// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature
|
/// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
fn lint(
|
fn lint(&self, lint: &'static Lint, decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>)) {
|
||||||
&self,
|
self.opt_span_lint(lint, None as Option<Span>, decorate);
|
||||||
lint: &'static Lint,
|
|
||||||
msg: impl Into<DiagMessage>,
|
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
|
||||||
) {
|
|
||||||
self.opt_span_lint(lint, None as Option<Span>, msg, decorate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This returns the lint level for the given lint at the current location.
|
/// This returns the lint level for the given lint at the current location.
|
||||||
@ -668,14 +663,13 @@ impl<'tcx> LintContext for LateContext<'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
span: Option<S>,
|
span: Option<S>,
|
||||||
msg: impl Into<DiagMessage>,
|
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
let hir_id = self.last_node_with_lint_attrs;
|
let hir_id = self.last_node_with_lint_attrs;
|
||||||
|
|
||||||
match span {
|
match span {
|
||||||
Some(s) => self.tcx.node_span_lint(lint, hir_id, s, msg, decorate),
|
Some(s) => self.tcx.node_span_lint(lint, hir_id, s, decorate),
|
||||||
None => self.tcx.node_lint(lint, hir_id, msg, decorate),
|
None => self.tcx.node_lint(lint, hir_id, decorate),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -695,10 +689,9 @@ impl LintContext for EarlyContext<'_> {
|
|||||||
&self,
|
&self,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
span: Option<S>,
|
span: Option<S>,
|
||||||
msg: impl Into<DiagMessage>,
|
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
self.builder.opt_span_lint(lint, span.map(|s| s.into()), msg, decorate)
|
self.builder.opt_span_lint(lint, span.map(|s| s.into()), decorate)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_lint_level(&self, lint: &'static Lint) -> Level {
|
fn get_lint_level(&self, lint: &'static Lint) -> Level {
|
||||||
|
@ -4,24 +4,19 @@
|
|||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use rustc_ast::util::unicode::TEXT_FLOW_CONTROL_CHARS;
|
use rustc_ast::util::unicode::TEXT_FLOW_CONTROL_CHARS;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::elided_lifetime_in_path_suggestion;
|
||||||
use rustc_errors::{elided_lifetime_in_path_suggestion, DiagArgValue, MultiSpan};
|
use rustc_errors::{Applicability, Diag, DiagArgValue, LintDiagnostic};
|
||||||
use rustc_middle::middle::stability;
|
use rustc_middle::middle::stability;
|
||||||
use rustc_session::lint::{BuiltinLintDiag, Lint};
|
use rustc_session::lint::BuiltinLintDiag;
|
||||||
|
use rustc_session::Session;
|
||||||
use rustc_span::BytePos;
|
use rustc_span::BytePos;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
use crate::{lints, EarlyContext, LintContext as _};
|
use crate::lints;
|
||||||
|
|
||||||
mod check_cfg;
|
mod check_cfg;
|
||||||
|
|
||||||
pub(super) fn emit_buffered_lint(
|
pub(super) fn decorate_lint(sess: &Session, diagnostic: BuiltinLintDiag, diag: &mut Diag<'_, ()>) {
|
||||||
ctx: &EarlyContext<'_>,
|
|
||||||
lint: &'static Lint,
|
|
||||||
span: MultiSpan,
|
|
||||||
diagnostic: BuiltinLintDiag,
|
|
||||||
) {
|
|
||||||
let sess = ctx.sess();
|
|
||||||
match diagnostic {
|
match diagnostic {
|
||||||
BuiltinLintDiag::UnicodeTextFlow(comment_span, content) => {
|
BuiltinLintDiag::UnicodeTextFlow(comment_span, content) => {
|
||||||
let spans: Vec<_> = content
|
let spans: Vec<_> = content
|
||||||
@ -40,16 +35,14 @@ pub(super) fn emit_buffered_lint(
|
|||||||
let suggestions = (!spans.is_empty()).then_some(lints::UnicodeTextFlowSuggestion {
|
let suggestions = (!spans.is_empty()).then_some(lints::UnicodeTextFlowSuggestion {
|
||||||
spans: spans.iter().map(|(_c, span)| *span).collect(),
|
spans: spans.iter().map(|(_c, span)| *span).collect(),
|
||||||
});
|
});
|
||||||
ctx.emit_span_lint(
|
|
||||||
lint,
|
lints::UnicodeTextFlow {
|
||||||
span,
|
comment_span,
|
||||||
lints::UnicodeTextFlow {
|
characters,
|
||||||
comment_span,
|
suggestions,
|
||||||
characters,
|
num_codepoints: spans.len(),
|
||||||
suggestions,
|
}
|
||||||
num_codepoints: spans.len(),
|
.decorate_lint(diag);
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::AbsPathWithModule(mod_span) => {
|
BuiltinLintDiag::AbsPathWithModule(mod_span) => {
|
||||||
let (replacement, applicability) = match sess.source_map().span_to_snippet(mod_span) {
|
let (replacement, applicability) = match sess.source_map().span_to_snippet(mod_span) {
|
||||||
@ -62,48 +55,35 @@ pub(super) fn emit_buffered_lint(
|
|||||||
}
|
}
|
||||||
Err(_) => ("crate::<path>".to_string(), Applicability::HasPlaceholders),
|
Err(_) => ("crate::<path>".to_string(), Applicability::HasPlaceholders),
|
||||||
};
|
};
|
||||||
ctx.emit_span_lint(
|
lints::AbsPathWithModule {
|
||||||
lint,
|
sugg: lints::AbsPathWithModuleSugg { span: mod_span, applicability, replacement },
|
||||||
span,
|
}
|
||||||
lints::AbsPathWithModule {
|
.decorate_lint(diag);
|
||||||
sugg: lints::AbsPathWithModuleSugg {
|
|
||||||
span: mod_span,
|
|
||||||
applicability,
|
|
||||||
replacement,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::ProcMacroDeriveResolutionFallback { span: macro_span, ns, ident } => ctx
|
BuiltinLintDiag::ProcMacroDeriveResolutionFallback { span: macro_span, ns, ident } => {
|
||||||
.emit_span_lint(
|
lints::ProcMacroDeriveResolutionFallback { span: macro_span, ns, ident }
|
||||||
lint,
|
.decorate_lint(diag)
|
||||||
span,
|
}
|
||||||
lints::ProcMacroDeriveResolutionFallback { span: macro_span, ns, ident },
|
BuiltinLintDiag::MacroExpandedMacroExportsAccessedByAbsolutePaths(span_def) => {
|
||||||
),
|
lints::MacroExpandedMacroExportsAccessedByAbsolutePaths { definition: span_def }
|
||||||
BuiltinLintDiag::MacroExpandedMacroExportsAccessedByAbsolutePaths(span_def) => ctx
|
.decorate_lint(diag)
|
||||||
.emit_span_lint(
|
}
|
||||||
lint,
|
|
||||||
span,
|
|
||||||
lints::MacroExpandedMacroExportsAccessedByAbsolutePaths { definition: span_def },
|
|
||||||
),
|
|
||||||
BuiltinLintDiag::ElidedLifetimesInPaths(n, path_span, incl_angl_brckt, insertion_span) => {
|
BuiltinLintDiag::ElidedLifetimesInPaths(n, path_span, incl_angl_brckt, insertion_span) => {
|
||||||
ctx.emit_span_lint(
|
lints::ElidedLifetimesInPaths {
|
||||||
lint,
|
subdiag: elided_lifetime_in_path_suggestion(
|
||||||
span,
|
sess.source_map(),
|
||||||
lints::ElidedLifetimesInPaths {
|
n,
|
||||||
subdiag: elided_lifetime_in_path_suggestion(
|
path_span,
|
||||||
sess.source_map(),
|
incl_angl_brckt,
|
||||||
n,
|
insertion_span,
|
||||||
path_span,
|
),
|
||||||
incl_angl_brckt,
|
}
|
||||||
insertion_span,
|
.decorate_lint(diag);
|
||||||
),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::UnknownCrateTypes { span, candidate } => {
|
BuiltinLintDiag::UnknownCrateTypes { span, candidate } => {
|
||||||
let sugg = candidate.map(|candidate| lints::UnknownCrateTypesSub { span, candidate });
|
let sugg = candidate.map(|candidate| lints::UnknownCrateTypesSub { span, candidate });
|
||||||
ctx.emit_span_lint(lint, span, lints::UnknownCrateTypes { sugg });
|
lints::UnknownCrateTypes { sugg }.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::UnusedImports {
|
BuiltinLintDiag::UnusedImports {
|
||||||
remove_whole_use,
|
remove_whole_use,
|
||||||
@ -120,18 +100,15 @@ pub(super) fn emit_buffered_lint(
|
|||||||
let test_module_span =
|
let test_module_span =
|
||||||
test_module_span.map(|span| sess.source_map().guess_head_span(span));
|
test_module_span.map(|span| sess.source_map().guess_head_span(span));
|
||||||
|
|
||||||
ctx.emit_span_lint(
|
lints::UnusedImports {
|
||||||
lint,
|
sugg,
|
||||||
span,
|
test_module_span,
|
||||||
lints::UnusedImports {
|
num_snippets: span_snippets.len(),
|
||||||
sugg,
|
span_snippets: DiagArgValue::StrListSepByAnd(
|
||||||
test_module_span,
|
span_snippets.into_iter().map(Cow::Owned).collect(),
|
||||||
num_snippets: span_snippets.len(),
|
),
|
||||||
span_snippets: DiagArgValue::StrListSepByAnd(
|
}
|
||||||
span_snippets.into_iter().map(Cow::Owned).collect(),
|
.decorate_lint(diag);
|
||||||
),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::RedundantImport(spans, ident) => {
|
BuiltinLintDiag::RedundantImport(spans, ident) => {
|
||||||
let subs = spans
|
let subs = spans
|
||||||
@ -145,7 +122,7 @@ pub(super) fn emit_buffered_lint(
|
|||||||
})(span)
|
})(span)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
ctx.emit_span_lint(lint, span, lints::RedundantImport { subs, ident });
|
lints::RedundantImport { subs, ident }.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::DeprecatedMacro {
|
BuiltinLintDiag::DeprecatedMacro {
|
||||||
suggestion,
|
suggestion,
|
||||||
@ -159,90 +136,63 @@ pub(super) fn emit_buffered_lint(
|
|||||||
kind: "macro".to_owned(),
|
kind: "macro".to_owned(),
|
||||||
suggestion,
|
suggestion,
|
||||||
});
|
});
|
||||||
ctx.emit_span_lint(
|
|
||||||
lint,
|
stability::Deprecated { sub, kind: "macro".to_owned(), path, note, since_kind }
|
||||||
span,
|
.decorate_lint(diag);
|
||||||
stability::Deprecated { sub, kind: "macro".to_owned(), path, note, since_kind },
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::UnusedDocComment(attr_span) => {
|
BuiltinLintDiag::UnusedDocComment(attr_span) => {
|
||||||
ctx.emit_span_lint(lint, span, lints::UnusedDocComment { span: attr_span });
|
lints::UnusedDocComment { span: attr_span }.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::PatternsInFnsWithoutBody { span: remove_span, ident, is_foreign } => {
|
BuiltinLintDiag::PatternsInFnsWithoutBody { span: remove_span, ident, is_foreign } => {
|
||||||
let sub = lints::PatternsInFnsWithoutBodySub { ident, span: remove_span };
|
let sub = lints::PatternsInFnsWithoutBodySub { ident, span: remove_span };
|
||||||
|
if is_foreign {
|
||||||
ctx.emit_span_lint(
|
lints::PatternsInFnsWithoutBody::Foreign { sub }
|
||||||
lint,
|
} else {
|
||||||
span,
|
lints::PatternsInFnsWithoutBody::Bodiless { sub }
|
||||||
if is_foreign {
|
}
|
||||||
lints::PatternsInFnsWithoutBody::Foreign { sub }
|
.decorate_lint(diag);
|
||||||
} else {
|
|
||||||
lints::PatternsInFnsWithoutBody::Bodiless { sub }
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::MissingAbi(label_span, default_abi) => {
|
BuiltinLintDiag::MissingAbi(label_span, default_abi) => {
|
||||||
ctx.emit_span_lint(
|
lints::MissingAbi { span: label_span, default_abi: default_abi.name() }
|
||||||
lint,
|
.decorate_lint(diag);
|
||||||
span,
|
|
||||||
lints::MissingAbi { span: label_span, default_abi: default_abi.name() },
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::LegacyDeriveHelpers(label_span) => {
|
BuiltinLintDiag::LegacyDeriveHelpers(label_span) => {
|
||||||
ctx.emit_span_lint(lint, span, lints::LegacyDeriveHelpers { span: label_span });
|
lints::LegacyDeriveHelpers { span: label_span }.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::ProcMacroBackCompat { crate_name, fixed_version } => {
|
BuiltinLintDiag::ProcMacroBackCompat { crate_name, fixed_version } => {
|
||||||
ctx.emit_span_lint(
|
lints::ProcMacroBackCompat { crate_name, fixed_version }.decorate_lint(diag);
|
||||||
lint,
|
|
||||||
span,
|
|
||||||
lints::ProcMacroBackCompat { crate_name, fixed_version },
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::OrPatternsBackCompat(suggestion_span, suggestion) => {
|
BuiltinLintDiag::OrPatternsBackCompat(suggestion_span, suggestion) => {
|
||||||
ctx.emit_span_lint(
|
lints::OrPatternsBackCompat { span: suggestion_span, suggestion }.decorate_lint(diag);
|
||||||
lint,
|
|
||||||
span,
|
|
||||||
lints::OrPatternsBackCompat { span: suggestion_span, suggestion },
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::ReservedPrefix(label_span, prefix) => {
|
BuiltinLintDiag::ReservedPrefix(label_span, prefix) => {
|
||||||
ctx.emit_span_lint(
|
lints::ReservedPrefix {
|
||||||
lint,
|
label: label_span,
|
||||||
span,
|
suggestion: label_span.shrink_to_hi(),
|
||||||
lints::ReservedPrefix {
|
prefix,
|
||||||
label: label_span,
|
}
|
||||||
suggestion: label_span.shrink_to_hi(),
|
.decorate_lint(diag);
|
||||||
prefix,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::UnusedBuiltinAttribute { attr_name, macro_name, invoc_span } => {
|
BuiltinLintDiag::UnusedBuiltinAttribute { attr_name, macro_name, invoc_span } => {
|
||||||
ctx.emit_span_lint(
|
lints::UnusedBuiltinAttribute { invoc_span, attr_name, macro_name }.decorate_lint(diag);
|
||||||
lint,
|
|
||||||
span,
|
|
||||||
lints::UnusedBuiltinAttribute { invoc_span, attr_name, macro_name },
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::TrailingMacro(is_trailing, name) => {
|
BuiltinLintDiag::TrailingMacro(is_trailing, name) => {
|
||||||
ctx.emit_span_lint(lint, span, lints::TrailingMacro { is_trailing, name });
|
lints::TrailingMacro { is_trailing, name }.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::BreakWithLabelAndLoop(sugg_span) => {
|
BuiltinLintDiag::BreakWithLabelAndLoop(sugg_span) => {
|
||||||
ctx.emit_span_lint(
|
lints::BreakWithLabelAndLoop {
|
||||||
lint,
|
sub: lints::BreakWithLabelAndLoopSub {
|
||||||
span,
|
left: sugg_span.shrink_to_lo(),
|
||||||
lints::BreakWithLabelAndLoop {
|
right: sugg_span.shrink_to_hi(),
|
||||||
sub: lints::BreakWithLabelAndLoopSub {
|
|
||||||
left: sugg_span.shrink_to_lo(),
|
|
||||||
right: sugg_span.shrink_to_hi(),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
}
|
||||||
|
.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::UnexpectedCfgName(name, value) => {
|
BuiltinLintDiag::UnexpectedCfgName(name, value) => {
|
||||||
ctx.emit_span_lint(lint, span, check_cfg::unexpected_cfg_name(sess, name, value));
|
check_cfg::unexpected_cfg_name(sess, name, value).decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::UnexpectedCfgValue(name, value) => {
|
BuiltinLintDiag::UnexpectedCfgValue(name, value) => {
|
||||||
ctx.emit_span_lint(lint, span, check_cfg::unexpected_cfg_value(sess, name, value));
|
check_cfg::unexpected_cfg_value(sess, name, value).decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::DeprecatedWhereclauseLocation(left_sp, sugg) => {
|
BuiltinLintDiag::DeprecatedWhereclauseLocation(left_sp, sugg) => {
|
||||||
let suggestion = match sugg {
|
let suggestion = match sugg {
|
||||||
@ -253,7 +203,7 @@ pub(super) fn emit_buffered_lint(
|
|||||||
},
|
},
|
||||||
None => lints::DeprecatedWhereClauseLocationSugg::RemoveWhere { span: left_sp },
|
None => lints::DeprecatedWhereClauseLocationSugg::RemoveWhere { span: left_sp },
|
||||||
};
|
};
|
||||||
ctx.emit_span_lint(lint, span, lints::DeprecatedWhereClauseLocation { suggestion });
|
lints::DeprecatedWhereClauseLocation { suggestion }.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::SingleUseLifetime {
|
BuiltinLintDiag::SingleUseLifetime {
|
||||||
param_span,
|
param_span,
|
||||||
@ -280,15 +230,12 @@ pub(super) fn emit_buffered_lint(
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx.emit_span_lint(
|
lints::SingleUseLifetime { suggestion, param_span, use_span, ident }
|
||||||
lint,
|
.decorate_lint(diag);
|
||||||
span,
|
|
||||||
lints::SingleUseLifetime { suggestion, param_span, use_span, ident },
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::SingleUseLifetime { use_span: None, deletion_span, ident, .. } => {
|
BuiltinLintDiag::SingleUseLifetime { use_span: None, deletion_span, ident, .. } => {
|
||||||
debug!(?deletion_span);
|
debug!(?deletion_span);
|
||||||
ctx.emit_span_lint(lint, span, lints::UnusedLifetime { deletion_span, ident });
|
lints::UnusedLifetime { deletion_span, ident }.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::NamedArgumentUsedPositionally {
|
BuiltinLintDiag::NamedArgumentUsedPositionally {
|
||||||
position_sp_to_replace,
|
position_sp_to_replace,
|
||||||
@ -316,35 +263,29 @@ pub(super) fn emit_buffered_lint(
|
|||||||
(None, String::new())
|
(None, String::new())
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx.emit_span_lint(
|
lints::NamedArgumentUsedPositionally {
|
||||||
lint,
|
named_arg_sp,
|
||||||
span,
|
position_label_sp: position_sp_for_msg,
|
||||||
lints::NamedArgumentUsedPositionally {
|
suggestion,
|
||||||
named_arg_sp,
|
name,
|
||||||
position_label_sp: position_sp_for_msg,
|
named_arg_name,
|
||||||
suggestion,
|
}
|
||||||
name,
|
.decorate_lint(diag);
|
||||||
named_arg_name,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::ByteSliceInPackedStructWithDerive { ty } => {
|
BuiltinLintDiag::ByteSliceInPackedStructWithDerive { ty } => {
|
||||||
ctx.emit_span_lint(lint, span, lints::ByteSliceInPackedStructWithDerive { ty })
|
lints::ByteSliceInPackedStructWithDerive { ty }.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::UnusedExternCrate { removal_span } => {
|
BuiltinLintDiag::UnusedExternCrate { removal_span } => {
|
||||||
ctx.emit_span_lint(lint, span, lints::UnusedExternCrate { removal_span })
|
lints::UnusedExternCrate { removal_span }.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::ExternCrateNotIdiomatic { vis_span, ident_span } => {
|
BuiltinLintDiag::ExternCrateNotIdiomatic { vis_span, ident_span } => {
|
||||||
let suggestion_span = vis_span.between(ident_span);
|
let suggestion_span = vis_span.between(ident_span);
|
||||||
let code = if vis_span.is_empty() { "use " } else { " use " };
|
let code = if vis_span.is_empty() { "use " } else { " use " };
|
||||||
ctx.emit_span_lint(
|
|
||||||
lint,
|
lints::ExternCrateNotIdiomatic { span: suggestion_span, code }.decorate_lint(diag);
|
||||||
span,
|
|
||||||
lints::ExternCrateNotIdiomatic { span: suggestion_span, code },
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::AmbiguousGlobImports { diag: ambiguity } => {
|
BuiltinLintDiag::AmbiguousGlobImports { diag: ambiguity } => {
|
||||||
ctx.emit_span_lint(lint, span, lints::AmbiguousGlobImports { ambiguity });
|
lints::AmbiguousGlobImports { ambiguity }.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::AmbiguousGlobReexports {
|
BuiltinLintDiag::AmbiguousGlobReexports {
|
||||||
name,
|
name,
|
||||||
@ -352,16 +293,13 @@ pub(super) fn emit_buffered_lint(
|
|||||||
first_reexport_span,
|
first_reexport_span,
|
||||||
duplicate_reexport_span,
|
duplicate_reexport_span,
|
||||||
} => {
|
} => {
|
||||||
ctx.emit_span_lint(
|
lints::AmbiguousGlobReexports {
|
||||||
lint,
|
first_reexport: first_reexport_span,
|
||||||
span,
|
duplicate_reexport: duplicate_reexport_span,
|
||||||
lints::AmbiguousGlobReexports {
|
name,
|
||||||
first_reexport: first_reexport_span,
|
namespace,
|
||||||
duplicate_reexport: duplicate_reexport_span,
|
}
|
||||||
name,
|
.decorate_lint(diag);
|
||||||
namespace,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::HiddenGlobReexports {
|
BuiltinLintDiag::HiddenGlobReexports {
|
||||||
name,
|
name,
|
||||||
@ -369,127 +307,112 @@ pub(super) fn emit_buffered_lint(
|
|||||||
glob_reexport_span,
|
glob_reexport_span,
|
||||||
private_item_span,
|
private_item_span,
|
||||||
} => {
|
} => {
|
||||||
ctx.emit_span_lint(
|
lints::HiddenGlobReexports {
|
||||||
lint,
|
glob_reexport: glob_reexport_span,
|
||||||
span,
|
private_item: private_item_span,
|
||||||
lints::HiddenGlobReexports {
|
|
||||||
glob_reexport: glob_reexport_span,
|
|
||||||
private_item: private_item_span,
|
|
||||||
|
|
||||||
name,
|
name,
|
||||||
namespace,
|
namespace,
|
||||||
},
|
}
|
||||||
);
|
.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::UnusedQualifications { removal_span } => {
|
BuiltinLintDiag::UnusedQualifications { removal_span } => {
|
||||||
ctx.emit_span_lint(lint, span, lints::UnusedQualifications { removal_span });
|
lints::UnusedQualifications { removal_span }.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::AssociatedConstElidedLifetime { elided, span: lt_span } => {
|
BuiltinLintDiag::AssociatedConstElidedLifetime { elided, span: lt_span } => {
|
||||||
let lt_span = if elided { lt_span.shrink_to_hi() } else { lt_span };
|
let lt_span = if elided { lt_span.shrink_to_hi() } else { lt_span };
|
||||||
let code = if elided { "'static " } else { "'static" };
|
let code = if elided { "'static " } else { "'static" };
|
||||||
ctx.emit_span_lint(
|
lints::AssociatedConstElidedLifetime { span: lt_span, code, elided }
|
||||||
lint,
|
.decorate_lint(diag);
|
||||||
span,
|
|
||||||
lints::AssociatedConstElidedLifetime { span: lt_span, code, elided },
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::RedundantImportVisibility { max_vis, span: vis_span, import_vis } => {
|
BuiltinLintDiag::RedundantImportVisibility { max_vis, span: vis_span, import_vis } => {
|
||||||
ctx.emit_span_lint(
|
lints::RedundantImportVisibility { span: vis_span, help: (), max_vis, import_vis }
|
||||||
lint,
|
.decorate_lint(diag);
|
||||||
span,
|
|
||||||
lints::RedundantImportVisibility { span: vis_span, help: (), max_vis, import_vis },
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::UnknownDiagnosticAttribute { span: typo_span, typo_name } => {
|
BuiltinLintDiag::UnknownDiagnosticAttribute { span: typo_span, typo_name } => {
|
||||||
let typo = typo_name.map(|typo_name| lints::UnknownDiagnosticAttributeTypoSugg {
|
let typo = typo_name.map(|typo_name| lints::UnknownDiagnosticAttributeTypoSugg {
|
||||||
span: typo_span,
|
span: typo_span,
|
||||||
typo_name,
|
typo_name,
|
||||||
});
|
});
|
||||||
ctx.emit_span_lint(lint, span, lints::UnknownDiagnosticAttribute { typo });
|
lints::UnknownDiagnosticAttribute { typo }.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::MacroUseDeprecated => {
|
BuiltinLintDiag::MacroUseDeprecated => {
|
||||||
ctx.emit_span_lint(lint, span, lints::MacroUseDeprecated)
|
lints::MacroUseDeprecated.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::UnusedMacroUse => ctx.emit_span_lint(lint, span, lints::UnusedMacroUse),
|
BuiltinLintDiag::UnusedMacroUse => lints::UnusedMacroUse.decorate_lint(diag),
|
||||||
BuiltinLintDiag::PrivateExternCrateReexport(ident) => {
|
BuiltinLintDiag::PrivateExternCrateReexport(ident) => {
|
||||||
ctx.emit_span_lint(lint, span, lints::PrivateExternCrateReexport { ident })
|
lints::PrivateExternCrateReexport { ident }.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::UnusedLabel => ctx.emit_span_lint(lint, span, lints::UnusedLabel),
|
BuiltinLintDiag::UnusedLabel => lints::UnusedLabel.decorate_lint(diag),
|
||||||
BuiltinLintDiag::MacroIsPrivate(ident) => {
|
BuiltinLintDiag::MacroIsPrivate(ident) => {
|
||||||
ctx.emit_span_lint(lint, span, lints::MacroIsPrivate { ident })
|
lints::MacroIsPrivate { ident }.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::UnusedMacroDefinition(name) => {
|
BuiltinLintDiag::UnusedMacroDefinition(name) => {
|
||||||
ctx.emit_span_lint(lint, span, lints::UnusedMacroDefinition { name })
|
lints::UnusedMacroDefinition { name }.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::MacroRuleNeverUsed(n, name) => {
|
BuiltinLintDiag::MacroRuleNeverUsed(n, name) => {
|
||||||
ctx.emit_span_lint(lint, span, lints::MacroRuleNeverUsed { n: n + 1, name })
|
lints::MacroRuleNeverUsed { n: n + 1, name }.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::UnstableFeature(msg) => {
|
BuiltinLintDiag::UnstableFeature(msg) => {
|
||||||
ctx.emit_span_lint(lint, span, lints::UnstableFeature { msg })
|
lints::UnstableFeature { msg }.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::AvoidUsingIntelSyntax => {
|
BuiltinLintDiag::AvoidUsingIntelSyntax => {
|
||||||
ctx.emit_span_lint(lint, span, lints::AvoidIntelSyntax)
|
lints::AvoidIntelSyntax.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::AvoidUsingAttSyntax => {
|
BuiltinLintDiag::AvoidUsingAttSyntax => {
|
||||||
ctx.emit_span_lint(lint, span, lints::AvoidAttSyntax)
|
lints::AvoidAttSyntax.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::IncompleteInclude => {
|
BuiltinLintDiag::IncompleteInclude => {
|
||||||
ctx.emit_span_lint(lint, span, lints::IncompleteInclude)
|
lints::IncompleteInclude.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::UnnameableTestItems => {
|
BuiltinLintDiag::UnnameableTestItems => {
|
||||||
ctx.emit_span_lint(lint, span, lints::UnnameableTestItems)
|
lints::UnnameableTestItems.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::DuplicateMacroAttribute => {
|
BuiltinLintDiag::DuplicateMacroAttribute => {
|
||||||
ctx.emit_span_lint(lint, span, lints::DuplicateMacroAttribute)
|
lints::DuplicateMacroAttribute.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::CfgAttrNoAttributes => {
|
BuiltinLintDiag::CfgAttrNoAttributes => {
|
||||||
ctx.emit_span_lint(lint, span, lints::CfgAttrNoAttributes)
|
lints::CfgAttrNoAttributes.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::CrateTypeInCfgAttr => {
|
BuiltinLintDiag::CrateTypeInCfgAttr => {
|
||||||
ctx.emit_span_lint(lint, span, lints::CrateTypeInCfgAttr)
|
lints::CrateTypeInCfgAttr.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::CrateNameInCfgAttr => {
|
BuiltinLintDiag::CrateNameInCfgAttr => {
|
||||||
ctx.emit_span_lint(lint, span, lints::CrateNameInCfgAttr)
|
lints::CrateNameInCfgAttr.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::MissingFragmentSpecifier => {
|
BuiltinLintDiag::MissingFragmentSpecifier => {
|
||||||
ctx.emit_span_lint(lint, span, lints::MissingFragmentSpecifier)
|
lints::MissingFragmentSpecifier.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::MetaVariableStillRepeating(name) => {
|
BuiltinLintDiag::MetaVariableStillRepeating(name) => {
|
||||||
ctx.emit_span_lint(lint, span, lints::MetaVariableStillRepeating { name })
|
lints::MetaVariableStillRepeating { name }.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::MetaVariableWrongOperator => {
|
BuiltinLintDiag::MetaVariableWrongOperator => {
|
||||||
ctx.emit_span_lint(lint, span, lints::MetaVariableWrongOperator)
|
lints::MetaVariableWrongOperator.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::DuplicateMatcherBinding => {
|
BuiltinLintDiag::DuplicateMatcherBinding => {
|
||||||
ctx.emit_span_lint(lint, span, lints::DuplicateMatcherBinding)
|
lints::DuplicateMatcherBinding.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::UnknownMacroVariable(name) => {
|
BuiltinLintDiag::UnknownMacroVariable(name) => {
|
||||||
ctx.emit_span_lint(lint, span, lints::UnknownMacroVariable { name })
|
lints::UnknownMacroVariable { name }.decorate_lint(diag);
|
||||||
}
|
}
|
||||||
BuiltinLintDiag::UnusedCrateDependency { extern_crate, local_crate } => ctx.emit_span_lint(
|
BuiltinLintDiag::UnusedCrateDependency { extern_crate, local_crate } => {
|
||||||
lint,
|
lints::UnusedCrateDependency { extern_crate, local_crate }.decorate_lint(diag)
|
||||||
span,
|
}
|
||||||
lints::UnusedCrateDependency { extern_crate, local_crate },
|
BuiltinLintDiag::WasmCAbi => lints::WasmCAbi.decorate_lint(diag),
|
||||||
),
|
BuiltinLintDiag::IllFormedAttributeInput { suggestions } => {
|
||||||
BuiltinLintDiag::WasmCAbi => ctx.emit_span_lint(lint, span, lints::WasmCAbi),
|
|
||||||
BuiltinLintDiag::IllFormedAttributeInput { suggestions } => ctx.emit_span_lint(
|
|
||||||
lint,
|
|
||||||
span,
|
|
||||||
lints::IllFormedAttributeInput {
|
lints::IllFormedAttributeInput {
|
||||||
num_suggestions: suggestions.len(),
|
num_suggestions: suggestions.len(),
|
||||||
suggestions: DiagArgValue::StrListSepByAnd(
|
suggestions: DiagArgValue::StrListSepByAnd(
|
||||||
suggestions.into_iter().map(|s| format!("`{s}`").into()).collect(),
|
suggestions.into_iter().map(|s| format!("`{s}`").into()).collect(),
|
||||||
),
|
),
|
||||||
},
|
}
|
||||||
),
|
.decorate_lint(diag)
|
||||||
BuiltinLintDiag::InnerAttributeUnstable { is_macro } => ctx.emit_span_lint(
|
}
|
||||||
lint,
|
BuiltinLintDiag::InnerAttributeUnstable { is_macro } => if is_macro {
|
||||||
span,
|
lints::InnerAttributeUnstable::InnerMacroAttribute
|
||||||
if is_macro {
|
} else {
|
||||||
lints::InnerAttributeUnstable::InnerMacroAttribute
|
lints::InnerAttributeUnstable::CustomInnerAttribute
|
||||||
} else {
|
}
|
||||||
lints::InnerAttributeUnstable::CustomInnerAttribute
|
.decorate_lint(diag),
|
||||||
},
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -361,6 +361,7 @@ struct ImplTraitOvercapturesLint<'tcx> {
|
|||||||
|
|
||||||
impl<'a> LintDiagnostic<'a, ()> for ImplTraitOvercapturesLint<'_> {
|
impl<'a> LintDiagnostic<'a, ()> for ImplTraitOvercapturesLint<'_> {
|
||||||
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) {
|
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) {
|
||||||
|
diag.primary_message(fluent::lint_impl_trait_overcaptures);
|
||||||
diag.arg("self_ty", self.self_ty.to_string())
|
diag.arg("self_ty", self.self_ty.to_string())
|
||||||
.arg("num_captured", self.num_captured)
|
.arg("num_captured", self.num_captured)
|
||||||
.span_note(self.uncaptured_spans, fluent::lint_note)
|
.span_note(self.uncaptured_spans, fluent::lint_note)
|
||||||
@ -374,10 +375,6 @@ impl<'a> LintDiagnostic<'a, ()> for ImplTraitOvercapturesLint<'_> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> rustc_errors::DiagMessage {
|
|
||||||
fluent::lint_impl_trait_overcaptures
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
|
@ -16,7 +16,7 @@ use crate::{
|
|||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_ast_pretty::pprust;
|
use rustc_ast_pretty::pprust;
|
||||||
use rustc_data_structures::fx::FxIndexMap;
|
use rustc_data_structures::fx::FxIndexMap;
|
||||||
use rustc_errors::{Diag, DiagMessage, LintDiagnostic, MultiSpan};
|
use rustc_errors::{Diag, LintDiagnostic, MultiSpan};
|
||||||
use rustc_feature::{Features, GateIssue};
|
use rustc_feature::{Features, GateIssue};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::intravisit::{self, Visitor};
|
use rustc_hir::intravisit::{self, Visitor};
|
||||||
@ -1064,26 +1064,19 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
|||||||
// FIXME: make this translatable
|
// FIXME: make this translatable
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
#[allow(rustc::untranslatable_diagnostic)]
|
||||||
lint_level(
|
lint_level(self.sess, lint, level, src, Some(span.into()), |lint| {
|
||||||
self.sess,
|
lint.primary_message(fluent::lint_unknown_gated_lint);
|
||||||
lint,
|
lint.arg("name", lint_id.lint.name_lower());
|
||||||
level,
|
lint.note(fluent::lint_note);
|
||||||
src,
|
rustc_session::parse::add_feature_diagnostics_for_issue(
|
||||||
Some(span.into()),
|
lint,
|
||||||
fluent::lint_unknown_gated_lint,
|
&self.sess,
|
||||||
|lint| {
|
feature,
|
||||||
lint.arg("name", lint_id.lint.name_lower());
|
GateIssue::Language,
|
||||||
lint.note(fluent::lint_note);
|
lint_from_cli,
|
||||||
rustc_session::parse::add_feature_diagnostics_for_issue(
|
None,
|
||||||
lint,
|
);
|
||||||
&self.sess,
|
});
|
||||||
feature,
|
|
||||||
GateIssue::Language,
|
|
||||||
lint_from_cli,
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
false
|
false
|
||||||
@ -1104,11 +1097,10 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
|||||||
&self,
|
&self,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
span: Option<MultiSpan>,
|
span: Option<MultiSpan>,
|
||||||
msg: impl Into<DiagMessage>,
|
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
let (level, src) = self.lint_level(lint);
|
let (level, src) = self.lint_level(lint);
|
||||||
lint_level(self.sess, lint, level, src, span, msg, decorate)
|
lint_level(self.sess, lint, level, src, span, decorate)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
@ -1119,7 +1111,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
|||||||
decorate: impl for<'a> LintDiagnostic<'a, ()>,
|
decorate: impl for<'a> LintDiagnostic<'a, ()>,
|
||||||
) {
|
) {
|
||||||
let (level, src) = self.lint_level(lint);
|
let (level, src) = self.lint_level(lint);
|
||||||
lint_level(self.sess, lint, level, src, Some(span), decorate.msg(), |lint| {
|
lint_level(self.sess, lint, level, src, Some(span), |lint| {
|
||||||
decorate.decorate_lint(lint);
|
decorate.decorate_lint(lint);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1127,7 +1119,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
|||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn emit_lint(&self, lint: &'static Lint, decorate: impl for<'a> LintDiagnostic<'a, ()>) {
|
pub fn emit_lint(&self, lint: &'static Lint, decorate: impl for<'a> LintDiagnostic<'a, ()>) {
|
||||||
let (level, src) = self.lint_level(lint);
|
let (level, src) = self.lint_level(lint);
|
||||||
lint_level(self.sess, lint, level, src, None, decorate.msg(), |lint| {
|
lint_level(self.sess, lint, level, src, None, |lint| {
|
||||||
decorate.decorate_lint(lint);
|
decorate.decorate_lint(lint);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -145,12 +145,9 @@ pub struct BuiltinMissingDebugImpl<'a> {
|
|||||||
// Needed for def_path_str
|
// Needed for def_path_str
|
||||||
impl<'a> LintDiagnostic<'a, ()> for BuiltinMissingDebugImpl<'_> {
|
impl<'a> LintDiagnostic<'a, ()> for BuiltinMissingDebugImpl<'_> {
|
||||||
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) {
|
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) {
|
||||||
|
diag.primary_message(fluent::lint_builtin_missing_debug_impl);
|
||||||
diag.arg("debug", self.tcx.def_path_str(self.def_id));
|
diag.arg("debug", self.tcx.def_path_str(self.def_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> DiagMessage {
|
|
||||||
fluent::lint_builtin_missing_debug_impl
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
@ -250,6 +247,7 @@ pub struct BuiltinUngatedAsyncFnTrackCaller<'a> {
|
|||||||
|
|
||||||
impl<'a> LintDiagnostic<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> {
|
impl<'a> LintDiagnostic<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> {
|
||||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||||
|
diag.primary_message(fluent::lint_ungated_async_fn_track_caller);
|
||||||
diag.span_label(self.label, fluent::lint_label);
|
diag.span_label(self.label, fluent::lint_label);
|
||||||
rustc_session::parse::add_feature_diagnostics(
|
rustc_session::parse::add_feature_diagnostics(
|
||||||
diag,
|
diag,
|
||||||
@ -257,10 +255,6 @@ impl<'a> LintDiagnostic<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> {
|
|||||||
sym::async_fn_track_caller,
|
sym::async_fn_track_caller,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> DiagMessage {
|
|
||||||
fluent::lint_ungated_async_fn_track_caller
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
@ -432,6 +426,7 @@ pub struct BuiltinUnpermittedTypeInit<'a> {
|
|||||||
|
|
||||||
impl<'a> LintDiagnostic<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
|
impl<'a> LintDiagnostic<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
|
||||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||||
|
diag.primary_message(self.msg);
|
||||||
diag.arg("ty", self.ty);
|
diag.arg("ty", self.ty);
|
||||||
diag.span_label(self.label, fluent::lint_builtin_unpermitted_type_init_label);
|
diag.span_label(self.label, fluent::lint_builtin_unpermitted_type_init_label);
|
||||||
if let InhabitedPredicate::True = self.ty.inhabited_predicate(self.tcx) {
|
if let InhabitedPredicate::True = self.ty.inhabited_predicate(self.tcx) {
|
||||||
@ -443,10 +438,6 @@ impl<'a> LintDiagnostic<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
|
|||||||
}
|
}
|
||||||
self.sub.add_to_diag(diag);
|
self.sub.add_to_diag(diag);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> DiagMessage {
|
|
||||||
self.msg.clone()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME(davidtwco): make translatable
|
// FIXME(davidtwco): make translatable
|
||||||
@ -1169,6 +1160,7 @@ pub struct NonFmtPanicUnused {
|
|||||||
// Used because of two suggestions based on one Option<Span>
|
// Used because of two suggestions based on one Option<Span>
|
||||||
impl<'a> LintDiagnostic<'a, ()> for NonFmtPanicUnused {
|
impl<'a> LintDiagnostic<'a, ()> for NonFmtPanicUnused {
|
||||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||||
|
diag.primary_message(fluent::lint_non_fmt_panic_unused);
|
||||||
diag.arg("count", self.count);
|
diag.arg("count", self.count);
|
||||||
diag.note(fluent::lint_note);
|
diag.note(fluent::lint_note);
|
||||||
if let Some(span) = self.suggestion {
|
if let Some(span) = self.suggestion {
|
||||||
@ -1186,10 +1178,6 @@ impl<'a> LintDiagnostic<'a, ()> for NonFmtPanicUnused {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> DiagMessage {
|
|
||||||
fluent::lint_non_fmt_panic_unused
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
@ -1411,13 +1399,10 @@ pub struct DropTraitConstraintsDiag<'a> {
|
|||||||
// Needed for def_path_str
|
// Needed for def_path_str
|
||||||
impl<'a> LintDiagnostic<'a, ()> for DropTraitConstraintsDiag<'_> {
|
impl<'a> LintDiagnostic<'a, ()> for DropTraitConstraintsDiag<'_> {
|
||||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||||
|
diag.primary_message(fluent::lint_drop_trait_constraints);
|
||||||
diag.arg("predicate", self.predicate);
|
diag.arg("predicate", self.predicate);
|
||||||
diag.arg("needs_drop", self.tcx.def_path_str(self.def_id));
|
diag.arg("needs_drop", self.tcx.def_path_str(self.def_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> DiagMessage {
|
|
||||||
fluent::lint_drop_trait_constraints
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DropGlue<'a> {
|
pub struct DropGlue<'a> {
|
||||||
@ -1428,12 +1413,9 @@ pub struct DropGlue<'a> {
|
|||||||
// Needed for def_path_str
|
// Needed for def_path_str
|
||||||
impl<'a> LintDiagnostic<'a, ()> for DropGlue<'_> {
|
impl<'a> LintDiagnostic<'a, ()> for DropGlue<'_> {
|
||||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||||
|
diag.primary_message(fluent::lint_drop_glue);
|
||||||
diag.arg("needs_drop", self.tcx.def_path_str(self.def_id));
|
diag.arg("needs_drop", self.tcx.def_path_str(self.def_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> DiagMessage {
|
|
||||||
fluent::lint_drop_glue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// types.rs
|
// types.rs
|
||||||
@ -1711,6 +1693,7 @@ pub struct ImproperCTypes<'a> {
|
|||||||
// Used because of the complexity of Option<DiagMessage>, DiagMessage, and Option<Span>
|
// Used because of the complexity of Option<DiagMessage>, DiagMessage, and Option<Span>
|
||||||
impl<'a> LintDiagnostic<'a, ()> for ImproperCTypes<'_> {
|
impl<'a> LintDiagnostic<'a, ()> for ImproperCTypes<'_> {
|
||||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||||
|
diag.primary_message(fluent::lint_improper_ctypes);
|
||||||
diag.arg("ty", self.ty);
|
diag.arg("ty", self.ty);
|
||||||
diag.arg("desc", self.desc);
|
diag.arg("desc", self.desc);
|
||||||
diag.span_label(self.label, fluent::lint_label);
|
diag.span_label(self.label, fluent::lint_label);
|
||||||
@ -1722,10 +1705,6 @@ impl<'a> LintDiagnostic<'a, ()> for ImproperCTypes<'_> {
|
|||||||
diag.span_note(note, fluent::lint_note);
|
diag.span_note(note, fluent::lint_note);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> DiagMessage {
|
|
||||||
fluent::lint_improper_ctypes
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
@ -1854,6 +1833,7 @@ pub enum UnusedDefSuggestion {
|
|||||||
// Needed because of def_path_str
|
// Needed because of def_path_str
|
||||||
impl<'a> LintDiagnostic<'a, ()> for UnusedDef<'_, '_> {
|
impl<'a> LintDiagnostic<'a, ()> for UnusedDef<'_, '_> {
|
||||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||||
|
diag.primary_message(fluent::lint_unused_def);
|
||||||
diag.arg("pre", self.pre);
|
diag.arg("pre", self.pre);
|
||||||
diag.arg("post", self.post);
|
diag.arg("post", self.post);
|
||||||
diag.arg("def", self.cx.tcx.def_path_str(self.def_id));
|
diag.arg("def", self.cx.tcx.def_path_str(self.def_id));
|
||||||
@ -1865,10 +1845,6 @@ impl<'a> LintDiagnostic<'a, ()> for UnusedDef<'_, '_> {
|
|||||||
diag.subdiagnostic(diag.dcx, sugg);
|
diag.subdiagnostic(diag.dcx, sugg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> DiagMessage {
|
|
||||||
fluent::lint_unused_def
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
@ -1937,15 +1913,12 @@ pub struct AsyncFnInTraitDiag {
|
|||||||
|
|
||||||
impl<'a> LintDiagnostic<'a, ()> for AsyncFnInTraitDiag {
|
impl<'a> LintDiagnostic<'a, ()> for AsyncFnInTraitDiag {
|
||||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||||
|
diag.primary_message(fluent::lint_async_fn_in_trait);
|
||||||
diag.note(fluent::lint_note);
|
diag.note(fluent::lint_note);
|
||||||
if let Some(sugg) = self.sugg {
|
if let Some(sugg) = self.sugg {
|
||||||
diag.multipart_suggestion(fluent::lint_suggestion, sugg, Applicability::MaybeIncorrect);
|
diag.multipart_suggestion(fluent::lint_suggestion, sugg, Applicability::MaybeIncorrect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> DiagMessage {
|
|
||||||
fluent::lint_async_fn_in_trait
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
@ -2273,10 +2246,8 @@ pub struct UnstableFeature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> LintDiagnostic<'a, ()> for UnstableFeature {
|
impl<'a> LintDiagnostic<'a, ()> for UnstableFeature {
|
||||||
fn decorate_lint<'b>(self, _diag: &'b mut Diag<'a, ()>) {}
|
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||||
|
diag.primary_message(self.msg);
|
||||||
fn msg(&self) -> DiagMessage {
|
|
||||||
self.msg.clone()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2738,12 +2709,9 @@ pub struct AmbiguousGlobImports {
|
|||||||
|
|
||||||
impl<'a, G: EmissionGuarantee> LintDiagnostic<'a, G> for AmbiguousGlobImports {
|
impl<'a, G: EmissionGuarantee> LintDiagnostic<'a, G> for AmbiguousGlobImports {
|
||||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>) {
|
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>) {
|
||||||
|
diag.primary_message(self.ambiguity.msg.clone());
|
||||||
rustc_errors::report_ambiguity_error(diag, self.ambiguity);
|
rustc_errors::report_ambiguity_error(diag, self.ambiguity);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> DiagMessage {
|
|
||||||
DiagMessage::Str(self.ambiguity.msg.clone().into())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
|
@ -123,7 +123,8 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||||
cx.span_lint(NON_FMT_PANICS, arg_span, fluent::lint_non_fmt_panic, |lint| {
|
cx.span_lint(NON_FMT_PANICS, arg_span, |lint| {
|
||||||
|
lint.primary_message(fluent::lint_non_fmt_panic);
|
||||||
lint.arg("name", symbol);
|
lint.arg("name", symbol);
|
||||||
lint.note(fluent::lint_note);
|
lint.note(fluent::lint_note);
|
||||||
lint.note(fluent::lint_more_info_note);
|
lint.note(fluent::lint_more_info_note);
|
||||||
|
@ -764,19 +764,7 @@ pub struct LintBuffer {
|
|||||||
|
|
||||||
impl LintBuffer {
|
impl LintBuffer {
|
||||||
pub fn add_early_lint(&mut self, early_lint: BufferedEarlyLint) {
|
pub fn add_early_lint(&mut self, early_lint: BufferedEarlyLint) {
|
||||||
let arr = self.map.entry(early_lint.node_id).or_default();
|
self.map.entry(early_lint.node_id).or_default().push(early_lint);
|
||||||
arr.push(early_lint);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn add_lint(
|
|
||||||
&mut self,
|
|
||||||
lint: &'static Lint,
|
|
||||||
node_id: NodeId,
|
|
||||||
span: MultiSpan,
|
|
||||||
diagnostic: BuiltinLintDiag,
|
|
||||||
) {
|
|
||||||
let lint_id = LintId::of(lint);
|
|
||||||
self.add_early_lint(BufferedEarlyLint { lint_id, node_id, span, diagnostic });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take(&mut self, id: NodeId) -> Vec<BufferedEarlyLint> {
|
pub fn take(&mut self, id: NodeId) -> Vec<BufferedEarlyLint> {
|
||||||
@ -787,11 +775,16 @@ impl LintBuffer {
|
|||||||
pub fn buffer_lint(
|
pub fn buffer_lint(
|
||||||
&mut self,
|
&mut self,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
id: NodeId,
|
node_id: NodeId,
|
||||||
sp: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
diagnostic: BuiltinLintDiag,
|
diagnostic: BuiltinLintDiag,
|
||||||
) {
|
) {
|
||||||
self.add_lint(lint, id, sp.into(), diagnostic)
|
self.add_early_lint(BufferedEarlyLint {
|
||||||
|
lint_id: LintId::of(lint),
|
||||||
|
node_id,
|
||||||
|
span: span.into(),
|
||||||
|
diagnostic,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,25 +105,12 @@ impl<'a> LintDiagnosticDerive<'a> {
|
|||||||
pub(crate) fn into_tokens(self) -> TokenStream {
|
pub(crate) fn into_tokens(self) -> TokenStream {
|
||||||
let LintDiagnosticDerive { mut structure } = self;
|
let LintDiagnosticDerive { mut structure } = self;
|
||||||
let kind = DiagnosticDeriveKind::LintDiagnostic;
|
let kind = DiagnosticDeriveKind::LintDiagnostic;
|
||||||
|
let slugs = RefCell::new(Vec::new());
|
||||||
let implementation = kind.each_variant(&mut structure, |mut builder, variant| {
|
let implementation = kind.each_variant(&mut structure, |mut builder, variant| {
|
||||||
let preamble = builder.preamble(variant);
|
let preamble = builder.preamble(variant);
|
||||||
let body = builder.body(variant);
|
let body = builder.body(variant);
|
||||||
|
|
||||||
let formatting_init = &builder.formatting_init;
|
let primary_message = match builder.slug.value_ref() {
|
||||||
quote! {
|
|
||||||
#preamble
|
|
||||||
#formatting_init
|
|
||||||
#body
|
|
||||||
diag
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let slugs = RefCell::new(Vec::new());
|
|
||||||
let msg = kind.each_variant(&mut structure, |mut builder, variant| {
|
|
||||||
// Collect the slug by generating the preamble.
|
|
||||||
let _ = builder.preamble(variant);
|
|
||||||
|
|
||||||
match builder.slug.value_ref() {
|
|
||||||
None => {
|
None => {
|
||||||
span_err(builder.span, "diagnostic slug not specified")
|
span_err(builder.span, "diagnostic slug not specified")
|
||||||
.help(
|
.help(
|
||||||
@ -146,9 +133,18 @@ impl<'a> LintDiagnosticDerive<'a> {
|
|||||||
Some(slug) => {
|
Some(slug) => {
|
||||||
slugs.borrow_mut().push(slug.clone());
|
slugs.borrow_mut().push(slug.clone());
|
||||||
quote! {
|
quote! {
|
||||||
crate::fluent_generated::#slug.into()
|
diag.primary_message(crate::fluent_generated::#slug);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let formatting_init = &builder.formatting_init;
|
||||||
|
quote! {
|
||||||
|
#primary_message
|
||||||
|
#preamble
|
||||||
|
#formatting_init
|
||||||
|
#body
|
||||||
|
diag
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -161,10 +157,6 @@ impl<'a> LintDiagnosticDerive<'a> {
|
|||||||
) {
|
) {
|
||||||
#implementation;
|
#implementation;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> rustc_errors::DiagMessage {
|
|
||||||
#msg
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
for test in slugs.borrow().iter().map(|s| generate_test(s, &structure)) {
|
for test in slugs.borrow().iter().map(|s| generate_test(s, &structure)) {
|
||||||
|
@ -91,7 +91,7 @@ pub fn diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
|||||||
/// Then, later, to emit the error:
|
/// Then, later, to emit the error:
|
||||||
///
|
///
|
||||||
/// ```ignore (rust)
|
/// ```ignore (rust)
|
||||||
/// cx.span_lint(INVALID_ATOMIC_ORDERING, fail_order_arg_span, AtomicOrderingInvalidLint {
|
/// cx.emit_span_lint(INVALID_ATOMIC_ORDERING, fail_order_arg_span, AtomicOrderingInvalidLint {
|
||||||
/// method,
|
/// method,
|
||||||
/// success_ordering,
|
/// success_ordering,
|
||||||
/// fail_ordering,
|
/// fail_ordering,
|
||||||
|
@ -2,7 +2,7 @@ use std::cmp;
|
|||||||
|
|
||||||
use rustc_data_structures::fx::FxIndexMap;
|
use rustc_data_structures::fx::FxIndexMap;
|
||||||
use rustc_data_structures::sorted_map::SortedMap;
|
use rustc_data_structures::sorted_map::SortedMap;
|
||||||
use rustc_errors::{Diag, DiagMessage, MultiSpan};
|
use rustc_errors::{Diag, MultiSpan};
|
||||||
use rustc_hir::{HirId, ItemLocalId};
|
use rustc_hir::{HirId, ItemLocalId};
|
||||||
use rustc_macros::HashStable;
|
use rustc_macros::HashStable;
|
||||||
use rustc_session::lint::{
|
use rustc_session::lint::{
|
||||||
@ -270,7 +270,6 @@ pub fn lint_level(
|
|||||||
level: Level,
|
level: Level,
|
||||||
src: LintLevelSource,
|
src: LintLevelSource,
|
||||||
span: Option<MultiSpan>,
|
span: Option<MultiSpan>,
|
||||||
msg: impl Into<DiagMessage>,
|
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
// Avoid codegen bloat from monomorphization by immediately doing dyn dispatch of `decorate` to
|
// Avoid codegen bloat from monomorphization by immediately doing dyn dispatch of `decorate` to
|
||||||
@ -282,7 +281,6 @@ pub fn lint_level(
|
|||||||
level: Level,
|
level: Level,
|
||||||
src: LintLevelSource,
|
src: LintLevelSource,
|
||||||
span: Option<MultiSpan>,
|
span: Option<MultiSpan>,
|
||||||
msg: impl Into<DiagMessage>,
|
|
||||||
decorate: Box<dyn '_ + for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>)>,
|
decorate: Box<dyn '_ + for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>)>,
|
||||||
) {
|
) {
|
||||||
// Check for future incompatibility lints and issue a stronger warning.
|
// Check for future incompatibility lints and issue a stronger warning.
|
||||||
@ -351,10 +349,6 @@ pub fn lint_level(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delay evaluating and setting the primary message until after we've
|
|
||||||
// suppressed the lint due to macros.
|
|
||||||
err.primary_message(msg);
|
|
||||||
|
|
||||||
err.is_lint(lint.name_lower(), has_future_breakage);
|
err.is_lint(lint.name_lower(), has_future_breakage);
|
||||||
|
|
||||||
// Lint diagnostics that are covered by the expect level will not be emitted outside
|
// Lint diagnostics that are covered by the expect level will not be emitted outside
|
||||||
@ -419,7 +413,7 @@ pub fn lint_level(
|
|||||||
explain_lint_level_source(lint, level, src, &mut err);
|
explain_lint_level_source(lint, level, src, &mut err);
|
||||||
err.emit()
|
err.emit()
|
||||||
}
|
}
|
||||||
lint_level_impl(sess, lint, level, src, span, msg, Box::new(decorate))
|
lint_level_impl(sess, lint, level, src, span, Box::new(decorate))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether `span` originates in a foreign crate's external macro.
|
/// Returns whether `span` originates in a foreign crate's external macro.
|
||||||
|
@ -157,6 +157,13 @@ pub struct Deprecated {
|
|||||||
|
|
||||||
impl<'a, G: EmissionGuarantee> rustc_errors::LintDiagnostic<'a, G> for Deprecated {
|
impl<'a, G: EmissionGuarantee> rustc_errors::LintDiagnostic<'a, G> for Deprecated {
|
||||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>) {
|
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>) {
|
||||||
|
diag.primary_message(match &self.since_kind {
|
||||||
|
DeprecatedSinceKind::InEffect => crate::fluent_generated::middle_deprecated,
|
||||||
|
DeprecatedSinceKind::InFuture => crate::fluent_generated::middle_deprecated_in_future,
|
||||||
|
DeprecatedSinceKind::InVersion(_) => {
|
||||||
|
crate::fluent_generated::middle_deprecated_in_version
|
||||||
|
}
|
||||||
|
});
|
||||||
diag.arg("kind", self.kind);
|
diag.arg("kind", self.kind);
|
||||||
diag.arg("path", self.path);
|
diag.arg("path", self.path);
|
||||||
if let DeprecatedSinceKind::InVersion(version) = self.since_kind {
|
if let DeprecatedSinceKind::InVersion(version) = self.since_kind {
|
||||||
@ -172,16 +179,6 @@ impl<'a, G: EmissionGuarantee> rustc_errors::LintDiagnostic<'a, G> for Deprecate
|
|||||||
diag.subdiagnostic(diag.dcx, sub);
|
diag.subdiagnostic(diag.dcx, sub);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> rustc_errors::DiagMessage {
|
|
||||||
match &self.since_kind {
|
|
||||||
DeprecatedSinceKind::InEffect => crate::fluent_generated::middle_deprecated,
|
|
||||||
DeprecatedSinceKind::InFuture => crate::fluent_generated::middle_deprecated_in_future,
|
|
||||||
DeprecatedSinceKind::InVersion(_) => {
|
|
||||||
crate::fluent_generated::middle_deprecated_in_version
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deprecated_since_kind(is_in_effect: bool, since: DeprecatedSince) -> DeprecatedSinceKind {
|
fn deprecated_since_kind(is_in_effect: bool, since: DeprecatedSince) -> DeprecatedSinceKind {
|
||||||
@ -598,7 +595,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
unmarked: impl FnOnce(Span, DefId),
|
unmarked: impl FnOnce(Span, DefId),
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let soft_handler = |lint, span, msg: String| {
|
let soft_handler = |lint, span, msg: String| {
|
||||||
self.node_span_lint(lint, id.unwrap_or(hir::CRATE_HIR_ID), span, msg, |_| {})
|
self.node_span_lint(lint, id.unwrap_or(hir::CRATE_HIR_ID), span, |lint| {
|
||||||
|
lint.primary_message(msg);
|
||||||
|
})
|
||||||
};
|
};
|
||||||
let eval_result =
|
let eval_result =
|
||||||
self.eval_stability_allow_unstable(def_id, id, span, method_span, allow_unstable);
|
self.eval_stability_allow_unstable(def_id, id, span, method_span, allow_unstable);
|
||||||
|
@ -113,8 +113,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
lint::builtin::CONST_EVALUATABLE_UNCHECKED,
|
lint::builtin::CONST_EVALUATABLE_UNCHECKED,
|
||||||
self.local_def_id_to_hir_id(local_def_id),
|
self.local_def_id_to_hir_id(local_def_id),
|
||||||
self.def_span(ct.def),
|
self.def_span(ct.def),
|
||||||
"cannot use constants which depend on generic parameters in types",
|
|lint| { lint.primary_message("cannot use constants which depend on generic parameters in types"); },
|
||||||
|_| {},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,9 +47,7 @@ use rustc_data_structures::sync::{self, FreezeReadGuard, Lock, Lrc, RwLock, Work
|
|||||||
#[cfg(parallel_compiler)]
|
#[cfg(parallel_compiler)]
|
||||||
use rustc_data_structures::sync::{DynSend, DynSync};
|
use rustc_data_structures::sync::{DynSend, DynSync};
|
||||||
use rustc_data_structures::unord::UnordSet;
|
use rustc_data_structures::unord::UnordSet;
|
||||||
use rustc_errors::{
|
use rustc_errors::{Applicability, Diag, DiagCtxt, ErrorGuaranteed, LintDiagnostic, MultiSpan};
|
||||||
Applicability, Diag, DiagCtxt, DiagMessage, ErrorGuaranteed, LintDiagnostic, MultiSpan,
|
|
||||||
};
|
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::DefKind;
|
use rustc_hir::def::DefKind;
|
||||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
|
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
|
||||||
@ -2471,10 +2469,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
decorator: impl for<'a> LintDiagnostic<'a, ()>,
|
decorator: impl for<'a> LintDiagnostic<'a, ()>,
|
||||||
) {
|
) {
|
||||||
let msg = decorator.msg();
|
|
||||||
let (level, src) = self.lint_level_at_node(lint, hir_id);
|
let (level, src) = self.lint_level_at_node(lint, hir_id);
|
||||||
lint_level(self.sess, lint, level, src, Some(span.into()), msg, |diag| {
|
lint_level(self.sess, lint, level, src, Some(span.into()), |lint| {
|
||||||
decorator.decorate_lint(diag);
|
decorator.decorate_lint(lint);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2488,11 +2485,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
hir_id: HirId,
|
hir_id: HirId,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagMessage>,
|
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
let (level, src) = self.lint_level_at_node(lint, hir_id);
|
let (level, src) = self.lint_level_at_node(lint, hir_id);
|
||||||
lint_level(self.sess, lint, level, src, Some(span.into()), msg, decorate);
|
lint_level(self.sess, lint, level, src, Some(span.into()), decorate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find the crate root and the appropriate span where `use` and outer attributes can be
|
/// Find the crate root and the appropriate span where `use` and outer attributes can be
|
||||||
@ -2543,8 +2539,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
id: HirId,
|
id: HirId,
|
||||||
decorator: impl for<'a> LintDiagnostic<'a, ()>,
|
decorator: impl for<'a> LintDiagnostic<'a, ()>,
|
||||||
) {
|
) {
|
||||||
self.node_lint(lint, id, decorator.msg(), |diag| {
|
self.node_lint(lint, id, |lint| {
|
||||||
decorator.decorate_lint(diag);
|
decorator.decorate_lint(lint);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2557,11 +2553,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
self,
|
self,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
id: HirId,
|
id: HirId,
|
||||||
msg: impl Into<DiagMessage>,
|
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
let (level, src) = self.lint_level_at_node(lint, id);
|
let (level, src) = self.lint_level_at_node(lint, id);
|
||||||
lint_level(self.sess, lint, level, src, None, msg, decorate);
|
lint_level(self.sess, lint, level, src, None, decorate);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx [TraitCandidate]> {
|
pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx [TraitCandidate]> {
|
||||||
|
@ -3314,7 +3314,7 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
|
|||||||
///
|
///
|
||||||
/// The implementation uses similar import discovery logic to that of 'use' suggestions.
|
/// The implementation uses similar import discovery logic to that of 'use' suggestions.
|
||||||
///
|
///
|
||||||
/// See also [`DelayDm`](rustc_error_messages::DelayDm) and [`with_no_trimmed_paths!`].
|
/// See also [`with_no_trimmed_paths!`].
|
||||||
// this is pub to be able to intra-doc-link it
|
// this is pub to be able to intra-doc-link it
|
||||||
pub fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> DefIdMap<Symbol> {
|
pub fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> DefIdMap<Symbol> {
|
||||||
// Trimming paths is expensive and not optimized, since we expect it to only be used for error
|
// Trimming paths is expensive and not optimized, since we expect it to only be used for error
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use rustc_errors::{codes::*, Diag, DiagMessage, LintDiagnostic};
|
use rustc_errors::{codes::*, Diag, LintDiagnostic};
|
||||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||||
use rustc_middle::mir::AssertKind;
|
use rustc_middle::mir::AssertKind;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
@ -50,18 +50,15 @@ pub(crate) enum AssertLintKind {
|
|||||||
|
|
||||||
impl<'a, P: std::fmt::Debug> LintDiagnostic<'a, ()> for AssertLint<P> {
|
impl<'a, P: std::fmt::Debug> LintDiagnostic<'a, ()> for AssertLint<P> {
|
||||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||||
let message = self.assert_kind.diagnostic_message();
|
diag.primary_message(match self.lint_kind {
|
||||||
|
AssertLintKind::ArithmeticOverflow => fluent::mir_transform_arithmetic_overflow,
|
||||||
|
AssertLintKind::UnconditionalPanic => fluent::mir_transform_operation_will_panic,
|
||||||
|
});
|
||||||
|
let label = self.assert_kind.diagnostic_message();
|
||||||
self.assert_kind.add_args(&mut |name, value| {
|
self.assert_kind.add_args(&mut |name, value| {
|
||||||
diag.arg(name, value);
|
diag.arg(name, value);
|
||||||
});
|
});
|
||||||
diag.span_label(self.span, message);
|
diag.span_label(self.span, label);
|
||||||
}
|
|
||||||
|
|
||||||
fn msg(&self) -> DiagMessage {
|
|
||||||
match self.lint_kind {
|
|
||||||
AssertLintKind::ArithmeticOverflow => fluent::mir_transform_arithmetic_overflow,
|
|
||||||
AssertLintKind::UnconditionalPanic => fluent::mir_transform_operation_will_panic,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,6 +101,7 @@ pub(crate) struct MustNotSupend<'tcx, 'a> {
|
|||||||
// Needed for def_path_str
|
// Needed for def_path_str
|
||||||
impl<'a> LintDiagnostic<'a, ()> for MustNotSupend<'_, '_> {
|
impl<'a> LintDiagnostic<'a, ()> for MustNotSupend<'_, '_> {
|
||||||
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) {
|
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) {
|
||||||
|
diag.primary_message(fluent::mir_transform_must_not_suspend);
|
||||||
diag.span_label(self.yield_sp, fluent::_subdiag::label);
|
diag.span_label(self.yield_sp, fluent::_subdiag::label);
|
||||||
if let Some(reason) = self.reason {
|
if let Some(reason) = self.reason {
|
||||||
diag.subdiagnostic(diag.dcx, reason);
|
diag.subdiagnostic(diag.dcx, reason);
|
||||||
@ -113,10 +111,6 @@ impl<'a> LintDiagnostic<'a, ()> for MustNotSupend<'_, '_> {
|
|||||||
diag.arg("def_path", self.tcx.def_path_str(self.def_id));
|
diag.arg("def_path", self.tcx.def_path_str(self.def_id));
|
||||||
diag.arg("post", self.post);
|
diag.arg("post", self.post);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> rustc_errors::DiagMessage {
|
|
||||||
fluent::mir_transform_must_not_suspend
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
|
@ -99,7 +99,6 @@ pub(crate) fn lint_nonexhaustive_missing_variants<'p, 'tcx>(
|
|||||||
|
|
||||||
use rustc_errors::LintDiagnostic;
|
use rustc_errors::LintDiagnostic;
|
||||||
let mut err = rcx.tcx.dcx().struct_span_warn(arm.pat.data().span, "");
|
let mut err = rcx.tcx.dcx().struct_span_warn(arm.pat.data().span, "");
|
||||||
err.primary_message(decorator.msg());
|
|
||||||
decorator.decorate_lint(&mut err);
|
decorator.decorate_lint(&mut err);
|
||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ use super::elaborate;
|
|||||||
use crate::infer::TyCtxtInferExt;
|
use crate::infer::TyCtxtInferExt;
|
||||||
use crate::traits::query::evaluate_obligation::InferCtxtExt;
|
use crate::traits::query::evaluate_obligation::InferCtxtExt;
|
||||||
use crate::traits::{self, Obligation, ObligationCause};
|
use crate::traits::{self, Obligation, ObligationCause};
|
||||||
use rustc_errors::{DelayDm, FatalError, MultiSpan};
|
use rustc_errors::{FatalError, MultiSpan};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_middle::query::Providers;
|
use rustc_middle::query::Providers;
|
||||||
@ -162,41 +162,36 @@ fn lint_object_unsafe_trait(
|
|||||||
) {
|
) {
|
||||||
// Using `CRATE_NODE_ID` is wrong, but it's hard to get a more precise id.
|
// Using `CRATE_NODE_ID` is wrong, but it's hard to get a more precise id.
|
||||||
// It's also hard to get a use site span, so we use the method definition span.
|
// It's also hard to get a use site span, so we use the method definition span.
|
||||||
tcx.node_span_lint(
|
tcx.node_span_lint(WHERE_CLAUSES_OBJECT_SAFETY, hir::CRATE_HIR_ID, span, |err| {
|
||||||
WHERE_CLAUSES_OBJECT_SAFETY,
|
err.primary_message(format!(
|
||||||
hir::CRATE_HIR_ID,
|
"the trait `{}` cannot be made into an object",
|
||||||
span,
|
tcx.def_path_str(trait_def_id)
|
||||||
DelayDm(|| format!("the trait `{}` cannot be made into an object", tcx.def_path_str(trait_def_id))),
|
));
|
||||||
|err| {
|
let node = tcx.hir().get_if_local(trait_def_id);
|
||||||
let node = tcx.hir().get_if_local(trait_def_id);
|
let mut spans = MultiSpan::from_span(span);
|
||||||
let mut spans = MultiSpan::from_span(span);
|
if let Some(hir::Node::Item(item)) = node {
|
||||||
if let Some(hir::Node::Item(item)) = node {
|
spans.push_span_label(item.ident.span, "this trait cannot be made into an object...");
|
||||||
spans.push_span_label(
|
spans.push_span_label(span, format!("...because {}", violation.error_msg()));
|
||||||
item.ident.span,
|
} else {
|
||||||
"this trait cannot be made into an object...",
|
spans.push_span_label(
|
||||||
);
|
span,
|
||||||
spans.push_span_label(span, format!("...because {}", violation.error_msg()));
|
format!(
|
||||||
} else {
|
"the trait cannot be made into an object because {}",
|
||||||
spans.push_span_label(
|
violation.error_msg()
|
||||||
span,
|
),
|
||||||
format!(
|
);
|
||||||
"the trait cannot be made into an object because {}",
|
};
|
||||||
violation.error_msg()
|
err.span_note(
|
||||||
),
|
spans,
|
||||||
);
|
"for a trait to be \"object safe\" it needs to allow building a vtable to allow the \
|
||||||
};
|
|
||||||
err.span_note(
|
|
||||||
spans,
|
|
||||||
"for a trait to be \"object safe\" it needs to allow building a vtable to allow the \
|
|
||||||
call to be resolvable dynamically; for more information visit \
|
call to be resolvable dynamically; for more information visit \
|
||||||
<https://doc.rust-lang.org/reference/items/traits.html#object-safety>",
|
<https://doc.rust-lang.org/reference/items/traits.html#object-safety>",
|
||||||
);
|
);
|
||||||
if node.is_some() {
|
if node.is_some() {
|
||||||
// Only provide the help if its a local trait, otherwise it's not
|
// Only provide the help if its a local trait, otherwise it's not
|
||||||
violation.solution().add_to(err);
|
violation.solution().add_to(err);
|
||||||
}
|
}
|
||||||
},
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sized_trait_bound_spans<'tcx>(
|
fn sized_trait_bound_spans<'tcx>(
|
||||||
|
@ -21,7 +21,7 @@ use crate::traits::{
|
|||||||
self, coherence, FutureCompatOverlapErrorKind, ObligationCause, ObligationCtxt,
|
self, coherence, FutureCompatOverlapErrorKind, ObligationCause, ObligationCtxt,
|
||||||
};
|
};
|
||||||
use rustc_data_structures::fx::FxIndexSet;
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_errors::{codes::*, DelayDm, Diag, EmissionGuarantee};
|
use rustc_errors::{codes::*, Diag, EmissionGuarantee};
|
||||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||||
use rustc_middle::bug;
|
use rustc_middle::bug;
|
||||||
use rustc_middle::ty::{self, ImplSubject, Ty, TyCtxt, TypeVisitableExt};
|
use rustc_middle::ty::{self, ImplSubject, Ty, TyCtxt, TypeVisitableExt};
|
||||||
@ -449,7 +449,7 @@ fn report_conflicting_impls<'tcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let msg = DelayDm(|| {
|
let msg = || {
|
||||||
format!(
|
format!(
|
||||||
"conflicting implementations of trait `{}`{}{}",
|
"conflicting implementations of trait `{}`{}{}",
|
||||||
overlap.trait_ref.print_trait_sugared(),
|
overlap.trait_ref.print_trait_sugared(),
|
||||||
@ -459,7 +459,7 @@ fn report_conflicting_impls<'tcx>(
|
|||||||
_ => "",
|
_ => "",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
});
|
};
|
||||||
|
|
||||||
// Don't report overlap errors if the header references error
|
// Don't report overlap errors if the header references error
|
||||||
if let Err(err) = (overlap.trait_ref, overlap.self_ty).error_reported() {
|
if let Err(err) = (overlap.trait_ref, overlap.self_ty).error_reported() {
|
||||||
@ -471,7 +471,7 @@ fn report_conflicting_impls<'tcx>(
|
|||||||
let reported = if overlap.with_impl.is_local()
|
let reported = if overlap.with_impl.is_local()
|
||||||
|| tcx.ensure().orphan_check_impl(impl_def_id).is_ok()
|
|| tcx.ensure().orphan_check_impl(impl_def_id).is_ok()
|
||||||
{
|
{
|
||||||
let mut err = tcx.dcx().struct_span_err(impl_span, msg);
|
let mut err = tcx.dcx().struct_span_err(impl_span, msg());
|
||||||
err.code(E0119);
|
err.code(E0119);
|
||||||
decorate(tcx, &overlap, impl_span, &mut err);
|
decorate(tcx, &overlap, impl_span, &mut err);
|
||||||
err.emit()
|
err.emit()
|
||||||
@ -485,15 +485,10 @@ fn report_conflicting_impls<'tcx>(
|
|||||||
FutureCompatOverlapErrorKind::OrderDepTraitObjects => ORDER_DEPENDENT_TRAIT_OBJECTS,
|
FutureCompatOverlapErrorKind::OrderDepTraitObjects => ORDER_DEPENDENT_TRAIT_OBJECTS,
|
||||||
FutureCompatOverlapErrorKind::LeakCheck => COHERENCE_LEAK_CHECK,
|
FutureCompatOverlapErrorKind::LeakCheck => COHERENCE_LEAK_CHECK,
|
||||||
};
|
};
|
||||||
tcx.node_span_lint(
|
tcx.node_span_lint(lint, tcx.local_def_id_to_hir_id(impl_def_id), impl_span, |err| {
|
||||||
lint,
|
err.primary_message(msg());
|
||||||
tcx.local_def_id_to_hir_id(impl_def_id),
|
decorate(tcx, &overlap, impl_span, err);
|
||||||
impl_span,
|
});
|
||||||
msg,
|
|
||||||
|err| {
|
|
||||||
decorate(tcx, &overlap, impl_span, err);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -372,8 +372,8 @@ pub(crate) fn run_global_ctxt(
|
|||||||
tcx.node_lint(
|
tcx.node_lint(
|
||||||
crate::lint::MISSING_CRATE_LEVEL_DOCS,
|
crate::lint::MISSING_CRATE_LEVEL_DOCS,
|
||||||
DocContext::as_local_hir_id(tcx, krate.module.item_id).unwrap(),
|
DocContext::as_local_hir_id(tcx, krate.module.item_id).unwrap(),
|
||||||
"no documentation found for this crate's top-level module",
|
|
||||||
|lint| {
|
|lint| {
|
||||||
|
lint.primary_message("no documentation found for this crate's top-level module");
|
||||||
lint.help(help);
|
lint.help(help);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -834,8 +834,9 @@ impl<'tcx> ExtraInfo<'tcx> {
|
|||||||
crate::lint::INVALID_CODEBLOCK_ATTRIBUTES,
|
crate::lint::INVALID_CODEBLOCK_ATTRIBUTES,
|
||||||
self.tcx.local_def_id_to_hir_id(def_id),
|
self.tcx.local_def_id_to_hir_id(def_id),
|
||||||
self.sp,
|
self.sp,
|
||||||
msg,
|
|lint| {
|
||||||
|_| {},
|
lint.primary_message(msg);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -850,8 +851,10 @@ impl<'tcx> ExtraInfo<'tcx> {
|
|||||||
crate::lint::INVALID_CODEBLOCK_ATTRIBUTES,
|
crate::lint::INVALID_CODEBLOCK_ATTRIBUTES,
|
||||||
self.tcx.local_def_id_to_hir_id(def_id),
|
self.tcx.local_def_id_to_hir_id(def_id),
|
||||||
self.sp,
|
self.sp,
|
||||||
msg,
|
|lint| {
|
||||||
f,
|
lint.primary_message(msg);
|
||||||
|
f(lint);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,13 +125,9 @@ pub(crate) fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item
|
|||||||
if should_have_doc_example(cx, item) {
|
if should_have_doc_example(cx, item) {
|
||||||
debug!("reporting error for {item:?} (hir_id={hir_id:?})");
|
debug!("reporting error for {item:?} (hir_id={hir_id:?})");
|
||||||
let sp = item.attr_span(cx.tcx);
|
let sp = item.attr_span(cx.tcx);
|
||||||
cx.tcx.node_span_lint(
|
cx.tcx.node_span_lint(crate::lint::MISSING_DOC_CODE_EXAMPLES, hir_id, sp, |lint| {
|
||||||
crate::lint::MISSING_DOC_CODE_EXAMPLES,
|
lint.primary_message("missing code example in this documentation");
|
||||||
hir_id,
|
});
|
||||||
sp,
|
|
||||||
"missing code example in this documentation",
|
|
||||||
|_| {},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else if tests.found_tests > 0
|
} else if tests.found_tests > 0
|
||||||
&& !cx.cache.effective_visibilities.is_exported(cx.tcx, item.item_id.expect_def_id())
|
&& !cx.cache.effective_visibilities.is_exported(cx.tcx, item.item_id.expect_def_id())
|
||||||
@ -140,8 +136,9 @@ pub(crate) fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item
|
|||||||
crate::lint::PRIVATE_DOC_TESTS,
|
crate::lint::PRIVATE_DOC_TESTS,
|
||||||
hir_id,
|
hir_id,
|
||||||
item.attr_span(cx.tcx),
|
item.attr_span(cx.tcx),
|
||||||
"documentation test in private item",
|
|lint| {
|
||||||
|_| {},
|
lint.primary_message("documentation test in private item");
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1689,7 +1689,9 @@ fn report_diagnostic(
|
|||||||
|
|
||||||
let sp = item.attr_span(tcx);
|
let sp = item.attr_span(tcx);
|
||||||
|
|
||||||
tcx.node_span_lint(lint, hir_id, sp, msg, |lint| {
|
tcx.node_span_lint(lint, hir_id, sp, |lint| {
|
||||||
|
lint.primary_message(msg);
|
||||||
|
|
||||||
let (span, link_range) = match link_range {
|
let (span, link_range) = match link_range {
|
||||||
MarkdownLinkRange::Destination(md_range) => {
|
MarkdownLinkRange::Destination(md_range) => {
|
||||||
let mut md_range = md_range.clone();
|
let mut md_range = md_range.clone();
|
||||||
|
@ -24,8 +24,9 @@ pub(super) fn visit_item(cx: &DocContext<'_>, item: &Item) {
|
|||||||
let sp =
|
let sp =
|
||||||
source_span_for_markdown_range(cx.tcx, &dox, &range, &item.attrs.doc_strings)
|
source_span_for_markdown_range(cx.tcx, &dox, &range, &item.attrs.doc_strings)
|
||||||
.unwrap_or_else(|| item.attr_span(cx.tcx));
|
.unwrap_or_else(|| item.attr_span(cx.tcx));
|
||||||
cx.tcx.node_span_lint(crate::lint::BARE_URLS, hir_id, sp, msg, |lint| {
|
cx.tcx.node_span_lint(crate::lint::BARE_URLS, hir_id, sp, |lint| {
|
||||||
lint.note("bare URLs are not automatically turned into clickable links")
|
lint.primary_message(msg)
|
||||||
|
.note("bare URLs are not automatically turned into clickable links")
|
||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
sp,
|
sp,
|
||||||
"use an automatic link instead",
|
"use an automatic link instead",
|
||||||
|
@ -99,7 +99,9 @@ fn check_rust_syntax(
|
|||||||
// All points of divergence have been handled earlier so this can be
|
// All points of divergence have been handled earlier so this can be
|
||||||
// done the same way whether the span is precise or not.
|
// done the same way whether the span is precise or not.
|
||||||
let hir_id = cx.tcx.local_def_id_to_hir_id(local_id);
|
let hir_id = cx.tcx.local_def_id_to_hir_id(local_id);
|
||||||
cx.tcx.node_span_lint(crate::lint::INVALID_RUST_CODEBLOCKS, hir_id, sp, msg, |lint| {
|
cx.tcx.node_span_lint(crate::lint::INVALID_RUST_CODEBLOCKS, hir_id, sp, |lint| {
|
||||||
|
lint.primary_message(msg);
|
||||||
|
|
||||||
let explanation = if is_ignore {
|
let explanation = if is_ignore {
|
||||||
"`ignore` code blocks require valid Rust code for syntax highlighting; \
|
"`ignore` code blocks require valid Rust code for syntax highlighting; \
|
||||||
mark blocks that do not contain Rust code as text"
|
mark blocks that do not contain Rust code as text"
|
||||||
|
@ -25,8 +25,11 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) {
|
|||||||
Some(sp) => sp,
|
Some(sp) => sp,
|
||||||
None => item.attr_span(tcx),
|
None => item.attr_span(tcx),
|
||||||
};
|
};
|
||||||
tcx.node_span_lint(crate::lint::INVALID_HTML_TAGS, hir_id, sp, msg, |lint| {
|
tcx.node_span_lint(crate::lint::INVALID_HTML_TAGS, hir_id, sp, |lint| {
|
||||||
use rustc_lint_defs::Applicability;
|
use rustc_lint_defs::Applicability;
|
||||||
|
|
||||||
|
lint.primary_message(msg);
|
||||||
|
|
||||||
// If a tag looks like `<this>`, it might actually be a generic.
|
// If a tag looks like `<this>`, it might actually be a generic.
|
||||||
// We don't try to detect stuff `<like, this>` because that's not valid HTML,
|
// We don't try to detect stuff `<like, this>` because that's not valid HTML,
|
||||||
// and we don't try to detect stuff `<like this>` because that's not valid Rust.
|
// and we don't try to detect stuff `<like this>` because that's not valid Rust.
|
||||||
|
@ -188,8 +188,9 @@ fn check_inline_or_reference_unknown_redundancy(
|
|||||||
&item.attrs.doc_strings,
|
&item.attrs.doc_strings,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
cx.tcx.node_span_lint(crate::lint::REDUNDANT_EXPLICIT_LINKS, hir_id, explicit_span, "redundant explicit link target", |lint| {
|
cx.tcx.node_span_lint(crate::lint::REDUNDANT_EXPLICIT_LINKS, hir_id, explicit_span, |lint| {
|
||||||
lint.span_label(explicit_span, "explicit target is redundant")
|
lint.primary_message("redundant explicit link target")
|
||||||
|
.span_label(explicit_span, "explicit target is redundant")
|
||||||
.span_label(display_span, "because label contains path that resolves to same destination")
|
.span_label(display_span, "because label contains path that resolves to same destination")
|
||||||
.note("when a link's destination is not specified,\nthe label is used to resolve intra-doc links")
|
.note("when a link's destination is not specified,\nthe label is used to resolve intra-doc links")
|
||||||
.span_suggestion_with_style(link_span, "remove explicit link target", format!("[{}]", link_data.display_link), Applicability::MaybeIncorrect, SuggestionStyle::ShowAlways);
|
.span_suggestion_with_style(link_span, "remove explicit link target", format!("[{}]", link_data.display_link), Applicability::MaybeIncorrect, SuggestionStyle::ShowAlways);
|
||||||
@ -238,8 +239,9 @@ fn check_reference_redundancy(
|
|||||||
&item.attrs.doc_strings,
|
&item.attrs.doc_strings,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
cx.tcx.node_span_lint(crate::lint::REDUNDANT_EXPLICIT_LINKS, hir_id, explicit_span, "redundant explicit link target", |lint| {
|
cx.tcx.node_span_lint(crate::lint::REDUNDANT_EXPLICIT_LINKS, hir_id, explicit_span, |lint| {
|
||||||
lint.span_label(explicit_span, "explicit target is redundant")
|
lint.primary_message("redundant explicit link target")
|
||||||
|
.span_label(explicit_span, "explicit target is redundant")
|
||||||
.span_label(display_span, "because label contains path that resolves to same destination")
|
.span_label(display_span, "because label contains path that resolves to same destination")
|
||||||
.span_note(def_span, "referenced explicit link target defined here")
|
.span_note(def_span, "referenced explicit link target defined here")
|
||||||
.note("when a link's destination is not specified,\nthe label is used to resolve intra-doc links")
|
.note("when a link's destination is not specified,\nthe label is used to resolve intra-doc links")
|
||||||
|
@ -56,17 +56,28 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) {
|
|||||||
)
|
)
|
||||||
.unwrap_or_else(|| item.attr_span(tcx));
|
.unwrap_or_else(|| item.attr_span(tcx));
|
||||||
|
|
||||||
tcx.node_span_lint(crate::lint::UNESCAPED_BACKTICKS, hir_id, span, "unescaped backtick", |lint| {
|
tcx.node_span_lint(crate::lint::UNESCAPED_BACKTICKS, hir_id, span, |lint| {
|
||||||
|
lint.primary_message("unescaped backtick");
|
||||||
|
|
||||||
let mut help_emitted = false;
|
let mut help_emitted = false;
|
||||||
|
|
||||||
match element.prev_code_guess {
|
match element.prev_code_guess {
|
||||||
PrevCodeGuess::None => {}
|
PrevCodeGuess::None => {}
|
||||||
PrevCodeGuess::Start { guess, .. } => {
|
PrevCodeGuess::Start { guess, .. } => {
|
||||||
// "foo` `bar`" -> "`foo` `bar`"
|
// "foo` `bar`" -> "`foo` `bar`"
|
||||||
if let Some(suggest_index) = clamp_start(guess, &element.suggestible_ranges)
|
if let Some(suggest_index) =
|
||||||
|
clamp_start(guess, &element.suggestible_ranges)
|
||||||
&& can_suggest_backtick(&dox, suggest_index)
|
&& can_suggest_backtick(&dox, suggest_index)
|
||||||
{
|
{
|
||||||
suggest_insertion(cx, item, &dox, lint, suggest_index, '`', "the opening backtick of a previous inline code may be missing");
|
suggest_insertion(
|
||||||
|
cx,
|
||||||
|
item,
|
||||||
|
&dox,
|
||||||
|
lint,
|
||||||
|
suggest_index,
|
||||||
|
'`',
|
||||||
|
"the opening backtick of a previous inline code may be missing",
|
||||||
|
);
|
||||||
help_emitted = true;
|
help_emitted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,7 +87,15 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) {
|
|||||||
// an inline code node and we intentionally "break" the inline code here.
|
// an inline code node and we intentionally "break" the inline code here.
|
||||||
let suggest_index = guess;
|
let suggest_index = guess;
|
||||||
if can_suggest_backtick(&dox, suggest_index) {
|
if can_suggest_backtick(&dox, suggest_index) {
|
||||||
suggest_insertion(cx, item, &dox, lint, suggest_index, '`', "a previous inline code might be longer than expected");
|
suggest_insertion(
|
||||||
|
cx,
|
||||||
|
item,
|
||||||
|
&dox,
|
||||||
|
lint,
|
||||||
|
suggest_index,
|
||||||
|
'`',
|
||||||
|
"a previous inline code might be longer than expected",
|
||||||
|
);
|
||||||
help_emitted = true;
|
help_emitted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,11 +103,21 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) {
|
|||||||
|
|
||||||
if !element.prev_code_guess.is_confident() {
|
if !element.prev_code_guess.is_confident() {
|
||||||
// "`foo` bar`" -> "`foo` `bar`"
|
// "`foo` bar`" -> "`foo` `bar`"
|
||||||
if let Some(guess) = guess_start_of_code(&dox, element.element_range.start..backtick_index)
|
if let Some(guess) =
|
||||||
&& let Some(suggest_index) = clamp_start(guess, &element.suggestible_ranges)
|
guess_start_of_code(&dox, element.element_range.start..backtick_index)
|
||||||
|
&& let Some(suggest_index) =
|
||||||
|
clamp_start(guess, &element.suggestible_ranges)
|
||||||
&& can_suggest_backtick(&dox, suggest_index)
|
&& can_suggest_backtick(&dox, suggest_index)
|
||||||
{
|
{
|
||||||
suggest_insertion(cx, item, &dox, lint, suggest_index, '`', "the opening backtick of an inline code may be missing");
|
suggest_insertion(
|
||||||
|
cx,
|
||||||
|
item,
|
||||||
|
&dox,
|
||||||
|
lint,
|
||||||
|
suggest_index,
|
||||||
|
'`',
|
||||||
|
"the opening backtick of an inline code may be missing",
|
||||||
|
);
|
||||||
help_emitted = true;
|
help_emitted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,21 +125,41 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) {
|
|||||||
// Don't suggest closing backtick after single trailing char,
|
// Don't suggest closing backtick after single trailing char,
|
||||||
// if we already suggested opening backtick. For example:
|
// if we already suggested opening backtick. For example:
|
||||||
// "foo`." -> "`foo`." or "foo`s" -> "`foo`s".
|
// "foo`." -> "`foo`." or "foo`s" -> "`foo`s".
|
||||||
if let Some(guess) = guess_end_of_code(&dox, backtick_index + 1..element.element_range.end)
|
if let Some(guess) =
|
||||||
&& let Some(suggest_index) = clamp_end(guess, &element.suggestible_ranges)
|
guess_end_of_code(&dox, backtick_index + 1..element.element_range.end)
|
||||||
|
&& let Some(suggest_index) =
|
||||||
|
clamp_end(guess, &element.suggestible_ranges)
|
||||||
&& can_suggest_backtick(&dox, suggest_index)
|
&& can_suggest_backtick(&dox, suggest_index)
|
||||||
&& (!help_emitted || suggest_index - backtick_index > 2)
|
&& (!help_emitted || suggest_index - backtick_index > 2)
|
||||||
{
|
{
|
||||||
suggest_insertion(cx, item, &dox, lint, suggest_index, '`', "the closing backtick of an inline code may be missing");
|
suggest_insertion(
|
||||||
|
cx,
|
||||||
|
item,
|
||||||
|
&dox,
|
||||||
|
lint,
|
||||||
|
suggest_index,
|
||||||
|
'`',
|
||||||
|
"the closing backtick of an inline code may be missing",
|
||||||
|
);
|
||||||
help_emitted = true;
|
help_emitted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !help_emitted {
|
if !help_emitted {
|
||||||
lint.help("the opening or closing backtick of an inline code may be missing");
|
lint.help(
|
||||||
|
"the opening or closing backtick of an inline code may be missing",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
suggest_insertion(cx, item, &dox, lint, backtick_index, '\\', "if you meant to use a literal backtick, escape it");
|
suggest_insertion(
|
||||||
|
cx,
|
||||||
|
item,
|
||||||
|
&dox,
|
||||||
|
lint,
|
||||||
|
backtick_index,
|
||||||
|
'\\',
|
||||||
|
"if you meant to use a literal backtick, escape it",
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Event::Code(_) => {
|
Event::Code(_) => {
|
||||||
|
@ -61,7 +61,8 @@ fn docs_link(diag: &mut Diag<'_, ()>, lint: &'static Lint) {
|
|||||||
/// ```
|
/// ```
|
||||||
pub fn span_lint<T: LintContext>(cx: &T, lint: &'static Lint, sp: impl Into<MultiSpan>, msg: impl Into<DiagMessage>) {
|
pub fn span_lint<T: LintContext>(cx: &T, lint: &'static Lint, sp: impl Into<MultiSpan>, msg: impl Into<DiagMessage>) {
|
||||||
#[expect(clippy::disallowed_methods)]
|
#[expect(clippy::disallowed_methods)]
|
||||||
cx.span_lint(lint, sp, msg.into(), |diag| {
|
cx.span_lint(lint, sp, |diag| {
|
||||||
|
diag.primary_message(msg);
|
||||||
docs_link(diag, lint);
|
docs_link(diag, lint);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -109,7 +110,8 @@ pub fn span_lint_and_help<T: LintContext>(
|
|||||||
help: impl Into<SubdiagMessage>,
|
help: impl Into<SubdiagMessage>,
|
||||||
) {
|
) {
|
||||||
#[expect(clippy::disallowed_methods)]
|
#[expect(clippy::disallowed_methods)]
|
||||||
cx.span_lint(lint, span, msg.into(), |diag| {
|
cx.span_lint(lint, span, |diag| {
|
||||||
|
diag.primary_message(msg);
|
||||||
if let Some(help_span) = help_span {
|
if let Some(help_span) = help_span {
|
||||||
diag.span_help(help_span, help.into());
|
diag.span_help(help_span, help.into());
|
||||||
} else {
|
} else {
|
||||||
@ -165,7 +167,8 @@ pub fn span_lint_and_note<T: LintContext>(
|
|||||||
note: impl Into<SubdiagMessage>,
|
note: impl Into<SubdiagMessage>,
|
||||||
) {
|
) {
|
||||||
#[expect(clippy::disallowed_methods)]
|
#[expect(clippy::disallowed_methods)]
|
||||||
cx.span_lint(lint, span, msg.into(), |diag| {
|
cx.span_lint(lint, span, |diag| {
|
||||||
|
diag.primary_message(msg);
|
||||||
if let Some(note_span) = note_span {
|
if let Some(note_span) = note_span {
|
||||||
diag.span_note(note_span, note.into());
|
diag.span_note(note_span, note.into());
|
||||||
} else {
|
} else {
|
||||||
@ -201,7 +204,8 @@ where
|
|||||||
F: FnOnce(&mut Diag<'_, ()>),
|
F: FnOnce(&mut Diag<'_, ()>),
|
||||||
{
|
{
|
||||||
#[expect(clippy::disallowed_methods)]
|
#[expect(clippy::disallowed_methods)]
|
||||||
cx.span_lint(lint, sp, msg, |diag| {
|
cx.span_lint(lint, sp, |diag| {
|
||||||
|
diag.primary_message(msg);
|
||||||
f(diag);
|
f(diag);
|
||||||
docs_link(diag, lint);
|
docs_link(diag, lint);
|
||||||
});
|
});
|
||||||
@ -233,7 +237,8 @@ where
|
|||||||
/// the `#[allow]` will work.
|
/// the `#[allow]` will work.
|
||||||
pub fn span_lint_hir(cx: &LateContext<'_>, lint: &'static Lint, hir_id: HirId, sp: Span, msg: impl Into<DiagMessage>) {
|
pub fn span_lint_hir(cx: &LateContext<'_>, lint: &'static Lint, hir_id: HirId, sp: Span, msg: impl Into<DiagMessage>) {
|
||||||
#[expect(clippy::disallowed_methods)]
|
#[expect(clippy::disallowed_methods)]
|
||||||
cx.tcx.node_span_lint(lint, hir_id, sp, msg.into(), |diag| {
|
cx.tcx.node_span_lint(lint, hir_id, sp, |diag| {
|
||||||
|
diag.primary_message(msg);
|
||||||
docs_link(diag, lint);
|
docs_link(diag, lint);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -271,7 +276,8 @@ pub fn span_lint_hir_and_then(
|
|||||||
f: impl FnOnce(&mut Diag<'_, ()>),
|
f: impl FnOnce(&mut Diag<'_, ()>),
|
||||||
) {
|
) {
|
||||||
#[expect(clippy::disallowed_methods)]
|
#[expect(clippy::disallowed_methods)]
|
||||||
cx.tcx.node_span_lint(lint, hir_id, sp, msg.into(), |diag| {
|
cx.tcx.node_span_lint(lint, hir_id, sp, |diag| {
|
||||||
|
diag.primary_message(msg);
|
||||||
f(diag);
|
f(diag);
|
||||||
docs_link(diag, lint);
|
docs_link(diag, lint);
|
||||||
});
|
});
|
||||||
|
@ -11,11 +11,11 @@ use rustc_lint::{Lint, LintContext};
|
|||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
|
|
||||||
pub fn a(cx: impl LintContext, lint: &'static Lint, span: impl Into<MultiSpan>, msg: impl Into<DiagMessage>) {
|
pub fn a(cx: impl LintContext, lint: &'static Lint, span: impl Into<MultiSpan>, msg: impl Into<DiagMessage>) {
|
||||||
cx.span_lint(lint, span, msg, |_| {});
|
cx.span_lint(lint, span, |lint| { lint.primary_message(msg); });
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn b(tcx: TyCtxt<'_>, lint: &'static Lint, hir_id: HirId, span: impl Into<MultiSpan>, msg: impl Into<DiagMessage>) {
|
pub fn b(tcx: TyCtxt<'_>, lint: &'static Lint, hir_id: HirId, span: impl Into<MultiSpan>, msg: impl Into<DiagMessage>) {
|
||||||
tcx.node_span_lint(lint, hir_id, span, msg, |_| {});
|
tcx.node_span_lint(lint, hir_id, span, |lint| { lint.primary_message(msg); });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error: use of a disallowed method `rustc_lint::context::LintContext::span_lint`
|
error: use of a disallowed method `rustc_lint::context::LintContext::span_lint`
|
||||||
--> tests/ui-internal/disallow_span_lint.rs:14:5
|
--> tests/ui-internal/disallow_span_lint.rs:14:5
|
||||||
|
|
|
|
||||||
LL | cx.span_lint(lint, span, msg, |_| {});
|
LL | cx.span_lint(lint, span, |lint| { lint.primary_message(msg); });
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: this function does not add a link to our documentation, please use the `clippy_utils::diagnostics::span_lint*` functions instead (from clippy.toml)
|
= note: this function does not add a link to our documentation, please use the `clippy_utils::diagnostics::span_lint*` functions instead (from clippy.toml)
|
||||||
= note: `-D clippy::disallowed-methods` implied by `-D warnings`
|
= note: `-D clippy::disallowed-methods` implied by `-D warnings`
|
||||||
@ -11,8 +11,8 @@ LL | cx.span_lint(lint, span, msg, |_| {});
|
|||||||
error: use of a disallowed method `rustc_middle::ty::context::TyCtxt::node_span_lint`
|
error: use of a disallowed method `rustc_middle::ty::context::TyCtxt::node_span_lint`
|
||||||
--> tests/ui-internal/disallow_span_lint.rs:18:5
|
--> tests/ui-internal/disallow_span_lint.rs:18:5
|
||||||
|
|
|
|
||||||
LL | tcx.node_span_lint(lint, hir_id, span, msg, |_| {});
|
LL | tcx.node_span_lint(lint, hir_id, span, |lint| { lint.primary_message(msg); });
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: this function does not add a link to our documentation, please use the `clippy_utils::diagnostics::span_lint_hir*` functions instead (from clippy.toml)
|
= note: this function does not add a link to our documentation, please use the `clippy_utils::diagnostics::span_lint_hir*` functions instead (from clippy.toml)
|
||||||
|
|
||||||
|
@ -85,10 +85,6 @@ impl<'a> LintDiagnostic<'a, ()> for UntranslatableInLintDiagnostic {
|
|||||||
diag.note("untranslatable diagnostic");
|
diag.note("untranslatable diagnostic");
|
||||||
//~^ ERROR diagnostics should be created using translatable messages
|
//~^ ERROR diagnostics should be created using translatable messages
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> DiagMessage {
|
|
||||||
unreachable!();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TranslatableInLintDiagnostic;
|
pub struct TranslatableInLintDiagnostic;
|
||||||
@ -97,10 +93,6 @@ impl<'a> LintDiagnostic<'a, ()> for TranslatableInLintDiagnostic {
|
|||||||
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) {
|
||||||
diag.note(crate::fluent_generated::no_crate_note);
|
diag.note(crate::fluent_generated::no_crate_note);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn msg(&self) -> DiagMessage {
|
|
||||||
unreachable!();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn make_diagnostics<'a>(dcx: &'a DiagCtxt) {
|
pub fn make_diagnostics<'a>(dcx: &'a DiagCtxt) {
|
||||||
|
@ -23,7 +23,7 @@ LL | diag.note("untranslatable diagnostic");
|
|||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
||||||
error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
|
error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
|
||||||
--> $DIR/diagnostics.rs:107:21
|
--> $DIR/diagnostics.rs:99:21
|
||||||
|
|
|
|
||||||
LL | let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example);
|
LL | let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example);
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^
|
||||||
@ -35,13 +35,13 @@ LL | #![deny(rustc::diagnostic_outside_of_impl)]
|
|||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
|
error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
|
||||||
--> $DIR/diagnostics.rs:110:21
|
--> $DIR/diagnostics.rs:102:21
|
||||||
|
|
|
|
||||||
LL | let _diag = dcx.struct_err("untranslatable diagnostic");
|
LL | let _diag = dcx.struct_err("untranslatable diagnostic");
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^
|
||||||
|
|
||||||
error: diagnostics should be created using translatable messages
|
error: diagnostics should be created using translatable messages
|
||||||
--> $DIR/diagnostics.rs:110:21
|
--> $DIR/diagnostics.rs:102:21
|
||||||
|
|
|
|
||||||
LL | let _diag = dcx.struct_err("untranslatable diagnostic");
|
LL | let _diag = dcx.struct_err("untranslatable diagnostic");
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^
|
||||||
|
@ -603,7 +603,6 @@ struct LintAttributeOnSessionDiag {}
|
|||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[lint(no_crate_example, code = E0123)]
|
#[lint(no_crate_example, code = E0123)]
|
||||||
//~^ ERROR `#[lint(...)]` is not a valid attribute
|
//~^ ERROR `#[lint(...)]` is not a valid attribute
|
||||||
//~| ERROR `#[lint(...)]` is not a valid attribute
|
|
||||||
//~| ERROR diagnostic slug not specified
|
//~| ERROR diagnostic slug not specified
|
||||||
//~| ERROR cannot find attribute `lint` in this scope
|
//~| ERROR cannot find attribute `lint` in this scope
|
||||||
struct LintAttributeOnLintDiag {}
|
struct LintAttributeOnLintDiag {}
|
||||||
|
@ -378,14 +378,6 @@ error: `#[lint(...)]` is not a valid attribute
|
|||||||
LL | #[lint(no_crate_example, code = E0123)]
|
LL | #[lint(no_crate_example, code = E0123)]
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: `#[lint(...)]` is not a valid attribute
|
|
||||||
--> $DIR/diagnostic-derive.rs:604:1
|
|
||||||
|
|
|
||||||
LL | #[lint(no_crate_example, code = E0123)]
|
|
||||||
| ^
|
|
||||||
|
|
|
||||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
|
||||||
|
|
||||||
error: diagnostic slug not specified
|
error: diagnostic slug not specified
|
||||||
--> $DIR/diagnostic-derive.rs:604:1
|
--> $DIR/diagnostic-derive.rs:604:1
|
||||||
|
|
|
|
||||||
@ -395,19 +387,19 @@ LL | #[lint(no_crate_example, code = E0123)]
|
|||||||
= help: specify the slug as the first argument to the attribute, such as `#[diag(compiletest_example)]`
|
= help: specify the slug as the first argument to the attribute, such as `#[diag(compiletest_example)]`
|
||||||
|
|
||||||
error: specified multiple times
|
error: specified multiple times
|
||||||
--> $DIR/diagnostic-derive.rs:614:53
|
--> $DIR/diagnostic-derive.rs:613:53
|
||||||
|
|
|
|
||||||
LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")]
|
LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")]
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
|
||||||
note: previously specified here
|
note: previously specified here
|
||||||
--> $DIR/diagnostic-derive.rs:614:39
|
--> $DIR/diagnostic-derive.rs:613:39
|
||||||
|
|
|
|
||||||
LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")]
|
LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")]
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
||||||
error: wrong types for suggestion
|
error: wrong types for suggestion
|
||||||
--> $DIR/diagnostic-derive.rs:623:24
|
--> $DIR/diagnostic-derive.rs:622:24
|
||||||
|
|
|
|
||||||
LL | suggestion: (Span, usize),
|
LL | suggestion: (Span, usize),
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
@ -415,7 +407,7 @@ LL | suggestion: (Span, usize),
|
|||||||
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
|
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
|
||||||
|
|
||||||
error: wrong types for suggestion
|
error: wrong types for suggestion
|
||||||
--> $DIR/diagnostic-derive.rs:631:17
|
--> $DIR/diagnostic-derive.rs:630:17
|
||||||
|
|
|
|
||||||
LL | suggestion: (Span,),
|
LL | suggestion: (Span,),
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
@ -423,13 +415,13 @@ LL | suggestion: (Span,),
|
|||||||
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
|
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
|
||||||
|
|
||||||
error: suggestion without `code = "..."`
|
error: suggestion without `code = "..."`
|
||||||
--> $DIR/diagnostic-derive.rs:638:5
|
--> $DIR/diagnostic-derive.rs:637:5
|
||||||
|
|
|
|
||||||
LL | #[suggestion(no_crate_suggestion)]
|
LL | #[suggestion(no_crate_suggestion)]
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: `#[multipart_suggestion(...)]` is not a valid attribute
|
error: `#[multipart_suggestion(...)]` is not a valid attribute
|
||||||
--> $DIR/diagnostic-derive.rs:645:1
|
--> $DIR/diagnostic-derive.rs:644:1
|
||||||
|
|
|
|
||||||
LL | #[multipart_suggestion(no_crate_suggestion)]
|
LL | #[multipart_suggestion(no_crate_suggestion)]
|
||||||
| ^
|
| ^
|
||||||
@ -437,7 +429,7 @@ LL | #[multipart_suggestion(no_crate_suggestion)]
|
|||||||
= help: consider creating a `Subdiagnostic` instead
|
= help: consider creating a `Subdiagnostic` instead
|
||||||
|
|
||||||
error: `#[multipart_suggestion(...)]` is not a valid attribute
|
error: `#[multipart_suggestion(...)]` is not a valid attribute
|
||||||
--> $DIR/diagnostic-derive.rs:648:1
|
--> $DIR/diagnostic-derive.rs:647:1
|
||||||
|
|
|
|
||||||
LL | #[multipart_suggestion()]
|
LL | #[multipart_suggestion()]
|
||||||
| ^
|
| ^
|
||||||
@ -445,7 +437,7 @@ LL | #[multipart_suggestion()]
|
|||||||
= help: consider creating a `Subdiagnostic` instead
|
= help: consider creating a `Subdiagnostic` instead
|
||||||
|
|
||||||
error: `#[multipart_suggestion(...)]` is not a valid attribute
|
error: `#[multipart_suggestion(...)]` is not a valid attribute
|
||||||
--> $DIR/diagnostic-derive.rs:652:5
|
--> $DIR/diagnostic-derive.rs:651:5
|
||||||
|
|
|
|
||||||
LL | #[multipart_suggestion(no_crate_suggestion)]
|
LL | #[multipart_suggestion(no_crate_suggestion)]
|
||||||
| ^
|
| ^
|
||||||
@ -453,7 +445,7 @@ LL | #[multipart_suggestion(no_crate_suggestion)]
|
|||||||
= help: consider creating a `Subdiagnostic` instead
|
= help: consider creating a `Subdiagnostic` instead
|
||||||
|
|
||||||
error: `#[suggestion(...)]` is not a valid attribute
|
error: `#[suggestion(...)]` is not a valid attribute
|
||||||
--> $DIR/diagnostic-derive.rs:660:1
|
--> $DIR/diagnostic-derive.rs:659:1
|
||||||
|
|
|
|
||||||
LL | #[suggestion(no_crate_suggestion, code = "...")]
|
LL | #[suggestion(no_crate_suggestion, code = "...")]
|
||||||
| ^
|
| ^
|
||||||
@ -461,7 +453,7 @@ LL | #[suggestion(no_crate_suggestion, code = "...")]
|
|||||||
= help: `#[label]` and `#[suggestion]` can only be applied to fields
|
= help: `#[label]` and `#[suggestion]` can only be applied to fields
|
||||||
|
|
||||||
error: `#[label]` is not a valid attribute
|
error: `#[label]` is not a valid attribute
|
||||||
--> $DIR/diagnostic-derive.rs:669:1
|
--> $DIR/diagnostic-derive.rs:668:1
|
||||||
|
|
|
|
||||||
LL | #[label]
|
LL | #[label]
|
||||||
| ^
|
| ^
|
||||||
@ -469,61 +461,61 @@ LL | #[label]
|
|||||||
= help: `#[label]` and `#[suggestion]` can only be applied to fields
|
= help: `#[label]` and `#[suggestion]` can only be applied to fields
|
||||||
|
|
||||||
error: `#[subdiagnostic(...)]` is not a valid attribute
|
error: `#[subdiagnostic(...)]` is not a valid attribute
|
||||||
--> $DIR/diagnostic-derive.rs:703:5
|
--> $DIR/diagnostic-derive.rs:702:5
|
||||||
|
|
|
|
||||||
LL | #[subdiagnostic(bad)]
|
LL | #[subdiagnostic(bad)]
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: `#[subdiagnostic = ...]` is not a valid attribute
|
error: `#[subdiagnostic = ...]` is not a valid attribute
|
||||||
--> $DIR/diagnostic-derive.rs:711:5
|
--> $DIR/diagnostic-derive.rs:710:5
|
||||||
|
|
|
|
||||||
LL | #[subdiagnostic = "bad"]
|
LL | #[subdiagnostic = "bad"]
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: `#[subdiagnostic(...)]` is not a valid attribute
|
error: `#[subdiagnostic(...)]` is not a valid attribute
|
||||||
--> $DIR/diagnostic-derive.rs:719:5
|
--> $DIR/diagnostic-derive.rs:718:5
|
||||||
|
|
|
|
||||||
LL | #[subdiagnostic(bad, bad)]
|
LL | #[subdiagnostic(bad, bad)]
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: `#[subdiagnostic(...)]` is not a valid attribute
|
error: `#[subdiagnostic(...)]` is not a valid attribute
|
||||||
--> $DIR/diagnostic-derive.rs:727:5
|
--> $DIR/diagnostic-derive.rs:726:5
|
||||||
|
|
|
|
||||||
LL | #[subdiagnostic("bad")]
|
LL | #[subdiagnostic("bad")]
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: `#[subdiagnostic(...)]` is not a valid attribute
|
error: `#[subdiagnostic(...)]` is not a valid attribute
|
||||||
--> $DIR/diagnostic-derive.rs:735:5
|
--> $DIR/diagnostic-derive.rs:734:5
|
||||||
|
|
|
|
||||||
LL | #[subdiagnostic(eager)]
|
LL | #[subdiagnostic(eager)]
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: `#[subdiagnostic(...)]` is not a valid attribute
|
error: `#[subdiagnostic(...)]` is not a valid attribute
|
||||||
--> $DIR/diagnostic-derive.rs:743:5
|
--> $DIR/diagnostic-derive.rs:742:5
|
||||||
|
|
|
|
||||||
LL | #[subdiagnostic(eager)]
|
LL | #[subdiagnostic(eager)]
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: `#[subdiagnostic(...)]` is not a valid attribute
|
error: `#[subdiagnostic(...)]` is not a valid attribute
|
||||||
--> $DIR/diagnostic-derive.rs:764:5
|
--> $DIR/diagnostic-derive.rs:763:5
|
||||||
|
|
|
|
||||||
LL | #[subdiagnostic(eager)]
|
LL | #[subdiagnostic(eager)]
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: expected at least one string literal for `code(...)`
|
error: expected at least one string literal for `code(...)`
|
||||||
--> $DIR/diagnostic-derive.rs:795:23
|
--> $DIR/diagnostic-derive.rs:794:23
|
||||||
|
|
|
|
||||||
LL | #[suggestion(code())]
|
LL | #[suggestion(code())]
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: `code(...)` must contain only string literals
|
error: `code(...)` must contain only string literals
|
||||||
--> $DIR/diagnostic-derive.rs:803:23
|
--> $DIR/diagnostic-derive.rs:802:23
|
||||||
|
|
|
|
||||||
LL | #[suggestion(code(foo))]
|
LL | #[suggestion(code(foo))]
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: `#[suggestion(...)]` is not a valid attribute
|
error: `#[suggestion(...)]` is not a valid attribute
|
||||||
--> $DIR/diagnostic-derive.rs:827:5
|
--> $DIR/diagnostic-derive.rs:826:5
|
||||||
|
|
|
|
||||||
LL | #[suggestion(no_crate_suggestion, code = "")]
|
LL | #[suggestion(no_crate_suggestion, code = "")]
|
||||||
| ^
|
| ^
|
||||||
@ -539,13 +531,13 @@ LL | #[diag = "E0123"]
|
|||||||
| ^ maybe a missing crate `core`?
|
| ^ maybe a missing crate `core`?
|
||||||
|
|
||||||
error[E0433]: failed to resolve: maybe a missing crate `core`?
|
error[E0433]: failed to resolve: maybe a missing crate `core`?
|
||||||
--> $DIR/diagnostic-derive.rs:803:23
|
--> $DIR/diagnostic-derive.rs:802:23
|
||||||
|
|
|
|
||||||
LL | #[suggestion(code(foo))]
|
LL | #[suggestion(code(foo))]
|
||||||
| ^^^ maybe a missing crate `core`?
|
| ^^^ maybe a missing crate `core`?
|
||||||
|
|
||||||
error[E0433]: failed to resolve: maybe a missing crate `core`?
|
error[E0433]: failed to resolve: maybe a missing crate `core`?
|
||||||
--> $DIR/diagnostic-derive.rs:812:25
|
--> $DIR/diagnostic-derive.rs:811:25
|
||||||
|
|
|
|
||||||
LL | #[suggestion(code = 3)]
|
LL | #[suggestion(code = 3)]
|
||||||
| ^ maybe a missing crate `core`?
|
| ^ maybe a missing crate `core`?
|
||||||
@ -587,19 +579,19 @@ LL | #[lint(no_crate_example, code = E0123)]
|
|||||||
| ^^^^ help: a built-in attribute with a similar name exists: `link`
|
| ^^^^ help: a built-in attribute with a similar name exists: `link`
|
||||||
|
|
||||||
error: cannot find attribute `multipart_suggestion` in this scope
|
error: cannot find attribute `multipart_suggestion` in this scope
|
||||||
--> $DIR/diagnostic-derive.rs:645:3
|
--> $DIR/diagnostic-derive.rs:644:3
|
||||||
|
|
|
|
||||||
LL | #[multipart_suggestion(no_crate_suggestion)]
|
LL | #[multipart_suggestion(no_crate_suggestion)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: cannot find attribute `multipart_suggestion` in this scope
|
error: cannot find attribute `multipart_suggestion` in this scope
|
||||||
--> $DIR/diagnostic-derive.rs:648:3
|
--> $DIR/diagnostic-derive.rs:647:3
|
||||||
|
|
|
|
||||||
LL | #[multipart_suggestion()]
|
LL | #[multipart_suggestion()]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: cannot find attribute `multipart_suggestion` in this scope
|
error: cannot find attribute `multipart_suggestion` in this scope
|
||||||
--> $DIR/diagnostic-derive.rs:652:7
|
--> $DIR/diagnostic-derive.rs:651:7
|
||||||
|
|
|
|
||||||
LL | #[multipart_suggestion(no_crate_suggestion)]
|
LL | #[multipart_suggestion(no_crate_suggestion)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
@ -611,7 +603,7 @@ LL | #[diag(nonsense, code = E0123)]
|
|||||||
| ^^^^^^^^ not found in `crate::fluent_generated`
|
| ^^^^^^^^ not found in `crate::fluent_generated`
|
||||||
|
|
||||||
error[E0425]: cannot find value `__code_34` in this scope
|
error[E0425]: cannot find value `__code_34` in this scope
|
||||||
--> $DIR/diagnostic-derive.rs:809:10
|
--> $DIR/diagnostic-derive.rs:808:10
|
||||||
|
|
|
|
||||||
LL | #[derive(Diagnostic)]
|
LL | #[derive(Diagnostic)]
|
||||||
| ^^^^^^^^^^ not found in this scope
|
| ^^^^^^^^^^ not found in this scope
|
||||||
@ -632,7 +624,7 @@ note: required by a bound in `Diag::<'a, G>::arg`
|
|||||||
--> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC
|
--> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC
|
||||||
= note: this error originates in the macro `with_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `with_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: aborting due to 86 previous errors
|
error: aborting due to 85 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0277, E0425, E0433.
|
Some errors have detailed explanations: E0277, E0425, E0433.
|
||||||
For more information about an error, try `rustc --explain E0277`.
|
For more information about an error, try `rustc --explain E0277`.
|
||||||
|
Loading…
Reference in New Issue
Block a user