From 54f16b818b58f6d6e81891b041fc751986e75155 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 24 Mar 2015 13:26:16 -0700 Subject: rustc: Remove support for int/uint This commit removes all parsing, resolve, and compiler support for the old and long-deprecated int/uint types. --- src/libsyntax/parse/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 4e851761212..bea42a88bf5 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -700,18 +700,18 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) -> if let Some(suf) = suffix { if suf.is_empty() { sd.span_bug(sp, "found empty literal suffix in Some")} ty = match suf { - "isize" => ast::SignedIntLit(ast::TyIs(false), ast::Plus), + "isize" => ast::SignedIntLit(ast::TyIs, ast::Plus), "i8" => ast::SignedIntLit(ast::TyI8, ast::Plus), "i16" => ast::SignedIntLit(ast::TyI16, ast::Plus), "i32" => ast::SignedIntLit(ast::TyI32, ast::Plus), "i64" => ast::SignedIntLit(ast::TyI64, ast::Plus), - "usize" => ast::UnsignedIntLit(ast::TyUs(false)), + "usize" => ast::UnsignedIntLit(ast::TyUs), "u8" => ast::UnsignedIntLit(ast::TyU8), "u16" => ast::UnsignedIntLit(ast::TyU16), "u32" => ast::UnsignedIntLit(ast::TyU32), "u64" => ast::UnsignedIntLit(ast::TyU64), - "i" | "is" => ast::SignedIntLit(ast::TyIs(true), ast::Plus), - "u" | "us" => ast::UnsignedIntLit(ast::TyUs(true)), + "is" => ast::SignedIntLit(ast::TyIs, ast::Plus), + "us" => ast::UnsignedIntLit(ast::TyUs), _ => { // i and u look like widths, so lets // give an error message along those lines -- cgit 1.4.1-3-g733a5 From 77de3ee6e572b66c9b0ee9d7d909fced980fe70f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 26 Mar 2015 09:57:58 -0700 Subject: syntax: Remove parsing of old slice syntax This syntax has been deprecated for quite some time, and there were only a few remaining uses of it in the codebase anyway. --- src/libcollections/vec_deque.rs | 2 +- src/libstd/old_io/buffered.rs | 32 +++++++++++++++--------------- src/libsyntax/parse/obsolete.rs | 6 ------ src/libsyntax/parse/parser.rs | 43 +++++----------------------------------- src/test/bench/noise.rs | 2 +- src/test/compile-fail/slice-1.rs | 20 ------------------- src/test/run-pass/issue-15149.rs | 2 +- 7 files changed, 24 insertions(+), 83 deletions(-) delete mode 100644 src/test/compile-fail/slice-1.rs (limited to 'src/libsyntax/parse') diff --git a/src/libcollections/vec_deque.rs b/src/libcollections/vec_deque.rs index af9db46f810..a9884b80e42 100644 --- a/src/libcollections/vec_deque.rs +++ b/src/libcollections/vec_deque.rs @@ -553,7 +553,7 @@ impl VecDeque { /// *num = *num - 2; /// } /// let b: &[_] = &[&mut 3, &mut 1, &mut 2]; - /// assert_eq!(&buf.iter_mut().collect::>()[], b); + /// assert_eq!(&buf.iter_mut().collect::>()[..], b); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn iter_mut(&mut self) -> IterMut { diff --git a/src/libstd/old_io/buffered.rs b/src/libstd/old_io/buffered.rs index 9a9d421dfe1..9c42fbf5c16 100644 --- a/src/libstd/old_io/buffered.rs +++ b/src/libstd/old_io/buffered.rs @@ -510,37 +510,37 @@ mod test { writer.write_all(&[0, 1]).unwrap(); let b: &[_] = &[]; - assert_eq!(&writer.get_ref()[], b); + assert_eq!(&writer.get_ref()[..], b); writer.write_all(&[2]).unwrap(); let b: &[_] = &[0, 1]; - assert_eq!(&writer.get_ref()[], b); + assert_eq!(&writer.get_ref()[..], b); writer.write_all(&[3]).unwrap(); - assert_eq!(&writer.get_ref()[], b); + assert_eq!(&writer.get_ref()[..], b); writer.flush().unwrap(); let a: &[_] = &[0, 1, 2, 3]; - assert_eq!(a, &writer.get_ref()[]); + assert_eq!(a, &writer.get_ref()[..]); writer.write_all(&[4]).unwrap(); writer.write_all(&[5]).unwrap(); - assert_eq!(a, &writer.get_ref()[]); + assert_eq!(a, &writer.get_ref()[..]); writer.write_all(&[6]).unwrap(); let a: &[_] = &[0, 1, 2, 3, 4, 5]; - assert_eq!(a, &writer.get_ref()[]); + assert_eq!(a, &writer.get_ref()[..]); writer.write_all(&[7, 8]).unwrap(); let a: &[_] = &[0, 1, 2, 3, 4, 5, 6]; - assert_eq!(a, &writer.get_ref()[]); + assert_eq!(a, &writer.get_ref()[..]); writer.write_all(&[9, 10, 11]).unwrap(); let a: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; - assert_eq!(a, &writer.get_ref()[]); + assert_eq!(a, &writer.get_ref()[..]); writer.flush().unwrap(); - assert_eq!(a, &writer.get_ref()[]); + assert_eq!(a, &writer.get_ref()[..]); } #[test] @@ -548,7 +548,7 @@ mod test { let mut w = BufferedWriter::with_capacity(3, Vec::new()); w.write_all(&[0, 1]).unwrap(); let a: &[_] = &[]; - assert_eq!(a, &w.get_ref()[]); + assert_eq!(a, &w.get_ref()[..]); let w = w.into_inner(); let a: &[_] = &[0, 1]; assert_eq!(a, &w[..]); @@ -593,21 +593,21 @@ mod test { let mut writer = LineBufferedWriter::new(Vec::new()); writer.write_all(&[0]).unwrap(); let b: &[_] = &[]; - assert_eq!(&writer.get_ref()[], b); + assert_eq!(&writer.get_ref()[..], b); writer.write_all(&[1]).unwrap(); - assert_eq!(&writer.get_ref()[], b); + assert_eq!(&writer.get_ref()[..], b); writer.flush().unwrap(); let b: &[_] = &[0, 1]; - assert_eq!(&writer.get_ref()[], b); + assert_eq!(&writer.get_ref()[..], b); writer.write_all(&[0, b'\n', 1, b'\n', 2]).unwrap(); let b: &[_] = &[0, 1, 0, b'\n', 1, b'\n']; - assert_eq!(&writer.get_ref()[], b); + assert_eq!(&writer.get_ref()[..], b); writer.flush().unwrap(); let b: &[_] = &[0, 1, 0, b'\n', 1, b'\n', 2]; - assert_eq!(&writer.get_ref()[], b); + assert_eq!(&writer.get_ref()[..], b); writer.write_all(&[3, b'\n']).unwrap(); let b: &[_] = &[0, 1, 0, b'\n', 1, b'\n', 2, 3, b'\n']; - assert_eq!(&writer.get_ref()[], b); + assert_eq!(&writer.get_ref()[..], b); } #[test] diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 276be73823a..bb9b586bb3f 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -23,7 +23,6 @@ use ptr::P; #[derive(Copy, PartialEq, Eq, Hash)] pub enum ObsoleteSyntax { ClosureKind, - EmptyIndex, ExternCrateString, } @@ -52,11 +51,6 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> { "rely on inference instead", true, ), - ObsoleteSyntax::EmptyIndex => ( - "[]", - "write `[..]` instead", - false, // warning for now - ), ObsoleteSyntax::ExternCrateString => ( "\"crate-name\"", "use an identifier not in quotes instead", diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 220ea30256e..d016576238c 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2312,46 +2312,13 @@ impl<'a> Parser<'a> { // expr[...] // Could be either an index expression or a slicing expression. token::OpenDelim(token::Bracket) => { - let bracket_pos = self.span.lo; self.bump(); - if self.eat(&token::CloseDelim(token::Bracket)) { - // No expression, expand to a RangeFull - // FIXME(#20516) It would be better to use a lang item or - // something for RangeFull. - hi = self.last_span.hi; - - let idents = vec![token::str_to_ident("std"), - token::str_to_ident("ops"), - token::str_to_ident("RangeFull")]; - let segments = idents.into_iter().map(|ident| { - ast::PathSegment { - identifier: ident, - parameters: ast::PathParameters::none(), - } - }).collect(); - let span = mk_sp(lo, hi); - let path = ast::Path { - span: span, - global: true, - segments: segments, - }; - - let range = ExprStruct(path, vec![], None); - let ix = self.mk_expr(bracket_pos, hi, range); - let index = self.mk_index(e, ix); - e = self.mk_expr(lo, hi, index); - - let obsolete_span = mk_sp(bracket_pos, hi); - self.obsolete(obsolete_span, ObsoleteSyntax::EmptyIndex); - } else { - let ix = self.parse_expr(); - hi = self.span.hi; - self.commit_expr_expecting(&*ix, token::CloseDelim(token::Bracket)); - let index = self.mk_index(e, ix); - e = self.mk_expr(lo, hi, index) - } - + let ix = self.parse_expr(); + hi = self.span.hi; + self.commit_expr_expecting(&*ix, token::CloseDelim(token::Bracket)); + let index = self.mk_index(e, ix); + e = self.mk_expr(lo, hi, index) } _ => return e } diff --git a/src/test/bench/noise.rs b/src/test/bench/noise.rs index 6cd75836187..42051e33e2e 100644 --- a/src/test/bench/noise.rs +++ b/src/test/bench/noise.rs @@ -47,7 +47,7 @@ impl Noise2DContext { let mut rng = StdRng::new().unwrap(); let mut rgradients = [Vec2 { x: 0.0, y: 0.0 }; 256]; - for x in &mut rgradients[] { + for x in &mut rgradients[..] { *x = random_gradient(&mut rng); } diff --git a/src/test/compile-fail/slice-1.rs b/src/test/compile-fail/slice-1.rs deleted file mode 100644 index 3b992e3bcc3..00000000000 --- a/src/test/compile-fail/slice-1.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test slicing &expr[] is deprecated and gives a helpful error message. - -struct Foo; - -fn main() { - let x = Foo; - &x[]; - //~^ WARN obsolete syntax - //~| ERROR cannot index -} diff --git a/src/test/run-pass/issue-15149.rs b/src/test/run-pass/issue-15149.rs index 0e194860251..ee348d9cb0c 100644 --- a/src/test/run-pass/issue-15149.rs +++ b/src/test/run-pass/issue-15149.rs @@ -28,7 +28,7 @@ fn main() { // checking that it ends_with the executable name. This // is needed because of Windows, which has a different behavior. // See #15149 for more info. - return assert!(args[0].ends_with(&format!("mytest{}", env::consts::EXE_SUFFIX)[])); + return assert!(args[0].ends_with(&format!("mytest{}", env::consts::EXE_SUFFIX))); } test(); -- cgit 1.4.1-3-g733a5 From afaa3b6a2066e4dacd4e7dafb5fd911bf35bdd6c Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Thu, 26 Mar 2015 09:38:25 +0100 Subject: Prevent ICEs when parsing invalid escapes, closes #23620 --- src/libsyntax/parse/lexer/mod.rs | 40 +++++++++++++------ src/test/parse-fail/issue-23620-invalid-escapes.rs | 45 ++++++++++++++++++++++ src/test/parse-fail/new-unicode-escapes-4.rs | 5 ++- 3 files changed, 78 insertions(+), 12 deletions(-) create mode 100644 src/test/parse-fail/issue-23620-invalid-escapes.rs (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 0843713681b..e11e9f62a5b 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -742,6 +742,7 @@ impl<'a> StringReader<'a> { let start_bpos = self.last_pos; let mut accum_int = 0; + let mut valid = true; for _ in 0..n_digits { if self.is_eof() { let last_bpos = self.last_pos; @@ -750,6 +751,7 @@ impl<'a> StringReader<'a> { if self.curr_is(delim) { let last_bpos = self.last_pos; self.err_span_(start_bpos, last_bpos, "numeric character escape is too short"); + valid = false; break; } let c = self.curr.unwrap_or('\x00'); @@ -757,6 +759,8 @@ impl<'a> StringReader<'a> { accum_int += c.to_digit(16).unwrap_or_else(|| { self.err_span_char(self.last_pos, self.pos, "illegal character in numeric character escape", c); + + valid = false; 0 }); self.bump(); @@ -767,10 +771,11 @@ impl<'a> StringReader<'a> { self.last_pos, "this form of character escape may only be used \ with characters in the range [\\x00-\\x7f]"); + valid = false; } match char::from_u32(accum_int) { - Some(_) => true, + Some(_) => valid, None => { let last_bpos = self.last_pos; self.err_span_(start_bpos, last_bpos, "illegal numeric character escape"); @@ -799,7 +804,18 @@ impl<'a> StringReader<'a> { 'n' | 'r' | 't' | '\\' | '\'' | '"' | '0' => true, 'x' => self.scan_byte_escape(delim, !ascii_only), 'u' if self.curr_is('{') => { - self.scan_unicode_escape(delim) + let valid = self.scan_unicode_escape(delim); + if valid && ascii_only { + self.err_span_( + escaped_pos, + self.last_pos, + "unicode escape sequences cannot be used as a byte or in \ + a byte string" + ); + false + } else { + valid + } } '\n' if delim == '"' => { self.consume_whitespace(); @@ -869,6 +885,7 @@ impl<'a> StringReader<'a> { let start_bpos = self.last_pos; let mut count = 0; let mut accum_int = 0; + let mut valid = true; while !self.curr_is('}') && count <= 6 { let c = match self.curr { @@ -884,29 +901,30 @@ impl<'a> StringReader<'a> { self.fatal_span_(self.last_pos, self.pos, "unterminated unicode escape (needed a `}`)"); } else { - self.fatal_span_char(self.last_pos, self.pos, + self.err_span_char(self.last_pos, self.pos, "illegal character in unicode escape", c); } + valid = false; + 0 }); self.bump(); count += 1; } if count > 6 { - self.fatal_span_(start_bpos, self.last_pos, + self.err_span_(start_bpos, self.last_pos, "overlong unicode escape (can have at most 6 hex digits)"); + valid = false; } self.bump(); // past the ending } - let mut valid = count >= 1 && count <= 6; - if char::from_u32(accum_int).is_none() { - valid = false; + if valid && (char::from_u32(accum_int).is_none() || count == 0) { + self.err_span_(start_bpos, self.last_pos, "illegal unicode character escape"); + valid= false; } - if !valid { - self.fatal_span_(start_bpos, self.last_pos, "illegal unicode character escape"); - } + valid } @@ -1330,7 +1348,7 @@ impl<'a> StringReader<'a> { "unterminated byte constant".to_string()); } - let id = if valid { self.name_from(start) } else { token::intern("??") }; + let id = if valid { self.name_from(start) } else { token::intern("?") }; self.bump(); // advance curr past token return token::Byte(id); } diff --git a/src/test/parse-fail/issue-23620-invalid-escapes.rs b/src/test/parse-fail/issue-23620-invalid-escapes.rs new file mode 100644 index 00000000000..7930ea75bf5 --- /dev/null +++ b/src/test/parse-fail/issue-23620-invalid-escapes.rs @@ -0,0 +1,45 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let _ = b"\u{a66e}"; + //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string + + let _ = b'\u{a66e}'; + //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string + + let _ = b'\u'; + //~^ ERROR unknown byte escape: u + + let _ = b'\x5'; + //~^ ERROR numeric character escape is too short + + let _ = b'\xxy'; + //~^ ERROR illegal character in numeric character escape: x + //~^^ ERROR illegal character in numeric character escape: y + + let _ = '\x5'; + //~^ ERROR numeric character escape is too short + + let _ = '\xxy'; + //~^ ERROR illegal character in numeric character escape: x + //~^^ ERROR illegal character in numeric character escape: y + + let _ = b"\u{a4a4} \xf \u"; + //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string + //~^^ ERROR illegal character in numeric character escape: + //~^^^ ERROR unknown byte escape: u + + let _ = "\u{ffffff} \xf \u"; + //~^ ERROR illegal unicode character escape + //~^^ ERROR illegal character in numeric character escape: + //~^^^ ERROR form of character escape may only be used with characters in the range [\x00-\x7f] + //~^^^^ ERROR unknown character escape: u +} diff --git a/src/test/parse-fail/new-unicode-escapes-4.rs b/src/test/parse-fail/new-unicode-escapes-4.rs index ffc2b11e0c1..96b86f1f563 100644 --- a/src/test/parse-fail/new-unicode-escapes-4.rs +++ b/src/test/parse-fail/new-unicode-escapes-4.rs @@ -9,5 +9,8 @@ // except according to those terms. pub fn main() { - let s = "\u{lol}"; //~ ERROR illegal character in unicode escape + let s = "\u{lol}"; + //~^ ERROR illegal character in unicode escape: l + //~^^ ERROR illegal character in unicode escape: o + //~^^^ ERROR illegal character in unicode escape: l } -- cgit 1.4.1-3-g733a5 From b24a3b82011c3b78573ace4ade3f99d7c4701a11 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 26 Mar 2015 17:35:13 -0700 Subject: rustc: Remove support for hyphens in crate names This commit removes parser support for `extern crate "foo" as bar` as the renamed crate is now required to be an identifier. Additionally this commit enables hard errors on crate names that contain hyphens in them, they must now solely contain alphanumeric characters or underscores. If the crate name is inferred from the file name, however, the file name `foo-bar.rs` will have the crate name inferred as `foo_bar`. If a binary is being emitted it will have the name `foo-bar` and a library will have the name `libfoo_bar.rlib`. This commit is a breaking change for a number of reasons: * Old syntax is being removed. This was previously only issuing warnings. * The output for the compiler when input is received on stdin is now `rust_out` instead of `rust-out`. * The crate name for a crate in the file `foo-bar.rs` is now `foo_bar` which can affect infrastructure such as logging. [breaking-change] --- src/librustc/metadata/creader.rs | 20 +++------- src/librustc_trans/back/link.rs | 18 +++++++-- src/librustdoc/test.rs | 2 +- src/libsyntax/parse/parser.rs | 47 +++++------------------- src/test/compile-fail/bad-crate-id.rs | 14 ------- src/test/compile-fail/bad-crate-id2.rs | 14 ------- src/test/run-make/output-with-hyphens/Makefile | 6 +++ src/test/run-make/output-with-hyphens/foo-bar.rs | 14 +++++++ 8 files changed, 51 insertions(+), 84 deletions(-) delete mode 100644 src/test/compile-fail/bad-crate-id.rs delete mode 100644 src/test/compile-fail/bad-crate-id2.rs create mode 100644 src/test/run-make/output-with-hyphens/Makefile create mode 100644 src/test/run-make/output-with-hyphens/foo-bar.rs (limited to 'src/libsyntax/parse') diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 7d8789c3cd1..b6a8525675e 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -73,24 +73,20 @@ struct CrateInfo { } pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option) { - 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(), @@ -306,13 +302,7 @@ impl<'a> CrateReader<'a> { -> Option { 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 } diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index bb7880161d5..8347571a480 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -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, @@ -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..]) + } } } } diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 7b37a5a9d1c..8e25ee095a0 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -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()); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 220ea30256e..92795bb2002 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4977,46 +4977,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) + lo: BytePos, + visibility: Visibility, + attrs: Vec) -> P { - 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); diff --git a/src/test/compile-fail/bad-crate-id.rs b/src/test/compile-fail/bad-crate-id.rs deleted file mode 100644 index 193666f8269..00000000000 --- a/src/test/compile-fail/bad-crate-id.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate "" as foo; //~ ERROR: crate name must not be empty -//~^ WARNING: obsolete syntax - -fn main() {} diff --git a/src/test/compile-fail/bad-crate-id2.rs b/src/test/compile-fail/bad-crate-id2.rs deleted file mode 100644 index 29df0fa705e..00000000000 --- a/src/test/compile-fail/bad-crate-id2.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate "#a" as bar; //~ ERROR: invalid character `#` in crate name: `#a` -//~^ WARNING: obsolete syntax - -fn main() {} diff --git a/src/test/run-make/output-with-hyphens/Makefile b/src/test/run-make/output-with-hyphens/Makefile new file mode 100644 index 00000000000..783d826a53d --- /dev/null +++ b/src/test/run-make/output-with-hyphens/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + $(RUSTC) foo-bar.rs + [ -f $(TMPDIR)/$(call BIN,foo-bar) ] + [ -f $(TMPDIR)/libfoo_bar.rlib ] diff --git a/src/test/run-make/output-with-hyphens/foo-bar.rs b/src/test/run-make/output-with-hyphens/foo-bar.rs new file mode 100644 index 00000000000..2f93b2d1ead --- /dev/null +++ b/src/test/run-make/output-with-hyphens/foo-bar.rs @@ -0,0 +1,14 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +#![crate_type = "bin"] + +fn main() {} -- cgit 1.4.1-3-g733a5