Skip to content

Commit c4f6ef2

Browse files
committed
remove extern_in_paths.
1 parent 75a369c commit c4f6ef2

30 files changed

+62
-233
lines changed

src/doc/unstable-book/src/language-features/extern-in-paths.md

-40
This file was deleted.

src/librustc/middle/cstore.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ pub enum ExternCrateSource {
140140
),
141141
// Crate is loaded by `use`.
142142
Use,
143-
/// Crate is implicitly loaded by an absolute or an `extern::` path.
143+
/// Crate is implicitly loaded by an absolute path.
144144
Path,
145145
}
146146

src/librustc_resolve/lib.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ enum ModuleOrUniformRoot<'a> {
10051005
CrateRootAndExternPrelude,
10061006

10071007
/// Virtual module that denotes resolution in extern prelude.
1008-
/// Used for paths starting with `::` on 2018 edition or `extern::`.
1008+
/// Used for paths starting with `::` on 2018 edition.
10091009
ExternPrelude,
10101010

10111011
/// Virtual module that denotes resolution in current scope.
@@ -3817,8 +3817,7 @@ impl<'a> Resolver<'a> {
38173817
self.resolve_self(&mut ctxt, self.current_module)));
38183818
continue;
38193819
}
3820-
if name == keywords::Extern.name() ||
3821-
name == keywords::PathRoot.name() && ident.span.rust_2018() {
3820+
if name == keywords::PathRoot.name() && ident.span.rust_2018() {
38223821
module = Some(ModuleOrUniformRoot::ExternPrelude);
38233822
continue;
38243823
}
@@ -3985,8 +3984,8 @@ impl<'a> Resolver<'a> {
39853984
};
39863985

39873986
// We're only interested in `use` paths which should start with
3988-
// `{{root}}` or `extern` currently.
3989-
if first_name != keywords::Extern.name() && first_name != keywords::PathRoot.name() {
3987+
// `{{root}}` currently.
3988+
if first_name != keywords::PathRoot.name() {
39903989
return
39913990
}
39923991

src/libsyntax/feature_gate.rs

+5-24
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ use syntax_pos::{Span, DUMMY_SP};
2525
use errors::{DiagnosticBuilder, Handler};
2626
use visit::{self, FnKind, Visitor};
2727
use parse::ParseSess;
28-
use symbol::{keywords, Symbol};
28+
use symbol::Symbol;
2929

30-
use std::{env};
30+
use std::env;
3131

3232
macro_rules! set {
3333
($field: ident) => {{
@@ -375,9 +375,6 @@ declare_features! (
375375
// Generic associated types (RFC 1598)
376376
(active, generic_associated_types, "1.23.0", Some(44265), None),
377377

378-
// `extern` in paths
379-
(active, extern_in_paths, "1.23.0", Some(55600), None),
380-
381378
// Infer static outlives requirements (RFC 2093).
382379
(active, infer_static_outlives_requirements, "1.26.0", Some(54185), None),
383380

@@ -506,6 +503,9 @@ declare_features! (
506503
// Allows the use of `#[derive(Anything)]` as sugar for `#[derive_Anything]`.
507504
(removed, custom_derive, "1.0.0", Some(29644), None,
508505
Some("subsumed by `#[proc_macro_derive]`")),
506+
// Paths of the form: `extern::foo::bar`
507+
(removed, extern_in_paths, "1.33.0", Some(55600), None,
508+
Some("subsumed by `::foo::bar` paths")),
509509
);
510510

511511
declare_features! (
@@ -1829,25 +1829,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
18291829
visit::walk_impl_item(self, ii);
18301830
}
18311831

1832-
fn visit_path(&mut self, path: &'a ast::Path, _id: NodeId) {
1833-
for segment in &path.segments {
1834-
// Identifiers we are going to check could come from a legacy macro (e.g., `#[test]`).
1835-
// For such macros identifiers must have empty context, because this context is
1836-
// used during name resolution and produced names must be unhygienic for compatibility.
1837-
// On the other hand, we need the actual non-empty context for feature gate checking
1838-
// because it's hygienic even for legacy macros. As previously stated, such context
1839-
// cannot be kept in identifiers, so it's kept in paths instead and we take it from
1840-
// there while keeping location info from the ident span.
1841-
let span = segment.ident.span.with_ctxt(path.span.ctxt());
1842-
if segment.ident.name == keywords::Extern.name() {
1843-
gate_feature_post!(&self, extern_in_paths, span,
1844-
"`extern` in paths is experimental");
1845-
}
1846-
}
1847-
1848-
visit::walk_path(self, path);
1849-
}
1850-
18511832
fn visit_vis(&mut self, vis: &'a ast::Visibility) {
18521833
if let ast::VisibilityKind::Crate(ast::CrateSugar::JustCrate) = vis.node {
18531834
gate_feature_post!(&self, crate_visibility_modifier, vis.span,

src/libsyntax/parse/parser.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ impl<'a> Parser<'a> {
12991299
fn token_is_bare_fn_keyword(&mut self) -> bool {
13001300
self.check_keyword(keywords::Fn) ||
13011301
self.check_keyword(keywords::Unsafe) ||
1302-
self.check_keyword(keywords::Extern) && self.is_extern_non_path()
1302+
self.check_keyword(keywords::Extern)
13031303
}
13041304

13051305
/// parse a `TyKind::BareFn` type:
@@ -4605,10 +4605,6 @@ impl<'a> Parser<'a> {
46054605
self.token.is_keyword(keywords::Crate) && self.look_ahead(1, |t| t != &token::ModSep)
46064606
}
46074607

4608-
fn is_extern_non_path(&self) -> bool {
4609-
self.token.is_keyword(keywords::Extern) && self.look_ahead(1, |t| t != &token::ModSep)
4610-
}
4611-
46124608
fn is_existential_type_decl(&self) -> bool {
46134609
self.token.is_keyword(keywords::Existential) &&
46144610
self.look_ahead(1, |t| t.is_keyword(keywords::Type))
@@ -4712,12 +4708,10 @@ impl<'a> Parser<'a> {
47124708
// like a path (1 token), but it fact not a path.
47134709
// `union::b::c` - path, `union U { ... }` - not a path.
47144710
// `crate::b::c` - path, `crate struct S;` - not a path.
4715-
// `extern::b::c` - path, `extern crate c;` - not a path.
47164711
} else if self.token.is_path_start() &&
47174712
!self.token.is_qpath_start() &&
47184713
!self.is_union_item() &&
47194714
!self.is_crate_vis() &&
4720-
!self.is_extern_non_path() &&
47214715
!self.is_existential_type_decl() &&
47224716
!self.is_auto_trait_item() {
47234717
let pth = self.parse_path(PathStyle::Expr)?;
@@ -7113,8 +7107,7 @@ impl<'a> Parser<'a> {
71137107
return Ok(Some(item));
71147108
}
71157109

7116-
if self.check_keyword(keywords::Extern) && self.is_extern_non_path() {
7117-
self.bump(); // `extern`
7110+
if self.eat_keyword(keywords::Extern) {
71187111
if self.eat_keyword(keywords::Crate) {
71197112
return Ok(Some(self.parse_item_extern_crate(lo, visibility, attrs)?));
71207113
}
@@ -7623,7 +7616,7 @@ impl<'a> Parser<'a> {
76237616
fn parse_assoc_macro_invoc(&mut self, item_kind: &str, vis: Option<&Visibility>,
76247617
at_end: &mut bool) -> PResult<'a, Option<Mac>>
76257618
{
7626-
if self.token.is_path_start() && !self.is_extern_non_path() {
7619+
if self.token.is_path_start() {
76277620
let prev_span = self.prev_span;
76287621
let lo = self.span;
76297622
let pth = self.parse_path(PathStyle::Mod)?;

src/libsyntax_pos/symbol.rs

-1
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,6 @@ impl Ident {
478478
self.name == keywords::Super.name() ||
479479
self.name == keywords::SelfLower.name() ||
480480
self.name == keywords::SelfUpper.name() ||
481-
self.name == keywords::Extern.name() ||
482481
self.name == keywords::Crate.name() ||
483482
self.name == keywords::PathRoot.name() ||
484483
self.name == keywords::DollarCrate.name()
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
-include ../tools.mk
22

3-
all: extern_absolute_paths.rs extern_in_paths.rs krate2
3+
all: extern_absolute_paths.rs krate2
44
$(RUSTC) extern_absolute_paths.rs -Zsave-analysis --edition=2018 \
55
-Z unstable-options --extern krate2
66
cat $(TMPDIR)/save-analysis/extern_absolute_paths.json | "$(PYTHON)" validate_json.py
7-
$(RUSTC) extern_in_paths.rs -Zsave-analysis --edition=2018 \
8-
-Z unstable-options --extern krate2
9-
cat $(TMPDIR)/save-analysis/extern_in_paths.json | "$(PYTHON)" validate_json.py
107

118
krate2: krate2.rs
129
$(RUSTC) $<

src/test/run-make-fulldeps/save-analysis-rfc2126/extern_in_paths.rs

-7
This file was deleted.

src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/extern.rs

-28
This file was deleted.

src/test/ui/feature-gates/feature-gate-extern_in_paths.rs

-5
This file was deleted.

src/test/ui/feature-gates/feature-gate-extern_in_paths.stderr

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
let s = extern::foo::Bar; //~ ERROR expected expression, found keyword `extern`
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: expected expression, found keyword `extern`
2+
--> $DIR/keyword-extern-as-identifier-expr.rs:2:13
3+
|
4+
LL | let s = extern::foo::Bar; //~ ERROR expected expression, found keyword `extern`
5+
| ^^^^^^ expected expression
6+
7+
error: aborting due to previous error
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
let extern = 0; //~ ERROR expected pattern, found keyword `extern`
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: expected pattern, found keyword `extern`
2+
--> $DIR/keyword-extern-as-identifier-pat.rs:2:9
3+
|
4+
LL | let extern = 0; //~ ERROR expected pattern, found keyword `extern`
5+
| ^^^^^^ expected pattern
6+
7+
error: aborting due to previous error
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
type A = extern::foo::bar; //~ ERROR expected `fn`, found `::`
2+
3+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: expected `fn`, found `::`
2+
--> $DIR/keyword-extern-as-identifier-type.rs:1:16
3+
|
4+
LL | type A = extern::foo::bar; //~ ERROR expected `fn`, found `::`
5+
| ^^ expected `fn` here
6+
7+
error: aborting due to previous error
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
use extern::foo; //~ ERROR expected identifier, found keyword `extern`
2+
3+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error: expected identifier, found keyword `extern`
2+
--> $DIR/keyword-extern-as-identifier-use.rs:1:5
3+
|
4+
LL | use extern::foo; //~ ERROR expected identifier, found keyword `extern`
5+
| ^^^^^^ expected identifier, found keyword
6+
help: you can escape reserved keywords to use them as identifiers
7+
|
8+
LL | use r#extern::foo; //~ ERROR expected identifier, found keyword `extern`
9+
| ^^^^^^^^
10+
11+
error: aborting due to previous error
12+

src/test/ui/keyword/keyword-extern-as-identifier.rs

-5
This file was deleted.

src/test/ui/keyword/keyword-extern-as-identifier.stderr

-9
This file was deleted.

src/test/ui/rfc-2126-extern-in-paths/auxiliary/xcrate.rs

-5
This file was deleted.

src/test/ui/rfc-2126-extern-in-paths/non-existent-1.rs

-5
This file was deleted.

src/test/ui/rfc-2126-extern-in-paths/non-existent-1.stderr

-9
This file was deleted.

src/test/ui/rfc-2126-extern-in-paths/non-existent-2.rs

-6
This file was deleted.

src/test/ui/rfc-2126-extern-in-paths/non-existent-2.stderr

-9
This file was deleted.

src/test/ui/rfc-2126-extern-in-paths/non-existent-3.rs

-5
This file was deleted.

src/test/ui/rfc-2126-extern-in-paths/non-existent-3.stderr

-9
This file was deleted.

0 commit comments

Comments
 (0)