Skip to content

Commit

Permalink
librustc: Obsolete the old external crate renaming syntax.
Browse files Browse the repository at this point in the history
Instead of `extern crate foo = bar`, write `extern crate bar as foo`.
Instead of `extern crate baz = "quux"`, write `extern crate "quux" as
baz`.

Closes #16461.

[breaking-change]
  • Loading branch information
pcwalton committed Sep 10, 2014
1 parent a1f4973 commit 1bce869
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ extern crate flate;
extern crate getopts;
extern crate graphviz;
extern crate libc;
extern crate "rustc_llvm" as llvm;
extern crate "rustc_back" as rustc_back;
extern crate rustc_llvm;
extern crate rustc_back;
extern crate serialize;
extern crate rbml;
extern crate time;
Expand All @@ -53,6 +53,8 @@ extern crate time;
#[cfg(test)]
extern crate test;

pub use rustc_llvm as llvm;

mod diagnostics;

pub mod back {
Expand Down
5 changes: 5 additions & 0 deletions src/libsyntax/parse/obsolete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub enum ObsoleteSyntax {
ObsoleteManagedExpr,
ObsoleteImportRenaming,
ObsoleteSubsliceMatch,
ObsoleteExternCrateRenaming,
}

pub trait ParserObsoleteMethods {
Expand Down Expand Up @@ -92,6 +93,10 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
ObsoleteSubsliceMatch => (
"subslice match syntax",
"instead of `..xs`, write `xs..` in a pattern"
),
ObsoleteExternCrateRenaming => (
"`extern crate foo = bar` syntax",
"write `extern crate bar as foo` instead"
)
};

Expand Down
6 changes: 1 addition & 5 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4783,11 +4783,7 @@ impl<'a> Parser<'a> {
self.bump();
let path = self.parse_str();
let span = self.span;
self.span_warn(span,
format!("this extern crate syntax is deprecated. \
Use: extern crate \"{}\" as {};",
path.ref0().get(), the_ident.as_str() ).as_slice()
);
self.obsolete(span, ObsoleteExternCrateRenaming);
Some(path)
} else {None};

Expand Down

5 comments on commit 1bce869

@bors
Copy link
Contributor

@bors bors commented on 1bce869 Sep 10, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from brson
at pcwalton@1bce869

@bors
Copy link
Contributor

@bors bors commented on 1bce869 Sep 10, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging pcwalton/rust/remove-old-import-renaming-syntax = 1bce869 into auto

@bors
Copy link
Contributor

@bors bors commented on 1bce869 Sep 10, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pcwalton/rust/remove-old-import-renaming-syntax = 1bce869 merged ok, testing candidate = 036f380

@bors
Copy link
Contributor

@bors bors commented on 1bce869 Sep 10, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 1bce869 Sep 10, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 036f380

Please sign in to comment.