Skip to content

Commit d97be7b

Browse files
committed
Auto merge of #28486 - nrc:pub-extern-crate, r=alexcrichton
Temporary 'fix' for #26775 r? @brson
2 parents 2915f89 + 269c59d commit d97be7b

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

src/libsyntax/parse/parser.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -5101,12 +5101,19 @@ impl<'a> Parser<'a> {
51015101
try!(self.expect(&token::Semi));
51025102

51035103
let last_span = self.last_span;
5104+
5105+
if visibility == ast::Public {
5106+
self.span_warn(mk_sp(lo, last_span.hi),
5107+
"`pub extern crate` does not work as expected and should not be used. \
5108+
Likely to become an error. Prefer `extern crate` and `pub use`.");
5109+
}
5110+
51045111
Ok(self.mk_item(lo,
5105-
last_span.hi,
5106-
ident,
5107-
ItemExternCrate(maybe_path),
5108-
visibility,
5109-
attrs))
5112+
last_span.hi,
5113+
ident,
5114+
ItemExternCrate(maybe_path),
5115+
visibility,
5116+
attrs))
51105117
}
51115118

51125119
/// Parse `extern` for foreign ABIs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Check that `pub extern crate` gives a warning.
12+
13+
14+
pub extern crate core; //~WARN `pub extern crate` does not work
15+
//~^ ERROR core
16+
17+
fn main() {
18+
}

0 commit comments

Comments
 (0)