diff options
| author | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-08-28 10:31:15 +0000 |
|---|---|---|
| committer | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-08-28 10:31:24 +0000 |
| commit | 37f30173a017c7c5fdfb98697daa087fa5ce50c7 (patch) | |
| tree | 61fac466a104c67e5f5fce102a91b150da9e949c /src/librustc_resolve | |
| parent | b833e8d0a0f964b5e4708531ab579ef5454a5066 (diff) | |
| parent | 9d99fe98ad1980b8bc00678f27b2e324e584bea9 (diff) | |
| download | rust-37f30173a017c7c5fdfb98697daa087fa5ce50c7.tar.gz rust-37f30173a017c7c5fdfb98697daa087fa5ce50c7.zip | |
Rollup merge of #35618 - jseyfried:ast_view_path_refactor, r=eddyb
Refactor `PathListItem`s This refactors away variant `Mod` of `ast::PathListItemKind` and refactors the remaining variant `Ident` to a struct `ast::PathListItem_`.
Diffstat (limited to 'src/librustc_resolve')
| -rw-r--r-- | src/librustc_resolve/build_reduced_graph.rs | 25 | ||||
| -rw-r--r-- | src/librustc_resolve/check_unused.rs | 2 |
2 files changed, 15 insertions, 12 deletions
diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 57985344652..12c55b3ac17 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -32,9 +32,9 @@ use syntax::parse::token; use syntax::ast::{Block, Crate}; use syntax::ast::{ForeignItem, ForeignItemKind, Item, ItemKind}; -use syntax::ast::{Mutability, PathListItemKind}; -use syntax::ast::{StmtKind, TraitItemKind}; +use syntax::ast::{Mutability, StmtKind, TraitItemKind}; use syntax::ast::{Variant, ViewPathGlob, ViewPathList, ViewPathSimple}; +use syntax::parse::token::keywords; use syntax::visit::{self, Visitor}; use syntax_pos::{Span, DUMMY_SP}; @@ -130,9 +130,10 @@ impl<'b> Resolver<'b> { ViewPathList(_, ref source_items) => { // Make sure there's at most one `mod` import in the list. let mod_spans = source_items.iter().filter_map(|item| { - match item.node { - PathListItemKind::Mod { .. } => Some(item.span), - _ => None, + if item.node.name.name == keywords::SelfValue.name() { + Some(item.span) + } else { + None } }).collect::<Vec<Span>>(); @@ -147,10 +148,12 @@ impl<'b> Resolver<'b> { } for source_item in source_items { - let (module_path, name, rename) = match source_item.node { - PathListItemKind::Ident { name, rename, .. } => - (module_path.clone(), name.name, rename.unwrap_or(name).name), - PathListItemKind::Mod { rename, .. } => { + let node = source_item.node; + let (module_path, name, rename) = { + if node.name.name != keywords::SelfValue.name() { + let rename = node.rename.unwrap_or(node.name).name; + (module_path.clone(), node.name.name, rename) + } else { let name = match module_path.last() { Some(name) => *name, None => { @@ -164,12 +167,12 @@ impl<'b> Resolver<'b> { } }; let module_path = module_path.split_last().unwrap().1; - let rename = rename.map(|i| i.name).unwrap_or(name); + let rename = node.rename.map(|i| i.name).unwrap_or(name); (module_path.to_vec(), name, rename) } }; let subclass = ImportDirectiveSubclass::single(rename, name); - let (span, id) = (source_item.span, source_item.node.id()); + let (span, id) = (source_item.span, source_item.node.id); self.add_import_directive(module_path, subclass, span, id, vis); } } diff --git a/src/librustc_resolve/check_unused.rs b/src/librustc_resolve/check_unused.rs index 3084d9abbe1..bc923ba29ca 100644 --- a/src/librustc_resolve/check_unused.rs +++ b/src/librustc_resolve/check_unused.rs @@ -101,7 +101,7 @@ impl<'a, 'b> Visitor for UnusedImportCheckVisitor<'a, 'b> { ViewPathList(_, ref list) => { for i in list { - self.check_import(i.node.id(), i.span); + self.check_import(i.node.id, i.span); } } ViewPathGlob(_) => { |
