Skip to content

Commit d3a4f36

Browse files
committed
rollup merge of #23786: alexcrichton/less-quotes
Conflicts: src/test/auxiliary/static-function-pointer-aux.rs src/test/auxiliary/trait_default_method_xc_aux.rs src/test/run-pass/issue-4545.rs
2 parents 1c0e1a8 + e77db16 commit d3a4f36

File tree

100 files changed

+259
-300
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+259
-300
lines changed

src/doc/reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ extern crate pcre;
937937
938938
extern crate std; // equivalent to: extern crate std as std;
939939
940-
extern crate "std" as ruststd; // linking to 'std' under another name
940+
extern crate std as ruststd; // linking to 'std' under another name
941941
```
942942

943943
##### Use declarations

src/librustc/metadata/creader.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,24 +73,20 @@ struct CrateInfo {
7373
}
7474

7575
pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
76-
let say = |s: &str, warn: bool| {
76+
let say = |s: &str| {
7777
match (sp, sess) {
7878
(_, None) => panic!("{}", s),
79-
(Some(sp), Some(sess)) if warn => sess.span_warn(sp, s),
8079
(Some(sp), Some(sess)) => sess.span_err(sp, s),
81-
(None, Some(sess)) if warn => sess.warn(s),
8280
(None, Some(sess)) => sess.err(s),
8381
}
8482
};
8583
if s.len() == 0 {
86-
say("crate name must not be empty", false);
87-
} else if s.contains("-") {
88-
say(&format!("crate names soon cannot contain hyphens: {}", s), true);
84+
say("crate name must not be empty");
8985
}
9086
for c in s.chars() {
9187
if c.is_alphanumeric() { continue }
92-
if c == '_' || c == '-' { continue }
93-
say(&format!("invalid character `{}` in crate name: `{}`", c, s), false);
88+
if c == '_' { continue }
89+
say(&format!("invalid character `{}` in crate name: `{}`", c, s));
9490
}
9591
match sess {
9692
Some(sess) => sess.abort_if_errors(),
@@ -306,13 +302,7 @@ impl<'a> CrateReader<'a> {
306302
-> Option<ast::CrateNum> {
307303
let mut ret = None;
308304
self.sess.cstore.iter_crate_data(|cnum, data| {
309-
// For now we do a "fuzzy match" on crate names by considering
310-
// hyphens equal to underscores. This is purely meant to be a
311-
// transitionary feature while we deprecate the quote syntax of
312-
// `extern crate` statements.
313-
if data.name != name.replace("-", "_") {
314-
return
315-
}
305+
if data.name != name { return }
316306

317307
match hash {
318308
Some(hash) if *hash == data.hash() => { ret = Some(cnum); return }

src/librustc_trans/back/link.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,19 @@ pub fn find_crate_name(sess: Option<&Session>,
159159
}
160160
if let Input::File(ref path) = *input {
161161
if let Some(s) = path.file_stem().and_then(|s| s.to_str()) {
162-
return validate(s.to_string(), None);
162+
if s.starts_with("-") {
163+
let msg = format!("crate names cannot start with a `-`, but \
164+
`{}` has a leading hyphen", s);
165+
if let Some(sess) = sess {
166+
sess.err(&msg);
167+
}
168+
} else {
169+
return validate(s.replace("-", "_"), None);
170+
}
163171
}
164172
}
165173

166-
"rust-out".to_string()
174+
"rust_out".to_string()
167175
}
168176

169177
pub fn build_link_meta(sess: &Session, krate: &ast::Crate,
@@ -455,7 +463,11 @@ pub fn filename_for_input(sess: &Session,
455463
}
456464
config::CrateTypeExecutable => {
457465
let suffix = &sess.target.target.options.exe_suffix;
458-
out_filename.with_file_name(&format!("{}{}", libname, suffix))
466+
if suffix.len() == 0 {
467+
out_filename.to_path_buf()
468+
} else {
469+
out_filename.with_extension(&suffix[1..])
470+
}
459471
}
460472
}
461473
}

src/librustdoc/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ fn runtest(test: &str, cratename: &str, libs: SearchPaths,
224224
// environment to ensure that the target loads the right libraries at
225225
// runtime. It would be a sad day if the *host* libraries were loaded as a
226226
// mistake.
227-
let mut cmd = Command::new(&outdir.path().join("rust-out"));
227+
let mut cmd = Command::new(&outdir.path().join("rust_out"));
228228
let var = DynamicLibrary::envvar();
229229
let newpath = {
230230
let path = env::var_os(var).unwrap_or(OsString::new());

src/libsyntax/parse/parser.rs

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4951,46 +4951,19 @@ impl<'a> Parser<'a> {
49514951
///
49524952
/// # Examples
49534953
///
4954-
/// extern crate url;
4955-
/// extern crate foo = "bar"; //deprecated
4956-
/// extern crate "bar" as foo;
4954+
/// extern crate foo;
4955+
/// extern crate bar as foo;
49574956
fn parse_item_extern_crate(&mut self,
4958-
lo: BytePos,
4959-
visibility: Visibility,
4960-
attrs: Vec<Attribute>)
4957+
lo: BytePos,
4958+
visibility: Visibility,
4959+
attrs: Vec<Attribute>)
49614960
-> P<Item> {
49624961

4963-
let (maybe_path, ident) = match self.token {
4964-
token::Ident(..) => {
4965-
let crate_name = self.parse_ident();
4966-
if self.eat_keyword(keywords::As) {
4967-
(Some(crate_name.name), self.parse_ident())
4968-
} else {
4969-
(None, crate_name)
4970-
}
4971-
},
4972-
token::Literal(token::Str_(..), suf) |
4973-
token::Literal(token::StrRaw(..), suf) => {
4974-
let sp = self.span;
4975-
self.expect_no_suffix(sp, "extern crate name", suf);
4976-
// forgo the internal suffix check of `parse_str` to
4977-
// avoid repeats (this unwrap will always succeed due
4978-
// to the restriction of the `match`)
4979-
let (s, _, _) = self.parse_optional_str().unwrap();
4980-
self.expect_keyword(keywords::As);
4981-
let the_ident = self.parse_ident();
4982-
self.obsolete(sp, ObsoleteSyntax::ExternCrateString);
4983-
let s = token::intern(&s);
4984-
(Some(s), the_ident)
4985-
},
4986-
_ => {
4987-
let span = self.span;
4988-
let token_str = self.this_token_to_string();
4989-
self.span_fatal(span,
4990-
&format!("expected extern crate name but \
4991-
found `{}`",
4992-
token_str));
4993-
}
4962+
let crate_name = self.parse_ident();
4963+
let (maybe_path, ident) = if self.eat_keyword(keywords::As) {
4964+
(Some(crate_name.name), self.parse_ident())
4965+
} else {
4966+
(None, crate_name)
49944967
};
49954968
self.expect(&token::Semi);
49964969

src/libsyntax/std_inject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct StandardLibraryInjector {
5252
impl fold::Folder for StandardLibraryInjector {
5353
fn fold_crate(&mut self, mut krate: ast::Crate) -> ast::Crate {
5454

55-
// The name to use in `extern crate "name" as std;`
55+
// The name to use in `extern crate name as std;`
5656
let actual_crate_name = match self.alt_std_name {
5757
Some(ref s) => token::intern(&s),
5858
None => token::intern("std"),

src/test/auxiliary/issue-12133-dylib2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212

1313
#![crate_type = "dylib"]
1414

15-
extern crate "issue-12133-rlib" as a;
16-
extern crate "issue-12133-dylib" as b;
15+
extern crate issue_12133_rlib as a;
16+
extern crate issue_12133_dylib as b;

src/test/auxiliary/issue-13560-3.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212

1313
#![crate_type = "rlib"]
1414

15-
#[macro_use] #[no_link] extern crate "issue-13560-1" as t1;
16-
#[macro_use] extern crate "issue-13560-2" as t2;
15+
#[macro_use] #[no_link] extern crate issue_13560_1 as t1;
16+
#[macro_use] extern crate issue_13560_2 as t2;

src/test/auxiliary/issue-13620-2.rs

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

11-
extern crate "issue-13620-1" as crate1;
11+
extern crate issue_13620_1 as crate1;
1212

1313
pub static FOO2: crate1::Foo = crate1::FOO;

src/test/auxiliary/issue-13872-2.rs

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

11-
extern crate "issue-13872-1" as foo;
11+
extern crate issue_13872_1 as foo;
1212

1313
pub use foo::A::B;

0 commit comments

Comments
 (0)