Skip to content

Commit a9d4967

Browse files
committed
Auto merge of #53236 - alexreg:stabilise-raw-idents, r=cramertj
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 #48589. r? @cramertj CC @cuviper @Centril
2 parents 70c33bb + e221fcc commit a9d4967

30 files changed

+42
-109
lines changed

src/librustc_lint/builtin.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -1928,14 +1928,12 @@ impl Async2018 {
19281928
);
19291929

19301930
// Don't suggest about raw identifiers if the feature isn't active
1931-
if cx.sess.features_untracked().raw_identifiers {
1932-
lint.span_suggestion_with_applicability(
1933-
span,
1934-
"you can use a raw identifier to stay compatible",
1935-
"r#async".to_string(),
1936-
Applicability::MachineApplicable,
1937-
);
1938-
}
1931+
lint.span_suggestion_with_applicability(
1932+
span,
1933+
"you can use a raw identifier to stay compatible",
1934+
"r#async".to_string(),
1935+
Applicability::MachineApplicable,
1936+
);
19391937
lint.emit()
19401938
}
19411939
}

src/libsyntax/diagnostic_list.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,9 @@ Erroneous code example:
382382
383383
```ignore (limited to a warning during 2018 edition development)
384384
#![feature(rust_2018_preview)]
385-
#![feature(raw_identifiers)] // error: the feature `raw_identifiers` is
386-
// included in the Rust 2018 edition
385+
#![feature(impl_header_lifetime_elision)] // error: the feature
386+
// `impl_header_lifetime_elision` is
387+
// included in the Rust 2018 edition
387388
```
388389
389390
"##,

src/libsyntax/feature_gate.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,6 @@ declare_features! (
423423
// `use path as _;` and `extern crate c as _;`
424424
(active, underscore_imports, "1.26.0", Some(48216), None),
425425

426-
// Allows keywords to be escaped for use as identifiers
427-
(active, raw_identifiers, "1.26.0", Some(48589), Some(Edition::Edition2018)),
428-
429426
// Allows macro invocations in `extern {}` blocks
430427
(active, macros_in_extern, "1.27.0", Some(49476), None),
431428

@@ -651,6 +648,8 @@ declare_features! (
651648
// Allows importing and reexporting macros with `use`,
652649
// enables macro modularization in general.
653650
(accepted, use_extern_macros, "1.30.0", Some(35896), None),
651+
// Allows keywords to be escaped for use as identifiers
652+
(accepted, raw_identifiers, "1.30.0", Some(48589), None),
654653
);
655654

656655
// If you change this, please modify src/doc/unstable-book as well. You must
@@ -2072,16 +2071,6 @@ pub fn check_crate(krate: &ast::Crate,
20722071
plugin_attributes,
20732072
};
20742073

2075-
if !features.raw_identifiers {
2076-
for &span in sess.raw_identifier_spans.borrow().iter() {
2077-
if !span.allows_unstable() {
2078-
gate_feature!(&ctx, raw_identifiers, span,
2079-
"raw identifiers are experimental and subject to change"
2080-
);
2081-
}
2082-
}
2083-
}
2084-
20852074
let visitor = &mut PostExpansionVisitor { context: &ctx };
20862075
visitor.whole_crate_feature_gates(krate);
20872076
visit::walk_crate(visitor, krate);

src/test/run-pass/auxiliary/edition-kw-macro-2015.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// edition:2015
1212

13-
#![feature(raw_identifiers)]
14-
1513
#[macro_export]
1614
macro_rules! produces_async {
1715
() => (pub fn async() {})

src/test/run-pass/edition-keywords-2015-2015.rs

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// edition:2015
1212
// aux-build:edition-kw-macro-2015.rs
1313

14-
#![feature(raw_identifiers)]
15-
1614
#[macro_use]
1715
extern crate edition_kw_macro_2015;
1816

src/test/run-pass/edition-keywords-2015-2018.rs

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// edition:2015
1212
// aux-build:edition-kw-macro-2018.rs
1313

14-
#![feature(raw_identifiers)]
15-
1614
#[macro_use]
1715
extern crate edition_kw_macro_2018;
1816

src/test/run-pass/rfc-2151-raw-identifiers/attr.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(raw_identifiers)]
12-
1311
use std::mem;
1412

1513
#[r#repr(r#C, r#packed)]

src/test/run-pass/rfc-2151-raw-identifiers/basic.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(raw_identifiers)]
12-
1311
fn r#fn(r#match: u32) -> u32 {
1412
r#match
1513
}

src/test/run-pass/rfc-2151-raw-identifiers/items.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(raw_identifiers)]
12-
1311
#[derive(Debug, PartialEq, Eq)]
1412
struct IntWrapper(u32);
1513

src/test/run-pass/rfc-2151-raw-identifiers/macros.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
#![feature(decl_macro)]
12-
#![feature(raw_identifiers)]
1312

1413
r#macro_rules! r#struct {
1514
($r#struct:expr) => { $r#struct }

src/test/ui/E0705.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@
1010

1111
// compile-pass
1212

13-
#![feature(raw_identifiers)]
14-
//~^ WARN the feature `raw_identifiers` is included in the Rust 2018 edition
13+
#![feature(impl_header_lifetime_elision)]
14+
//~^ WARN the feature `impl_header_lifetime_elision` is included in the Rust 2018 edition
1515
#![feature(rust_2018_preview)]
1616

17-
fn main() {
18-
let foo = 0;
19-
let bar = r#foo;
20-
}
17+
fn main() {}

src/test/ui/E0705.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
warning[E0705]: the feature `raw_identifiers` is included in the Rust 2018 edition
1+
warning[E0705]: the feature `impl_header_lifetime_elision` is included in the Rust 2018 edition
22
--> $DIR/E0705.rs:13:12
33
|
4-
LL | #![feature(raw_identifiers)]
5-
| ^^^^^^^^^^^^^^^
4+
LL | #![feature(impl_header_lifetime_elision)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

src/test/ui/editions/auxiliary/edition-kw-macro-2015.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// edition:2015
1212

13-
#![feature(raw_identifiers)]
1413
#![allow(async_idents)]
1514

1615
#[macro_export]

src/test/ui/editions/edition-keywords-2015-2015-expansion.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// aux-build:edition-kw-macro-2015.rs
1313
// compile-pass
1414

15-
#![feature(raw_identifiers)]
1615
#![allow(async_idents)]
1716

1817
#[macro_use]

src/test/ui/editions/edition-keywords-2015-2015-parsing.rs

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// edition:2015
1212
// aux-build:edition-kw-macro-2015.rs
1313

14-
#![feature(raw_identifiers)]
15-
1614
#[macro_use]
1715
extern crate edition_kw_macro_2015;
1816

src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: no rules expected the token `r#async`
2-
--> $DIR/edition-keywords-2015-2015-parsing.rs:24:31
2+
--> $DIR/edition-keywords-2015-2015-parsing.rs:22:31
33
|
44
LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
55
| ^^^^^^^
66

77
error: no rules expected the token `async`
8-
--> $DIR/edition-keywords-2015-2015-parsing.rs:25:35
8+
--> $DIR/edition-keywords-2015-2015-parsing.rs:23:35
99
|
1010
LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
1111
| ^^^^^

src/test/ui/editions/edition-keywords-2015-2018-expansion.rs

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// edition:2015
1212
// aux-build:edition-kw-macro-2018.rs
1313

14-
#![feature(raw_identifiers)]
15-
1614
#[macro_use]
1715
extern crate edition_kw_macro_2018;
1816

src/test/ui/editions/edition-keywords-2015-2018-expansion.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected identifier, found reserved keyword `async`
2-
--> $DIR/edition-keywords-2015-2018-expansion.rs:20:5
2+
--> $DIR/edition-keywords-2015-2018-expansion.rs:18:5
33
|
44
LL | produces_async! {} //~ ERROR expected identifier, found reserved keyword
55
| ^^^^^^^^^^^^^^^^^^ expected identifier, found reserved keyword

src/test/ui/editions/edition-keywords-2015-2018-parsing.rs

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// edition:2015
1212
// aux-build:edition-kw-macro-2018.rs
1313

14-
#![feature(raw_identifiers)]
15-
1614
#[macro_use]
1715
extern crate edition_kw_macro_2018;
1816

src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: no rules expected the token `r#async`
2-
--> $DIR/edition-keywords-2015-2018-parsing.rs:24:31
2+
--> $DIR/edition-keywords-2015-2018-parsing.rs:22:31
33
|
44
LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
55
| ^^^^^^^
66

77
error: no rules expected the token `async`
8-
--> $DIR/edition-keywords-2015-2018-parsing.rs:25:35
8+
--> $DIR/edition-keywords-2015-2018-parsing.rs:23:35
99
|
1010
LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
1111
| ^^^^^

src/test/ui/feature-gates/feature-gate-raw-identifiers.rs

-14
This file was deleted.

src/test/ui/feature-gates/feature-gate-raw-identifiers.stderr

-11
This file was deleted.

src/test/ui/raw/raw-literal-keywords.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// compile-flags: -Z parse-only
1212

13-
#![feature(raw_identifiers)]
14-
1513
fn test_if() {
1614
r#if true { } //~ ERROR found `true`
1715
}

src/test/ui/raw/raw-literal-keywords.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `true`
2-
--> $DIR/raw-literal-keywords.rs:16:10
2+
--> $DIR/raw-literal-keywords.rs:14:10
33
|
44
LL | r#if true { } //~ ERROR found `true`
55
| ^^^^ expected one of 8 possible tokens here
66

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

1313
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test`
14-
--> $DIR/raw-literal-keywords.rs:24:13
14+
--> $DIR/raw-literal-keywords.rs:22:13
1515
|
1616
LL | r#union Test; //~ ERROR found `Test`
1717
| ^^^^ expected one of 8 possible tokens here

src/test/ui/raw/raw-literal-self.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// compile-flags: -Z parse-only
1212

13-
#![feature(raw_identifiers)]
14-
1513
fn self_test(r#self: u32) {
1614
//~^ ERROR `r#self` is not currently supported.
1715
}

src/test/ui/raw/raw-literal-self.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `r#self` is not currently supported.
2-
--> $DIR/raw-literal-self.rs:15:14
2+
--> $DIR/raw-literal-self.rs:13:14
33
|
44
LL | fn self_test(r#self: u32) {
55
| ^^^^^^

src/test/ui/rust-2018/async-ident-allowed.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: `async` is a keyword in the 2018 edition
22
--> $DIR/async-ident-allowed.rs:19:9
33
|
44
LL | let async = 3; //~ ERROR: is a keyword
5-
| ^^^^^
5+
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#async`
66
|
77
note: lint level defined here
88
--> $DIR/async-ident-allowed.rs:13:9

src/test/ui/rust-2018/async-ident.fixed

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(raw_identifiers)]
1211
#![allow(dead_code, unused_variables, non_camel_case_types, non_upper_case_globals)]
1312
#![deny(async_idents)]
1413

src/test/ui/rust-2018/async-ident.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(raw_identifiers)]
1211
#![allow(dead_code, unused_variables, non_camel_case_types, non_upper_case_globals)]
1312
#![deny(async_idents)]
1413

0 commit comments

Comments
 (0)