From f16ef7d7ce0357d63435201ae51e2c0a6916e07d Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 30 Dec 2020 14:33:46 +0100 Subject: Add edition 2021. --- compiler/rustc_parse/src/parser/expr.rs | 5 +++-- compiler/rustc_parse/src/parser/item.rs | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'compiler/rustc_parse/src/parser') diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index b147f42fada..40210f747ff 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -15,6 +15,7 @@ use rustc_ast::{AnonConst, BinOp, BinOpKind, FnDecl, FnRetTy, MacCall, Param, Ty use rustc_ast::{Arm, Async, BlockCheckMode, Expr, ExprKind, Label, Movability, RangeLimits}; use rustc_ast_pretty::pprust; use rustc_errors::{Applicability, DiagnosticBuilder, PResult}; +use rustc_span::edition::LATEST_STABLE_EDITION; use rustc_span::source_map::{self, Span, Spanned}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{BytePos, Pos}; @@ -2108,8 +2109,8 @@ impl<'a> Parser<'a> { let mut async_block_err = |e: &mut DiagnosticBuilder<'_>, span: Span| { recover_async = true; - e.span_label(span, "`async` blocks are only allowed in the 2018 edition"); - e.help("set `edition = \"2018\"` in `Cargo.toml`"); + e.span_label(span, "`async` blocks are only allowed in edition 2018 or later"); + e.help(&format!("set `edition = \"{}\"` in `Cargo.toml`", LATEST_STABLE_EDITION)); e.note("for more on editions, read https://doc.rust-lang.org/edition-guide"); }; diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index c6669f04682..6d79a6ac09c 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -16,7 +16,7 @@ use rustc_ast::{FnHeader, ForeignItem, Path, PathSegment, Visibility, Visibility use rustc_ast::{MacArgs, MacCall, MacDelimiter}; use rustc_ast_pretty::pprust; use rustc_errors::{struct_span_err, Applicability, PResult, StashKey}; -use rustc_span::edition::Edition; +use rustc_span::edition::{Edition, LATEST_STABLE_EDITION}; use rustc_span::source_map::{self, Span}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; @@ -1668,8 +1668,8 @@ impl<'a> Parser<'a> { if span.rust_2015() { let diag = self.diagnostic(); struct_span_err!(diag, span, E0670, "`async fn` is not permitted in the 2015 edition") - .span_label(span, "to use `async fn`, switch to Rust 2018") - .help("set `edition = \"2018\"` in `Cargo.toml`") + .span_label(span, "to use `async fn`, switch to Rust 2018 or later") + .help(&format!("set `edition = \"{}\"` in `Cargo.toml`", LATEST_STABLE_EDITION)) .note("for more on editions, read https://doc.rust-lang.org/edition-guide") .emit(); } -- cgit 1.4.1-3-g733a5 From c574ded57da4c7c631b836c397f31d2a72dc1280 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Mon, 30 Nov 2020 22:11:29 +0100 Subject: Consistently call editions "Rust 20xx" in messages. --- compiler/rustc_parse/src/parser/expr.rs | 2 +- compiler/rustc_parse/src/parser/item.rs | 2 +- compiler/rustc_resolve/src/late/diagnostics.rs | 4 ++-- src/test/ui/async-await/edition-deny-async-fns-2015.rs | 18 +++++++++--------- .../ui/async-await/edition-deny-async-fns-2015.stderr | 18 +++++++++--------- src/test/ui/editions/async-block-2015.rs | 8 ++++---- src/test/ui/editions/async-block-2015.stderr | 8 ++++---- src/test/ui/try-block/try-block-in-edition2015.stderr | 2 +- 8 files changed, 31 insertions(+), 31 deletions(-) (limited to 'compiler/rustc_parse/src/parser') diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 40210f747ff..d11db74a3bd 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -2109,7 +2109,7 @@ impl<'a> Parser<'a> { let mut async_block_err = |e: &mut DiagnosticBuilder<'_>, span: Span| { recover_async = true; - e.span_label(span, "`async` blocks are only allowed in edition 2018 or later"); + e.span_label(span, "`async` blocks are only allowed in Rust 2018 or later"); e.help(&format!("set `edition = \"{}\"` in `Cargo.toml`", LATEST_STABLE_EDITION)); e.note("for more on editions, read https://doc.rust-lang.org/edition-guide"); }; diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 6d79a6ac09c..e49b1a54e9b 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1667,7 +1667,7 @@ impl<'a> Parser<'a> { fn ban_async_in_2015(&self, span: Span) { if span.rust_2015() { let diag = self.diagnostic(); - struct_span_err!(diag, span, E0670, "`async fn` is not permitted in the 2015 edition") + struct_span_err!(diag, span, E0670, "`async fn` is not permitted in Rust 2015") .span_label(span, "to use `async fn`, switch to Rust 2018 or later") .help(&format!("set `edition = \"{}\"` in `Cargo.toml`", LATEST_STABLE_EDITION)) .note("for more on editions, read https://doc.rust-lang.org/edition-guide") diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 7d8f112af8a..55623c9bd9c 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -180,7 +180,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { ( format!("cannot find {} `{}` in {}{}", expected, item_str, mod_prefix, mod_str), if path_str == "async" && expected.starts_with("struct") { - "`async` blocks are only allowed in the 2018 edition".to_string() + "`async` blocks are only allowed in Rust 2018 or later".to_string() } else { format!("not found in {}", mod_str) }, @@ -904,7 +904,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { Applicability::MaybeIncorrect, ); if path_str == "try" && span.rust_2015() { - err.note("if you want the `try` keyword, you need to be in the 2018 edition"); + err.note("if you want the `try` keyword, you need Rust 2018 or later"); } } (Res::Def(DefKind::TyAlias, def_id), PathSource::Trait(_)) => { diff --git a/src/test/ui/async-await/edition-deny-async-fns-2015.rs b/src/test/ui/async-await/edition-deny-async-fns-2015.rs index 5d2d186137e..e5dc9c8a5fe 100644 --- a/src/test/ui/async-await/edition-deny-async-fns-2015.rs +++ b/src/test/ui/async-await/edition-deny-async-fns-2015.rs @@ -1,21 +1,21 @@ // edition:2015 -async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition +async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015 -fn baz() { async fn foo() {} } //~ ERROR `async fn` is not permitted in the 2015 edition +fn baz() { async fn foo() {} } //~ ERROR `async fn` is not permitted in Rust 2015 -async fn async_baz() { //~ ERROR `async fn` is not permitted in the 2015 edition - async fn bar() {} //~ ERROR `async fn` is not permitted in the 2015 edition +async fn async_baz() { //~ ERROR `async fn` is not permitted in Rust 2015 + async fn bar() {} //~ ERROR `async fn` is not permitted in Rust 2015 } struct Foo {} impl Foo { - async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition + async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015 } trait Bar { - async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition + async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015 //~^ ERROR functions in traits cannot be declared `async` } @@ -23,16 +23,16 @@ fn main() { macro_rules! accept_item { ($x:item) => {} } accept_item! { - async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition + async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015 } accept_item! { impl Foo { - async fn bar() {} //~ ERROR `async fn` is not permitted in the 2015 edition + async fn bar() {} //~ ERROR `async fn` is not permitted in Rust 2015 } } let inside_closure = || { - async fn bar() {} //~ ERROR `async fn` is not permitted in the 2015 edition + async fn bar() {} //~ ERROR `async fn` is not permitted in Rust 2015 }; } diff --git a/src/test/ui/async-await/edition-deny-async-fns-2015.stderr b/src/test/ui/async-await/edition-deny-async-fns-2015.stderr index 39bc8e7be8f..43364a8e858 100644 --- a/src/test/ui/async-await/edition-deny-async-fns-2015.stderr +++ b/src/test/ui/async-await/edition-deny-async-fns-2015.stderr @@ -1,4 +1,4 @@ -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/edition-deny-async-fns-2015.rs:3:1 | LL | async fn foo() {} @@ -7,7 +7,7 @@ LL | async fn foo() {} = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/edition-deny-async-fns-2015.rs:5:12 | LL | fn baz() { async fn foo() {} } @@ -16,7 +16,7 @@ LL | fn baz() { async fn foo() {} } = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/edition-deny-async-fns-2015.rs:7:1 | LL | async fn async_baz() { @@ -25,7 +25,7 @@ LL | async fn async_baz() { = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/edition-deny-async-fns-2015.rs:8:5 | LL | async fn bar() {} @@ -34,7 +34,7 @@ LL | async fn bar() {} = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/edition-deny-async-fns-2015.rs:14:5 | LL | async fn foo() {} @@ -43,7 +43,7 @@ LL | async fn foo() {} = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/edition-deny-async-fns-2015.rs:18:5 | LL | async fn foo() {} @@ -52,7 +52,7 @@ LL | async fn foo() {} = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/edition-deny-async-fns-2015.rs:36:9 | LL | async fn bar() {} @@ -61,7 +61,7 @@ LL | async fn bar() {} = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/edition-deny-async-fns-2015.rs:26:9 | LL | async fn foo() {} @@ -70,7 +70,7 @@ LL | async fn foo() {} = help: set `edition = "2018"` in `Cargo.toml` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/edition-deny-async-fns-2015.rs:31:13 | LL | async fn bar() {} diff --git a/src/test/ui/editions/async-block-2015.rs b/src/test/ui/editions/async-block-2015.rs index b35cc1564b3..92eae9e3c14 100644 --- a/src/test/ui/editions/async-block-2015.rs +++ b/src/test/ui/editions/async-block-2015.rs @@ -1,13 +1,13 @@ async fn foo() { -//~^ ERROR `async fn` is not permitted in the 2015 edition +//~^ ERROR `async fn` is not permitted in Rust 2015 //~| NOTE to use `async fn`, switch to Rust 2018 or later //~| HELP set `edition = "2018"` in `Cargo.toml` //~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide let x = async {}; //~^ ERROR cannot find struct, variant or union type `async` in this scope - //~| NOTE `async` blocks are only allowed in the 2018 edition - let y = async { //~ NOTE `async` blocks are only allowed in edition 2018 or later + //~| NOTE `async` blocks are only allowed in Rust 2018 or later + let y = async { //~ NOTE `async` blocks are only allowed in Rust 2018 or later let x = 42; //~^ ERROR expected identifier, found keyword `let` //~| NOTE expected identifier, found keyword @@ -15,7 +15,7 @@ async fn foo() { //~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide 42 }; - let z = async { //~ NOTE `async` blocks are only allowed in edition 2018 or later + let z = async { //~ NOTE `async` blocks are only allowed in Rust 2018 or later 42 //~^ ERROR expected identifier, found `42` //~| NOTE expected identifier diff --git a/src/test/ui/editions/async-block-2015.stderr b/src/test/ui/editions/async-block-2015.stderr index d65761d79ff..e42747c804c 100644 --- a/src/test/ui/editions/async-block-2015.stderr +++ b/src/test/ui/editions/async-block-2015.stderr @@ -1,4 +1,4 @@ -error[E0670]: `async fn` is not permitted in the 2015 edition +error[E0670]: `async fn` is not permitted in Rust 2015 --> $DIR/async-block-2015.rs:1:1 | LL | async fn foo() { @@ -11,7 +11,7 @@ error: expected identifier, found keyword `let` --> $DIR/async-block-2015.rs:11:9 | LL | let y = async { - | ----- `async` blocks are only allowed in edition 2018 or later + | ----- `async` blocks are only allowed in Rust 2018 or later LL | let x = 42; | ^^^ expected identifier, found keyword | @@ -22,7 +22,7 @@ error: expected identifier, found `42` --> $DIR/async-block-2015.rs:19:9 | LL | let z = async { - | ----- `async` blocks are only allowed in edition 2018 or later + | ----- `async` blocks are only allowed in Rust 2018 or later LL | 42 | ^^ expected identifier | @@ -33,7 +33,7 @@ error[E0422]: cannot find struct, variant or union type `async` in this scope --> $DIR/async-block-2015.rs:7:13 | LL | let x = async {}; - | ^^^^^ `async` blocks are only allowed in the 2018 edition + | ^^^^^ `async` blocks are only allowed in Rust 2018 or later error: aborting due to 4 previous errors diff --git a/src/test/ui/try-block/try-block-in-edition2015.stderr b/src/test/ui/try-block/try-block-in-edition2015.stderr index 78cdfb2cc7f..0f3c14b1386 100644 --- a/src/test/ui/try-block/try-block-in-edition2015.stderr +++ b/src/test/ui/try-block/try-block-in-edition2015.stderr @@ -13,7 +13,7 @@ error[E0574]: expected struct, variant or union type, found macro `try` LL | let try_result: Option<_> = try { | ^^^ not a struct, variant or union type | - = note: if you want the `try` keyword, you need to be in the 2018 edition + = note: if you want the `try` keyword, you need Rust 2018 or later help: use `!` to invoke the macro | LL | let try_result: Option<_> = try! { -- cgit 1.4.1-3-g733a5