Skip to content

Commit

Permalink
Fix rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Nov 18, 2018
1 parent 139d109 commit 38025e0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
8 changes: 5 additions & 3 deletions src/librustc_resolve/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,18 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
parent_prefix, use_tree, nested);

let mut prefix_iter = parent_prefix.iter().cloned()
.chain(use_tree.prefix.segments.iter().map(|seg| seg.ident)).peekable();
.chain(use_tree.prefix.segments.iter().map(|seg| seg.into())).peekable();

// On 2015 edition imports are resolved as crate-relative by default,
// so prefixes are prepended with crate root segment if necessary.
// The root is prepended lazily, when the first non-empty prefix or terminating glob
// appears, so imports in braced groups can have roots prepended independently.
let is_glob = if let ast::UseTreeKind::Glob = use_tree.kind { true } else { false };
let crate_root = if !self.session.rust_2018() &&
prefix_iter.peek().map_or(is_glob, |ident| !ident.is_path_segment_keyword()) {
Some(Ident::new(keywords::CrateRoot.name(), use_tree.prefix.span.shrink_to_lo()))
prefix_iter.peek().map_or(is_glob, |seg| !seg.ident.is_path_segment_keyword()) {
Some(Segment::from_ident(Ident::new(
keywords::CrateRoot.name(), use_tree.prefix.span.shrink_to_lo()
)))
} else {
None
};
Expand Down
9 changes: 4 additions & 5 deletions src/librustc_resolve/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use {CrateLint, PathResult, Segment};
use macros::ParentScope;

use syntax::ast::Ident;
use syntax::symbol::keywords;
use syntax_pos::Span;

Expand All @@ -31,12 +30,12 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
match (path.get(0), path.get(1)) {
// `{{root}}::ident::...` on both editions.
// On 2015 `{{root}}` is usually added implicitly.
(Some(fst), Some(snd)) if fst.name == keywords::CrateRoot.name() &&
!snd.is_path_segment_keyword() => {}
(Some(fst), Some(snd)) if fst.ident.name == keywords::CrateRoot.name() &&
!snd.ident.is_path_segment_keyword() => {}
// `ident::...` on 2018
(Some(fst), _) if self.session.rust_2018() && !fst.is_path_segment_keyword() => {
(Some(fst), _) if self.session.rust_2018() && !fst.ident.is_path_segment_keyword() => {
// Insert a placeholder that's later replaced by `self`/`super`/etc.
path.insert(0, keywords::Invalid.ident());
path.insert(0, Segment::from_ident(keywords::Invalid.ident()));
}
_ => return None,
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1747,8 +1747,8 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
let segments = &path.segments;
let path = Segment::from_path(&path);
// FIXME (Manishearth): Intra doc links won't get warned of epoch changes
match self.resolve_path_without_parent_scope(&path, Some(namespace), true, span,
CrateLint::No) {
let def = match self.resolve_path_without_parent_scope(&path, Some(namespace), true,
span, CrateLint::No) {
PathResult::Module(ModuleOrUniformRoot::Module(module)) =>
module.def().unwrap(),
PathResult::NonModule(path_res) if path_res.unresolved_segments() == 0 =>
Expand Down
11 changes: 6 additions & 5 deletions src/librustc_resolve/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
// except according to those terms.

use {AmbiguityError, AmbiguityKind, AmbiguityErrorMisc};
use {CrateLint, Resolver, ResolutionError, Weak};
use {CrateLint, Resolver, ResolutionError, Segment, Weak};
use {Module, ModuleKind, NameBinding, NameBindingKind, PathResult, ToNameBinding};
use {is_known_tool, names_to_string, resolve_error};
use {is_known_tool, resolve_error};
use ModuleOrUniformRoot;
use Namespace::{self, *};
use build_reduced_graph::{BuildReducedGraphVisitor, IsMacroExport};
Expand Down Expand Up @@ -946,7 +946,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
pub fn finalize_current_module_macro_resolutions(&mut self) {
let module = self.current_module;

let check_consistency = |this: &mut Self, path: &[Ident], span,
let check_consistency = |this: &mut Self, path: &[Segment], span,
kind: MacroKind, initial_def, def| {
if let Some(initial_def) = initial_def {
if def != initial_def && def != Def::Err && this.ambiguity_errors.is_empty() {
Expand All @@ -965,7 +965,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
// less informative error if the privacy error is reported elsewhere.
if this.privacy_errors.is_empty() {
let msg = format!("cannot determine resolution for the {} `{}`",
kind.descr(), names_to_string(path));
kind.descr(), Segment::names_to_string(path));
let msg_note = "import resolution is stuck, try simplifying macro imports";
this.session.struct_span_err(span, &msg).note(msg_note).emit();
}
Expand Down Expand Up @@ -1007,7 +1007,8 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
initial_binding.def_ignoring_ambiguity()
});
let def = binding.def_ignoring_ambiguity();
check_consistency(self, &[ident], ident.span, kind, initial_def, def);
let seg = Segment::from_ident(ident);
check_consistency(self, &[seg], ident.span, kind, initial_def, def);
}
Err(..) => {
assert!(initial_binding.is_none());
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/imports/issue-55457.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ error[E0432]: unresolved import `non_existent`
--> $DIR/issue-55457.rs:2:5
|
LL | use non_existent::non_existent; //~ ERROR unresolved import `non_existent`
| ^^^^^^^^^^^^ Maybe a missing `extern crate non_existent;`?
| ^^^^^^^^^^^^ maybe a missing `extern crate non_existent;`?

error: cannot determine resolution for the derive macro `NonExistent`
--> $DIR/issue-55457.rs:5:10
Expand Down

0 comments on commit 38025e0

Please sign in to comment.