diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-03-30 20:18:16 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-03-30 20:18:16 +0530 |
| commit | 3b4547010011b948168d64eb8d05a5cfa7652765 (patch) | |
| tree | d3e133c446a8aab157f145122223c7d2ab944dc1 /src/libsyntax | |
| parent | db50084cd9d83f7b342f481c2d03f78b50d99059 (diff) | |
| parent | d9252bde18360e5815f0d83a83efd597bc6bb5b7 (diff) | |
| download | rust-3b4547010011b948168d64eb8d05a5cfa7652765.tar.gz rust-3b4547010011b948168d64eb8d05a5cfa7652765.zip | |
Rollup merge of #23855 - tshepang:doc-nit, r=Manishearth
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 42 | ||||
| -rw-r--r-- | src/libsyntax/ast_map/blocks.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/attr.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/concat_idents.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/rand.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 9 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 110 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/lib.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 49 | ||||
| -rw-r--r-- | src/libsyntax/ptr.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/std_inject.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/test.rs | 14 | ||||
| -rw-r--r-- | src/libsyntax/util/parser_testing.rs | 4 |
19 files changed, 69 insertions, 207 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index fec67c7aef4..f815e8e7843 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1249,29 +1249,15 @@ pub enum ImplItem_ { MacImplItem(Mac), } -#[derive(Clone, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] +#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] pub enum IntTy { - TyIs(bool /* is this deprecated `int`? */), + TyIs, TyI8, TyI16, TyI32, TyI64, } -impl PartialEq for IntTy { - fn eq(&self, other: &IntTy) -> bool { - match (*self, *other) { - // true/false need to compare the same, so this can't be derived - (TyIs(_), TyIs(_)) | - (TyI8, TyI8) | - (TyI16, TyI16) | - (TyI32, TyI32) | - (TyI64, TyI64) => true, - _ => false - } - } -} - impl fmt::Debug for IntTy { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(self, f) @@ -1287,41 +1273,25 @@ impl fmt::Display for IntTy { impl IntTy { pub fn suffix_len(&self) -> usize { match *self { - TyIs(true) /* i */ => 1, - TyIs(false) /* is */ | TyI8 => 2, + TyIs | TyI8 => 2, TyI16 | TyI32 | TyI64 => 3, } } } -#[derive(Clone, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] +#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] pub enum UintTy { - TyUs(bool /* is this deprecated uint? */), + TyUs, TyU8, TyU16, TyU32, TyU64, } -impl PartialEq for UintTy { - fn eq(&self, other: &UintTy) -> bool { - match (*self, *other) { - // true/false need to compare the same, so this can't be derived - (TyUs(_), TyUs(_)) | - (TyU8, TyU8) | - (TyU16, TyU16) | - (TyU32, TyU32) | - (TyU64, TyU64) => true, - _ => false - } - } -} - impl UintTy { pub fn suffix_len(&self) -> usize { match *self { - TyUs(true) /* u */ => 1, - TyUs(false) /* us */ | TyU8 => 2, + TyUs | TyU8 => 2, TyU16 | TyU32 | TyU64 => 3, } } diff --git a/src/libsyntax/ast_map/blocks.rs b/src/libsyntax/ast_map/blocks.rs index 16a339cdcb5..1994ca70bbb 100644 --- a/src/libsyntax/ast_map/blocks.rs +++ b/src/libsyntax/ast_map/blocks.rs @@ -26,7 +26,7 @@ pub use self::Code::*; use abi; use ast::{Block, FnDecl, NodeId}; use ast; -use ast_map::{Node}; +use ast_map::Node; use ast_map; use codemap::Span; use visit; diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index cec824e79ff..b7aa2aebbfa 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -140,7 +140,7 @@ pub fn is_path(e: P<Expr>) -> bool { /// We want to avoid "45int" and "-3int" in favor of "45" and "-3" pub fn int_ty_to_string(t: IntTy, val: Option<i64>) -> String { let s = match t { - TyIs(_) => "isize", + TyIs => "isize", TyI8 => "i8", TyI16 => "i16", TyI32 => "i32", @@ -160,7 +160,7 @@ pub fn int_ty_max(t: IntTy) -> u64 { match t { TyI8 => 0x80, TyI16 => 0x8000, - TyIs(_) | TyI32 => 0x80000000, // actually ni about TyIs + TyIs | TyI32 => 0x80000000, // actually ni about TyIs TyI64 => 0x8000000000000000 } } @@ -169,7 +169,7 @@ pub fn int_ty_max(t: IntTy) -> u64 { /// We want to avoid "42u" in favor of "42us". "42uint" is right out. pub fn uint_ty_to_string(t: UintTy, val: Option<u64>) -> String { let s = match t { - TyUs(_) => "usize", + TyUs => "usize", TyU8 => "u8", TyU16 => "u16", TyU32 => "u32", @@ -186,7 +186,7 @@ pub fn uint_ty_max(t: UintTy) -> u64 { match t { TyU8 => 0xff, TyU16 => 0xffff, - TyUs(_) | TyU32 => 0xffffffff, // actually ni about TyUs + TyUs | TyU32 => 0xffffffff, // actually ni about TyUs TyU64 => 0xffffffffffffffff } } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 1c7930b9bc9..2d8484e95bb 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -565,10 +565,8 @@ fn int_type_of_word(s: &str) -> Option<IntType> { "u32" => Some(UnsignedInt(ast::TyU32)), "i64" => Some(SignedInt(ast::TyI64)), "u64" => Some(UnsignedInt(ast::TyU64)), - "int" => Some(SignedInt(ast::TyIs(true))), - "uint" => Some(UnsignedInt(ast::TyUs(true))), - "isize" => Some(SignedInt(ast::TyIs(false))), - "usize" => Some(UnsignedInt(ast::TyUs(false))), + "isize" => Some(SignedInt(ast::TyIs)), + "usize" => Some(UnsignedInt(ast::TyUs)), _ => None } } @@ -612,7 +610,7 @@ impl IntType { SignedInt(ast::TyI16) | UnsignedInt(ast::TyU16) | SignedInt(ast::TyI32) | UnsignedInt(ast::TyU32) | SignedInt(ast::TyI64) | UnsignedInt(ast::TyU64) => true, - SignedInt(ast::TyIs(_)) | UnsignedInt(ast::TyUs(_)) => false + SignedInt(ast::TyIs) | UnsignedInt(ast::TyUs) => false } } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index d916651b056..5d0853761ee 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -696,10 +696,10 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr(sp, ast::ExprLit(P(respan(sp, lit)))) } fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr> { - self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::TyUs(false)))) + self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::TyUs))) } fn expr_int(&self, sp: Span, i: isize) -> P<ast::Expr> { - self.expr_lit(sp, ast::LitInt(i as u64, ast::SignedIntLit(ast::TyIs(false), + self.expr_lit(sp, ast::LitInt(i as u64, ast::SignedIntLit(ast::TyIs, ast::Sign::new(i)))) } fn expr_u32(&self, sp: Span, u: u32) -> P<ast::Expr> { diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index e350ce61017..5d07c36c929 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -14,7 +14,7 @@ use ext::base::*; use ext::base; use feature_gate; use parse::token; -use parse::token::{str_to_ident}; +use parse::token::str_to_ident; use ptr::P; pub fn expand_syntax_ext<'cx>(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index 0c5e4d67642..397775fdbfe 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -1163,7 +1163,7 @@ impl<'a> MethodDef<'a> { let arms: Vec<ast::Arm> = variants.iter().enumerate() .map(|(index, variant)| { let pat = variant_to_pat(cx, sp, type_ident, &**variant); - let lit = ast::LitInt(index as u64, ast::UnsignedIntLit(ast::TyUs(false))); + let lit = ast::LitInt(index as u64, ast::UnsignedIntLit(ast::TyUs)); cx.arm(sp, vec![pat], cx.expr_lit(sp, lit)) }).collect(); diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs index 8a764fded6f..631e5f979d9 100644 --- a/src/libsyntax/ext/deriving/rand.rs +++ b/src/libsyntax/ext/deriving/rand.rs @@ -12,7 +12,7 @@ use ast; use ast::{MetaItem, Item, Expr}; use codemap::Span; use ext::base::ExtCtxt; -use ext::build::{AstBuilder}; +use ext::build::AstBuilder; use ext::deriving::generic::*; use ext::deriving::generic::ty::*; use ptr::P; diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 5bbcdea879d..87299721fb3 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -264,7 +264,6 @@ pub mod rt { (unsigned, $t:ty, $tag:expr) => ( impl ToSource for $t { fn to_source(&self) -> String { - #![allow(trivial_numeric_casts)] let lit = ast::LitInt(*self as u64, ast::UnsignedIntLit($tag)); pprust::lit_to_string(&dummy_spanned(lit)) } @@ -277,13 +276,13 @@ pub mod rt { ); } - impl_to_source_int! { signed, int, ast::TyIs(false) } + impl_to_source_int! { signed, isize, ast::TyIs } impl_to_source_int! { signed, i8, ast::TyI8 } impl_to_source_int! { signed, i16, ast::TyI16 } impl_to_source_int! { signed, i32, ast::TyI32 } impl_to_source_int! { signed, i64, ast::TyI64 } - impl_to_source_int! { unsigned, uint, ast::TyUs(false) } + impl_to_source_int! { unsigned, usize, ast::TyUs } impl_to_source_int! { unsigned, u8, ast::TyU8 } impl_to_source_int! { unsigned, u16, ast::TyU16 } impl_to_source_int! { unsigned, u32, ast::TyU32 } @@ -332,12 +331,12 @@ pub mod rt { impl_to_tokens! { () } impl_to_tokens! { char } impl_to_tokens! { bool } - impl_to_tokens! { int } + impl_to_tokens! { isize } impl_to_tokens! { i8 } impl_to_tokens! { i16 } impl_to_tokens! { i32 } impl_to_tokens! { i64 } - impl_to_tokens! { uint } + impl_to_tokens! { usize } impl_to_tokens! { u8 } impl_to_tokens! { u16 } impl_to_tokens! { u32 } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 46115ae468f..1b03a180720 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -54,12 +54,10 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[ ("non_ascii_idents", "1.0.0", Active), ("thread_local", "1.0.0", Active), ("link_args", "1.0.0", Active), - ("phase", "1.0.0", Removed), ("plugin_registrar", "1.0.0", Active), ("log_syntax", "1.0.0", Active), ("trace_macros", "1.0.0", Active), ("concat_idents", "1.0.0", Active), - ("unsafe_destructor", "1.0.0", Active), ("intrinsics", "1.0.0", Active), ("lang_items", "1.0.0", Active), @@ -93,6 +91,10 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[ ("start", "1.0.0", Active), ("main", "1.0.0", Active), + // Deprecate after snapshot + // SNAP a923278 + ("unsafe_destructor", "1.0.0", Active), + // A temporary feature gate used to enable parser extensions needed // to bootstrap fix for #5723. ("issue_5723_bootstrap", "1.0.0", Accepted), @@ -103,15 +105,9 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[ // A way to temporarily opt out of the new orphan rules. This will *never* be accepted. ("old_orphan_check", "1.0.0", Deprecated), - // A way to temporarily opt out of the new impl rules. This will *never* be accepted. - ("old_impl_check", "1.0.0", Deprecated), - // OIBIT specific features ("optin_builtin_traits", "1.0.0", Active), - // int and uint are now deprecated - ("int_uint", "1.0.0", Active), - // macro reexport needs more discussion and stabilization ("macro_reexport", "1.0.0", Active), @@ -154,6 +150,9 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[ // below (it has to be checked before expansion possibly makes // macros disappear). ("allow_internal_unstable", "1.0.0", Active), + + // #23121. Array patterns have some hazards yet. + ("slice_patterns", "1.0.0", Active), ]; // (changing above list without updating src/doc/reference.md makes @cmr sad) @@ -197,12 +196,10 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType)] = &[ ("repr", Normal), ("path", Normal), ("abi", Normal), - ("unsafe_destructor", Normal), ("automatically_derived", Normal), ("no_mangle", Normal), ("no_link", Normal), ("derive", Normal), - ("should_fail", Normal), ("should_panic", Normal), ("ignore", Normal), ("no_implicit_prelude", Normal), @@ -210,7 +207,8 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType)] = &[ ("link_args", Normal), ("macro_escape", Normal), - + ("unsafe_destructor", Gated("unsafe_destructor", + "`#[unsafe_destructor]` does nothing anymore")), ("staged_api", Gated("staged_api", "staged_api is for use by rustc only")), ("plugin", Gated("plugin", @@ -281,7 +279,6 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType)] = &[ // FIXME: #19470 this shouldn't be needed forever ("old_orphan_check", Whitelisted), - ("old_impl_check", Whitelisted), ("rustc_paren_sugar", Gated("unboxed_closures", "unboxed_closures are still evolving")), @@ -365,7 +362,6 @@ struct Context<'a> { features: Vec<&'static str>, span_handler: &'a SpanHandler, cm: &'a CodeMap, - do_warnings: bool, } impl<'a> Context<'a> { @@ -376,12 +372,6 @@ impl<'a> Context<'a> { emit_feature_err(self.span_handler, feature, span, explain); } } - - fn warn_feature(&self, feature: &str, span: Span, explain: &str) { - if !self.has_feature(feature) && self.do_warnings { - emit_feature_warn(self.span_handler, feature, span, explain); - } - } fn has_feature(&self, feature: &str) -> bool { self.features.iter().any(|&n| n == feature) } @@ -584,15 +574,6 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { _ => {} } - if attr::contains_name(&i.attrs, - "unsafe_destructor") { - self.gate_feature("unsafe_destructor", - i.span, - "`#[unsafe_destructor]` allows too \ - many unsafe patterns and may be \ - removed in the future"); - } - if attr::contains_name(&i.attrs[..], "old_orphan_check") { self.gate_feature( @@ -600,13 +581,6 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { i.span, "the new orphan check rules will eventually be strictly enforced"); } - - if attr::contains_name(&i.attrs[..], - "old_impl_check") { - self.gate_feature("old_impl_check", - i.span, - "`#[old_impl_check]` will be removed in the future"); - } } _ => {} @@ -629,35 +603,6 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { visit::walk_foreign_item(self, i) } - fn visit_ty(&mut self, t: &ast::Ty) { - match t.node { - ast::TyPath(None, ref p) => { - match &*p.segments { - - [ast::PathSegment { identifier, .. }] => { - let name = token::get_ident(identifier); - let msg = if name == "int" { - Some("the `int` type is deprecated; \ - use `isize` or a fixed-sized integer") - } else if name == "uint" { - Some("the `uint` type is deprecated; \ - use `usize` or a fixed-sized integer") - } else { - None - }; - - if let Some(msg) = msg { - self.context.warn_feature("int_uint", t.span, msg) - } - } - _ => {} - } - } - _ => {} - } - visit::walk_ty(self, t); - } - fn visit_expr(&mut self, e: &ast::Expr) { match e.node { ast::ExprBox(..) | ast::ExprUnary(ast::UnOp::UnUniq, _) => { @@ -666,25 +611,6 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { "box expression syntax is experimental; \ you can call `Box::new` instead."); } - ast::ExprLit(ref lit) => { - match lit.node { - ast::LitInt(_, ty) => { - let msg = if let ast::SignedIntLit(ast::TyIs(true), _) = ty { - Some("the `i` and `is` suffixes on integers are deprecated; \ - use `isize` or one of the fixed-sized suffixes") - } else if let ast::UnsignedIntLit(ast::TyUs(true)) = ty { - Some("the `u` and `us` suffixes on integers are deprecated; \ - use `usize` or one of the fixed-sized suffixes") - } else { - None - }; - if let Some(msg) = msg { - self.context.warn_feature("int_uint", e.span, msg); - } - } - _ => {} - } - } _ => {} } visit::walk_expr(self, e); @@ -699,6 +625,11 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { but at the end of a slice (e.g. \ `[0, ..xs, 0]` are experimental") } + ast::PatVec(..) => { + self.gate_feature("slice_patterns", + pattern.span, + "slice pattern syntax is experimental"); + } ast::PatBox(..) => { self.gate_feature("box_patterns", pattern.span, @@ -727,8 +658,8 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { } } -fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::Crate, - do_warnings: bool, +fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, + krate: &ast::Crate, check: F) -> Features where F: FnOnce(&mut Context, &ast::Crate) @@ -736,7 +667,6 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::C let mut cx = Context { features: Vec::new(), span_handler: span_handler, - do_warnings: do_warnings, cm: cm, }; @@ -817,14 +747,14 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::C pub fn check_crate_macros(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::Crate) -> Features { - check_crate_inner(cm, span_handler, krate, true, + check_crate_inner(cm, span_handler, krate, |ctx, krate| visit::walk_crate(&mut MacroVisitor { context: ctx }, krate)) } -pub fn check_crate(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::Crate, - do_warnings: bool) -> Features +pub fn check_crate(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::Crate) + -> Features { - check_crate_inner(cm, span_handler, krate, do_warnings, + check_crate_inner(cm, span_handler, krate, |ctx, krate| visit::walk_crate(&mut PostExpansionVisitor { context: ctx }, krate)) } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 105a61d0857..d4451cc7b71 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -40,7 +40,7 @@ impl<T> MoveMap<T> for Vec<T> { for p in &mut self { unsafe { // FIXME(#5016) this shouldn't need to zero to be safe. - ptr::write(p, f(ptr::read_and_zero(p))); + ptr::write(p, f(ptr::read_and_drop(p))); } } self diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index cf4594f514b..c471d9e3179 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -29,7 +29,6 @@ #![feature(box_syntax)] #![feature(collections)] #![feature(core)] -#![feature(int_uint)] #![feature(libc)] #![feature(old_path)] #![feature(quote, unsafe_destructor)] @@ -40,6 +39,7 @@ #![feature(str_char)] #![feature(convert)] #![feature(into_cow)] +#![feature(slice_patterns)] extern crate arena; extern crate fmt_macros; diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index e11e9f62a5b..532b632fac8 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -14,7 +14,7 @@ use codemap; use diagnostic::SpanHandler; use ext::tt::transcribe::tt_next_token; use parse::token; -use parse::token::{str_to_ident}; +use parse::token::str_to_ident; use std::borrow::{IntoCow, Cow}; use std::char; 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<digits> and u<digits> look like widths, so lets // give an error message along those lines diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9d8d4eec18a..6f1f73aa2a9 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -11,7 +11,7 @@ pub use self::PathParsingMode::*; use abi; -use ast::{BareFnTy}; +use ast::BareFnTy; use ast::{RegionTyParamBound, TraitTyParamBound, TraitBoundModifier}; use ast::{Public, Unsafety}; use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindByRef, BindByValue}; @@ -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); diff --git a/src/libsyntax/ptr.rs b/src/libsyntax/ptr.rs index ca3a1848c3a..7e0bcd3e1dc 100644 --- a/src/libsyntax/ptr.rs +++ b/src/libsyntax/ptr.rs @@ -71,8 +71,8 @@ impl<T: 'static> P<T> { { unsafe { let p = &mut *self.ptr; - // FIXME(#5016) this shouldn't need to zero to be safe. - ptr::write(p, f(ptr::read_and_zero(p))); + // FIXME(#5016) this shouldn't need to drop-fill to be safe. + ptr::write(p, f(ptr::read_and_drop(p))); } self } diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs index 0fa7e4f902c..021ec4738ed 100644 --- a/src/libsyntax/std_inject.rs +++ b/src/libsyntax/std_inject.rs @@ -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"), diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 2a47a696b1c..fbee11ee657 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -134,7 +134,7 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> { path: self.cx.path.clone(), bench: is_bench_fn(&self.cx, &*i), ignore: is_ignored(&*i), - should_panic: should_panic(&*i, self.cx.span_diagnostic) + should_panic: should_panic(&*i) }; self.cx.testfns.push(test); self.tests.push(i.ident); @@ -386,16 +386,8 @@ fn is_ignored(i: &ast::Item) -> bool { i.attrs.iter().any(|attr| attr.check_name("ignore")) } -fn should_panic(i: &ast::Item, diag: &diagnostic::SpanHandler) -> ShouldPanic { - match i.attrs.iter().find(|attr| { - if attr.check_name("should_panic") { return true; } - if attr.check_name("should_fail") { - diag.span_warn(attr.span, "`#[should_fail]` is deprecated. Use `#[should_panic]` \ - instead"); - return true; - } - false - }) { +fn should_panic(i: &ast::Item) -> ShouldPanic { + match i.attrs.iter().find(|attr| attr.check_name("should_panic")) { Some(attr) => { let msg = attr.meta_item_list() .and_then(|list| list.iter().find(|mi| mi.check_name("expected"))) diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs index 9b570c2b1fe..ec608646327 100644 --- a/src/libsyntax/util/parser_testing.rs +++ b/src/libsyntax/util/parser_testing.rs @@ -9,9 +9,9 @@ // except according to those terms. use ast; -use parse::{new_parse_sess}; +use parse::new_parse_sess; use parse::{ParseSess,string_to_filemap,filemap_to_tts}; -use parse::{new_parser_from_source_str}; +use parse::new_parser_from_source_str; use parse::parser::Parser; use parse::token; use ptr::P; |
