Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beta backports #56240

Merged
merged 8 commits into from
Nov 26, 2018
11 changes: 2 additions & 9 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1484,15 +1484,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// done with either: `-Ztwo-phase-borrows`, `#![feature(nll)]`,
/// or by opting into an edition after 2015.
pub fn two_phase_borrows(self) -> bool {
if self.features().nll || self.sess.opts.debugging_opts.two_phase_borrows {
return true;
}

match self.sess.edition() {
Edition::Edition2015 => false,
Edition::Edition2018 => true,
_ => true,
}
self.sess.rust_2018() || self.features().nll ||
self.sess.opts.debugging_opts.two_phase_borrows
}

/// What mode(s) of borrowck should we run? AST? MIR? both?
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/ty/item_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use ty::{self, DefIdTree, Ty, TyCtxt};
use middle::cstore::{ExternCrate, ExternCrateSource};
use syntax::ast;
use syntax::symbol::{keywords, LocalInternedString, Symbol};
use syntax_pos::edition::Edition;

use std::cell::Cell;
use std::fmt::Debug;
Expand Down Expand Up @@ -140,7 +139,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
debug!("push_krate_path: name={:?}", name);
buffer.push(&name);
}
} else if self.sess.edition() == Edition::Edition2018 && !pushed_prelude_crate {
} else if self.sess.rust_2018() && !pushed_prelude_crate {
SHOULD_PREFIX_WITH_CRATE.with(|flag| {
// We only add the `crate::` keyword where appropriate. In particular,
// when we've not previously pushed a prelude crate to this path.
Expand Down
24 changes: 14 additions & 10 deletions src/librustc_resolve/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,21 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
// 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.
// 2015 identifiers used on global 2018 edition enter special "virtual 2015 mode", don't
// get crate root prepended, but get special treatment during in-scope resolution instead.
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, |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
};
let crate_root = match prefix_iter.peek() {
Some(seg) if !seg.ident.is_path_segment_keyword() &&
seg.ident.span.rust_2015() && self.session.rust_2015() => {
Some(seg.ident.span.ctxt())
}
None if is_glob && use_tree.span.rust_2015() => {
Some(use_tree.span.ctxt())
}
_ => None,
}.map(|ctxt| Segment::from_ident(Ident::new(
keywords::CrateRoot.name(), use_tree.prefix.span.shrink_to_lo().with_ctxt(ctxt)
)));

let prefix = crate_root.into_iter().chain(prefix_iter).collect::<Vec<_>>();
debug!("build_reduced_graph_for_use_tree: prefix={:?}", prefix);
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_resolve/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
(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.ident.is_path_segment_keyword() => {
(Some(fst), _) if fst.ident.span.rust_2018() &&
!fst.ident.is_path_segment_keyword() => {
// Insert a placeholder that's later replaced by `self`/`super`/etc.
path.insert(0, Segment::from_ident(keywords::Invalid.ident()));
}
Expand Down Expand Up @@ -141,7 +142,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
mut path: Vec<Segment>,
parent_scope: &ParentScope<'b>,
) -> Option<(Vec<Segment>, Option<String>)> {
if !self.session.rust_2018() {
if path[1].ident.span.rust_2015() {
return None;
}

Expand Down
Loading