1
Fork 0

Rename rust_2015 => is_rust_2015

This commit is contained in:
Maybe Waffle 2023-02-01 10:42:20 +00:00
parent 131f0c6df6
commit 9fe8ae792e
11 changed files with 21 additions and 18 deletions

View file

@ -265,7 +265,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
let ident = path.segments.get(0).expect("empty path in visibility").ident;
let crate_root = if ident.is_path_segment_keyword() {
None
} else if ident.span.rust_2015() {
} else if ident.span.is_rust_2015() {
Some(Segment::from_ident(Ident::new(
kw::PathRoot,
path.span.shrink_to_lo().with_ctxt(ident.span.ctxt()),
@ -435,10 +435,10 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
// appears, so imports in braced groups can have roots prepended independently.
let is_glob = matches!(use_tree.kind, ast::UseTreeKind::Glob);
let crate_root = match prefix_iter.peek() {
Some(seg) if !seg.ident.is_path_segment_keyword() && seg.ident.span.rust_2015() => {
Some(seg) if !seg.ident.is_path_segment_keyword() && seg.ident.span.is_rust_2015() => {
Some(seg.ident.span.ctxt())
}
None if is_glob && use_tree.span.rust_2015() => Some(use_tree.span.ctxt()),
None if is_glob && use_tree.span.is_rust_2015() => Some(use_tree.span.ctxt()),
_ => None,
}
.map(|ctxt| {

View file

@ -462,7 +462,9 @@ impl<'a> Resolver<'a> {
let first_name = match path.get(0) {
// In the 2018 edition this lint is a hard error, so nothing to do
Some(seg) if seg.ident.span.rust_2015() && self.session.rust_2015() => seg.ident.name,
Some(seg) if seg.ident.span.is_rust_2015() && self.session.is_rust_2015() => {
seg.ident.name
}
_ => return,
};
@ -1717,7 +1719,7 @@ impl<'a> Resolver<'a> {
Applicability::MaybeIncorrect,
)),
)
} else if self.session.rust_2015() {
} else if self.session.is_rust_2015() {
(
format!("maybe a missing crate `{ident}`?"),
Some((
@ -1996,7 +1998,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
mut path: Vec<Segment>,
parent_scope: &ParentScope<'b>,
) -> Option<(Vec<Segment>, Option<String>)> {
if path[1].ident.span.rust_2015() {
if path[1].ident.span.is_rust_2015() {
return None;
}

View file

@ -85,7 +85,7 @@ impl<'a> Resolver<'a> {
// 4c. Standard library prelude (de-facto closed, controlled).
// 6. Language prelude: builtin attributes (closed, controlled).
let rust_2015 = ctxt.edition().rust_2015();
let rust_2015 = ctxt.edition().is_rust_2015();
let (ns, macro_kind, is_absolute_path) = match scope_set {
ScopeSet::All(ns, _) => (ns, None, false),
ScopeSet::AbsolutePath(ns) => (ns, None, true),
@ -1397,7 +1397,8 @@ impl<'a> Resolver<'a> {
module = Some(ModuleOrUniformRoot::ExternPrelude);
continue;
}
if name == kw::PathRoot && ident.span.rust_2015() && self.session.rust_2018() {
if name == kw::PathRoot && ident.span.is_rust_2015() && self.session.rust_2018()
{
// `::a::b` from 2015 macro on 2018 global edition
module = Some(ModuleOrUniformRoot::CrateRootAndExternPrelude);
continue;

View file

@ -2145,7 +2145,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
let segments = &use_tree.prefix.segments;
if !segments.is_empty() {
let ident = segments[0].ident;
if ident.is_path_segment_keyword() || ident.span.rust_2015() {
if ident.is_path_segment_keyword() || ident.span.is_rust_2015() {
return;
}

View file

@ -1343,7 +1343,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
"!",
Applicability::MaybeIncorrect,
);
if path_str == "try" && span.rust_2015() {
if path_str == "try" && span.is_rust_2015() {
err.note("if you want the `try` keyword, you need Rust 2018 or later");
}
}