Skip to content

Commit fd5774a

Browse files
committed
Use Edition methods a bit more
1 parent dc3e59c commit fd5774a

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 1 addition & 1 deletion
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 == Edition::Edition2015 {
134+
if edition.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_resolve/src/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,7 @@ impl<'a> Resolver<'a> {
17171717
Applicability::MaybeIncorrect,
17181718
)),
17191719
)
1720-
} else if self.session.edition() == Edition::Edition2015 {
1720+
} else if self.session.edition().rust_2015() {
17211721
(
17221722
format!("maybe a missing crate `{ident}`?"),
17231723
Some((

compiler/rustc_resolve/src/ident.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use rustc_middle::ty;
77
use rustc_session::lint::builtin::PROC_MACRO_DERIVE_RESOLUTION_FALLBACK;
88
use rustc_session::lint::BuiltinLintDiagnostics;
99
use rustc_span::def_id::LocalDefId;
10-
use rustc_span::edition::Edition;
1110
use rustc_span::hygiene::{ExpnId, ExpnKind, LocalExpnId, MacroKind, SyntaxContext};
1211
use rustc_span::symbol::{kw, Ident};
1312
use rustc_span::{Span, DUMMY_SP};
@@ -86,7 +85,7 @@ impl<'a> Resolver<'a> {
8685
// 4c. Standard library prelude (de-facto closed, controlled).
8786
// 6. Language prelude: builtin attributes (closed, controlled).
8887

89-
let rust_2015 = ctxt.edition() == Edition::Edition2015;
88+
let rust_2015 = ctxt.edition().rust_2015();
9089
let (ns, macro_kind, is_absolute_path) = match scope_set {
9190
ScopeSet::All(ns, _) => (ns, None, false),
9291
ScopeSet::AbsolutePath(ns) => (ns, None, true),

compiler/rustc_session/src/session.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -900,22 +900,22 @@ impl Session {
900900
}
901901

902902
pub fn rust_2015(&self) -> bool {
903-
self.edition() == Edition::Edition2015
903+
self.edition().rust_2015()
904904
}
905905

906906
/// Are we allowed to use features from the Rust 2018 edition?
907907
pub fn rust_2018(&self) -> bool {
908-
self.edition() >= Edition::Edition2018
908+
self.edition().rust_2018()
909909
}
910910

911911
/// Are we allowed to use features from the Rust 2021 edition?
912912
pub fn rust_2021(&self) -> bool {
913-
self.edition() >= Edition::Edition2021
913+
self.edition().rust_2021()
914914
}
915915

916916
/// Are we allowed to use features from the Rust 2024 edition?
917917
pub fn rust_2024(&self) -> bool {
918-
self.edition() >= Edition::Edition2024
918+
self.edition().rust_2024()
919919
}
920920

921921
/// Returns `true` if we cannot skip the PLT for shared library calls.

compiler/rustc_span/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -706,22 +706,22 @@ impl Span {
706706

707707
#[inline]
708708
pub fn rust_2015(self) -> bool {
709-
self.edition() == edition::Edition::Edition2015
709+
self.edition().rust_2015()
710710
}
711711

712712
#[inline]
713713
pub fn rust_2018(self) -> bool {
714-
self.edition() >= edition::Edition::Edition2018
714+
self.edition().rust_2018()
715715
}
716716

717717
#[inline]
718718
pub fn rust_2021(self) -> bool {
719-
self.edition() >= edition::Edition::Edition2021
719+
self.edition().rust_2021()
720720
}
721721

722722
#[inline]
723723
pub fn rust_2024(self) -> bool {
724-
self.edition() >= edition::Edition::Edition2024
724+
self.edition().rust_2024()
725725
}
726726

727727
/// Returns the source callee.

0 commit comments

Comments
 (0)