Skip to content

Commit

Permalink
fix errors caused by cherry picking
Browse files Browse the repository at this point in the history
  • Loading branch information
pietroalbini committed Oct 29, 2018
1 parent 4b3b4d2 commit 7c81496
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3095,7 +3095,7 @@ impl<'a> LoweringContext<'a> {
// the stability of `use a::{};`, to avoid it showing up as
// a re-export by accident when `pub`, e.g. in documentation.
let def = self.expect_full_def_from_use(id).next().unwrap_or(Def::Err);
let path = P(self.lower_path_extra(def, &prefix, None, ParamMode::Explicit, None));
let path = P(self.lower_path_extra(def, &prefix, None, ParamMode::Explicit));
*vis = respan(prefix.span.shrink_to_lo(), hir::VisibilityKind::Inherited);
hir::ItemKind::Use(path, hir::UseKind::ListStem)
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_resolve/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
uniform_paths_canary_emitted = true;
}

let empty_for_self = |prefix: &[Segment]| {
let empty_for_self = |prefix: &[Ident]| {
prefix.is_empty() ||
prefix.len() == 1 && prefix[0].ident.name == keywords::CrateRoot.name()
prefix.len() == 1 && prefix[0].name == keywords::CrateRoot.name()
};
match use_tree.kind {
ast::UseTreeKind::Simple(rename, ..) => {
Expand Down Expand Up @@ -400,7 +400,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
// `a::b::c::{self as _}`, so that their prefixes are correctly
// resolved and checked for privacy/stability/etc.
if items.is_empty() && !empty_for_self(&prefix) {
let new_span = prefix[prefix.len() - 1].ident.span;
let new_span = prefix[prefix.len() - 1].span;
let tree = ast::UseTree {
prefix: ast::Path::from_ident(
Ident::new(keywords::SelfValue.name(), new_span)
Expand Down
17 changes: 8 additions & 9 deletions src/librustc_resolve/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
pub(crate) fn make_path_suggestion(
&mut self,
span: Span,
path: Vec<Ident>
path: Vec<Ident>,
parent_scope: &ParentScope<'b>,
) -> Option<(Vec<Ident>, Option<String>)> {
debug!("make_path_suggestion: span={:?} path={:?}", span, path);
Expand Down Expand Up @@ -63,11 +63,11 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
fn make_missing_self_suggestion(
&mut self,
span: Span,
mut path: Vec<Ident>
mut path: Vec<Ident>,
parent_scope: &ParentScope<'b>,
) -> Option<(Vec<Ident>, Option<String>)> {
// Replace first ident with `self` and check if that is valid.
path[0] = keywords::SelfValue.name();
path[0].name = keywords::SelfValue.name();
let result = self.resolve_path(None, &path, None, parent_scope, false, span, CrateLint::No);
debug!("make_missing_self_suggestion: path={:?} result={:?}", path, result);
if let PathResult::Module(..) = result {
Expand All @@ -87,11 +87,11 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
fn make_missing_crate_suggestion(
&mut self,
span: Span,
mut path: Vec<Ident>
mut path: Vec<Ident>,
parent_scope: &ParentScope<'b>,
) -> Option<(Vec<Ident>, Option<String>)> {
// Replace first ident with `crate` and check if that is valid.
path[0] = keywords::Crate.name();
path[0].name = keywords::Crate.name();
let result = self.resolve_path(None, &path, None, parent_scope, false, span, CrateLint::No);
debug!("make_missing_crate_suggestion: path={:?} result={:?}", path, result);
if let PathResult::Module(..) = result {
Expand All @@ -118,12 +118,11 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
fn make_missing_super_suggestion(
&mut self,
span: Span,
mut path: Vec<Ident>
mut path: Vec<Ident>,
parent_scope: &ParentScope<'b>,
) -> Option<(Vec<Ident>, Option<String>)> {
// Replace first ident with `crate` and check if that is valid.
path[0] = keywords::Super.name();
let result = self.resolve_path(None, &path, None, false, span, CrateLint::No);
path[0].name = keywords::Super.name();
let result = self.resolve_path(None, &path, None, parent_scope, false, span, CrateLint::No);
debug!("make_missing_super_suggestion: path={:?} result={:?}", path, result);
if let PathResult::Module(..) = result {
Expand All @@ -146,7 +145,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
fn make_external_crate_suggestion(
&mut self,
span: Span,
mut path: Vec<Ident>
mut path: Vec<Ident>,
parent_scope: &ParentScope<'b>,
) -> Option<(Vec<Ident>, Option<String>)> {
// Need to clone else we can't call `resolve_path` without a borrow error. We also store
Expand Down
17 changes: 5 additions & 12 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ pub struct ModuleData<'a> {
resolutions: RefCell<FxHashMap<(Ident, Namespace), &'a RefCell<NameResolution<'a>>>>,
legacy_macro_resolutions: RefCell<Vec<(Ident, MacroKind, ParentScope<'a>,
Option<&'a NameBinding<'a>>)>>,
macro_resolutions: RefCell<Vec<(Vec<Segment>, ParentScope<'a>, Span)>>,
macro_resolutions: RefCell<Vec<(Vec<Ident>, ParentScope<'a>, Span)>>,
builtin_attrs: RefCell<Vec<(Ident, ParentScope<'a>)>>,

// Macro invocations that can expand into items in this module.
Expand Down Expand Up @@ -1627,17 +1627,10 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
*def = module.def().unwrap(),
PathResult::NonModule(path_res) if path_res.unresolved_segments() == 0 =>
*def = path_res.base_def(),
PathResult::NonModule(..) =>
if let PathResult::Failed(span, msg, _) = self.resolve_path(
None,
&path,
None,
true,
span,
CrateLint::No,
) {
error_callback(self, span, ResolutionError::FailedToResolve(&msg));
},
PathResult::NonModule(..) => {
let msg = "type-relative paths are not supported in this context";
error_callback(self, span, ResolutionError::FailedToResolve(msg));
}
PathResult::Module(ModuleOrUniformRoot::UniformRoot(_)) |
PathResult::Indeterminate => unreachable!(),
PathResult::Failed(span, msg, _) => {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_resolve/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
force: bool,
) -> Result<Def, Determinacy> {
let path_span = path.span;
let mut path: Vec<_> = segments.iter().map(|seg| seg.ident).collect();
let mut path = path.segments.iter().map(|s| s.ident).collect::<Vec<_>>();

// Possibly apply the macro helper hack
if kind == MacroKind::Bang && path.len() == 1 &&
Expand Down Expand Up @@ -497,7 +497,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
};

parent_scope.module.macro_resolutions.borrow_mut()
.push((path.into_boxed_slice(), parent_scope.clone(), span));
.push((path, parent_scope.clone(), path_span));

def
} else {
Expand Down Expand Up @@ -849,7 +849,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {

let macro_resolutions =
mem::replace(&mut *module.macro_resolutions.borrow_mut(), Vec::new());
for (mut path, parent_scope, path_span) in macro_resolutions {
for (path, parent_scope, path_span) in macro_resolutions {
match self.resolve_path(None, &path, Some(MacroNS), &parent_scope,
true, path_span, CrateLint::No) {
PathResult::NonModule(_) => {},
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_resolve/resolve_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
) {
Some((
span,
format!("Did you mean `{}`?", names_to_string(&suggested_path[..]))
format!("Did you mean `{}`?", names_to_string(&suggested_path[..])),
note,
))
} else {
Expand Down

0 comments on commit 7c81496

Please sign in to comment.