Cleanup Resolver::disallowed_shadowing
.
This commit is contained in:
parent
f5a702dc78
commit
6c4b551403
2 changed files with 11 additions and 11 deletions
|
@ -77,7 +77,7 @@ use std::mem::replace;
|
|||
use std::rc::Rc;
|
||||
|
||||
use resolve_imports::{ImportDirective, NameResolution};
|
||||
use macros::{InvocationData, LegacyBinding, LegacyScope};
|
||||
use macros::{InvocationData, LegacyBinding};
|
||||
|
||||
// NB: This module needs to be declared first so diagnostics are
|
||||
// registered before they are used.
|
||||
|
@ -1067,7 +1067,7 @@ pub struct Resolver<'a> {
|
|||
|
||||
privacy_errors: Vec<PrivacyError<'a>>,
|
||||
ambiguity_errors: Vec<AmbiguityError<'a>>,
|
||||
disallowed_shadowing: Vec<(Name, Span, LegacyScope<'a>)>,
|
||||
disallowed_shadowing: Vec<&'a LegacyBinding<'a>>,
|
||||
|
||||
arenas: &'a ResolverArenas<'a>,
|
||||
dummy_binding: &'a NameBinding<'a>,
|
||||
|
@ -3364,11 +3364,11 @@ impl<'a> Resolver<'a> {
|
|||
|
||||
fn report_shadowing_errors(&mut self) {
|
||||
let mut reported_errors = FnvHashSet();
|
||||
for (name, span, scope) in replace(&mut self.disallowed_shadowing, Vec::new()) {
|
||||
if self.resolve_macro_name(scope, name, false).is_some() &&
|
||||
reported_errors.insert((name, span)) {
|
||||
let msg = format!("`{}` is already in scope", name);
|
||||
self.session.struct_span_err(span, &msg)
|
||||
for binding in replace(&mut self.disallowed_shadowing, Vec::new()) {
|
||||
if self.resolve_macro_name(binding.parent, binding.name, false).is_some() &&
|
||||
reported_errors.insert((binding.name, binding.span)) {
|
||||
let msg = format!("`{}` is already in scope", binding.name);
|
||||
self.session.struct_span_err(binding.span, &msg)
|
||||
.note("macro-expanded `macro_rules!`s may not shadow \
|
||||
existing macros (see RFC 1560)")
|
||||
.emit();
|
||||
|
|
|
@ -74,10 +74,10 @@ impl<'a> LegacyScope<'a> {
|
|||
}
|
||||
|
||||
pub struct LegacyBinding<'a> {
|
||||
parent: LegacyScope<'a>,
|
||||
name: ast::Name,
|
||||
pub parent: LegacyScope<'a>,
|
||||
pub name: ast::Name,
|
||||
ext: Rc<SyntaxExtension>,
|
||||
span: Span,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
pub type LegacyImports = FnvHashMap<ast::Name, (Rc<SyntaxExtension>, Span)>;
|
||||
|
@ -213,7 +213,7 @@ impl<'a> Resolver<'a> {
|
|||
LegacyScope::Binding(binding) => {
|
||||
if binding.name == name {
|
||||
if record_used && relative_depth > 0 {
|
||||
self.disallowed_shadowing.push((name, binding.span, binding.parent));
|
||||
self.disallowed_shadowing.push(binding);
|
||||
}
|
||||
return Some(binding.ext.clone());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue