Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unaccept extern_in_paths #57572

Merged
merged 1 commit into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions src/doc/unstable-book/src/language-features/extern-in-paths.md

This file was deleted.

2 changes: 1 addition & 1 deletion src/librustc/middle/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub enum ExternCrateSource {
),
// Crate is loaded by `use`.
Use,
/// Crate is implicitly loaded by an absolute or an `extern::` path.
/// Crate is implicitly loaded by an absolute path.
Path,
}

Expand Down
9 changes: 4 additions & 5 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ enum ModuleOrUniformRoot<'a> {
CrateRootAndExternPrelude,

/// Virtual module that denotes resolution in extern prelude.
/// Used for paths starting with `::` on 2018 edition or `extern::`.
/// Used for paths starting with `::` on 2018 edition.
ExternPrelude,

/// Virtual module that denotes resolution in current scope.
Expand Down Expand Up @@ -3817,8 +3817,7 @@ impl<'a> Resolver<'a> {
self.resolve_self(&mut ctxt, self.current_module)));
continue;
}
if name == keywords::Extern.name() ||
name == keywords::PathRoot.name() && ident.span.rust_2018() {
if name == keywords::PathRoot.name() && ident.span.rust_2018() {
module = Some(ModuleOrUniformRoot::ExternPrelude);
continue;
}
Expand Down Expand Up @@ -3985,8 +3984,8 @@ impl<'a> Resolver<'a> {
};

// We're only interested in `use` paths which should start with
// `{{root}}` or `extern` currently.
if first_name != keywords::Extern.name() && first_name != keywords::PathRoot.name() {
// `{{root}}` currently.
if first_name != keywords::PathRoot.name() {
return
}

Expand Down
29 changes: 5 additions & 24 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ use syntax_pos::{Span, DUMMY_SP};
use errors::{DiagnosticBuilder, Handler};
use visit::{self, FnKind, Visitor};
use parse::ParseSess;
use symbol::{keywords, Symbol};
use symbol::Symbol;

use std::{env};
use std::env;

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

// `extern` in paths
(active, extern_in_paths, "1.23.0", Some(55600), None),

// Infer static outlives requirements (RFC 2093).
(active, infer_static_outlives_requirements, "1.26.0", Some(54185), None),

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

declare_features! (
Expand Down Expand Up @@ -1829,25 +1829,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
visit::walk_impl_item(self, ii);
}

fn visit_path(&mut self, path: &'a ast::Path, _id: NodeId) {
for segment in &path.segments {
// Identifiers we are going to check could come from a legacy macro (e.g., `#[test]`).
// For such macros identifiers must have empty context, because this context is
// used during name resolution and produced names must be unhygienic for compatibility.
// On the other hand, we need the actual non-empty context for feature gate checking
// because it's hygienic even for legacy macros. As previously stated, such context
// cannot be kept in identifiers, so it's kept in paths instead and we take it from
// there while keeping location info from the ident span.
let span = segment.ident.span.with_ctxt(path.span.ctxt());
if segment.ident.name == keywords::Extern.name() {
gate_feature_post!(&self, extern_in_paths, span,
"`extern` in paths is experimental");
}
}

visit::walk_path(self, path);
}

fn visit_vis(&mut self, vis: &'a ast::Visibility) {
if let ast::VisibilityKind::Crate(ast::CrateSugar::JustCrate) = vis.node {
gate_feature_post!(&self, crate_visibility_modifier, vis.span,
Expand Down
13 changes: 3 additions & 10 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ impl<'a> Parser<'a> {
fn token_is_bare_fn_keyword(&mut self) -> bool {
self.check_keyword(keywords::Fn) ||
self.check_keyword(keywords::Unsafe) ||
self.check_keyword(keywords::Extern) && self.is_extern_non_path()
self.check_keyword(keywords::Extern)
}

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

fn is_extern_non_path(&self) -> bool {
self.token.is_keyword(keywords::Extern) && self.look_ahead(1, |t| t != &token::ModSep)
}

fn is_existential_type_decl(&self) -> bool {
self.token.is_keyword(keywords::Existential) &&
self.look_ahead(1, |t| t.is_keyword(keywords::Type))
Expand Down Expand Up @@ -4712,12 +4708,10 @@ impl<'a> Parser<'a> {
// like a path (1 token), but it fact not a path.
// `union::b::c` - path, `union U { ... }` - not a path.
// `crate::b::c` - path, `crate struct S;` - not a path.
// `extern::b::c` - path, `extern crate c;` - not a path.
} else if self.token.is_path_start() &&
!self.token.is_qpath_start() &&
!self.is_union_item() &&
!self.is_crate_vis() &&
!self.is_extern_non_path() &&
!self.is_existential_type_decl() &&
!self.is_auto_trait_item() {
let pth = self.parse_path(PathStyle::Expr)?;
Expand Down Expand Up @@ -7113,8 +7107,7 @@ impl<'a> Parser<'a> {
return Ok(Some(item));
}

if self.check_keyword(keywords::Extern) && self.is_extern_non_path() {
self.bump(); // `extern`
if self.eat_keyword(keywords::Extern) {
if self.eat_keyword(keywords::Crate) {
return Ok(Some(self.parse_item_extern_crate(lo, visibility, attrs)?));
}
Expand Down Expand Up @@ -7623,7 +7616,7 @@ impl<'a> Parser<'a> {
fn parse_assoc_macro_invoc(&mut self, item_kind: &str, vis: Option<&Visibility>,
at_end: &mut bool) -> PResult<'a, Option<Mac>>
{
if self.token.is_path_start() && !self.is_extern_non_path() {
if self.token.is_path_start() {
let prev_span = self.prev_span;
let lo = self.span;
let pth = self.parse_path(PathStyle::Mod)?;
Expand Down
1 change: 0 additions & 1 deletion src/libsyntax_pos/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ impl Ident {
self.name == keywords::Super.name() ||
self.name == keywords::SelfLower.name() ||
self.name == keywords::SelfUpper.name() ||
self.name == keywords::Extern.name() ||
self.name == keywords::Crate.name() ||
self.name == keywords::PathRoot.name() ||
self.name == keywords::DollarCrate.name()
Expand Down
5 changes: 1 addition & 4 deletions src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
-include ../tools.mk

all: extern_absolute_paths.rs extern_in_paths.rs krate2
all: extern_absolute_paths.rs krate2
$(RUSTC) extern_absolute_paths.rs -Zsave-analysis --edition=2018 \
-Z unstable-options --extern krate2
cat $(TMPDIR)/save-analysis/extern_absolute_paths.json | "$(PYTHON)" validate_json.py
$(RUSTC) extern_in_paths.rs -Zsave-analysis --edition=2018 \
-Z unstable-options --extern krate2
cat $(TMPDIR)/save-analysis/extern_in_paths.json | "$(PYTHON)" validate_json.py

krate2: krate2.rs
$(RUSTC) $<

This file was deleted.

28 changes: 0 additions & 28 deletions src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/extern.rs

This file was deleted.

5 changes: 0 additions & 5 deletions src/test/ui/feature-gates/feature-gate-extern_in_paths.rs

This file was deleted.

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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
let s = extern::foo::Bar; //~ ERROR expected expression, found keyword `extern`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: expected expression, found keyword `extern`
--> $DIR/keyword-extern-as-identifier-expr.rs:2:13
|
LL | let s = extern::foo::Bar; //~ ERROR expected expression, found keyword `extern`
| ^^^^^^ expected expression

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
let extern = 0; //~ ERROR expected pattern, found keyword `extern`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: expected pattern, found keyword `extern`
--> $DIR/keyword-extern-as-identifier-pat.rs:2:9
|
LL | let extern = 0; //~ ERROR expected pattern, found keyword `extern`
| ^^^^^^ expected pattern

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type A = extern::foo::bar; //~ ERROR expected `fn`, found `::`

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: expected `fn`, found `::`
--> $DIR/keyword-extern-as-identifier-type.rs:1:16
|
LL | type A = extern::foo::bar; //~ ERROR expected `fn`, found `::`
| ^^ expected `fn` here

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
use extern::foo; //~ ERROR expected identifier, found keyword `extern`

fn main() {}
12 changes: 12 additions & 0 deletions src/test/ui/keyword/extern/keyword-extern-as-identifier-use.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error: expected identifier, found keyword `extern`
--> $DIR/keyword-extern-as-identifier-use.rs:1:5
|
LL | use extern::foo; //~ ERROR expected identifier, found keyword `extern`
| ^^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | use r#extern::foo; //~ ERROR expected identifier, found keyword `extern`
| ^^^^^^^^

error: aborting due to previous error

5 changes: 0 additions & 5 deletions src/test/ui/keyword/keyword-extern-as-identifier.rs

This file was deleted.

9 changes: 0 additions & 9 deletions src/test/ui/keyword/keyword-extern-as-identifier.stderr

This file was deleted.

5 changes: 0 additions & 5 deletions src/test/ui/rfc-2126-extern-in-paths/auxiliary/xcrate.rs

This file was deleted.

5 changes: 0 additions & 5 deletions src/test/ui/rfc-2126-extern-in-paths/non-existent-1.rs

This file was deleted.

9 changes: 0 additions & 9 deletions src/test/ui/rfc-2126-extern-in-paths/non-existent-1.stderr

This file was deleted.

6 changes: 0 additions & 6 deletions src/test/ui/rfc-2126-extern-in-paths/non-existent-2.rs

This file was deleted.

9 changes: 0 additions & 9 deletions src/test/ui/rfc-2126-extern-in-paths/non-existent-2.stderr

This file was deleted.

5 changes: 0 additions & 5 deletions src/test/ui/rfc-2126-extern-in-paths/non-existent-3.rs

This file was deleted.

9 changes: 0 additions & 9 deletions src/test/ui/rfc-2126-extern-in-paths/non-existent-3.stderr

This file was deleted.

Loading