mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Migrate resolver over to internal lint buffer
This commit is contained in:
parent
1bd6b48914
commit
bb0c930f82
@ -646,6 +646,27 @@ impl LintBuffer {
|
|||||||
fn take(&mut self, id: ast::NodeId) -> Vec<BufferedEarlyLint> {
|
fn take(&mut self, id: ast::NodeId) -> Vec<BufferedEarlyLint> {
|
||||||
self.map.remove(&id).unwrap_or_default()
|
self.map.remove(&id).unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn buffer_lint<S: Into<MultiSpan>>(
|
||||||
|
&mut self,
|
||||||
|
lint: &'static Lint,
|
||||||
|
id: ast::NodeId,
|
||||||
|
sp: S,
|
||||||
|
msg: &str,
|
||||||
|
) {
|
||||||
|
self.add_lint(lint, id, sp.into(), msg, BuiltinLintDiagnostics::Normal)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn buffer_lint_with_diagnostic<S: Into<MultiSpan>>(
|
||||||
|
&mut self,
|
||||||
|
lint: &'static Lint,
|
||||||
|
id: ast::NodeId,
|
||||||
|
sp: S,
|
||||||
|
msg: &str,
|
||||||
|
diagnostic: BuiltinLintDiagnostics,
|
||||||
|
) {
|
||||||
|
self.add_lint(lint, id, sp.into(), msg, diagnostic)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn struct_lint_level<'a>(sess: &'a Session,
|
pub fn struct_lint_level<'a>(sess: &'a Session,
|
||||||
|
@ -586,7 +586,7 @@ pub fn rustc_deprecation_message(depr: &RustcDeprecation, path: &str) -> (String
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn early_report_deprecation(
|
pub fn early_report_deprecation(
|
||||||
sess: &Session,
|
lint_buffer: &'a mut lint::LintBuffer,
|
||||||
message: &str,
|
message: &str,
|
||||||
suggestion: Option<Symbol>,
|
suggestion: Option<Symbol>,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
@ -597,7 +597,7 @@ pub fn early_report_deprecation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let diag = BuiltinLintDiagnostics::DeprecatedMacro(suggestion, span);
|
let diag = BuiltinLintDiagnostics::DeprecatedMacro(suggestion, span);
|
||||||
sess.buffer_lint_with_diagnostic(lint, CRATE_NODE_ID, span, message, diag);
|
lint_buffer.buffer_lint_with_diagnostic(lint, CRATE_NODE_ID, span, message, diag);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn late_report_deprecation(
|
fn late_report_deprecation(
|
||||||
|
@ -270,12 +270,14 @@ fn configure_and_expand_inner<'a>(
|
|||||||
rustc_lint::BuiltinCombinedPreExpansionLintPass::new());
|
rustc_lint::BuiltinCombinedPreExpansionLintPass::new());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let lint_buffer = lint::LintBuffer::default();
|
||||||
let mut resolver = Resolver::new(
|
let mut resolver = Resolver::new(
|
||||||
sess,
|
sess,
|
||||||
&krate,
|
&krate,
|
||||||
crate_name,
|
crate_name,
|
||||||
metadata_loader,
|
metadata_loader,
|
||||||
&resolver_arenas,
|
&resolver_arenas,
|
||||||
|
lint_buffer,
|
||||||
);
|
);
|
||||||
syntax_ext::register_builtin_macros(&mut resolver, sess.edition());
|
syntax_ext::register_builtin_macros(&mut resolver, sess.edition());
|
||||||
|
|
||||||
@ -366,7 +368,7 @@ fn configure_and_expand_inner<'a>(
|
|||||||
for span in missing_fragment_specifiers {
|
for span in missing_fragment_specifiers {
|
||||||
let lint = lint::builtin::MISSING_FRAGMENT_SPECIFIER;
|
let lint = lint::builtin::MISSING_FRAGMENT_SPECIFIER;
|
||||||
let msg = "missing fragment specifier";
|
let msg = "missing fragment specifier";
|
||||||
sess.buffer_lint(lint, ast::CRATE_NODE_ID, span, msg);
|
resolver.lint_buffer.buffer_lint(lint, ast::CRATE_NODE_ID, span, msg);
|
||||||
}
|
}
|
||||||
if cfg!(windows) {
|
if cfg!(windows) {
|
||||||
env::set_var("PATH", &old_path);
|
env::set_var("PATH", &old_path);
|
||||||
@ -395,7 +397,7 @@ fn configure_and_expand_inner<'a>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let has_proc_macro_decls = time(sess, "AST validation", || {
|
let has_proc_macro_decls = time(sess, "AST validation", || {
|
||||||
ast_validation::check_crate(sess, &krate)
|
ast_validation::check_crate(sess, &krate, &mut resolver.lint_buffer)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -464,7 +466,7 @@ fn configure_and_expand_inner<'a>(
|
|||||||
info!("{} parse sess buffered_lints", buffered_lints.len());
|
info!("{} parse sess buffered_lints", buffered_lints.len());
|
||||||
for BufferedEarlyLint{id, span, msg, lint_id} in buffered_lints.drain(..) {
|
for BufferedEarlyLint{id, span, msg, lint_id} in buffered_lints.drain(..) {
|
||||||
let lint = lint::Lint::from_parser_lint_id(lint_id);
|
let lint = lint::Lint::from_parser_lint_id(lint_id);
|
||||||
sess.buffer_lint(lint, id, span, &msg);
|
resolver.lint_buffer.buffer_lint(lint, id, span, &msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -73,6 +73,8 @@ struct AstValidator<'a> {
|
|||||||
/// these booleans.
|
/// these booleans.
|
||||||
warning_period_57979_didnt_record_next_impl_trait: bool,
|
warning_period_57979_didnt_record_next_impl_trait: bool,
|
||||||
warning_period_57979_impl_trait_in_proj: bool,
|
warning_period_57979_impl_trait_in_proj: bool,
|
||||||
|
|
||||||
|
lint_buffer: &'a mut lint::LintBuffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> AstValidator<'a> {
|
impl<'a> AstValidator<'a> {
|
||||||
@ -229,7 +231,7 @@ impl<'a> AstValidator<'a> {
|
|||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_decl_no_pat<ReportFn: Fn(Span, bool)>(&self, decl: &FnDecl, report_err: ReportFn) {
|
fn check_decl_no_pat<F: FnMut(Span, bool)>(decl: &FnDecl, mut report_err: F) {
|
||||||
for arg in &decl.inputs {
|
for arg in &decl.inputs {
|
||||||
match arg.pat.kind {
|
match arg.pat.kind {
|
||||||
PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), _, None) |
|
PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), _, None) |
|
||||||
@ -460,7 +462,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||||||
match ty.kind {
|
match ty.kind {
|
||||||
TyKind::BareFn(ref bfty) => {
|
TyKind::BareFn(ref bfty) => {
|
||||||
self.check_fn_decl(&bfty.decl);
|
self.check_fn_decl(&bfty.decl);
|
||||||
self.check_decl_no_pat(&bfty.decl, |span, _| {
|
Self::check_decl_no_pat(&bfty.decl, |span, _| {
|
||||||
struct_span_err!(self.session, span, E0561,
|
struct_span_err!(self.session, span, E0561,
|
||||||
"patterns aren't allowed in function pointer types").emit();
|
"patterns aren't allowed in function pointer types").emit();
|
||||||
});
|
});
|
||||||
@ -483,7 +485,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||||||
TyKind::ImplTrait(_, ref bounds) => {
|
TyKind::ImplTrait(_, ref bounds) => {
|
||||||
if self.is_impl_trait_banned {
|
if self.is_impl_trait_banned {
|
||||||
if self.warning_period_57979_impl_trait_in_proj {
|
if self.warning_period_57979_impl_trait_in_proj {
|
||||||
self.session.buffer_lint(
|
self.lint_buffer.buffer_lint(
|
||||||
NESTED_IMPL_TRAIT, ty.id, ty.span,
|
NESTED_IMPL_TRAIT, ty.id, ty.span,
|
||||||
"`impl Trait` is not allowed in path parameters");
|
"`impl Trait` is not allowed in path parameters");
|
||||||
} else {
|
} else {
|
||||||
@ -494,7 +496,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||||||
|
|
||||||
if let Some(outer_impl_trait) = self.outer_impl_trait {
|
if let Some(outer_impl_trait) = self.outer_impl_trait {
|
||||||
if outer_impl_trait.should_warn_instead_of_error() {
|
if outer_impl_trait.should_warn_instead_of_error() {
|
||||||
self.session.buffer_lint_with_diagnostic(
|
self.lint_buffer.buffer_lint_with_diagnostic(
|
||||||
NESTED_IMPL_TRAIT, ty.id, ty.span,
|
NESTED_IMPL_TRAIT, ty.id, ty.span,
|
||||||
"nested `impl Trait` is not allowed",
|
"nested `impl Trait` is not allowed",
|
||||||
BuiltinLintDiagnostics::NestedImplTrait {
|
BuiltinLintDiagnostics::NestedImplTrait {
|
||||||
@ -634,9 +636,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||||||
self.check_trait_fn_not_async(trait_item.span, sig.header.asyncness.node);
|
self.check_trait_fn_not_async(trait_item.span, sig.header.asyncness.node);
|
||||||
self.check_trait_fn_not_const(sig.header.constness);
|
self.check_trait_fn_not_const(sig.header.constness);
|
||||||
if block.is_none() {
|
if block.is_none() {
|
||||||
self.check_decl_no_pat(&sig.decl, |span, mut_ident| {
|
Self::check_decl_no_pat(&sig.decl, |span, mut_ident| {
|
||||||
if mut_ident {
|
if mut_ident {
|
||||||
self.session.buffer_lint(
|
self.lint_buffer.buffer_lint(
|
||||||
lint::builtin::PATTERNS_IN_FNS_WITHOUT_BODY,
|
lint::builtin::PATTERNS_IN_FNS_WITHOUT_BODY,
|
||||||
trait_item.id, span,
|
trait_item.id, span,
|
||||||
"patterns aren't allowed in methods without bodies");
|
"patterns aren't allowed in methods without bodies");
|
||||||
@ -655,7 +657,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||||||
if attr::contains_name(&item.attrs, sym::warn_directory_ownership) {
|
if attr::contains_name(&item.attrs, sym::warn_directory_ownership) {
|
||||||
let lint = lint::builtin::LEGACY_DIRECTORY_OWNERSHIP;
|
let lint = lint::builtin::LEGACY_DIRECTORY_OWNERSHIP;
|
||||||
let msg = "cannot declare a new module at this location";
|
let msg = "cannot declare a new module at this location";
|
||||||
self.session.buffer_lint(lint, item.id, item.span, msg);
|
self.lint_buffer.buffer_lint(lint, item.id, item.span, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ItemKind::Union(ref vdata, _) => {
|
ItemKind::Union(ref vdata, _) => {
|
||||||
@ -686,7 +688,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||||||
match fi.kind {
|
match fi.kind {
|
||||||
ForeignItemKind::Fn(ref decl, _) => {
|
ForeignItemKind::Fn(ref decl, _) => {
|
||||||
self.check_fn_decl(decl);
|
self.check_fn_decl(decl);
|
||||||
self.check_decl_no_pat(decl, |span, _| {
|
Self::check_decl_no_pat(decl, |span, _| {
|
||||||
struct_span_err!(self.session, span, E0130,
|
struct_span_err!(self.session, span, E0130,
|
||||||
"patterns aren't allowed in foreign function declarations")
|
"patterns aren't allowed in foreign function declarations")
|
||||||
.span_label(span, "pattern not allowed in foreign function").emit();
|
.span_label(span, "pattern not allowed in foreign function").emit();
|
||||||
@ -840,7 +842,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_crate(session: &Session, krate: &Crate) -> bool {
|
pub fn check_crate(session: &Session, krate: &Crate, lints: &mut lint::LintBuffer) -> bool {
|
||||||
let mut validator = AstValidator {
|
let mut validator = AstValidator {
|
||||||
session,
|
session,
|
||||||
has_proc_macro_decls: false,
|
has_proc_macro_decls: false,
|
||||||
@ -849,6 +851,7 @@ pub fn check_crate(session: &Session, krate: &Crate) -> bool {
|
|||||||
is_assoc_ty_bound_banned: false,
|
is_assoc_ty_bound_banned: false,
|
||||||
warning_period_57979_didnt_record_next_impl_trait: false,
|
warning_period_57979_didnt_record_next_impl_trait: false,
|
||||||
warning_period_57979_impl_trait_in_proj: false,
|
warning_period_57979_impl_trait_in_proj: false,
|
||||||
|
lint_buffer: lints,
|
||||||
};
|
};
|
||||||
visit::walk_crate(&mut validator, krate);
|
visit::walk_crate(&mut validator, krate);
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ impl Resolver<'_> {
|
|||||||
directive.span.is_dummy() => {
|
directive.span.is_dummy() => {
|
||||||
if let ImportDirectiveSubclass::MacroUse = directive.subclass {
|
if let ImportDirectiveSubclass::MacroUse = directive.subclass {
|
||||||
if !directive.span.is_dummy() {
|
if !directive.span.is_dummy() {
|
||||||
self.session.buffer_lint(
|
self.lint_buffer.buffer_lint(
|
||||||
lint::builtin::MACRO_USE_EXTERN_CRATE,
|
lint::builtin::MACRO_USE_EXTERN_CRATE,
|
||||||
directive.id,
|
directive.id,
|
||||||
directive.span,
|
directive.span,
|
||||||
@ -250,7 +250,7 @@ impl Resolver<'_> {
|
|||||||
ImportDirectiveSubclass::MacroUse => {
|
ImportDirectiveSubclass::MacroUse => {
|
||||||
let lint = lint::builtin::UNUSED_IMPORTS;
|
let lint = lint::builtin::UNUSED_IMPORTS;
|
||||||
let msg = "unused `#[macro_use]` import";
|
let msg = "unused `#[macro_use]` import";
|
||||||
self.session.buffer_lint(lint, directive.id, directive.span, msg);
|
self.lint_buffer.buffer_lint(lint, directive.id, directive.span, msg);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@ -312,7 +312,7 @@ impl Resolver<'_> {
|
|||||||
"remove the unused import"
|
"remove the unused import"
|
||||||
};
|
};
|
||||||
|
|
||||||
visitor.r.session.buffer_lint_with_diagnostic(
|
visitor.r.lint_buffer.buffer_lint_with_diagnostic(
|
||||||
lint::builtin::UNUSED_IMPORTS,
|
lint::builtin::UNUSED_IMPORTS,
|
||||||
unused.use_tree_id,
|
unused.use_tree_id,
|
||||||
ms,
|
ms,
|
||||||
|
@ -1548,7 +1548,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
|||||||
if is_expected(ctor_res) &&
|
if is_expected(ctor_res) &&
|
||||||
self.r.is_accessible_from(ctor_vis, self.parent_scope.module) {
|
self.r.is_accessible_from(ctor_vis, self.parent_scope.module) {
|
||||||
let lint = lint::builtin::LEGACY_CONSTRUCTOR_VISIBILITY;
|
let lint = lint::builtin::LEGACY_CONSTRUCTOR_VISIBILITY;
|
||||||
self.r.session.buffer_lint(lint, id, span,
|
self.r.lint_buffer.buffer_lint(lint, id, span,
|
||||||
"private struct constructors are not usable through \
|
"private struct constructors are not usable through \
|
||||||
re-exports in outer modules",
|
re-exports in outer modules",
|
||||||
);
|
);
|
||||||
@ -1774,7 +1774,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
|||||||
};
|
};
|
||||||
if result.base_res() == unqualified_result {
|
if result.base_res() == unqualified_result {
|
||||||
let lint = lint::builtin::UNUSED_QUALIFICATIONS;
|
let lint = lint::builtin::UNUSED_QUALIFICATIONS;
|
||||||
self.r.session.buffer_lint(lint, id, span, "unnecessary qualification")
|
self.r.lint_buffer.buffer_lint(lint, id, span, "unnecessary qualification")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2111,7 +2111,7 @@ impl<'a> Resolver<'a> {
|
|||||||
let mut late_resolution_visitor = LateResolutionVisitor::new(self);
|
let mut late_resolution_visitor = LateResolutionVisitor::new(self);
|
||||||
visit::walk_crate(&mut late_resolution_visitor, krate);
|
visit::walk_crate(&mut late_resolution_visitor, krate);
|
||||||
for (id, span) in late_resolution_visitor.diagnostic_metadata.unused_labels.iter() {
|
for (id, span) in late_resolution_visitor.diagnostic_metadata.unused_labels.iter() {
|
||||||
self.session.buffer_lint(lint::builtin::UNUSED_LABELS, *id, *span, "unused label");
|
self.lint_buffer.buffer_lint(lint::builtin::UNUSED_LABELS, *id, *span, "unused label");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -962,6 +962,8 @@ pub struct Resolver<'a> {
|
|||||||
/// Stores enum visibilities to properly build a reduced graph
|
/// Stores enum visibilities to properly build a reduced graph
|
||||||
/// when visiting the correspondent variants.
|
/// when visiting the correspondent variants.
|
||||||
variant_vis: DefIdMap<ty::Visibility>,
|
variant_vis: DefIdMap<ty::Visibility>,
|
||||||
|
|
||||||
|
pub lint_buffer: lint::LintBuffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Nothing really interesting here; it just provides memory for the rest of the crate.
|
/// Nothing really interesting here; it just provides memory for the rest of the crate.
|
||||||
@ -1088,7 +1090,8 @@ impl<'a> Resolver<'a> {
|
|||||||
krate: &Crate,
|
krate: &Crate,
|
||||||
crate_name: &str,
|
crate_name: &str,
|
||||||
metadata_loader: &'a MetadataLoaderDyn,
|
metadata_loader: &'a MetadataLoaderDyn,
|
||||||
arenas: &'a ResolverArenas<'a>)
|
arenas: &'a ResolverArenas<'a>,
|
||||||
|
lint_buffer: lint::LintBuffer)
|
||||||
-> Resolver<'a> {
|
-> Resolver<'a> {
|
||||||
let root_def_id = DefId::local(CRATE_DEF_INDEX);
|
let root_def_id = DefId::local(CRATE_DEF_INDEX);
|
||||||
let root_module_kind = ModuleKind::Def(
|
let root_module_kind = ModuleKind::Def(
|
||||||
@ -1227,7 +1230,8 @@ impl<'a> Resolver<'a> {
|
|||||||
features.declared_lib_features.iter().map(|(feat, ..)| *feat)
|
features.declared_lib_features.iter().map(|(feat, ..)| *feat)
|
||||||
.chain(features.declared_lang_features.iter().map(|(feat, ..)| *feat))
|
.chain(features.declared_lang_features.iter().map(|(feat, ..)| *feat))
|
||||||
.collect(),
|
.collect(),
|
||||||
variant_vis: Default::default()
|
variant_vis: Default::default(),
|
||||||
|
lint_buffer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1653,7 +1657,7 @@ impl<'a> Resolver<'a> {
|
|||||||
match result {
|
match result {
|
||||||
Ok(binding) => {
|
Ok(binding) => {
|
||||||
if let Some(node_id) = poisoned {
|
if let Some(node_id) = poisoned {
|
||||||
self.session.buffer_lint_with_diagnostic(
|
self.lint_buffer.buffer_lint_with_diagnostic(
|
||||||
lint::builtin::PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
|
lint::builtin::PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
|
||||||
node_id, ident.span,
|
node_id, ident.span,
|
||||||
&format!("cannot find {} `{}` in this scope", ns.descr(), ident),
|
&format!("cannot find {} `{}` in this scope", ns.descr(), ident),
|
||||||
@ -2118,7 +2122,7 @@ impl<'a> Resolver<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn lint_if_path_starts_with_module(
|
fn lint_if_path_starts_with_module(
|
||||||
&self,
|
&mut self,
|
||||||
crate_lint: CrateLint,
|
crate_lint: CrateLint,
|
||||||
path: &[Segment],
|
path: &[Segment],
|
||||||
path_span: Span,
|
path_span: Span,
|
||||||
@ -2169,7 +2173,7 @@ impl<'a> Resolver<'a> {
|
|||||||
|
|
||||||
let diag = lint::builtin::BuiltinLintDiagnostics
|
let diag = lint::builtin::BuiltinLintDiagnostics
|
||||||
::AbsPathWithModule(diag_span);
|
::AbsPathWithModule(diag_span);
|
||||||
self.session.buffer_lint_with_diagnostic(
|
self.lint_buffer.buffer_lint_with_diagnostic(
|
||||||
lint::builtin::ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
|
lint::builtin::ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
|
||||||
diag_id, diag_span,
|
diag_id, diag_span,
|
||||||
"absolute paths must start with `self`, `super`, \
|
"absolute paths must start with `self`, `super`, \
|
||||||
@ -2419,7 +2423,7 @@ impl<'a> Resolver<'a> {
|
|||||||
for &(span_use, span_def) in &self.macro_expanded_macro_export_errors {
|
for &(span_use, span_def) in &self.macro_expanded_macro_export_errors {
|
||||||
let msg = "macro-expanded `macro_export` macros from the current crate \
|
let msg = "macro-expanded `macro_export` macros from the current crate \
|
||||||
cannot be referred to by absolute paths";
|
cannot be referred to by absolute paths";
|
||||||
self.session.buffer_lint_with_diagnostic(
|
self.lint_buffer.buffer_lint_with_diagnostic(
|
||||||
lint::builtin::MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
|
lint::builtin::MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
|
||||||
CRATE_NODE_ID, span_use, msg,
|
CRATE_NODE_ID, span_use, msg,
|
||||||
lint::builtin::BuiltinLintDiagnostics::
|
lint::builtin::BuiltinLintDiagnostics::
|
||||||
|
@ -247,9 +247,9 @@ impl<'a> base::Resolver for Resolver<'a> {
|
|||||||
Ok(InvocationRes::Single(ext))
|
Ok(InvocationRes::Single(ext))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_unused_macros(&self) {
|
fn check_unused_macros(&mut self) {
|
||||||
for (&node_id, &span) in self.unused_macros.iter() {
|
for (&node_id, &span) in self.unused_macros.iter() {
|
||||||
self.session.buffer_lint(
|
self.lint_buffer.buffer_lint(
|
||||||
lint::builtin::UNUSED_MACROS, node_id, span, "unused macro definition"
|
lint::builtin::UNUSED_MACROS, node_id, span, "unused macro definition"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -789,15 +789,17 @@ impl<'a> Resolver<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_stability_and_deprecation(&self, ext: &SyntaxExtension, path: &ast::Path) {
|
fn check_stability_and_deprecation(&mut self, ext: &SyntaxExtension, path: &ast::Path) {
|
||||||
let span = path.span;
|
let span = path.span;
|
||||||
if let Some(stability) = &ext.stability {
|
if let Some(stability) = &ext.stability {
|
||||||
if let StabilityLevel::Unstable { reason, issue, is_soft } = stability.level {
|
if let StabilityLevel::Unstable { reason, issue, is_soft } = stability.level {
|
||||||
let feature = stability.feature;
|
let feature = stability.feature;
|
||||||
if !self.active_features.contains(&feature) && !span.allows_unstable(feature) {
|
if !self.active_features.contains(&feature) && !span.allows_unstable(feature) {
|
||||||
let node_id = ast::CRATE_NODE_ID;
|
let node_id = ast::CRATE_NODE_ID;
|
||||||
let soft_handler =
|
let lint_buffer = &mut self.lint_buffer;
|
||||||
|lint, span, msg: &_| self.session.buffer_lint(lint, node_id, span, msg);
|
let soft_handler = |lint, span, msg: &_| {
|
||||||
|
lint_buffer.buffer_lint(lint, node_id, span, msg)
|
||||||
|
};
|
||||||
stability::report_unstable(
|
stability::report_unstable(
|
||||||
self.session, feature, reason, issue, is_soft, span, soft_handler
|
self.session, feature, reason, issue, is_soft, span, soft_handler
|
||||||
);
|
);
|
||||||
@ -807,14 +809,14 @@ impl<'a> Resolver<'a> {
|
|||||||
let path = pprust::path_to_string(path);
|
let path = pprust::path_to_string(path);
|
||||||
let (message, lint) = stability::rustc_deprecation_message(depr, &path);
|
let (message, lint) = stability::rustc_deprecation_message(depr, &path);
|
||||||
stability::early_report_deprecation(
|
stability::early_report_deprecation(
|
||||||
self.session, &message, depr.suggestion, lint, span
|
&mut self.lint_buffer, &message, depr.suggestion, lint, span
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(depr) = &ext.deprecation {
|
if let Some(depr) = &ext.deprecation {
|
||||||
let path = pprust::path_to_string(&path);
|
let path = pprust::path_to_string(&path);
|
||||||
let (message, lint) = stability::deprecation_message(depr, &path);
|
let (message, lint) = stability::deprecation_message(depr, &path);
|
||||||
stability::early_report_deprecation(self.session, &message, None, lint, span);
|
stability::early_report_deprecation(&mut self.lint_buffer, &message, None, lint, span);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,7 +496,7 @@ impl<'a> Resolver<'a> {
|
|||||||
if let (&NameBindingKind::Res(_, true), &NameBindingKind::Res(_, true)) =
|
if let (&NameBindingKind::Res(_, true), &NameBindingKind::Res(_, true)) =
|
||||||
(&old_binding.kind, &binding.kind) {
|
(&old_binding.kind, &binding.kind) {
|
||||||
|
|
||||||
this.session.buffer_lint_with_diagnostic(
|
this.lint_buffer.buffer_lint_with_diagnostic(
|
||||||
DUPLICATE_MACRO_EXPORTS,
|
DUPLICATE_MACRO_EXPORTS,
|
||||||
CRATE_NODE_ID,
|
CRATE_NODE_ID,
|
||||||
binding.span,
|
binding.span,
|
||||||
@ -979,7 +979,9 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
|
|||||||
!max_vis.get().is_at_least(directive.vis.get(), &*self) {
|
!max_vis.get().is_at_least(directive.vis.get(), &*self) {
|
||||||
let msg =
|
let msg =
|
||||||
"glob import doesn't reexport anything because no candidate is public enough";
|
"glob import doesn't reexport anything because no candidate is public enough";
|
||||||
self.r.session.buffer_lint(UNUSED_IMPORTS, directive.id, directive.span, msg);
|
self.r.lint_buffer.buffer_lint(
|
||||||
|
UNUSED_IMPORTS, directive.id, directive.span, msg,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@ -1148,7 +1150,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
|
|||||||
re-exported (error E0365), consider declaring with \
|
re-exported (error E0365), consider declaring with \
|
||||||
`pub`",
|
`pub`",
|
||||||
ident);
|
ident);
|
||||||
self.r.session.buffer_lint(PUB_USE_OF_PRIVATE_EXTERN_CRATE,
|
self.r.lint_buffer.buffer_lint(PUB_USE_OF_PRIVATE_EXTERN_CRATE,
|
||||||
directive.id,
|
directive.id,
|
||||||
directive.span,
|
directive.span,
|
||||||
&msg);
|
&msg);
|
||||||
@ -1273,7 +1275,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
|
|||||||
let mut redundant_spans: Vec<_> = redundant_span.present_items().collect();
|
let mut redundant_spans: Vec<_> = redundant_span.present_items().collect();
|
||||||
redundant_spans.sort();
|
redundant_spans.sort();
|
||||||
redundant_spans.dedup();
|
redundant_spans.dedup();
|
||||||
self.r.session.buffer_lint_with_diagnostic(
|
self.r.lint_buffer.buffer_lint_with_diagnostic(
|
||||||
UNUSED_IMPORTS,
|
UNUSED_IMPORTS,
|
||||||
directive.id,
|
directive.id,
|
||||||
directive.span,
|
directive.span,
|
||||||
|
@ -858,7 +858,7 @@ pub trait Resolver {
|
|||||||
&mut self, invoc: &Invocation, eager_expansion_root: ExpnId, force: bool
|
&mut self, invoc: &Invocation, eager_expansion_root: ExpnId, force: bool
|
||||||
) -> Result<InvocationRes, Indeterminate>;
|
) -> Result<InvocationRes, Indeterminate>;
|
||||||
|
|
||||||
fn check_unused_macros(&self);
|
fn check_unused_macros(&mut self);
|
||||||
|
|
||||||
fn has_derives(&self, expn_id: ExpnId, derives: SpecialDerives) -> bool;
|
fn has_derives(&self, expn_id: ExpnId, derives: SpecialDerives) -> bool;
|
||||||
fn add_derives(&mut self, expn_id: ExpnId, derives: SpecialDerives);
|
fn add_derives(&mut self, expn_id: ExpnId, derives: SpecialDerives);
|
||||||
@ -1053,7 +1053,7 @@ impl<'a> ExtCtxt<'a> {
|
|||||||
Symbol::intern(st)
|
Symbol::intern(st)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_unused_macros(&self) {
|
pub fn check_unused_macros(&mut self) {
|
||||||
self.resolver.check_unused_macros();
|
self.resolver.check_unused_macros();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user