Skip to content

Commit 3d92100

Browse files
authored
Rollup merge of #107559 - WaffleLapkin:is_it_2015¿, r=davidtwco
Rename `rust_2015` → `is_rust_2015` r? ```@compiler-errors``` #107508 (comment)
2 parents 3e0995a + a7f97a7 commit 3d92100

File tree

11 files changed

+21
-18
lines changed

11 files changed

+21
-18
lines changed

compiler/rustc_ast_pretty/src/pprust/state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub fn print_crate<'a>(
131131

132132
// Currently, in Rust 2018 we don't have `extern crate std;` at the crate
133133
// root, so this is not needed, and actually breaks things.
134-
if edition.rust_2015() {
134+
if edition.is_rust_2015() {
135135
// `#![no_std]`
136136
let fake_attr = attr::mk_attr_word(g, ast::AttrStyle::Inner, sym::no_std, DUMMY_SP);
137137
s.print_attribute(&fake_attr);

compiler/rustc_parse/src/parser/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2247,7 +2247,7 @@ impl<'a> Parser<'a> {
22472247
let ext = self.parse_extern(case);
22482248

22492249
if let Async::Yes { span, .. } = asyncness {
2250-
if span.rust_2015() {
2250+
if span.is_rust_2015() {
22512251
self.sess.emit_err(AsyncFnIn2015 { span, help: HelpUseLatestEdition::new() });
22522252
}
22532253
}

compiler/rustc_parse/src/parser/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ impl<'a> Parser<'a> {
614614
/// Is a `dyn B0 + ... + Bn` type allowed here?
615615
fn is_explicit_dyn_type(&mut self) -> bool {
616616
self.check_keyword(kw::Dyn)
617-
&& (!self.token.uninterpolated_span().rust_2015()
617+
&& (self.token.uninterpolated_span().rust_2018()
618618
|| self.look_ahead(1, |t| {
619619
(t.can_begin_bound() || t.kind == TokenKind::BinOp(token::Star))
620620
&& !can_continue_type_after_non_fn_ident(t)

compiler/rustc_resolve/src/build_reduced_graph.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
265265
let ident = path.segments.get(0).expect("empty path in visibility").ident;
266266
let crate_root = if ident.is_path_segment_keyword() {
267267
None
268-
} else if ident.span.rust_2015() {
268+
} else if ident.span.is_rust_2015() {
269269
Some(Segment::from_ident(Ident::new(
270270
kw::PathRoot,
271271
path.span.shrink_to_lo().with_ctxt(ident.span.ctxt()),
@@ -435,10 +435,10 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
435435
// appears, so imports in braced groups can have roots prepended independently.
436436
let is_glob = matches!(use_tree.kind, ast::UseTreeKind::Glob);
437437
let crate_root = match prefix_iter.peek() {
438-
Some(seg) if !seg.ident.is_path_segment_keyword() && seg.ident.span.rust_2015() => {
438+
Some(seg) if !seg.ident.is_path_segment_keyword() && seg.ident.span.is_rust_2015() => {
439439
Some(seg.ident.span.ctxt())
440440
}
441-
None if is_glob && use_tree.span.rust_2015() => Some(use_tree.span.ctxt()),
441+
None if is_glob && use_tree.span.is_rust_2015() => Some(use_tree.span.ctxt()),
442442
_ => None,
443443
}
444444
.map(|ctxt| {

compiler/rustc_resolve/src/diagnostics.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,9 @@ impl<'a> Resolver<'a> {
462462

463463
let first_name = match path.get(0) {
464464
// In the 2018 edition this lint is a hard error, so nothing to do
465-
Some(seg) if seg.ident.span.rust_2015() && self.session.rust_2015() => seg.ident.name,
465+
Some(seg) if seg.ident.span.is_rust_2015() && self.session.is_rust_2015() => {
466+
seg.ident.name
467+
}
466468
_ => return,
467469
};
468470

@@ -1717,7 +1719,7 @@ impl<'a> Resolver<'a> {
17171719
Applicability::MaybeIncorrect,
17181720
)),
17191721
)
1720-
} else if self.session.rust_2015() {
1722+
} else if self.session.is_rust_2015() {
17211723
(
17221724
format!("maybe a missing crate `{ident}`?"),
17231725
Some((
@@ -1996,7 +1998,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
19961998
mut path: Vec<Segment>,
19971999
parent_scope: &ParentScope<'b>,
19982000
) -> Option<(Vec<Segment>, Option<String>)> {
1999-
if path[1].ident.span.rust_2015() {
2001+
if path[1].ident.span.is_rust_2015() {
20002002
return None;
20012003
}
20022004

compiler/rustc_resolve/src/ident.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl<'a> Resolver<'a> {
8585
// 4c. Standard library prelude (de-facto closed, controlled).
8686
// 6. Language prelude: builtin attributes (closed, controlled).
8787

88-
let rust_2015 = ctxt.edition().rust_2015();
88+
let rust_2015 = ctxt.edition().is_rust_2015();
8989
let (ns, macro_kind, is_absolute_path) = match scope_set {
9090
ScopeSet::All(ns, _) => (ns, None, false),
9191
ScopeSet::AbsolutePath(ns) => (ns, None, true),
@@ -1397,7 +1397,8 @@ impl<'a> Resolver<'a> {
13971397
module = Some(ModuleOrUniformRoot::ExternPrelude);
13981398
continue;
13991399
}
1400-
if name == kw::PathRoot && ident.span.rust_2015() && self.session.rust_2018() {
1400+
if name == kw::PathRoot && ident.span.is_rust_2015() && self.session.rust_2018()
1401+
{
14011402
// `::a::b` from 2015 macro on 2018 global edition
14021403
module = Some(ModuleOrUniformRoot::CrateRootAndExternPrelude);
14031404
continue;

compiler/rustc_resolve/src/late.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2145,7 +2145,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
21452145
let segments = &use_tree.prefix.segments;
21462146
if !segments.is_empty() {
21472147
let ident = segments[0].ident;
2148-
if ident.is_path_segment_keyword() || ident.span.rust_2015() {
2148+
if ident.is_path_segment_keyword() || ident.span.is_rust_2015() {
21492149
return;
21502150
}
21512151

compiler/rustc_resolve/src/late/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
13431343
"!",
13441344
Applicability::MaybeIncorrect,
13451345
);
1346-
if path_str == "try" && span.rust_2015() {
1346+
if path_str == "try" && span.is_rust_2015() {
13471347
err.note("if you want the `try` keyword, you need Rust 2018 or later");
13481348
}
13491349
}

compiler/rustc_session/src/session.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,8 @@ impl Session {
919919
}
920920

921921
/// Is this edition 2015?
922-
pub fn rust_2015(&self) -> bool {
923-
self.edition().rust_2015()
922+
pub fn is_rust_2015(&self) -> bool {
923+
self.edition().is_rust_2015()
924924
}
925925

926926
/// Are we allowed to use features from the Rust 2018 edition?

compiler/rustc_span/src/edition.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl Edition {
7777
}
7878

7979
/// Is this edition 2015?
80-
pub fn rust_2015(self) -> bool {
80+
pub fn is_rust_2015(self) -> bool {
8181
self == Edition::Edition2015
8282
}
8383

compiler/rustc_span/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,8 @@ impl Span {
705705
}
706706

707707
#[inline]
708-
pub fn rust_2015(self) -> bool {
709-
self.edition().rust_2015()
708+
pub fn is_rust_2015(self) -> bool {
709+
self.edition().is_rust_2015()
710710
}
711711

712712
#[inline]

0 commit comments

Comments
 (0)