|
14 | 14 | extern crate bitflags; |
15 | 15 | #[macro_use] |
16 | 16 | extern crate log; |
| 17 | +extern crate smallvec; |
17 | 18 | #[macro_use] |
18 | 19 | extern crate syntax; |
19 | 20 | extern crate syntax_pos; |
@@ -66,6 +67,7 @@ use syntax::ptr::P; |
66 | 67 | use syntax_pos::{Span, DUMMY_SP, MultiSpan}; |
67 | 68 | use errors::{Applicability, DiagnosticBuilder, DiagnosticId}; |
68 | 69 |
|
| 70 | +use smallvec::SmallVec; |
69 | 71 | use std::cell::{Cell, RefCell}; |
70 | 72 | use std::{cmp, fmt, iter, mem, ptr}; |
71 | 73 | use std::collections::BTreeSet; |
@@ -1677,7 +1679,7 @@ impl<'a> hir::lowering::Resolver for Resolver<'a> { |
1677 | 1679 | crate_root.into_iter() |
1678 | 1680 | .chain(components.iter().cloned()) |
1679 | 1681 | .map(Ident::from_str) |
1680 | | - ).map(|i| self.new_ast_path_segment(i)).collect::<Vec<_>>(); |
| 1682 | + ).map(|i| self.new_ast_path_segment(i)).collect::<SmallVec<[_; 1]>>(); |
1681 | 1683 |
|
1682 | 1684 |
|
1683 | 1685 | let path = ast::Path { |
@@ -4621,7 +4623,8 @@ impl<'a> Resolver<'a> { |
4621 | 4623 | let mut candidates = Vec::new(); |
4622 | 4624 | let mut seen_modules = FxHashSet::default(); |
4623 | 4625 | let not_local_module = crate_name != keywords::Crate.ident(); |
4624 | | - let mut worklist = vec![(start_module, Vec::<ast::PathSegment>::new(), not_local_module)]; |
| 4626 | + let mut worklist = |
| 4627 | + vec![(start_module, SmallVec::<[ast::PathSegment; 1]>::new(), not_local_module)]; |
4625 | 4628 |
|
4626 | 4629 | while let Some((in_module, |
4627 | 4630 | path_segments, |
@@ -4737,7 +4740,7 @@ impl<'a> Resolver<'a> { |
4737 | 4740 | { |
4738 | 4741 | let mut result = None; |
4739 | 4742 | let mut seen_modules = FxHashSet::default(); |
4740 | | - let mut worklist = vec![(self.graph_root, Vec::new())]; |
| 4743 | + let mut worklist = vec![(self.graph_root, SmallVec::new())]; |
4741 | 4744 |
|
4742 | 4745 | while let Some((in_module, path_segments)) = worklist.pop() { |
4743 | 4746 | // abort if the module is already found |
@@ -5214,9 +5217,10 @@ fn import_candidate_to_enum_paths(suggestion: &ImportSuggestion) -> (String, Str |
5214 | 5217 | let variant_path_string = path_names_to_string(variant_path); |
5215 | 5218 |
|
5216 | 5219 | let path_len = suggestion.path.segments.len(); |
| 5220 | + let segments = suggestion.path.segments[0..path_len - 1].iter().cloned().collect(); |
5217 | 5221 | let enum_path = ast::Path { |
5218 | 5222 | span: suggestion.path.span, |
5219 | | - segments: suggestion.path.segments[0..path_len - 1].to_vec(), |
| 5223 | + segments, |
5220 | 5224 | }; |
5221 | 5225 | let enum_path_string = path_names_to_string(&enum_path); |
5222 | 5226 |
|
|
0 commit comments