Skip to content

Commit

Permalink
Rollup merge of rust-lang#53236 - alexreg:stabilise-raw-idents, r=cra…
Browse files Browse the repository at this point in the history
…mertj

Stabilise raw_identifiers feature

* [Reference PR](rust-lang/reference#395)
* [Book PR](rust-lang/book#1480)
* [Rust by Example PR](rust-lang/rust-by-example#1095)

Closes rust-lang#48589.

r? @cramertj
CC @cuviper @Centril
  • Loading branch information
kennytm committed Aug 11, 2018
2 parents c95edca + 176f8c2 commit dcfbdea
Show file tree
Hide file tree
Showing 30 changed files with 42 additions and 109 deletions.
14 changes: 6 additions & 8 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1927,14 +1927,12 @@ impl Async2018 {
);

// Don't suggest about raw identifiers if the feature isn't active
if cx.sess.features_untracked().raw_identifiers {
lint.span_suggestion_with_applicability(
span,
"you can use a raw identifier to stay compatible",
"r#async".to_string(),
Applicability::MachineApplicable,
);
}
lint.span_suggestion_with_applicability(
span,
"you can use a raw identifier to stay compatible",
"r#async".to_string(),
Applicability::MachineApplicable,
);
lint.emit()
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/libsyntax/diagnostic_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,9 @@ Erroneous code example:
```ignore (limited to a warning during 2018 edition development)
#![feature(rust_2018_preview)]
#![feature(raw_identifiers)] // error: the feature `raw_identifiers` is
// included in the Rust 2018 edition
#![feature(impl_header_lifetime_elision)] // error: the feature
// `impl_header_lifetime_elision` is
// included in the Rust 2018 edition
```
"##,
Expand Down
15 changes: 2 additions & 13 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,6 @@ declare_features! (
// `use path as _;` and `extern crate c as _;`
(active, underscore_imports, "1.26.0", Some(48216), None),

// Allows keywords to be escaped for use as identifiers
(active, raw_identifiers, "1.26.0", Some(48589), Some(Edition::Edition2018)),

// Allows macro invocations in `extern {}` blocks
(active, macros_in_extern, "1.27.0", Some(49476), None),

Expand Down Expand Up @@ -646,6 +643,8 @@ declare_features! (
(accepted, repr_transparent, "1.28.0", Some(43036), None),
// Defining procedural macros in `proc-macro` crates
(accepted, proc_macro, "1.29.0", Some(38356), None),
// Allows keywords to be escaped for use as identifiers
(accepted, raw_identifiers, "1.30.0", Some(48589), None),
);

// If you change this, please modify src/doc/unstable-book as well. You must
Expand Down Expand Up @@ -2021,16 +2020,6 @@ pub fn check_crate(krate: &ast::Crate,
plugin_attributes,
};

if !features.raw_identifiers {
for &span in sess.raw_identifier_spans.borrow().iter() {
if !span.allows_unstable() {
gate_feature!(&ctx, raw_identifiers, span,
"raw identifiers are experimental and subject to change"
);
}
}
}

let visitor = &mut PostExpansionVisitor { context: &ctx };
visitor.whole_crate_feature_gates(krate);
visit::walk_crate(visitor, krate);
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/auxiliary/edition-kw-macro-2015.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

// edition:2015

#![feature(raw_identifiers)]

#[macro_export]
macro_rules! produces_async {
() => (pub fn async() {})
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/edition-keywords-2015-2015.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
// edition:2015
// aux-build:edition-kw-macro-2015.rs

#![feature(raw_identifiers)]

#[macro_use]
extern crate edition_kw_macro_2015;

Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/edition-keywords-2015-2018.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
// edition:2015
// aux-build:edition-kw-macro-2018.rs

#![feature(raw_identifiers)]

#[macro_use]
extern crate edition_kw_macro_2018;

Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/rfc-2151-raw-identifiers/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(raw_identifiers)]

use std::mem;

#[r#repr(r#C, r#packed)]
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/rfc-2151-raw-identifiers/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(raw_identifiers)]

fn r#fn(r#match: u32) -> u32 {
r#match
}
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/rfc-2151-raw-identifiers/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(raw_identifiers)]

#[derive(Debug, PartialEq, Eq)]
struct IntWrapper(u32);

Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/rfc-2151-raw-identifiers/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

#![feature(decl_macro)]
#![feature(raw_identifiers)]

r#macro_rules! r#struct {
($r#struct:expr) => { $r#struct }
Expand Down
9 changes: 3 additions & 6 deletions src/test/ui/E0705.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
// compile-pass

#![feature(rust_2018_preview)]
#![feature(raw_identifiers)]
//~^ WARN the feature `raw_identifiers` is included in the Rust 2018 edition
#![feature(impl_header_lifetime_elision)]
//~^ WARN the feature `impl_header_lifetime_elision` is included in the Rust 2018 edition

fn main() {
let foo = 0;
let bar = r#foo;
}
fn main() {}
6 changes: 3 additions & 3 deletions src/test/ui/E0705.stderr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
warning[E0705]: the feature `raw_identifiers` is included in the Rust 2018 edition
warning[E0705]: the feature `impl_header_lifetime_elision` is included in the Rust 2018 edition
--> $DIR/E0705.rs:14:12
|
LL | #![feature(raw_identifiers)]
| ^^^^^^^^^^^^^^^
LL | #![feature(impl_header_lifetime_elision)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1 change: 0 additions & 1 deletion src/test/ui/auxiliary/edition-kw-macro-2015.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

// edition:2015

#![feature(raw_identifiers)]
#![allow(async_idents)]

#[macro_export]
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/edition-keywords-2015-2015-expansion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// aux-build:edition-kw-macro-2015.rs
// compile-pass

#![feature(raw_identifiers)]
#![allow(async_idents)]

#[macro_use]
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/edition-keywords-2015-2015-parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
// edition:2015
// aux-build:edition-kw-macro-2015.rs

#![feature(raw_identifiers)]

#[macro_use]
extern crate edition_kw_macro_2015;

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/edition-keywords-2015-2015-parsing.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error: no rules expected the token `r#async`
--> $DIR/edition-keywords-2015-2015-parsing.rs:24:31
--> $DIR/edition-keywords-2015-2015-parsing.rs:22:31
|
LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
| ^^^^^^^

error: no rules expected the token `async`
--> $DIR/edition-keywords-2015-2015-parsing.rs:25:35
--> $DIR/edition-keywords-2015-2015-parsing.rs:23:35
|
LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
| ^^^^^
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/edition-keywords-2015-2018-expansion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
// edition:2015
// aux-build:edition-kw-macro-2018.rs

#![feature(raw_identifiers)]

#[macro_use]
extern crate edition_kw_macro_2018;

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/edition-keywords-2015-2018-expansion.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected identifier, found reserved keyword `async`
--> $DIR/edition-keywords-2015-2018-expansion.rs:20:5
--> $DIR/edition-keywords-2015-2018-expansion.rs:18:5
|
LL | produces_async! {} //~ ERROR expected identifier, found reserved keyword
| ^^^^^^^^^^^^^^^^^^ expected identifier, found reserved keyword
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/edition-keywords-2015-2018-parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
// edition:2015
// aux-build:edition-kw-macro-2018.rs

#![feature(raw_identifiers)]

#[macro_use]
extern crate edition_kw_macro_2018;

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/edition-keywords-2015-2018-parsing.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error: no rules expected the token `r#async`
--> $DIR/edition-keywords-2015-2018-parsing.rs:24:31
--> $DIR/edition-keywords-2015-2018-parsing.rs:22:31
|
LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
| ^^^^^^^

error: no rules expected the token `async`
--> $DIR/edition-keywords-2015-2018-parsing.rs:25:35
--> $DIR/edition-keywords-2015-2018-parsing.rs:23:35
|
LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
| ^^^^^
Expand Down
14 changes: 0 additions & 14 deletions src/test/ui/feature-gate-raw-identifiers.rs

This file was deleted.

11 changes: 0 additions & 11 deletions src/test/ui/feature-gate-raw-identifiers.stderr

This file was deleted.

2 changes: 0 additions & 2 deletions src/test/ui/raw-literal-keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

// compile-flags: -Z parse-only

#![feature(raw_identifiers)]

fn test_if() {
r#if true { } //~ ERROR found `true`
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/raw-literal-keywords.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `true`
--> $DIR/raw-literal-keywords.rs:16:10
--> $DIR/raw-literal-keywords.rs:14:10
|
LL | r#if true { } //~ ERROR found `true`
| ^^^^ expected one of 8 possible tokens here

error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test`
--> $DIR/raw-literal-keywords.rs:20:14
--> $DIR/raw-literal-keywords.rs:18:14
|
LL | r#struct Test; //~ ERROR found `Test`
| ^^^^ expected one of 8 possible tokens here

error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test`
--> $DIR/raw-literal-keywords.rs:24:13
--> $DIR/raw-literal-keywords.rs:22:13
|
LL | r#union Test; //~ ERROR found `Test`
| ^^^^ expected one of 8 possible tokens here
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/raw-literal-self.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

// compile-flags: -Z parse-only

#![feature(raw_identifiers)]

fn self_test(r#self: u32) {
//~^ ERROR `r#self` is not currently supported.
}
2 changes: 1 addition & 1 deletion src/test/ui/raw-literal-self.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: `r#self` is not currently supported.
--> $DIR/raw-literal-self.rs:15:14
--> $DIR/raw-literal-self.rs:13:14
|
LL | fn self_test(r#self: u32) {
| ^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/rust-2018/async-ident-allowed.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: `async` is a keyword in the 2018 edition
--> $DIR/async-ident-allowed.rs:19:9
|
LL | let async = 3; //~ ERROR: is a keyword
| ^^^^^
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
|
note: lint level defined here
--> $DIR/async-ident-allowed.rs:13:9
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/rust-2018/async-ident.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(raw_identifiers)]
#![allow(dead_code, unused_variables, non_camel_case_types, non_upper_case_globals)]
#![deny(async_idents)]

Expand Down
1 change: 0 additions & 1 deletion src/test/ui/rust-2018/async-ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(raw_identifiers)]
#![allow(dead_code, unused_variables, non_camel_case_types, non_upper_case_globals)]
#![deny(async_idents)]

Expand Down
Loading

0 comments on commit dcfbdea

Please sign in to comment.