Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Consistently call editions "Rust 20xx" in messages.
  • Loading branch information
m-ou-se committed Dec 31, 2020
1 parent f16ef7d commit c574ded
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/expr.rs
Expand Up @@ -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");
};
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/item.rs
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Expand Up @@ -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)
},
Expand Down Expand Up @@ -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(_)) => {
Expand Down
18 changes: 9 additions & 9 deletions src/test/ui/async-await/edition-deny-async-fns-2015.rs
@@ -1,38 +1,38 @@
// 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`
}

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
};
}
18 changes: 9 additions & 9 deletions 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() {}
Expand All @@ -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() {} }
Expand All @@ -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() {
Expand All @@ -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() {}
Expand All @@ -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() {}
Expand All @@ -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() {}
Expand All @@ -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() {}
Expand All @@ -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() {}
Expand All @@ -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() {}
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/editions/async-block-2015.rs
@@ -1,21 +1,21 @@
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
//~| HELP set `edition = "2018"` in `Cargo.toml`
//~| 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
Expand Down
8 changes: 4 additions & 4 deletions 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() {
Expand All @@ -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
|
Expand All @@ -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
|
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/try-block/try-block-in-edition2015.stderr
Expand Up @@ -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! {
Expand Down

0 comments on commit c574ded

Please sign in to comment.