]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #107559 - WaffleLapkin:is_it_2015¿, r=davidtwco
authorMatthias Krüger <matthias.krueger@famsik.de>
Thu, 2 Feb 2023 16:14:08 +0000 (17:14 +0100)
committerGitHub <noreply@github.com>
Thu, 2 Feb 2023 16:14:08 +0000 (17:14 +0100)
Rename `rust_2015` → `is_rust_2015`

r? ```@compiler-errors```
https://github.com/rust-lang/rust/pull/107508#discussion_r1092300088

compiler/rustc_ast_pretty/src/pprust/state.rs
compiler/rustc_parse/src/parser/item.rs
compiler/rustc_parse/src/parser/ty.rs
compiler/rustc_resolve/src/build_reduced_graph.rs
compiler/rustc_resolve/src/diagnostics.rs
compiler/rustc_resolve/src/ident.rs
compiler/rustc_resolve/src/late.rs
compiler/rustc_resolve/src/late/diagnostics.rs
compiler/rustc_session/src/session.rs
compiler/rustc_span/src/edition.rs
compiler/rustc_span/src/lib.rs

index fa8567eac609074925d82b465c6bae7feaf21ea9..d7767efa9841bc65383b76767c821ddae74379d0 100644 (file)
@@ -131,7 +131,7 @@ pub fn print_crate<'a>(
 
         // Currently, in Rust 2018 we don't have `extern crate std;` at the crate
         // root, so this is not needed, and actually breaks things.
-        if edition.rust_2015() {
+        if edition.is_rust_2015() {
             // `#![no_std]`
             let fake_attr = attr::mk_attr_word(g, ast::AttrStyle::Inner, sym::no_std, DUMMY_SP);
             s.print_attribute(&fake_attr);
index 81fd084ccb38e25c691e7d72a8e4598ad0b47c15..628e9d88cf1df27451b7811dc010fc9b08ed5cdd 100644 (file)
@@ -2247,7 +2247,7 @@ pub(super) fn parse_fn_front_matter(
         let ext = self.parse_extern(case);
 
         if let Async::Yes { span, .. } = asyncness {
-            if span.rust_2015() {
+            if span.is_rust_2015() {
                 self.sess.emit_err(AsyncFnIn2015 { span, help: HelpUseLatestEdition::new() });
             }
         }
index 646e2f45e640cb8a6a233bf01170f5cba002afc8..a19ea04fa5e75e47128fa769952be3b6083a68c6 100644 (file)
@@ -614,7 +614,7 @@ fn parse_impl_ty(&mut self, impl_dyn_multi: &mut bool) -> PResult<'a, TyKind> {
     /// Is a `dyn B0 + ... + Bn` type allowed here?
     fn is_explicit_dyn_type(&mut self) -> bool {
         self.check_keyword(kw::Dyn)
-            && (!self.token.uninterpolated_span().rust_2015()
+            && (self.token.uninterpolated_span().rust_2018()
                 || self.look_ahead(1, |t| {
                     (t.can_begin_bound() || t.kind == TokenKind::BinOp(token::Star))
                         && !can_continue_type_after_non_fn_ident(t)
index 84421dc1f62253354794e3b8079c190213e7d66b..2fb62ce53ba6e357b0f4be8d04eef0fa949b949d 100644 (file)
@@ -265,7 +265,7 @@ fn try_resolve_visibility<'ast>(
                 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 @@ fn build_reduced_graph_for_use_tree(
         // 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| {
index 3bf041cebcb88a6996b704dce8f2ce409a304cd9..a08ae0f184bb2f62cb7400353a063e6e417ed998 100644 (file)
@@ -462,7 +462,9 @@ pub(crate) fn lint_if_path_starts_with_module(
 
         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 @@ pub(crate) fn report_path_resolution_error(
                         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 @@ fn make_external_crate_suggestion(
         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;
         }
 
index 1c985d43658ae25f1b66acfedfc1ccde9a75cdfa..d03ccf256fad79f2ddc6a1d48e002e821a67e7fe 100644 (file)
@@ -85,7 +85,7 @@ pub(crate) fn visit_scopes<T>(
         // 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 @@ pub(crate) fn resolve_path_with_ribs(
                         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;
index 83932c089b311afba738f9e3fb9ff652befe1079..3ca10ac50baa6392ed0fcf47f46de5ad34b9871e 100644 (file)
@@ -2145,7 +2145,7 @@ fn future_proof_import(&mut self, use_tree: &UseTree) {
         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;
             }
 
index 37beff37c1fb9d988c33ae968afa86fb96370603..cee0a7f3c203d8e4eeb871f99f978ccfac100839 100644 (file)
@@ -1343,7 +1343,7 @@ fn smart_resolve_context_dependent_help(
                     "!",
                     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");
                 }
             }
index 746e0f169bcf30ca37971009f60aabce0cc5b481..dbd419c1406f867c09644875e70b9231e8b355fd 100644 (file)
@@ -919,8 +919,8 @@ pub fn consider_optimizing<T: Fn() -> String>(&self, crate_name: &str, msg: T) -
     }
 
     /// Is this edition 2015?
-    pub fn rust_2015(&self) -> bool {
-        self.edition().rust_2015()
+    pub fn is_rust_2015(&self) -> bool {
+        self.edition().is_rust_2015()
     }
 
     /// Are we allowed to use features from the Rust 2018 edition?
index e66ec07904341b8585d529f82c2d87adc829bbc7..f16db69aae2323d6efef2998b64dc43ee307837a 100644 (file)
@@ -77,7 +77,7 @@ pub fn is_stable(self) -> bool {
     }
 
     /// Is this edition 2015?
-    pub fn rust_2015(self) -> bool {
+    pub fn is_rust_2015(self) -> bool {
         self == Edition::Edition2015
     }
 
index 006102a5f2fcfc471abf0c1523bd1d1f22c029fc..e095cf3fda20d53cef6edd184b5c29d998d74b99 100644 (file)
@@ -705,8 +705,8 @@ pub fn edition(self) -> edition::Edition {
     }
 
     #[inline]
-    pub fn rust_2015(self) -> bool {
-        self.edition().rust_2015()
+    pub fn is_rust_2015(self) -> bool {
+        self.edition().is_rust_2015()
     }
 
     #[inline]