Skip to content

Commit

Permalink
Rename LintContext::emit_spanned_lint as `LintContext::emit_span_li…
Browse files Browse the repository at this point in the history
…nt`.
  • Loading branch information
nnethercote committed Jan 22, 2024
1 parent c915e90 commit 1881bfa
Show file tree
Hide file tree
Showing 27 changed files with 112 additions and 128 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/array_into_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter {
} else {
None
};
cx.emit_spanned_lint(
cx.emit_span_lint(
ARRAY_INTO_ITER,
call.ident.span,
ArrayIntoIterDiag { target, suggestion: call.ident.span, sub },
Expand Down
60 changes: 30 additions & 30 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl EarlyLintPass for WhileTrue {
"{}loop",
label.map_or_else(String::new, |label| format!("{}: ", label.ident,))
);
cx.emit_spanned_lint(
cx.emit_span_lint(
WHILE_TRUE,
condition_span,
BuiltinWhileTrue { suggestion: condition_span, replace },
Expand Down Expand Up @@ -162,7 +162,7 @@ impl BoxPointers {
if let GenericArgKind::Type(leaf_ty) = leaf.unpack()
&& leaf_ty.is_box()
{
cx.emit_spanned_lint(BOX_POINTERS, span, BuiltinBoxPointers { ty });
cx.emit_span_lint(BOX_POINTERS, span, BuiltinBoxPointers { ty });
}
}
}
Expand Down Expand Up @@ -265,7 +265,7 @@ impl<'tcx> LateLintPass<'tcx> for NonShorthandFieldPatterns {
if cx.tcx.find_field_index(ident, variant)
== Some(cx.typeck_results().field_index(fieldpat.hir_id))
{
cx.emit_spanned_lint(
cx.emit_span_lint(
NON_SHORTHAND_FIELD_PATTERNS,
fieldpat.span,
BuiltinNonShorthandFieldPatterns {
Expand Down Expand Up @@ -334,7 +334,7 @@ impl UnsafeCode {
return;
}

cx.emit_spanned_lint(UNSAFE_CODE, span, decorate);
cx.emit_span_lint(UNSAFE_CODE, span, decorate);
}
}

Expand Down Expand Up @@ -509,7 +509,7 @@ impl MissingDoc {
let attrs = cx.tcx.hir().attrs(cx.tcx.local_def_id_to_hir_id(def_id));
let has_doc = attrs.iter().any(has_doc);
if !has_doc {
cx.emit_spanned_lint(
cx.emit_span_lint(
MISSING_DOCS,
cx.tcx.def_span(def_id),
BuiltinMissingDoc { article, desc },
Expand Down Expand Up @@ -710,7 +710,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingCopyImplementations {
)
.is_ok()
{
cx.emit_spanned_lint(MISSING_COPY_IMPLEMENTATIONS, item.span, BuiltinMissingCopyImpl);
cx.emit_span_lint(MISSING_COPY_IMPLEMENTATIONS, item.span, BuiltinMissingCopyImpl);
}
}
}
Expand Down Expand Up @@ -795,7 +795,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDebugImplementations {
.next()
.is_some();
if !has_impl {
cx.emit_spanned_lint(
cx.emit_span_lint(
MISSING_DEBUG_IMPLEMENTATIONS,
item.span,
BuiltinMissingDebugImpl { tcx: cx.tcx, def_id: debug },
Expand Down Expand Up @@ -874,7 +874,7 @@ impl EarlyLintPass for AnonymousParameters {
} else {
("<type>", Applicability::HasPlaceholders)
};
cx.emit_spanned_lint(
cx.emit_span_lint(
ANONYMOUS_PARAMETERS,
arg.pat.span,
BuiltinAnonymousParams { suggestion: (arg.pat.span, appl), ty_snip },
Expand Down Expand Up @@ -921,7 +921,7 @@ impl EarlyLintPass for DeprecatedAttr {
BuiltinDeprecatedAttrLinkSuggestion::Default { suggestion: attr.span }
}
};
cx.emit_spanned_lint(
cx.emit_span_lint(
DEPRECATED,
attr.span,
BuiltinDeprecatedAttrLink { name, reason, link, suggestion },
Expand All @@ -931,7 +931,7 @@ impl EarlyLintPass for DeprecatedAttr {
}
}
if attr.has_name(sym::no_start) || attr.has_name(sym::crate_id) {
cx.emit_spanned_lint(
cx.emit_span_lint(
DEPRECATED,
attr.span,
BuiltinDeprecatedAttrUsed {
Expand Down Expand Up @@ -973,7 +973,7 @@ fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: &
BuiltinUnusedDocCommentSub::BlockHelp
}
};
cx.emit_spanned_lint(
cx.emit_span_lint(
UNUSED_DOC_COMMENTS,
span,
BuiltinUnusedDocComment { kind: node_kind, label: node_span, sub },
Expand Down Expand Up @@ -1107,7 +1107,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems {
match param.kind {
GenericParamKind::Lifetime { .. } => {}
GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => {
cx.emit_spanned_lint(
cx.emit_span_lint(
NO_MANGLE_GENERIC_ITEMS,
span,
BuiltinNoMangleGeneric { suggestion: no_mangle_attr.span },
Expand Down Expand Up @@ -1138,7 +1138,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems {

// Const items do not refer to a particular location in memory, and therefore
// don't have anything to attach a symbol to
cx.emit_spanned_lint(
cx.emit_span_lint(
NO_MANGLE_CONST_ITEMS,
it.span,
BuiltinConstNoMangle { suggestion },
Expand Down Expand Up @@ -1201,7 +1201,7 @@ impl<'tcx> LateLintPass<'tcx> for MutableTransmutes {
get_transmute_from_to(cx, expr).map(|(ty1, ty2)| (ty1.kind(), ty2.kind()))
{
if from_mutbl < to_mutbl {
cx.emit_spanned_lint(MUTABLE_TRANSMUTES, expr.span, BuiltinMutablesTransmutes);
cx.emit_span_lint(MUTABLE_TRANSMUTES, expr.span, BuiltinMutablesTransmutes);
}
}

Expand Down Expand Up @@ -1270,7 +1270,7 @@ impl<'tcx> LateLintPass<'tcx> for UnstableFeatures {
&& let Some(items) = attr.meta_item_list()
{
for item in items {
cx.emit_spanned_lint(UNSTABLE_FEATURES, item.span(), BuiltinUnstableFeatures);
cx.emit_span_lint(UNSTABLE_FEATURES, item.span(), BuiltinUnstableFeatures);
}
}
}
Expand Down Expand Up @@ -1323,7 +1323,7 @@ impl<'tcx> LateLintPass<'tcx> for UngatedAsyncFnTrackCaller {
// Now, check if the function has the `#[track_caller]` attribute
&& let Some(attr) = cx.tcx.get_attr(def_id, sym::track_caller)
{
cx.emit_spanned_lint(
cx.emit_span_lint(
UNGATED_ASYNC_FN_TRACK_CALLER,
attr.span,
BuiltinUngatedAsyncFnTrackCaller { label: span, session: &cx.tcx.sess },
Expand Down Expand Up @@ -1389,7 +1389,7 @@ impl UnreachablePub {
applicability = Applicability::MaybeIncorrect;
}
let def_span = cx.tcx.def_span(def_id);
cx.emit_spanned_lint(
cx.emit_span_lint(
UNREACHABLE_PUB,
def_span,
BuiltinUnreachablePub {
Expand Down Expand Up @@ -1518,7 +1518,7 @@ impl<'tcx> LateLintPass<'tcx> for TypeAliasBounds {
suggested_changing_assoc_types = true;
SuggestChangingAssocTypes { ty: hir_ty }
});
cx.emit_spanned_lint(
cx.emit_span_lint(
TYPE_ALIAS_BOUNDS,
where_spans,
BuiltinTypeAliasWhereClause {
Expand All @@ -1534,7 +1534,7 @@ impl<'tcx> LateLintPass<'tcx> for TypeAliasBounds {
suggested_changing_assoc_types = true;
SuggestChangingAssocTypes { ty: hir_ty }
});
cx.emit_spanned_lint(
cx.emit_span_lint(
TYPE_ALIAS_BOUNDS,
inline_spans,
BuiltinTypeAliasGenericBounds { suggestion, sub },
Expand Down Expand Up @@ -1633,7 +1633,7 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
| ClauseKind::ConstEvaluatable(..) => continue,
};
if predicate.is_global() {
cx.emit_spanned_lint(
cx.emit_span_lint(
TRIVIAL_BOUNDS,
span,
BuiltinTrivialBounds { predicate_kind_name, predicate },
Expand Down Expand Up @@ -1751,7 +1751,7 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
replace,
});
} else {
cx.emit_spanned_lint(
cx.emit_span_lint(
ELLIPSIS_INCLUSIVE_RANGE_PATTERNS,
pat.span,
BuiltinEllipsisInclusiveRangePatternsLint::Parenthesise {
Expand All @@ -1769,7 +1769,7 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
replace: replace.to_string(),
});
} else {
cx.emit_spanned_lint(
cx.emit_span_lint(
ELLIPSIS_INCLUSIVE_RANGE_PATTERNS,
join,
BuiltinEllipsisInclusiveRangePatternsLint::NonParenthesise {
Expand Down Expand Up @@ -1895,7 +1895,7 @@ impl KeywordIdents {
return;
}

cx.emit_spanned_lint(
cx.emit_span_lint(
KEYWORD_IDENTS,
ident.span,
BuiltinKeywordIdents { kw: ident, next: next_edition, suggestion: ident.span },
Expand Down Expand Up @@ -2203,7 +2203,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
lint_spans.sort_unstable();
lint_spans.dedup();

cx.emit_spanned_lint(
cx.emit_span_lint(
EXPLICIT_OUTLIVES_REQUIREMENTS,
lint_spans.clone(),
BuiltinExplicitOutlives {
Expand Down Expand Up @@ -2290,13 +2290,13 @@ impl EarlyLintPass for IncompleteInternalFeatures {
let help =
HAS_MIN_FEATURES.contains(&name).then_some(BuiltinIncompleteFeaturesHelp);

cx.emit_spanned_lint(
cx.emit_span_lint(
INCOMPLETE_FEATURES,
span,
BuiltinIncompleteFeatures { name, note, help },
);
} else {
cx.emit_spanned_lint(INTERNAL_FEATURES, span, BuiltinInternalFeatures { name });
cx.emit_span_lint(INTERNAL_FEATURES, span, BuiltinInternalFeatures { name });
}
});
}
Expand Down Expand Up @@ -2612,7 +2612,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue {
InitKind::Uninit => fluent::lint_builtin_unpermitted_type_init_uninit,
};
let sub = BuiltinUnpermittedTypeInitSub { err };
cx.emit_spanned_lint(
cx.emit_span_lint(
INVALID_VALUE,
expr.span,
BuiltinUnpermittedTypeInit {
Expand Down Expand Up @@ -2700,7 +2700,7 @@ impl<'tcx> LateLintPass<'tcx> for DerefNullPtr {

if let rustc_hir::ExprKind::Unary(rustc_hir::UnOp::Deref, expr_deref) = expr.kind {
if is_null_ptr(cx, expr_deref) {
cx.emit_spanned_lint(
cx.emit_span_lint(
DEREF_NULLPTR,
expr.span,
BuiltinDerefNullptr { label: expr.span },
Expand Down Expand Up @@ -2925,12 +2925,12 @@ impl EarlyLintPass for SpecialModuleName {
}

match item.ident.name.as_str() {
"lib" => cx.emit_spanned_lint(
"lib" => cx.emit_span_lint(
SPECIAL_MODULE_NAME,
item.span,
BuiltinSpecialModuleNameUsed::Lib,
),
"main" => cx.emit_spanned_lint(
"main" => cx.emit_span_lint(
SPECIAL_MODULE_NAME,
item.span,
BuiltinSpecialModuleNameUsed::Main,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ pub trait LintContext {

/// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`,
/// typically generated by `#[derive(LintDiagnostic)]`).
fn emit_spanned_lint<S: Into<MultiSpan>>(
fn emit_span_lint<S: Into<MultiSpan>>(
&self,
lint: &'static Lint,
span: S,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/deref_into_dyn_supertrait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<'tcx> LateLintPass<'tcx> for DerefIntoDynSupertrait {
.find_map(|i| (i.ident.name == sym::Target).then_some(i.span))
.map(|label| SupertraitAsDerefTargetLabel { label });
let span = tcx.def_span(item.owner_id.def_id);
cx.emit_spanned_lint(
cx.emit_span_lint(
DEREF_INTO_DYN_SUPERTRAIT,
span,
SupertraitAsDerefTarget {
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_lint/src/drop_forget_useless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,28 +149,28 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless {
let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr);
match fn_name {
sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => {
cx.emit_spanned_lint(
cx.emit_span_lint(
DROPPING_REFERENCES,
expr.span,
DropRefDiag { arg_ty, label: arg.span },
);
}
sym::mem_forget if arg_ty.is_ref() => {
cx.emit_spanned_lint(
cx.emit_span_lint(
FORGETTING_REFERENCES,
expr.span,
ForgetRefDiag { arg_ty, label: arg.span },
);
}
sym::mem_drop if is_copy && !drop_is_single_call_in_arm => {
cx.emit_spanned_lint(
cx.emit_span_lint(
DROPPING_COPY_TYPES,
expr.span,
DropCopyDiag { arg_ty, label: arg.span },
);
}
sym::mem_forget if is_copy => {
cx.emit_spanned_lint(
cx.emit_span_lint(
FORGETTING_COPY_TYPES,
expr.span,
ForgetCopyDiag { arg_ty, label: arg.span },
Expand All @@ -180,7 +180,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless {
if let ty::Adt(adt, _) = arg_ty.kind()
&& adt.is_manually_drop() =>
{
cx.emit_spanned_lint(
cx.emit_span_lint(
UNDROPPED_MANUALLY_DROPS,
expr.span,
UndroppedManuallyDropsDiag {
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_lint/src/enum_intrinsics_non_enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn enforce_mem_discriminant(
) {
let ty_param = cx.typeck_results().node_args(func_expr.hir_id).type_at(0);
if is_non_enum(ty_param) {
cx.emit_spanned_lint(
cx.emit_span_lint(
ENUM_INTRINSICS_NON_ENUMS,
expr_span,
EnumIntrinsicsMemDiscriminate { ty_param, note: args_span },
Expand All @@ -64,11 +64,7 @@ fn enforce_mem_discriminant(
fn enforce_mem_variant_count(cx: &LateContext<'_>, func_expr: &hir::Expr<'_>, span: Span) {
let ty_param = cx.typeck_results().node_args(func_expr.hir_id).type_at(0);
if is_non_enum(ty_param) {
cx.emit_spanned_lint(
ENUM_INTRINSICS_NON_ENUMS,
span,
EnumIntrinsicsMemVariant { ty_param },
);
cx.emit_span_lint(ENUM_INTRINSICS_NON_ENUMS, span, EnumIntrinsicsMemVariant { ty_param });
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/for_loops_over_fallibles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopsOverFallibles {
end_span: pat.span.between(arg.span),
};

cx.emit_spanned_lint(
cx.emit_span_lint(
FOR_LOOPS_OVER_FALLIBLES,
arg.span,
ForLoopsOverFalliblesDiag { article, ty, sub, question_mark, suggestion },
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/hidden_unicode_codepoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl HiddenUnicodeCodepoints {
HiddenUnicodeCodepointsDiagSub::NoEscape { spans }
};

cx.emit_spanned_lint(
cx.emit_span_lint(
TEXT_DIRECTION_CODEPOINT_IN_LITERAL,
span,
HiddenUnicodeCodepointsDiag { label, count, span_label: span, labels, sub },
Expand Down
Loading

0 comments on commit 1881bfa

Please sign in to comment.