Rename buffer_lint_with_diagnostic to buffer_lint

This commit is contained in:
Xiretza 2024-05-20 17:47:54 +00:00
parent c4f6502c6d
commit 98dd6c7e8f
28 changed files with 57 additions and 57 deletions

View File

@ -765,7 +765,7 @@ fn maybe_lint_missing_abi(&mut self, span: Span, id: NodeId) {
.span_to_snippet(span)
.is_ok_and(|snippet| !snippet.starts_with("#["))
{
self.lint_buffer.buffer_lint_with_diagnostic(
self.lint_buffer.buffer_lint(
MISSING_ABI,
id,
span,
@ -1426,7 +1426,7 @@ fn visit_fn(&mut self, fk: FnKind<'a>, span: Span, id: NodeId) {
Self::check_decl_no_pat(&sig.decl, |span, ident, mut_ident| {
if mut_ident && matches!(ctxt, FnCtxt::Assoc(_)) {
if let Some(ident) = ident {
self.lint_buffer.buffer_lint_with_diagnostic(
self.lint_buffer.buffer_lint(
PATTERNS_IN_FNS_WITHOUT_BODY,
id,
span,
@ -1506,7 +1506,7 @@ fn visit_assoc_item(&mut self, item: &'a AssocItem, ctxt: AssocCtxt) {
Some((right, snippet))
}
};
self.lint_buffer.buffer_lint_with_diagnostic(
self.lint_buffer.buffer_lint(
DEPRECATED_WHERE_CLAUSE_LOCATION,
item.id,
err.span,

View File

@ -528,7 +528,7 @@ pub fn cfg_matches(
try_gate_cfg(cfg.name, cfg.span, sess, features);
match sess.psess.check_config.expecteds.get(&cfg.name) {
Some(ExpectedValues::Some(values)) if !values.contains(&cfg.value) => {
sess.psess.buffer_lint_with_diagnostic(
sess.psess.buffer_lint(
UNEXPECTED_CFGS,
cfg.span,
lint_node_id,
@ -539,7 +539,7 @@ pub fn cfg_matches(
);
}
None if sess.psess.check_config.exhaustive_names => {
sess.psess.buffer_lint_with_diagnostic(
sess.psess.buffer_lint(
UNEXPECTED_CFGS,
cfg.span,
lint_node_id,

View File

@ -510,7 +510,7 @@ fn expand_preparsed_asm(
};
if template_str.contains(".intel_syntax") {
ecx.psess().buffer_lint_with_diagnostic(
ecx.psess().buffer_lint(
lint::builtin::BAD_ASM_STYLE,
find_span(".intel_syntax"),
ecx.current_expansion.lint_node_id,
@ -518,7 +518,7 @@ fn expand_preparsed_asm(
);
}
if template_str.contains(".att_syntax") {
ecx.psess().buffer_lint_with_diagnostic(
ecx.psess().buffer_lint(
lint::builtin::BAD_ASM_STYLE,
find_span(".att_syntax"),
ecx.current_expansion.lint_node_id,

View File

@ -1621,7 +1621,7 @@ fn create_struct_field_access_fields(
};
if let Some(ty) = exception {
cx.sess.psess.buffer_lint_with_diagnostic(
cx.sess.psess.buffer_lint(
BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE,
sp,
ast::CRATE_NODE_ID,

View File

@ -144,7 +144,7 @@ impl<'a> MacResult for ExpandInclude<'a> {
fn make_expr(mut self: Box<ExpandInclude<'a>>) -> Option<P<ast::Expr>> {
let expr = parse_expr(&mut self.p).ok()?;
if self.p.token != token::Eof {
self.p.psess.buffer_lint_with_diagnostic(
self.p.psess.buffer_lint(
INCOMPLETE_INCLUDE,
self.p.token.span,
self.node_id,

View File

@ -160,7 +160,7 @@ struct InnerItemLinter<'a> {
impl<'a> Visitor<'a> for InnerItemLinter<'_> {
fn visit_item(&mut self, i: &'a ast::Item) {
if let Some(attr) = attr::find_by_name(&i.attrs, sym::rustc_test_marker) {
self.sess.psess.buffer_lint_with_diagnostic(
self.sess.psess.buffer_lint(
UNNAMEABLE_TEST_ITEMS,
attr.span,
i.id,

View File

@ -42,7 +42,7 @@ pub(crate) fn warn_on_duplicate_attribute(ecx: &ExtCtxt<'_>, item: &Annotatable,
};
if let Some(attrs) = attrs {
if let Some(attr) = attr::find_by_name(attrs, name) {
ecx.psess().buffer_lint_with_diagnostic(
ecx.psess().buffer_lint(
DUPLICATE_MACRO_ATTRIBUTES,
attr.span,
ecx.current_expansion.lint_node_id,

View File

@ -1364,7 +1364,7 @@ fn pretty_printing_compatibility_hack(item: &Item, sess: &Session) -> bool {
};
if crate_matches {
sess.psess.buffer_lint_with_diagnostic(
sess.psess.buffer_lint(
PROC_MACRO_BACK_COMPAT,
item.ident.span,
ast::CRATE_NODE_ID,

View File

@ -258,7 +258,7 @@ pub(crate) fn expand_cfg_attr(&self, attr: &Attribute, recursive: bool) -> Vec<A
// Lint on zero attributes in source.
if expanded_attrs.is_empty() {
self.sess.psess.buffer_lint_with_diagnostic(
self.sess.psess.buffer_lint(
rustc_lint_defs::builtin::UNUSED_ATTRIBUTES,
attr.span,
ast::CRATE_NODE_ID,
@ -341,7 +341,7 @@ fn expand_cfg_attr_item(
item_span,
);
if attr.has_name(sym::crate_type) {
self.sess.psess.buffer_lint_with_diagnostic(
self.sess.psess.buffer_lint(
rustc_lint_defs::builtin::DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME,
attr.span,
ast::CRATE_NODE_ID,
@ -349,7 +349,7 @@ fn expand_cfg_attr_item(
);
}
if attr.has_name(sym::crate_name) {
self.sess.psess.buffer_lint_with_diagnostic(
self.sess.psess.buffer_lint(
rustc_lint_defs::builtin::DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME,
attr.span,
ast::CRATE_NODE_ID,

View File

@ -1799,7 +1799,7 @@ fn check_attributes(&self, attrs: &[ast::Attribute], call: &ast::MacCall) {
}
if attr.is_doc_comment() {
self.cx.sess.psess.buffer_lint_with_diagnostic(
self.cx.sess.psess.buffer_lint(
UNUSED_DOC_COMMENTS,
current_span,
self.cx.current_expansion.lint_node_id,
@ -1810,7 +1810,7 @@ fn check_attributes(&self, attrs: &[ast::Attribute], call: &ast::MacCall) {
// `#[cfg]` and `#[cfg_attr]` are special - they are
// eagerly evaluated.
if attr_name != sym::cfg && attr_name != sym::cfg_attr {
self.cx.sess.psess.buffer_lint_with_diagnostic(
self.cx.sess.psess.buffer_lint(
UNUSED_ATTRIBUTES,
attr.span,
self.cx.current_expansion.lint_node_id,

View File

@ -268,7 +268,7 @@ fn check_binders(
// FIXME: Report this as a hard error eventually and remove equivalent errors from
// `parse_tt_inner` and `nameize`. Until then the error may be reported twice, once
// as a hard error and then once as a buffered lint.
psess.buffer_lint_with_diagnostic(
psess.buffer_lint(
MISSING_FRAGMENT_SPECIFIER,
span,
node_id,
@ -646,6 +646,6 @@ fn ops_is_prefix(
fn buffer_lint(psess: &ParseSess, span: MultiSpan, node_id: NodeId, diag: BuiltinLintDiag) {
// Macros loaded from other crates have dummy node ids.
if node_id != DUMMY_NODE_ID {
psess.buffer_lint_with_diagnostic(META_VARIABLE_MISUSE, span, node_id, diag);
psess.buffer_lint(META_VARIABLE_MISUSE, span, node_id, diag);
}
}

View File

@ -79,7 +79,7 @@ pub(crate) fn make(mut self: Box<ParserAnyMacro<'a>>, kind: AstFragmentKind) ->
// but `m!()` is allowed in expression positions (cf. issue #34706).
if kind == AstFragmentKind::Expr && parser.token == token::Semi {
if is_local {
parser.psess.buffer_lint_with_diagnostic(
parser.psess.buffer_lint(
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
parser.token.span,
lint_node_id,
@ -1153,7 +1153,7 @@ fn check_matcher_core<'tt>(
name,
Some(NonterminalKind::PatParam { inferred: false }),
));
sess.psess.buffer_lint_with_diagnostic(
sess.psess.buffer_lint(
RUST_2021_INCOMPATIBLE_OR_PATTERNS,
span,
ast::CRATE_NODE_ID,

View File

@ -404,7 +404,7 @@ pub(crate) fn check_attr_crate_type(
n,
None,
);
lint_buffer.buffer_lint_with_diagnostic(
lint_buffer.buffer_lint(
lint::builtin::UNKNOWN_CRATE_TYPES,
ast::CRATE_NODE_ID,
span,

View File

@ -784,7 +784,7 @@ pub fn take(&mut self, id: NodeId) -> Vec<BufferedEarlyLint> {
self.map.swap_remove(&id).unwrap_or_default()
}
pub fn buffer_lint_with_diagnostic(
pub fn buffer_lint(
&mut self,
lint: &'static Lint,
id: NodeId,

View File

@ -974,7 +974,7 @@ fn report_unused_deps(&mut self, krate: &ast::Crate) {
continue;
}
self.sess.psess.buffer_lint_with_diagnostic(
self.sess.psess.buffer_lint(
lint::builtin::UNUSED_CRATE_DEPENDENCIES,
span,
ast::CRATE_NODE_ID,
@ -1015,7 +1015,7 @@ fn report_future_incompatible_deps(&self, krate: &ast::Crate) {
// Make a point span rather than covering the whole file
let span = krate.spans.inner_span.shrink_to_lo();
self.sess.psess.buffer_lint_with_diagnostic(
self.sess.psess.buffer_lint(
lint::builtin::WASM_C_ABI,
span,
ast::CRATE_NODE_ID,

View File

@ -220,7 +220,7 @@ pub fn early_report_macro_deprecation(
path,
since_kind: deprecated_since_kind(is_in_effect, depr.since.clone()),
};
lint_buffer.buffer_lint_with_diagnostic(deprecation_lint(is_in_effect), node_id, span, diag);
lint_buffer.buffer_lint(deprecation_lint(is_in_effect), node_id, span, diag);
}
fn late_report_deprecation(

View File

@ -370,7 +370,7 @@ fn lint_unicode_text_flow(&self, start: BytePos) {
let content = self.str_from(content_start);
if contains_text_flow_control_chars(content) {
let span = self.mk_sp(start, self.pos);
self.psess.buffer_lint_with_diagnostic(
self.psess.buffer_lint(
TEXT_DIRECTION_CODEPOINT_IN_COMMENT,
span,
ast::CRATE_NODE_ID,
@ -722,7 +722,7 @@ fn report_unknown_prefix(&self, start: BytePos) {
self.dcx().emit_err(errors::UnknownPrefix { span: prefix_span, prefix, sugg });
} else {
// Before Rust 2021, only emit a lint for migration.
self.psess.buffer_lint_with_diagnostic(
self.psess.buffer_lint(
RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX,
prefix_span,
ast::CRATE_NODE_ID,

View File

@ -1913,7 +1913,7 @@ fn parse_expr_break(&mut self) -> PResult<'a, P<Expr>> {
| ExprKind::Block(_, None)
)
{
self.psess.buffer_lint_with_diagnostic(
self.psess.buffer_lint(
BREAK_WITH_LABEL_AND_LOOP,
lo.to(expr.span),
ast::CRATE_NODE_ID,

View File

@ -189,7 +189,7 @@ fn emit_malformed_attribute(
suggestions.push(format!("#{inner}[{name} = \"{descr}\"]"));
}
if should_warn(name) {
psess.buffer_lint_with_diagnostic(
psess.buffer_lint(
ILL_FORMED_ATTRIBUTE_INPUT,
span,
ast::CRATE_NODE_ID,

View File

@ -151,7 +151,7 @@ fn report_unused_extern_crate_items(
// We do this in any edition.
if warn_if_unused {
if let Some(&span) = maybe_unused_extern_crates.get(&extern_crate.id) {
self.r.lint_buffer.buffer_lint_with_diagnostic(
self.r.lint_buffer.buffer_lint(
UNUSED_EXTERN_CRATES,
extern_crate.id,
span,
@ -203,7 +203,7 @@ fn report_unused_extern_crate_items(
.span
.find_ancestor_inside(extern_crate.span)
.unwrap_or(extern_crate.ident.span);
self.r.lint_buffer.buffer_lint_with_diagnostic(
self.r.lint_buffer.buffer_lint(
UNUSED_EXTERN_CRATES,
extern_crate.id,
extern_crate.span,
@ -388,7 +388,7 @@ pub(crate) fn check_unused(&mut self, krate: &ast::Crate) {
{
if let ImportKind::MacroUse { .. } = import.kind {
if !import.span.is_dummy() {
self.lint_buffer.buffer_lint_with_diagnostic(
self.lint_buffer.buffer_lint(
MACRO_USE_EXTERN_CRATE,
import.root_id,
import.span,
@ -409,7 +409,7 @@ pub(crate) fn check_unused(&mut self, krate: &ast::Crate) {
}
}
ImportKind::MacroUse { .. } => {
self.lint_buffer.buffer_lint_with_diagnostic(
self.lint_buffer.buffer_lint(
UNUSED_IMPORTS,
import.root_id,
import.span,
@ -477,7 +477,7 @@ pub(crate) fn check_unused(&mut self, krate: &ast::Crate) {
}
};
visitor.r.lint_buffer.buffer_lint_with_diagnostic(
visitor.r.lint_buffer.buffer_lint(
UNUSED_IMPORTS,
unused.use_tree_id,
ms,
@ -533,7 +533,7 @@ pub(crate) fn check_unused(&mut self, krate: &ast::Crate) {
continue;
}
self.lint_buffer.buffer_lint_with_diagnostic(
self.lint_buffer.buffer_lint(
UNUSED_QUALIFICATIONS,
unn_qua.node_id,
unn_qua.path_span,

View File

@ -128,7 +128,7 @@ pub(crate) fn report_errors(&mut self, krate: &Crate) {
self.report_with_use_injections(krate);
for &(span_use, span_def) in &self.macro_expanded_macro_export_errors {
self.lint_buffer.buffer_lint_with_diagnostic(
self.lint_buffer.buffer_lint(
MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
CRATE_NODE_ID,
span_use,
@ -142,7 +142,7 @@ pub(crate) fn report_errors(&mut self, krate: &Crate) {
let NameBindingKind::Import { import, .. } = ambiguity_error.b1.0.kind else {
unreachable!()
};
self.lint_buffer.buffer_lint_with_diagnostic(
self.lint_buffer.buffer_lint(
AMBIGUOUS_GLOB_IMPORTS,
import.root_id,
ambiguity_error.ident.span,
@ -522,7 +522,7 @@ pub(crate) fn lint_if_path_starts_with_module(
}
let diag = BuiltinLintDiag::AbsPathWithModule(root_span);
self.lint_buffer.buffer_lint_with_diagnostic(
self.lint_buffer.buffer_lint(
ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
node_id,
root_span,

View File

@ -524,7 +524,7 @@ struct Flags: u8 {
match binding {
Ok(binding) => {
if let Some(lint_id) = derive_fallback_lint_id {
this.lint_buffer.buffer_lint_with_diagnostic(
this.lint_buffer.buffer_lint(
PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
lint_id,
orig_ident.span,

View File

@ -619,7 +619,7 @@ pub(crate) fn check_hidden_glob_reexports(
&& binding.res() != Res::Err
&& exported_ambiguities.contains(&binding)
{
self.lint_buffer.buffer_lint_with_diagnostic(
self.lint_buffer.buffer_lint(
AMBIGUOUS_GLOB_REEXPORTS,
import.root_id,
import.root_span,
@ -654,7 +654,7 @@ pub(crate) fn check_hidden_glob_reexports(
&& glob_binding.vis.is_public()
&& !binding.vis.is_public()
{
self.lint_buffer.buffer_lint_with_diagnostic(
self.lint_buffer.buffer_lint(
HIDDEN_GLOB_REEXPORTS,
binding_id,
binding.span,
@ -1013,7 +1013,7 @@ fn finalize_import(&mut self, import: Import<'a>) -> Option<UnresolvedImportErro
&& !max_vis.is_at_least(import_vis, self.tcx)
{
let def_id = self.local_def_id(id);
self.lint_buffer.buffer_lint_with_diagnostic(
self.lint_buffer.buffer_lint(
UNUSED_IMPORTS,
id,
import.span,
@ -1246,7 +1246,7 @@ fn finalize_import(&mut self, import: Import<'a>) -> Option<UnresolvedImportErro
if !any_successful_reexport {
let (ns, binding) = reexport_error.unwrap();
if pub_use_of_private_extern_crate_hack(import, binding) {
self.lint_buffer.buffer_lint_with_diagnostic(
self.lint_buffer.buffer_lint(
PUB_USE_OF_PRIVATE_EXTERN_CRATE,
import_id,
import.span,

View File

@ -1675,7 +1675,7 @@ fn resolve_anonymous_lifetime(&mut self, lifetime: &Lifetime, elided: bool) {
return;
}
LifetimeRibKind::AnonymousWarn(node_id) => {
self.r.lint_buffer.buffer_lint_with_diagnostic(
self.r.lint_buffer.buffer_lint(
lint::builtin::ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT,
node_id,
lifetime.ident.span,
@ -1960,7 +1960,7 @@ fn resolve_elided_lifetimes_in_path(
}
if should_lint {
self.r.lint_buffer.buffer_lint_with_diagnostic(
self.r.lint_buffer.buffer_lint(
lint::builtin::ELIDED_LIFETIMES_IN_PATHS,
segment_id,
elided_lifetime_span,
@ -4815,7 +4815,7 @@ pub(crate) fn late_resolve_crate(&mut self, krate: &Crate) {
late_resolution_visitor.resolve_doc_links(&krate.attrs, MaybeExported::Ok(CRATE_NODE_ID));
visit::walk_crate(&mut late_resolution_visitor, krate);
for (id, span) in late_resolution_visitor.diag_metadata.unused_labels.iter() {
self.lint_buffer.buffer_lint_with_diagnostic(
self.lint_buffer.buffer_lint(
lint::builtin::UNUSED_LABELS,
*id,
*span,

View File

@ -2651,7 +2651,7 @@ pub(crate) fn maybe_report_lifetime_uses(
let deletion_span =
if param.bounds.is_empty() { deletion_span() } else { None };
self.r.lint_buffer.buffer_lint_with_diagnostic(
self.r.lint_buffer.buffer_lint(
lint::builtin::SINGLE_USE_LIFETIMES,
param.id,
param.ident.span,
@ -2669,7 +2669,7 @@ pub(crate) fn maybe_report_lifetime_uses(
// if the lifetime originates from expanded code, we won't be able to remove it #104432
if deletion_span.is_some_and(|sp| !sp.in_derive_expansion()) {
self.r.lint_buffer.buffer_lint_with_diagnostic(
self.r.lint_buffer.buffer_lint(
lint::builtin::UNUSED_LIFETIMES,
param.id,
param.ident.span,

View File

@ -1860,7 +1860,7 @@ fn record_use_inner(
}
if let NameBindingKind::Import { import, binding } = used_binding.kind {
if let ImportKind::MacroUse { warn_private: true } = import.kind {
self.lint_buffer().buffer_lint_with_diagnostic(
self.lint_buffer().buffer_lint(
PRIVATE_MACRO_USE,
import.root_id,
ident.span,

View File

@ -311,7 +311,7 @@ fn record_macro_rule_usage(&mut self, id: NodeId, rule_i: usize) {
fn check_unused_macros(&mut self) {
for (_, &(node_id, ident)) in self.unused_macros.iter() {
self.lint_buffer.buffer_lint_with_diagnostic(
self.lint_buffer.buffer_lint(
UNUSED_MACROS,
node_id,
ident.span,
@ -324,7 +324,7 @@ fn check_unused_macros(&mut self) {
continue;
}
let node_id = self.def_id_to_node_id[def_id];
self.lint_buffer.buffer_lint_with_diagnostic(
self.lint_buffer.buffer_lint(
UNUSED_MACRO_RULES,
node_id,
rule_span,
@ -558,7 +558,7 @@ fn smart_resolve_macro_path(
_ => unreachable!(),
};
if soft_custom_inner_attributes_gate {
self.tcx.sess.psess.buffer_lint_with_diagnostic(
self.tcx.sess.psess.buffer_lint(
SOFT_UNSTABLE,
path.span,
node_id,
@ -585,7 +585,7 @@ fn smart_resolve_macro_path(
let typo_name = distance.map(|_| sym::on_unimplemented);
self.tcx.sess.psess.buffer_lint_with_diagnostic(
self.tcx.sess.psess.buffer_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
attribute.span(),
node_id,
@ -789,7 +789,7 @@ pub(crate) fn finalize_macro_resolutions(&mut self, krate: &Crate) {
.invocation_parents
.get(&parent_scope.expansion)
.map_or(ast::CRATE_NODE_ID, |id| self.def_id_to_node_id[id.0]);
self.lint_buffer.buffer_lint_with_diagnostic(
self.lint_buffer.buffer_lint(
LEGACY_DERIVE_HELPERS,
node_id,
ident.span,
@ -843,7 +843,7 @@ fn check_stability_and_deprecation(
if !is_allowed(feature) && !allowed_by_implication {
let lint_buffer = &mut self.lint_buffer;
let soft_handler = |lint, span, msg: String| {
lint_buffer.buffer_lint_with_diagnostic(
lint_buffer.buffer_lint(
lint,
node_id,
span,

View File

@ -300,7 +300,7 @@ pub fn clone_source_map(&self) -> Lrc<SourceMap> {
self.source_map.clone()
}
pub fn buffer_lint_with_diagnostic(
pub fn buffer_lint(
&self,
lint: &'static Lint,
span: impl Into<MultiSpan>,