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

+1-1
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

+5-15
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

+15-3
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

+1-1
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

+10-37
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

+1-1
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

+2-2
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

+2-2
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

+1-1
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

+1-1
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;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
extern crate "issue-13872-2" as bar;
11+
extern crate issue_13872_2 as bar;
1212

1313
use bar::B;
1414

src/test/auxiliary/static-function-pointer-aux.rs

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

11-
#![crate_name="static-function-pointer-aux"]
1211

1312
pub fn f(x: isize) -> isize { -x }
1413

src/test/auxiliary/syntax_extension_with_dll_deps_2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#![crate_type = "dylib"]
1414
#![feature(plugin_registrar, quote, rustc_private)]
1515

16-
extern crate "syntax_extension_with_dll_deps_1" as other;
16+
extern crate syntax_extension_with_dll_deps_1 as other;
1717
extern crate syntax;
1818
extern crate rustc;
1919

src/test/auxiliary/trait_default_method_xc_aux.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![crate_name="trait_default_method_xc_aux"]
12-
1311
pub struct Something { pub x: isize }
1412

1513
pub trait A {

src/test/auxiliary/trait_default_method_xc_aux_2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// aux-build:trait_default_method_xc_aux.rs
1212

13-
extern crate "trait_default_method_xc_aux" as aux;
13+
extern crate trait_default_method_xc_aux as aux;
1414
use aux::A;
1515

1616
pub struct a_struct { pub x: isize }

src/test/compile-fail/bad-crate-id2.rs

-14
This file was deleted.

src/test/compile-fail/use-meta-mismatch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010

1111
// error-pattern:can't find crate for `extra`
1212

13-
extern crate "fake-crate" as extra;
13+
extern crate fake_crate as extra;
1414

1515
fn main() { }

src/test/compile-fail/weak-lang-item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
#![no_std]
1818

1919
extern crate core;
20-
extern crate "weak-lang-items" as other;
20+
extern crate weak_lang_items;

src/test/debuginfo/basic-types-globals-metadata.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,33 @@
1212

1313
// compile-flags:-g
1414
// gdb-command:run
15-
// gdb-command:whatis 'basic-types-globals-metadata::B'
15+
// gdb-command:whatis 'basic_types_globals_metadata::B'
1616
// gdb-check:type = bool
17-
// gdb-command:whatis 'basic-types-globals-metadata::I'
17+
// gdb-command:whatis 'basic_types_globals_metadata::I'
1818
// gdb-check:type = isize
19-
// gdb-command:whatis 'basic-types-globals-metadata::C'
19+
// gdb-command:whatis 'basic_types_globals_metadata::C'
2020
// gdb-check:type = char
21-
// gdb-command:whatis 'basic-types-globals-metadata::I8'
21+
// gdb-command:whatis 'basic_types_globals_metadata::I8'
2222
// gdb-check:type = i8
23-
// gdb-command:whatis 'basic-types-globals-metadata::I16'
23+
// gdb-command:whatis 'basic_types_globals_metadata::I16'
2424
// gdb-check:type = i16
25-
// gdb-command:whatis 'basic-types-globals-metadata::I32'
25+
// gdb-command:whatis 'basic_types_globals_metadata::I32'
2626
// gdb-check:type = i32
27-
// gdb-command:whatis 'basic-types-globals-metadata::I64'
27+
// gdb-command:whatis 'basic_types_globals_metadata::I64'
2828
// gdb-check:type = i64
29-
// gdb-command:whatis 'basic-types-globals-metadata::U'
29+
// gdb-command:whatis 'basic_types_globals_metadata::U'
3030
// gdb-check:type = usize
31-
// gdb-command:whatis 'basic-types-globals-metadata::U8'
31+
// gdb-command:whatis 'basic_types_globals_metadata::U8'
3232
// gdb-check:type = u8
33-
// gdb-command:whatis 'basic-types-globals-metadata::U16'
33+
// gdb-command:whatis 'basic_types_globals_metadata::U16'
3434
// gdb-check:type = u16
35-
// gdb-command:whatis 'basic-types-globals-metadata::U32'
35+
// gdb-command:whatis 'basic_types_globals_metadata::U32'
3636
// gdb-check:type = u32
37-
// gdb-command:whatis 'basic-types-globals-metadata::U64'
37+
// gdb-command:whatis 'basic_types_globals_metadata::U64'
3838
// gdb-check:type = u64
39-
// gdb-command:whatis 'basic-types-globals-metadata::F32'
39+
// gdb-command:whatis 'basic_types_globals_metadata::F32'
4040
// gdb-check:type = f32
41-
// gdb-command:whatis 'basic-types-globals-metadata::F64'
41+
// gdb-command:whatis 'basic_types_globals_metadata::F64'
4242
// gdb-check:type = f64
4343
// gdb-command:continue
4444

src/test/debuginfo/basic-types-globals.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,33 @@
1818

1919
// compile-flags:-g
2020
// gdb-command:run
21-
// gdb-command:print 'basic-types-globals::B'
21+
// gdb-command:print 'basic_types_globals::B'
2222
// gdb-check:$1 = false
23-
// gdb-command:print 'basic-types-globals::I'
23+
// gdb-command:print 'basic_types_globals::I'
2424
// gdb-check:$2 = -1
25-
// gdb-command:print 'basic-types-globals::C'
25+
// gdb-command:print 'basic_types_globals::C'
2626
// gdb-check:$3 = 97
27-
// gdb-command:print/d 'basic-types-globals::I8'
27+
// gdb-command:print/d 'basic_types_globals::I8'
2828
// gdb-check:$4 = 68
29-
// gdb-command:print 'basic-types-globals::I16'
29+
// gdb-command:print 'basic_types_globals::I16'
3030
// gdb-check:$5 = -16
31-
// gdb-command:print 'basic-types-globals::I32'
31+
// gdb-command:print 'basic_types_globals::I32'
3232
// gdb-check:$6 = -32
33-
// gdb-command:print 'basic-types-globals::I64'
33+
// gdb-command:print 'basic_types_globals::I64'
3434
// gdb-check:$7 = -64
35-
// gdb-command:print 'basic-types-globals::U'
35+
// gdb-command:print 'basic_types_globals::U'
3636
// gdb-check:$8 = 1
37-
// gdb-command:print/d 'basic-types-globals::U8'
37+
// gdb-command:print/d 'basic_types_globals::U8'
3838
// gdb-check:$9 = 100
39-
// gdb-command:print 'basic-types-globals::U16'
39+
// gdb-command:print 'basic_types_globals::U16'
4040
// gdb-check:$10 = 16
41-
// gdb-command:print 'basic-types-globals::U32'
41+
// gdb-command:print 'basic_types_globals::U32'
4242
// gdb-check:$11 = 32
43-
// gdb-command:print 'basic-types-globals::U64'
43+
// gdb-command:print 'basic_types_globals::U64'
4444
// gdb-check:$12 = 64
45-
// gdb-command:print 'basic-types-globals::F32'
45+
// gdb-command:print 'basic_types_globals::F32'
4646
// gdb-check:$13 = 2.5
47-
// gdb-command:print 'basic-types-globals::F64'
47+
// gdb-command:print 'basic_types_globals::F64'
4848
// gdb-check:$14 = 3.5
4949
// gdb-command:continue
5050

0 commit comments

Comments
 (0)