Skip to content

Commit

Permalink
rollup merge of rust-lang#23786: alexcrichton/less-quotes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alexcrichton committed Mar 27, 2015
2 parents 1c0e1a8 + e77db16 commit d3a4f36
Show file tree
Hide file tree
Showing 100 changed files with 259 additions and 300 deletions.
2 changes: 1 addition & 1 deletion src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ extern crate pcre;
extern crate std; // equivalent to: extern crate std as std;
extern crate "std" as ruststd; // linking to 'std' under another name
extern crate std as ruststd; // linking to 'std' under another name
```

##### Use declarations
Expand Down
20 changes: 5 additions & 15 deletions src/librustc/metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,20 @@ struct CrateInfo {
}

pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
let say = |s: &str, warn: bool| {
let say = |s: &str| {
match (sp, sess) {
(_, None) => panic!("{}", s),
(Some(sp), Some(sess)) if warn => sess.span_warn(sp, s),
(Some(sp), Some(sess)) => sess.span_err(sp, s),
(None, Some(sess)) if warn => sess.warn(s),
(None, Some(sess)) => sess.err(s),
}
};
if s.len() == 0 {
say("crate name must not be empty", false);
} else if s.contains("-") {
say(&format!("crate names soon cannot contain hyphens: {}", s), true);
say("crate name must not be empty");
}
for c in s.chars() {
if c.is_alphanumeric() { continue }
if c == '_' || c == '-' { continue }
say(&format!("invalid character `{}` in crate name: `{}`", c, s), false);
if c == '_' { continue }
say(&format!("invalid character `{}` in crate name: `{}`", c, s));
}
match sess {
Some(sess) => sess.abort_if_errors(),
Expand Down Expand Up @@ -306,13 +302,7 @@ impl<'a> CrateReader<'a> {
-> Option<ast::CrateNum> {
let mut ret = None;
self.sess.cstore.iter_crate_data(|cnum, data| {
// For now we do a "fuzzy match" on crate names by considering
// hyphens equal to underscores. This is purely meant to be a
// transitionary feature while we deprecate the quote syntax of
// `extern crate` statements.
if data.name != name.replace("-", "_") {
return
}
if data.name != name { return }

match hash {
Some(hash) if *hash == data.hash() => { ret = Some(cnum); return }
Expand Down
18 changes: 15 additions & 3 deletions src/librustc_trans/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,19 @@ pub fn find_crate_name(sess: Option<&Session>,
}
if let Input::File(ref path) = *input {
if let Some(s) = path.file_stem().and_then(|s| s.to_str()) {
return validate(s.to_string(), None);
if s.starts_with("-") {
let msg = format!("crate names cannot start with a `-`, but \
`{}` has a leading hyphen", s);
if let Some(sess) = sess {
sess.err(&msg);
}
} else {
return validate(s.replace("-", "_"), None);
}
}
}

"rust-out".to_string()
"rust_out".to_string()
}

pub fn build_link_meta(sess: &Session, krate: &ast::Crate,
Expand Down Expand Up @@ -455,7 +463,11 @@ pub fn filename_for_input(sess: &Session,
}
config::CrateTypeExecutable => {
let suffix = &sess.target.target.options.exe_suffix;
out_filename.with_file_name(&format!("{}{}", libname, suffix))
if suffix.len() == 0 {
out_filename.to_path_buf()
} else {
out_filename.with_extension(&suffix[1..])
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ fn runtest(test: &str, cratename: &str, libs: SearchPaths,
// environment to ensure that the target loads the right libraries at
// runtime. It would be a sad day if the *host* libraries were loaded as a
// mistake.
let mut cmd = Command::new(&outdir.path().join("rust-out"));
let mut cmd = Command::new(&outdir.path().join("rust_out"));
let var = DynamicLibrary::envvar();
let newpath = {
let path = env::var_os(var).unwrap_or(OsString::new());
Expand Down
47 changes: 10 additions & 37 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4951,46 +4951,19 @@ impl<'a> Parser<'a> {
///
/// # Examples
///
/// extern crate url;
/// extern crate foo = "bar"; //deprecated
/// extern crate "bar" as foo;
/// extern crate foo;
/// extern crate bar as foo;
fn parse_item_extern_crate(&mut self,
lo: BytePos,
visibility: Visibility,
attrs: Vec<Attribute>)
lo: BytePos,
visibility: Visibility,
attrs: Vec<Attribute>)
-> P<Item> {

let (maybe_path, ident) = match self.token {
token::Ident(..) => {
let crate_name = self.parse_ident();
if self.eat_keyword(keywords::As) {
(Some(crate_name.name), self.parse_ident())
} else {
(None, crate_name)
}
},
token::Literal(token::Str_(..), suf) |
token::Literal(token::StrRaw(..), suf) => {
let sp = self.span;
self.expect_no_suffix(sp, "extern crate name", suf);
// forgo the internal suffix check of `parse_str` to
// avoid repeats (this unwrap will always succeed due
// to the restriction of the `match`)
let (s, _, _) = self.parse_optional_str().unwrap();
self.expect_keyword(keywords::As);
let the_ident = self.parse_ident();
self.obsolete(sp, ObsoleteSyntax::ExternCrateString);
let s = token::intern(&s);
(Some(s), the_ident)
},
_ => {
let span = self.span;
let token_str = self.this_token_to_string();
self.span_fatal(span,
&format!("expected extern crate name but \
found `{}`",
token_str));
}
let crate_name = self.parse_ident();
let (maybe_path, ident) = if self.eat_keyword(keywords::As) {
(Some(crate_name.name), self.parse_ident())
} else {
(None, crate_name)
};
self.expect(&token::Semi);

Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/std_inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct StandardLibraryInjector {
impl fold::Folder for StandardLibraryInjector {
fn fold_crate(&mut self, mut krate: ast::Crate) -> ast::Crate {

// The name to use in `extern crate "name" as std;`
// The name to use in `extern crate name as std;`
let actual_crate_name = match self.alt_std_name {
Some(ref s) => token::intern(&s),
None => token::intern("std"),
Expand Down
4 changes: 2 additions & 2 deletions src/test/auxiliary/issue-12133-dylib2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@

#![crate_type = "dylib"]

extern crate "issue-12133-rlib" as a;
extern crate "issue-12133-dylib" as b;
extern crate issue_12133_rlib as a;
extern crate issue_12133_dylib as b;
4 changes: 2 additions & 2 deletions src/test/auxiliary/issue-13560-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@

#![crate_type = "rlib"]

#[macro_use] #[no_link] extern crate "issue-13560-1" as t1;
#[macro_use] extern crate "issue-13560-2" as t2;
#[macro_use] #[no_link] extern crate issue_13560_1 as t1;
#[macro_use] extern crate issue_13560_2 as t2;
2 changes: 1 addition & 1 deletion src/test/auxiliary/issue-13620-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

extern crate "issue-13620-1" as crate1;
extern crate issue_13620_1 as crate1;

pub static FOO2: crate1::Foo = crate1::FOO;
2 changes: 1 addition & 1 deletion src/test/auxiliary/issue-13872-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

extern crate "issue-13872-1" as foo;
extern crate issue_13872_1 as foo;

pub use foo::A::B;
2 changes: 1 addition & 1 deletion src/test/auxiliary/issue-13872-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

extern crate "issue-13872-2" as bar;
extern crate issue_13872_2 as bar;

use bar::B;

Expand Down
1 change: 0 additions & 1 deletion src/test/auxiliary/static-function-pointer-aux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/test/auxiliary/syntax_extension_with_dll_deps_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#![crate_type = "dylib"]
#![feature(plugin_registrar, quote, rustc_private)]

extern crate "syntax_extension_with_dll_deps_1" as other;
extern crate syntax_extension_with_dll_deps_1 as other;
extern crate syntax;
extern crate rustc;

Expand Down
2 changes: 0 additions & 2 deletions src/test/auxiliary/trait_default_method_xc_aux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![crate_name="trait_default_method_xc_aux"]

pub struct Something { pub x: isize }

pub trait A {
Expand Down
2 changes: 1 addition & 1 deletion src/test/auxiliary/trait_default_method_xc_aux_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// aux-build:trait_default_method_xc_aux.rs

extern crate "trait_default_method_xc_aux" as aux;
extern crate trait_default_method_xc_aux as aux;
use aux::A;

pub struct a_struct { pub x: isize }
Expand Down
14 changes: 0 additions & 14 deletions src/test/compile-fail/bad-crate-id2.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/test/compile-fail/use-meta-mismatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

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

extern crate "fake-crate" as extra;
extern crate fake_crate as extra;

fn main() { }
2 changes: 1 addition & 1 deletion src/test/compile-fail/weak-lang-item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
#![no_std]

extern crate core;
extern crate "weak-lang-items" as other;
extern crate weak_lang_items;
28 changes: 14 additions & 14 deletions src/test/debuginfo/basic-types-globals-metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,33 @@

// compile-flags:-g
// gdb-command:run
// gdb-command:whatis 'basic-types-globals-metadata::B'
// gdb-command:whatis 'basic_types_globals_metadata::B'
// gdb-check:type = bool
// gdb-command:whatis 'basic-types-globals-metadata::I'
// gdb-command:whatis 'basic_types_globals_metadata::I'
// gdb-check:type = isize
// gdb-command:whatis 'basic-types-globals-metadata::C'
// gdb-command:whatis 'basic_types_globals_metadata::C'
// gdb-check:type = char
// gdb-command:whatis 'basic-types-globals-metadata::I8'
// gdb-command:whatis 'basic_types_globals_metadata::I8'
// gdb-check:type = i8
// gdb-command:whatis 'basic-types-globals-metadata::I16'
// gdb-command:whatis 'basic_types_globals_metadata::I16'
// gdb-check:type = i16
// gdb-command:whatis 'basic-types-globals-metadata::I32'
// gdb-command:whatis 'basic_types_globals_metadata::I32'
// gdb-check:type = i32
// gdb-command:whatis 'basic-types-globals-metadata::I64'
// gdb-command:whatis 'basic_types_globals_metadata::I64'
// gdb-check:type = i64
// gdb-command:whatis 'basic-types-globals-metadata::U'
// gdb-command:whatis 'basic_types_globals_metadata::U'
// gdb-check:type = usize
// gdb-command:whatis 'basic-types-globals-metadata::U8'
// gdb-command:whatis 'basic_types_globals_metadata::U8'
// gdb-check:type = u8
// gdb-command:whatis 'basic-types-globals-metadata::U16'
// gdb-command:whatis 'basic_types_globals_metadata::U16'
// gdb-check:type = u16
// gdb-command:whatis 'basic-types-globals-metadata::U32'
// gdb-command:whatis 'basic_types_globals_metadata::U32'
// gdb-check:type = u32
// gdb-command:whatis 'basic-types-globals-metadata::U64'
// gdb-command:whatis 'basic_types_globals_metadata::U64'
// gdb-check:type = u64
// gdb-command:whatis 'basic-types-globals-metadata::F32'
// gdb-command:whatis 'basic_types_globals_metadata::F32'
// gdb-check:type = f32
// gdb-command:whatis 'basic-types-globals-metadata::F64'
// gdb-command:whatis 'basic_types_globals_metadata::F64'
// gdb-check:type = f64
// gdb-command:continue

Expand Down
28 changes: 14 additions & 14 deletions src/test/debuginfo/basic-types-globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,33 @@

// compile-flags:-g
// gdb-command:run
// gdb-command:print 'basic-types-globals::B'
// gdb-command:print 'basic_types_globals::B'
// gdb-check:$1 = false
// gdb-command:print 'basic-types-globals::I'
// gdb-command:print 'basic_types_globals::I'
// gdb-check:$2 = -1
// gdb-command:print 'basic-types-globals::C'
// gdb-command:print 'basic_types_globals::C'
// gdb-check:$3 = 97
// gdb-command:print/d 'basic-types-globals::I8'
// gdb-command:print/d 'basic_types_globals::I8'
// gdb-check:$4 = 68
// gdb-command:print 'basic-types-globals::I16'
// gdb-command:print 'basic_types_globals::I16'
// gdb-check:$5 = -16
// gdb-command:print 'basic-types-globals::I32'
// gdb-command:print 'basic_types_globals::I32'
// gdb-check:$6 = -32
// gdb-command:print 'basic-types-globals::I64'
// gdb-command:print 'basic_types_globals::I64'
// gdb-check:$7 = -64
// gdb-command:print 'basic-types-globals::U'
// gdb-command:print 'basic_types_globals::U'
// gdb-check:$8 = 1
// gdb-command:print/d 'basic-types-globals::U8'
// gdb-command:print/d 'basic_types_globals::U8'
// gdb-check:$9 = 100
// gdb-command:print 'basic-types-globals::U16'
// gdb-command:print 'basic_types_globals::U16'
// gdb-check:$10 = 16
// gdb-command:print 'basic-types-globals::U32'
// gdb-command:print 'basic_types_globals::U32'
// gdb-check:$11 = 32
// gdb-command:print 'basic-types-globals::U64'
// gdb-command:print 'basic_types_globals::U64'
// gdb-check:$12 = 64
// gdb-command:print 'basic-types-globals::F32'
// gdb-command:print 'basic_types_globals::F32'
// gdb-check:$13 = 2.5
// gdb-command:print 'basic-types-globals::F64'
// gdb-command:print 'basic_types_globals::F64'
// gdb-check:$14 = 3.5
// gdb-command:continue

Expand Down
Loading

0 comments on commit d3a4f36

Please sign in to comment.