]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #27980 - tbu-:pr_cloexec_dup, r=alexcrichton
authorbors <bors@rust-lang.org>
Mon, 31 Aug 2015 07:24:39 +0000 (07:24 +0000)
committerbors <bors@rust-lang.org>
Mon, 31 Aug 2015 07:24:39 +0000 (07:24 +0000)
Still needs values of F_DUPFD_CLOEXEC on other OSs.

For Bitrig, NetBSD and OpenBSD the constant was incorrectly in posix01, when
it's actually posix08. In order to maintain backwards-compatiblity, the
constant was only copied, not moved.

cc #24237

31 files changed:
src/librustc/ast_map/blocks.rs
src/librustc/ast_map/mod.rs
src/librustc/lint/context.rs
src/librustc/middle/check_const.rs
src/librustc/middle/check_match.rs
src/librustc/middle/const_eval.rs
src/librustc/middle/effect.rs
src/librustc/middle/intrinsicck.rs
src/librustc/middle/resolve_lifetime.rs
src/librustc/middle/ty.rs
src/librustc/session/config.rs
src/librustc/session/mod.rs
src/librustc/session/search_paths.rs
src/librustc/util/ppaux.rs
src/librustc_borrowck/borrowck/mod.rs
src/librustc_driver/lib.rs
src/librustc_lint/builtin.rs
src/librustc_resolve/lib.rs
src/librustc_trans/trans/adt.rs
src/librustc_typeck/check/intrinsic.rs
src/librustc_typeck/check/wf.rs
src/librustc_typeck/diagnostics.rs
src/librustdoc/lib.rs
src/libsyntax/ast.rs
src/libsyntax/ast_util.rs
src/libsyntax/feature_gate.rs
src/libsyntax/parse/parser.rs
src/libsyntax/visit.rs
src/test/compile-fail/intrinsic-invalid-number-of-arguments.rs [new file with mode: 0644]
src/test/compile-fail/issue-28105.rs [new file with mode: 0644]
src/test/run-pass-fulldeps/compiler-calls.rs

index 59eba6880a6d05a6cf49f859a62be85fddf966fe..8f24d20ebbf47a2b4e87fa4efa3e3079cb3eb7e0 100644 (file)
@@ -28,7 +28,7 @@
 use syntax::ast::{Block, FnDecl, NodeId};
 use syntax::ast;
 use syntax::codemap::Span;
-use syntax::visit;
+use syntax::visit::FnKind;
 
 /// An FnLikeNode is a Node that is like a fn, in that it has a decl
 /// and a body (as well as a NodeId, a span, etc).
@@ -50,7 +50,7 @@ pub struct FnLikeNode<'a> { node: ast_map::Node<'a> }
 pub struct FnParts<'a> {
     pub decl: &'a FnDecl,
     pub body: &'a Block,
-    pub kind: visit::FnKind<'a>,
+    pub kind: FnKind<'a>,
     pub span: Span,
     pub id:   NodeId,
 }
@@ -186,15 +186,15 @@ pub fn id(self) -> NodeId {
                     |c: ClosureParts|    c.id)
     }
 
-    pub fn kind(self) -> visit::FnKind<'a> {
-        let item = |p: ItemFnParts<'a>| -> visit::FnKind<'a> {
-            visit::FkItemFn(p.ident, p.generics, p.unsafety, p.constness, p.abi, p.vis)
+    pub fn kind(self) -> FnKind<'a> {
+        let item = |p: ItemFnParts<'a>| -> FnKind<'a> {
+            FnKind::ItemFn(p.ident, p.generics, p.unsafety, p.constness, p.abi, p.vis)
         };
         let closure = |_: ClosureParts| {
-            visit::FkClosure
+            FnKind::Closure
         };
         let method = |_, ident, sig: &'a ast::MethodSig, vis, _, _| {
-            visit::FkMethod(ident, sig, vis)
+            FnKind::Method(ident, sig, vis)
         };
         self.handle(item, method, closure)
     }
index f7f926d9d971afa5be26fad044a89ae5b5c873ae..a212594a326b81587820c4e35cd4d6374c55d6ab 100644 (file)
@@ -480,6 +480,7 @@ pub fn get_path_elem(&self, id: NodeId) -> PathElem {
             NodeImplItem(ii) => PathName(ii.ident.name),
             NodeTraitItem(ti) => PathName(ti.ident.name),
             NodeVariant(v) => PathName(v.node.name.name),
+            NodeLifetime(lt) => PathName(lt.name),
             _ => panic!("no path elem for {:?}", node)
         }
     }
index 40ee023b7e86110c0ce68ba2a3d3c391c20805ee..144dc15dd8aea408eac65d375f938440069d6f3b 100644 (file)
@@ -43,6 +43,7 @@
 use syntax::visit::{Visitor, FnKind};
 use syntax::parse::token::InternedString;
 use syntax::{ast, ast_util, visit};
+use syntax::diagnostic;
 
 /// Information about the registered lints.
 ///
@@ -141,7 +142,7 @@ pub fn register_pass(&mut self, sess: Option<&Session>,
                 match (sess, from_plugin) {
                     // We load builtin lints first, so a duplicate is a compiler bug.
                     // Use early_error when handling -W help with no crate.
-                    (None, _) => early_error(&msg[..]),
+                    (None, _) => early_error(diagnostic::Auto, &msg[..]),
                     (Some(sess), false) => sess.bug(&msg[..]),
 
                     // A duplicate name from a plugin is a user error.
@@ -166,7 +167,7 @@ pub fn register_group(&mut self, sess: Option<&Session>,
             match (sess, from_plugin) {
                 // We load builtin lints first, so a duplicate is a compiler bug.
                 // Use early_error when handling -W help with no crate.
-                (None, _) => early_error(&msg[..]),
+                (None, _) => early_error(diagnostic::Auto, &msg[..]),
                 (Some(sess), false) => sess.bug(&msg[..]),
 
                 // A duplicate name from a plugin is a user error.
index 9153fd6484e2e9632b920f116d6e8eea9549023c..47b61767f10e9d489bd7067d2648b2c8c30cc6cb 100644 (file)
@@ -38,7 +38,7 @@
 
 use syntax::ast;
 use syntax::codemap::Span;
-use syntax::visit::{self, Visitor};
+use syntax::visit::{self, FnKind, Visitor};
 
 use std::collections::hash_map::Entry;
 use std::cmp::Ordering;
@@ -142,7 +142,7 @@ fn global_expr(&mut self, mode: Mode, expr: &ast::Expr) -> ConstQualif {
     }
 
     fn fn_like(&mut self,
-               fk: visit::FnKind,
+               fk: FnKind,
                fd: &ast::FnDecl,
                b: &ast::Block,
                s: Span,
@@ -157,10 +157,10 @@ fn fn_like(&mut self,
         }
 
         let mode = match fk {
-            visit::FkItemFn(_, _, _, ast::Constness::Const, _, _) => {
+            FnKind::ItemFn(_, _, _, ast::Constness::Const, _, _) => {
                 Mode::ConstFn
             }
-            visit::FkMethod(_, m, _) => {
+            FnKind::Method(_, m, _) => {
                 if m.constness == ast::Constness::Const {
                     Mode::ConstFn
                 } else {
@@ -352,7 +352,7 @@ fn visit_impl_item(&mut self, i: &'v ast::ImplItem) {
     }
 
     fn visit_fn(&mut self,
-                fk: visit::FnKind<'v>,
+                fk: FnKind<'v>,
                 fd: &'v ast::FnDecl,
                 b: &'v ast::Block,
                 s: Span,
index 25390535e608762810f654040ac8732636b042c0..332ccb03729fe961ffe52adb01cfd1b76ff185b0 100644 (file)
@@ -1007,7 +1007,7 @@ fn check_fn(cx: &mut MatchCheckCtxt,
             sp: Span,
             fn_id: NodeId) {
     match kind {
-        visit::FkClosure => {}
+        FnKind::Closure => {}
         _ => cx.param_env = ParameterEnvironment::for_item(cx.tcx, fn_id),
     }
 
index 98a1e07adfb7431e4d9f4341998aadea4fd6f098..35057037fbac93fa179e0241abfc62d00e852e1c 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![allow(non_camel_case_types)]
+//#![allow(non_camel_case_types)]
 
 use self::ConstVal::*;
 use self::ErrKind::*;
 use util::num::ToPrimitive;
 
 use syntax::ast::{self, Expr};
-use syntax::codemap::Span;
+use syntax::codemap::{self, Span};
 use syntax::parse::token::InternedString;
 use syntax::ptr::P;
-use syntax::{codemap, visit};
+use syntax::visit::FnKind;
 
 use std::borrow::{Cow, IntoCow};
 use std::num::wrapping::OverflowingOps;
@@ -246,10 +246,10 @@ pub fn lookup_const_fn_by_id<'tcx>(tcx: &ty::ctxt<'tcx>, def_id: DefId)
     };
 
     match fn_like.kind() {
-        visit::FkItemFn(_, _, _, ast::Constness::Const, _, _) => {
+        FnKind::ItemFn(_, _, _, ast::Constness::Const, _, _) => {
             Some(fn_like)
         }
-        visit::FkMethod(_, m, _) => {
+        FnKind::Method(_, m, _) => {
             if m.constness == ast::Constness::Const {
                 Some(fn_like)
             } else {
index 3fe1e2f5e8369903974114a506d532c48e1dd2d1..f78ec28c7f051ef5d87638bf6be831e512d4eefa 100644 (file)
@@ -19,7 +19,7 @@
 use syntax::ast;
 use syntax::codemap::Span;
 use syntax::visit;
-use syntax::visit::Visitor;
+use syntax::visit::{FnKind, Visitor};
 
 #[derive(Copy, Clone)]
 struct UnsafeContext {
@@ -75,13 +75,13 @@ fn require_unsafe(&mut self, span: Span, description: &str) {
 }
 
 impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
-    fn visit_fn(&mut self, fn_kind: visit::FnKind<'v>, fn_decl: &'v ast::FnDecl,
+    fn visit_fn(&mut self, fn_kind: FnKind<'v>, fn_decl: &'v ast::FnDecl,
                 block: &'v ast::Block, span: Span, _: ast::NodeId) {
 
         let (is_item_fn, is_unsafe_fn) = match fn_kind {
-            visit::FkItemFn(_, _, unsafety, _, _, _) =>
+            FnKind::ItemFn(_, _, unsafety, _, _, _) =>
                 (true, unsafety == ast::Unsafety::Unsafe),
-            visit::FkMethod(_, sig, _) =>
+            FnKind::Method(_, sig, _) =>
                 (true, sig.unsafety == ast::Unsafety::Unsafe),
             _ => (false, false),
         };
index 1e640ce47b6b2d5a23fc2bb3e4e6d4c9d043173a..f88e5a69f8a4e43ddc4f399c52809fd968287b56 100644 (file)
@@ -19,7 +19,7 @@
 use syntax::abi::RustIntrinsic;
 use syntax::ast;
 use syntax::codemap::Span;
-use syntax::visit::Visitor;
+use syntax::visit::{FnKind, Visitor};
 use syntax::visit;
 
 pub fn check_crate(tcx: &ctxt) {
@@ -216,16 +216,16 @@ fn push_transmute_restriction(&self, restriction: TransmuteRestriction<'tcx>) {
 }
 
 impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> {
-    fn visit_fn(&mut self, fk: visit::FnKind<'v>, fd: &'v ast::FnDecl,
+    fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v ast::FnDecl,
                 b: &'v ast::Block, s: Span, id: ast::NodeId) {
         match fk {
-            visit::FkItemFn(..) | visit::FkMethod(..) => {
+            FnKind::ItemFn(..) | FnKind::Method(..) => {
                 let param_env = ty::ParameterEnvironment::for_item(self.tcx, id);
                 self.param_envs.push(param_env);
                 visit::walk_fn(self, fk, fd, b, s);
                 self.param_envs.pop();
             }
-            visit::FkClosure(..) => {
+            FnKind::Closure(..) => {
                 visit::walk_fn(self, fk, fd, b, s);
             }
         }
index fee24f61d4cc388811e6f01a376d0847de0b68cc..f8d7ed9d1b11f04f8e76afcfa6f76d042814d326 100644 (file)
@@ -30,7 +30,7 @@
 use syntax::parse::token::special_idents;
 use syntax::print::pprust::lifetime_to_string;
 use syntax::visit;
-use syntax::visit::Visitor;
+use syntax::visit::{FnKind, Visitor};
 use util::nodemap::NodeMap;
 
 #[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug)]
@@ -173,20 +173,20 @@ fn visit_foreign_item(&mut self, item: &ast::ForeignItem) {
         replace(&mut self.labels_in_fn, saved);
     }
 
-    fn visit_fn(&mut self, fk: visit::FnKind<'v>, fd: &'v ast::FnDecl,
+    fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v ast::FnDecl,
                 b: &'v ast::Block, s: Span, _: ast::NodeId) {
         match fk {
-            visit::FkItemFn(_, generics, _, _, _, _) => {
+            FnKind::ItemFn(_, generics, _, _, _, _) => {
                 self.visit_early_late(subst::FnSpace, generics, |this| {
                     this.walk_fn(fk, fd, b, s)
                 })
             }
-            visit::FkMethod(_, sig, _) => {
+            FnKind::Method(_, sig, _) => {
                 self.visit_early_late(subst::FnSpace, &sig.generics, |this| {
                     this.walk_fn(fk, fd, b, s)
                 })
             }
-            visit::FkClosure(..) => {
+            FnKind::Closure(..) => {
                 self.walk_fn(fk, fd, b, s)
             }
         }
@@ -470,21 +470,21 @@ impl<'a> LifetimeContext<'a> {
     // labels of the function body and swaps them in before visiting
     // the function body itself.
     fn walk_fn<'b>(&mut self,
-                   fk: visit::FnKind,
+                   fk: FnKind,
                    fd: &ast::FnDecl,
                    fb: &'b ast::Block,
                    _span: Span) {
         match fk {
-            visit::FkItemFn(_, generics, _, _, _, _) => {
+            FnKind::ItemFn(_, generics, _, _, _, _) => {
                 visit::walk_fn_decl(self, fd);
                 self.visit_generics(generics);
             }
-            visit::FkMethod(_, sig, _) => {
+            FnKind::Method(_, sig, _) => {
                 visit::walk_fn_decl(self, fd);
                 self.visit_generics(&sig.generics);
                 self.visit_explicit_self(&sig.explicit_self);
             }
-            visit::FkClosure(..) => {
+            FnKind::Closure(..) => {
                 visit::walk_fn_decl(self, fd);
             }
         }
index e9be9010d4a8ca815b7005245e4af3d8c3f4b687..372bbfc9a1a7e0bf31201216d083477cc39e64c2 100644 (file)
@@ -1733,7 +1733,7 @@ pub struct FreeRegion {
 }
 
 #[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash,
-         RustcEncodable, RustcDecodable, Copy, Debug)]
+         RustcEncodable, RustcDecodable, Copy)]
 pub enum BoundRegion {
     /// An anonymous region parameter for a given fn (&T)
     BrAnon(u32),
@@ -2325,7 +2325,7 @@ pub struct TypeParameterDef<'tcx> {
     pub object_lifetime_default: ObjectLifetimeDefault,
 }
 
-#[derive(Clone, Debug)]
+#[derive(Clone)]
 pub struct RegionParameterDef {
     pub name: ast::Name,
     pub def_id: DefId,
index c5db7cd718b8ed931f6946d42fbb1cd05d253b82..f0f824a0218bb4dda91ca0c4bfb221b153c211f6 100644 (file)
@@ -288,7 +288,7 @@ pub fn $defaultfn() -> $struct_name {
         $struct_name { $($opt: $init),* }
     }
 
-    pub fn $buildfn(matches: &getopts::Matches) -> $struct_name
+    pub fn $buildfn(matches: &getopts::Matches, color: ColorConfig) -> $struct_name
     {
         let mut op = $defaultfn();
         for option in matches.opt_strs($prefix) {
@@ -302,20 +302,20 @@ pub fn $buildfn(matches: &getopts::Matches) -> $struct_name
                 if !setter(&mut op, value) {
                     match (value, opt_type_desc) {
                         (Some(..), None) => {
-                            early_error(&format!("{} option `{}` takes no \
-                                                 value", $outputname, key))
+                            early_error(color, &format!("{} option `{}` takes no \
+                                                         value", $outputname, key))
                         }
                         (None, Some(type_desc)) => {
-                            early_error(&format!("{0} option `{1}` requires \
-                                                 {2} ({3} {1}=<value>)",
-                                                $outputname, key,
-                                                type_desc, $prefix))
+                            early_error(color, &format!("{0} option `{1}` requires \
+                                                         {2} ({3} {1}=<value>)",
+                                                        $outputname, key,
+                                                        type_desc, $prefix))
                         }
                         (Some(value), Some(type_desc)) => {
-                            early_error(&format!("incorrect value `{}` for {} \
-                                                 option `{}` - {} was expected",
-                                                 value, $outputname,
-                                                 key, type_desc))
+                            early_error(color, &format!("incorrect value `{}` for {} \
+                                                         option `{}` - {} was expected",
+                                                        value, $outputname,
+                                                        key, type_desc))
                         }
                         (None, None) => unreachable!()
                     }
@@ -324,8 +324,8 @@ pub fn $buildfn(matches: &getopts::Matches) -> $struct_name
                 break;
             }
             if !found {
-                early_error(&format!("unknown {} option: `{}`",
-                                    $outputname, key));
+                early_error(color, &format!("unknown {} option: `{}`",
+                                            $outputname, key));
             }
         }
         return op;
@@ -850,9 +850,23 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String> ) -> ast::CrateConfig {
 }
 
 pub fn build_session_options(matches: &getopts::Matches) -> Options {
+    let color = match matches.opt_str("color").as_ref().map(|s| &s[..]) {
+        Some("auto")   => Auto,
+        Some("always") => Always,
+        Some("never")  => Never,
+
+        None => Auto,
+
+        Some(arg) => {
+            early_error(Auto, &format!("argument for --color must be auto, always \
+                                        or never (instead was `{}`)",
+                                       arg))
+        }
+    };
+
     let unparsed_crate_types = matches.opt_strs("crate-type");
     let crate_types = parse_crate_types_from_list(unparsed_crate_types)
-        .unwrap_or_else(|e| early_error(&e[..]));
+        .unwrap_or_else(|e| early_error(color, &e[..]));
 
     let mut lint_opts = vec!();
     let mut describe_lints = false;
@@ -869,11 +883,11 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
 
     let lint_cap = matches.opt_str("cap-lints").map(|cap| {
         lint::Level::from_str(&cap).unwrap_or_else(|| {
-            early_error(&format!("unknown lint level: `{}`", cap))
+            early_error(color, &format!("unknown lint level: `{}`", cap))
         })
     });
 
-    let debugging_opts = build_debugging_options(matches);
+    let debugging_opts = build_debugging_options(matches, color);
 
     let parse_only = debugging_opts.parse_only;
     let no_trans = debugging_opts.no_trans;
@@ -897,8 +911,8 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
                     "link" => OutputTypeExe,
                     "dep-info" => OutputTypeDepInfo,
                     _ => {
-                        early_error(&format!("unknown emission type: `{}`",
-                                            part))
+                        early_error(color, &format!("unknown emission type: `{}`",
+                                                    part))
                     }
                 };
                 output_types.push(output_type)
@@ -911,7 +925,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
         output_types.push(OutputTypeExe);
     }
 
-    let cg = build_codegen_options(matches);
+    let cg = build_codegen_options(matches, color);
 
     let sysroot_opt = matches.opt_str("sysroot").map(|m| PathBuf::from(&m));
     let target = matches.opt_str("target").unwrap_or(
@@ -919,7 +933,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
     let opt_level = {
         if matches.opt_present("O") {
             if cg.opt_level.is_some() {
-                early_error("-O and -C opt-level both provided");
+                early_error(color, "-O and -C opt-level both provided");
             }
             Default
         } else {
@@ -930,9 +944,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
                 Some(2) => Default,
                 Some(3) => Aggressive,
                 Some(arg) => {
-                    early_error(&format!("optimization level needs to be \
-                                          between 0-3 (instead was `{}`)",
-                                         arg));
+                    early_error(color, &format!("optimization level needs to be \
+                                                 between 0-3 (instead was `{}`)",
+                                                arg));
                 }
             }
         }
@@ -941,7 +955,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
     let gc = debugging_opts.gc;
     let debuginfo = if matches.opt_present("g") {
         if cg.debuginfo.is_some() {
-            early_error("-g and -C debuginfo both provided");
+            early_error(color, "-g and -C debuginfo both provided");
         }
         FullDebugInfo
     } else {
@@ -950,16 +964,16 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
             Some(1) => LimitedDebugInfo,
             Some(2) => FullDebugInfo,
             Some(arg) => {
-                early_error(&format!("debug info level needs to be between \
-                                      0-2 (instead was `{}`)",
-                                     arg));
+                early_error(color, &format!("debug info level needs to be between \
+                                             0-2 (instead was `{}`)",
+                                            arg));
             }
         }
     };
 
     let mut search_paths = SearchPaths::new();
     for s in &matches.opt_strs("L") {
-        search_paths.add_path(&s[..]);
+        search_paths.add_path(&s[..], color);
     }
 
     let libs = matches.opt_strs("l").into_iter().map(|s| {
@@ -971,9 +985,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
             (Some(name), "framework") => (name, cstore::NativeFramework),
             (Some(name), "static") => (name, cstore::NativeStatic),
             (_, s) => {
-                early_error(&format!("unknown library kind `{}`, expected \
-                                     one of dylib, framework, or static",
-                                    s));
+                early_error(color, &format!("unknown library kind `{}`, expected \
+                                             one of dylib, framework, or static",
+                                            s));
             }
         };
         (name.to_string(), kind)
@@ -989,40 +1003,26 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
             "file-names" => PrintRequest::FileNames,
             "sysroot" => PrintRequest::Sysroot,
             req => {
-                early_error(&format!("unknown print request `{}`", req))
+                early_error(color, &format!("unknown print request `{}`", req))
             }
         }
     }).collect::<Vec<_>>();
 
     if !cg.remark.is_empty() && debuginfo == NoDebugInfo {
-        early_warn("-C remark will not show source locations without \
-                    --debuginfo");
+        early_warn(color, "-C remark will not show source locations without \
+                           --debuginfo");
     }
 
-    let color = match matches.opt_str("color").as_ref().map(|s| &s[..]) {
-        Some("auto")   => Auto,
-        Some("always") => Always,
-        Some("never")  => Never,
-
-        None => Auto,
-
-        Some(arg) => {
-            early_error(&format!("argument for --color must be auto, always \
-                                 or never (instead was `{}`)",
-                                arg))
-        }
-    };
-
     let mut externs = HashMap::new();
     for arg in &matches.opt_strs("extern") {
         let mut parts = arg.splitn(2, '=');
         let name = match parts.next() {
             Some(s) => s,
-            None => early_error("--extern value must not be empty"),
+            None => early_error(color, "--extern value must not be empty"),
         };
         let location = match parts.next() {
             Some(s) => s,
-            None => early_error("--extern value must be of the format `foo=bar`"),
+            None => early_error(color, "--extern value must be of the format `foo=bar`"),
         };
 
         externs.entry(name.to_string()).or_insert(vec![]).push(location.to_string());
index 18982215f588f056416ba3bc15391ab755094e8f..ff732ee7b9d80c60099da78a70c3c65adec28c11 100644 (file)
@@ -473,13 +473,13 @@ pub fn expect<T, M>(sess: &Session, opt: Option<T>, msg: M) -> T where
     diagnostic::expect(sess.diagnostic(), opt, msg)
 }
 
-pub fn early_error(msg: &str) -> ! {
-    let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto, None);
+pub fn early_error(color: diagnostic::ColorConfig, msg: &str) -> ! {
+    let mut emitter = diagnostic::EmitterWriter::stderr(color, None);
     emitter.emit(None, msg, None, diagnostic::Fatal);
     panic!(diagnostic::FatalError);
 }
 
-pub fn early_warn(msg: &str) {
-    let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto, None);
+pub fn early_warn(color: diagnostic::ColorConfig, msg: &str) {
+    let mut emitter = diagnostic::EmitterWriter::stderr(color, None);
     emitter.emit(None, msg, None, diagnostic::Warning);
 }
index 3dc31f9524effe1e5b32668c7c7d707bbf9ce1fb..caf776dad85e06ff28ebda7ee9a77b19dbb4b680 100644 (file)
@@ -11,6 +11,7 @@
 use std::slice;
 use std::path::{Path, PathBuf};
 use session::early_error;
+use syntax::diagnostic;
 
 #[derive(Clone, Debug)]
 pub struct SearchPaths {
@@ -37,7 +38,7 @@ pub fn new() -> SearchPaths {
         SearchPaths { paths: Vec::new() }
     }
 
-    pub fn add_path(&mut self, path: &str) {
+    pub fn add_path(&mut self, path: &str, color: diagnostic::ColorConfig) {
         let (kind, path) = if path.starts_with("native=") {
             (PathKind::Native, &path["native=".len()..])
         } else if path.starts_with("crate=") {
@@ -52,7 +53,7 @@ pub fn add_path(&mut self, path: &str) {
             (PathKind::All, path)
         };
         if path.is_empty() {
-            early_error("empty search path given via `-L`");
+            early_error(color, "empty search path given via `-L`");
         }
         self.paths.push((kind, PathBuf::from(path)));
     }
index ac51f46a7e94354daec181af74c57a6b39f84704..62ece6af4f2be6c9959a1531ccba3885af16dcd9 100644 (file)
@@ -307,8 +307,20 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 
 impl<'tcx> fmt::Debug for ty::TypeParameterDef<'tcx> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "TypeParameterDef({:?}, {:?}/{})",
-               self.def_id, self.space, self.index)
+        write!(f, "TypeParameterDef({}, {}:{}, {:?}/{})",
+               self.name,
+               self.def_id.krate, self.def_id.node,
+               self.space, self.index)
+    }
+}
+
+impl fmt::Debug for ty::RegionParameterDef {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f, "RegionParameterDef({}, {}:{}, {:?}/{}, {:?})",
+               self.name,
+               self.def_id.krate, self.def_id.node,
+               self.space, self.index,
+               self.bounds)
     }
 }
 
@@ -388,6 +400,19 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+impl fmt::Debug for ty::BoundRegion {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        match *self {
+            BrAnon(n) => write!(f, "BrAnon({:?})", n),
+            BrFresh(n) => write!(f, "BrFresh({:?})", n),
+            BrNamed(did, name) => {
+                write!(f, "BrNamed({}:{}, {:?})", did.krate, did.node, name)
+            }
+            BrEnv => "BrEnv".fmt(f),
+        }
+    }
+}
+
 impl fmt::Debug for ty::Region {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
index 9a684021fcdd33d8d261ed1497cbf3cbf2448827..fe341ca44755f1a1f77e936cd81d67c9e7a0fd7e 100644 (file)
@@ -59,8 +59,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for BorrowckCtxt<'a, 'tcx> {
     fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl,
                 b: &'v Block, s: Span, id: ast::NodeId) {
         match fk {
-            visit::FkItemFn(..) |
-            visit::FkMethod(..) => {
+            FnKind::ItemFn(..) |
+            FnKind::Method(..) => {
                 let new_free_region_map = self.tcx.free_region_map(id);
                 let old_free_region_map =
                     mem::replace(&mut self.free_region_map, new_free_region_map);
@@ -68,7 +68,7 @@ fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl,
                 self.free_region_map = old_free_region_map;
             }
 
-            visit::FkClosure => {
+            FnKind::Closure => {
                 borrowck_fn(self, fk, fd, b, s, id);
             }
         }
index 60eaffd71cbc6a91bd1ab5dfa341cdf787a8fe08..ed63b8153544e348308332a553f3f18d06429294 100644 (file)
@@ -117,11 +117,11 @@ macro_rules! do_or_return {($expr: expr) => {
         None => return
     };
 
-    let descriptions = diagnostics_registry();
+    let sopts = config::build_session_options(&matches);
 
-    do_or_return!(callbacks.early_callback(&matches, &descriptions));
+    let descriptions = diagnostics_registry();
 
-    let sopts = config::build_session_options(&matches);
+    do_or_return!(callbacks.early_callback(&matches, &descriptions, sopts.color));
 
     let (odir, ofile) = make_output(&matches);
     let (input, input_file_path) = match make_input(&matches.free) {
@@ -205,7 +205,8 @@ pub trait CompilerCalls<'a> {
     // else (e.g., selecting input and output).
     fn early_callback(&mut self,
                       _: &getopts::Matches,
-                      _: &diagnostics::registry::Registry)
+                      _: &diagnostics::registry::Registry,
+                      _: diagnostic::ColorConfig)
                       -> Compilation {
         Compilation::Continue
     }
@@ -277,7 +278,8 @@ fn parse_pretty(&mut self,
 impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
     fn early_callback(&mut self,
                       matches: &getopts::Matches,
-                      descriptions: &diagnostics::registry::Registry)
+                      descriptions: &diagnostics::registry::Registry,
+                      color: diagnostic::ColorConfig)
                       -> Compilation {
         match matches.opt_str("explain") {
             Some(ref code) => {
@@ -287,7 +289,7 @@ fn early_callback(&mut self,
                         print!("{}", &description[1..]);
                     }
                     None => {
-                        early_error(&format!("no extended information for {}", code));
+                        early_error(color, &format!("no extended information for {}", code));
                     }
                 }
                 return Compilation::Stop;
@@ -319,10 +321,10 @@ fn no_input(&mut self,
                 if should_stop == Compilation::Stop {
                     return None;
                 }
-                early_error("no input filename given");
+                early_error(sopts.color, "no input filename given");
             }
             1 => panic!("make_input should have provided valid inputs"),
-            _ => early_error("multiple input filenames provided")
+            _ => early_error(sopts.color, "multiple input filenames provided")
         }
 
         None
@@ -414,7 +416,7 @@ pub fn list_metadata(sess: &Session,
                     println!("{}", String::from_utf8(v).unwrap());
                 }
                 &Input::Str(_) => {
-                    early_error("cannot list metadata for stdin");
+                    early_error(sess.opts.color, "cannot list metadata for stdin");
                 }
             }
             return Compilation::Stop;
@@ -441,7 +443,7 @@ fn print_crate_info(sess: &Session,
                 PrintRequest::CrateName => {
                     let input = match input {
                         Some(input) => input,
-                        None => early_error("no input file provided"),
+                        None => early_error(sess.opts.color, "no input file provided"),
                     };
                     let attrs = attrs.as_ref().unwrap();
                     let t_outputs = driver::build_output_filenames(input,
@@ -701,14 +703,15 @@ fn parse_all_options(args: &Vec<String>) -> getopts::Matches {
                             &opt.opt_group.short_name
                         };
                         if m.opt_present(opt_name) {
-                            early_error(&format!("use of unstable option '{}' requires \
-                                                  -Z unstable-options", opt_name));
+                            early_error(diagnostic::Auto, &format!("use of unstable option '{}' \
+                                                                    requires -Z unstable-options",
+                                                                   opt_name));
                         }
                     }
                 }
                 m
             }
-            Err(f) => early_error(&f.to_string())
+            Err(f) => early_error(diagnostic::Auto, &f.to_string())
         }
     }
 
index abdeb6ae46e01cc7e09d873d4d0a3a5ebb0cbf92..c723bad5265b704ce24c8ad121f46db66673d748 100644 (file)
@@ -51,7 +51,7 @@
 use syntax::feature_gate::{KNOWN_ATTRIBUTES, AttributeType};
 use syntax::ast::{TyIs, TyUs, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64};
 use syntax::ptr::P;
-use syntax::visit::{self, Visitor};
+use syntax::visit::{self, FnKind, Visitor};
 
 // hardwired lints from librustc
 pub use lint::builtin::*;
@@ -1242,10 +1242,10 @@ fn check_crate(&mut self, cx: &Context, cr: &ast::Crate) {
     }
 
     fn check_fn(&mut self, cx: &Context,
-                fk: visit::FnKind, _: &ast::FnDecl,
+                fk: FnKind, _: &ast::FnDecl,
                 _: &ast::Block, span: Span, id: ast::NodeId) {
         match fk {
-            visit::FkMethod(ident, _, _) => match method_context(cx, id, span) {
+            FnKind::Method(ident, _, _) => match method_context(cx, id, span) {
                 MethodContext::PlainImpl => {
                     self.check_snake_case(cx, "method", &ident.name.as_str(), Some(span))
                 },
@@ -1254,7 +1254,7 @@ fn check_fn(&mut self, cx: &Context,
                 },
                 _ => (),
             },
-            visit::FkItemFn(ident, _, _, _, _, _) => {
+            FnKind::ItemFn(ident, _, _, _, _, _) => {
                 self.check_snake_case(cx, "function", &ident.name.as_str(), Some(span))
             },
             _ => (),
@@ -1600,13 +1600,13 @@ fn check_item(&mut self, cx: &Context, it: &ast::Item) {
         }
     }
 
-    fn check_fn(&mut self, cx: &Context, fk: visit::FnKind, _: &ast::FnDecl,
+    fn check_fn(&mut self, cx: &Context, fk: FnKind, _: &ast::FnDecl,
                 _: &ast::Block, span: Span, _: ast::NodeId) {
         match fk {
-            visit::FkItemFn(_, _, ast::Unsafety::Unsafe, _, _, _) =>
+            FnKind::ItemFn(_, _, ast::Unsafety::Unsafe, _, _, _) =>
                 cx.span_lint(UNSAFE_CODE, span, "declaration of an `unsafe` function"),
 
-            visit::FkMethod(_, sig, _) => {
+            FnKind::Method(_, sig, _) => {
                 if sig.unsafety == ast::Unsafety::Unsafe {
                     cx.span_lint(UNSAFE_CODE, span, "implementation of an `unsafe` method")
                 }
@@ -1687,7 +1687,7 @@ fn check_stmt(&mut self, cx: &Context, s: &ast::Stmt) {
     }
 
     fn check_fn(&mut self, cx: &Context,
-                _: visit::FnKind, decl: &ast::FnDecl,
+                _: FnKind, decl: &ast::FnDecl,
                 _: &ast::Block, _: Span, _: ast::NodeId) {
         for a in &decl.inputs {
             self.check_unused_mut_pat(cx, slice::ref_slice(&a.pat));
@@ -2128,18 +2128,18 @@ fn get_lints(&self) -> LintArray {
         lint_array![UNCONDITIONAL_RECURSION]
     }
 
-    fn check_fn(&mut self, cx: &Context, fn_kind: visit::FnKind, _: &ast::FnDecl,
+    fn check_fn(&mut self, cx: &Context, fn_kind: FnKind, _: &ast::FnDecl,
                 blk: &ast::Block, sp: Span, id: ast::NodeId) {
         type F = for<'tcx> fn(&ty::ctxt<'tcx>,
                               ast::NodeId, ast::NodeId, ast::Ident, ast::NodeId) -> bool;
 
         let method = match fn_kind {
-            visit::FkItemFn(..) => None,
-            visit::FkMethod(..) => {
+            FnKind::ItemFn(..) => None,
+            FnKind::Method(..) => {
                 cx.tcx.impl_or_trait_item(DefId::local(id)).as_opt_method()
             }
             // closures can't recur, so they don't matter.
-            visit::FkClosure => return
+            FnKind::Closure => return
         };
 
         // Walk through this function (say `f`) looking to see if
index 0f8dc4d54a0c9da563bdad1e66a92cb17e891dc7..c79fdf1bca47ed6fd3033c24bfa1f3ae0d98ce65 100644 (file)
@@ -88,7 +88,7 @@
 use syntax::parse::token::{self, special_names, special_idents};
 use syntax::ptr::P;
 use syntax::codemap::{self, Span, Pos};
-use syntax::visit::{self, Visitor};
+use syntax::visit::{self, FnKind, Visitor};
 
 use std::collections::{HashMap, HashSet};
 use std::collections::hash_map::Entry::{Occupied, Vacant};
@@ -527,22 +527,22 @@ fn visit_foreign_item(&mut self, foreign_item: &ast::ForeignItem) {
         });
     }
     fn visit_fn(&mut self,
-                function_kind: visit::FnKind<'v>,
+                function_kind: FnKind<'v>,
                 declaration: &'v FnDecl,
                 block: &'v Block,
                 _: Span,
                 node_id: NodeId) {
         let rib_kind = match function_kind {
-            visit::FkItemFn(_, generics, _, _, _, _) => {
+            FnKind::ItemFn(_, generics, _, _, _, _) => {
                 self.visit_generics(generics);
                 ItemRibKind
             }
-            visit::FkMethod(_, sig, _) => {
+            FnKind::Method(_, sig, _) => {
                 self.visit_generics(&sig.generics);
                 self.visit_explicit_self(&sig.explicit_self);
                 MethodRibKind
             }
-            visit::FkClosure(..) => ClosureRibKind(node_id)
+            FnKind::Closure(..) => ClosureRibKind(node_id)
         };
         self.resolve_function(rib_kind, declaration, block);
     }
index e425ffcaebf647ac242c238b0d7e625e9462516e..de09e33ec142786b0f6442281c8b5a0e00ac65ea 100644 (file)
@@ -177,15 +177,12 @@ pub fn represent_type<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
     repr
 }
 
-macro_rules! repeat_u8_as_u32 {
-    ($name:expr) => { (($name as u32) << 24 |
-                       ($name as u32) << 16 |
-                       ($name as u32) <<  8 |
-                       ($name as u32)) }
+const fn repeat_u8_as_u32(val: u8) -> u32 {
+    (val as u32) << 24 | (val as u32) << 16 | (val as u32) << 8 | val as u32
 }
-macro_rules! repeat_u8_as_u64 {
-    ($name:expr) => { ((repeat_u8_as_u32!($name) as u64) << 32 |
-                       (repeat_u8_as_u32!($name) as u64)) }
+
+const fn repeat_u8_as_u64(val: u8) -> u64 {
+    (repeat_u8_as_u32(val) as u64) << 32 | repeat_u8_as_u32(val) as u64
 }
 
 /// `DTOR_NEEDED_HINT` is a stack-local hint that just means
@@ -203,8 +200,8 @@ macro_rules! repeat_u8_as_u64 {
 pub const DTOR_MOVED_HINT: u8 = 0x2d;
 
 pub const DTOR_NEEDED: u8 = 0xd4;
-pub const DTOR_NEEDED_U32: u32 = repeat_u8_as_u32!(DTOR_NEEDED);
-pub const DTOR_NEEDED_U64: u64 = repeat_u8_as_u64!(DTOR_NEEDED);
+pub const DTOR_NEEDED_U32: u32 = repeat_u8_as_u32(DTOR_NEEDED);
+pub const DTOR_NEEDED_U64: u64 = repeat_u8_as_u64(DTOR_NEEDED);
 #[allow(dead_code)]
 pub fn dtor_needed_usize(ccx: &CrateContext) -> usize {
     match &ccx.tcx().sess.target.target.target_pointer_width[..] {
@@ -215,8 +212,8 @@ pub fn dtor_needed_usize(ccx: &CrateContext) -> usize {
 }
 
 pub const DTOR_DONE: u8 = 0x1d;
-pub const DTOR_DONE_U32: u32 = repeat_u8_as_u32!(DTOR_DONE);
-pub const DTOR_DONE_U64: u64 = repeat_u8_as_u64!(DTOR_DONE);
+pub const DTOR_DONE_U32: u32 = repeat_u8_as_u32(DTOR_DONE);
+pub const DTOR_DONE_U64: u64 = repeat_u8_as_u64(DTOR_DONE);
 #[allow(dead_code)]
 pub fn dtor_done_usize(ccx: &CrateContext) -> usize {
     match &ccx.tcx().sess.target.target.target_pointer_width[..] {
index 83ac406119ee4393c857a6a66ea16702b99d705a..e75e512594ccb215a261a4ceb5d1ae1f0ec867c8 100644 (file)
@@ -408,6 +408,13 @@ pub fn check_platform_intrinsic_type(ccx: &CrateCtxt,
                     let mut structural_to_nomimal = HashMap::new();
 
                     let sig = tcx.no_late_bound_regions(i_ty.ty.fn_sig()).unwrap();
+                    if intr.inputs.len() != sig.inputs.len() {
+                        span_err!(tcx.sess, it.span, E0444,
+                                  "platform-specific intrinsic has invalid number of \
+                                   arguments: found {}, expected {}",
+                                  intr.inputs.len(), sig.inputs.len());
+                        return
+                    }
                     let input_pairs = intr.inputs.iter().zip(&sig.inputs);
                     for (i, (expected_arg, arg)) in input_pairs.enumerate() {
                         match_intrinsic_type_to_type(tcx, &format!("argument {}", i + 1), it.span,
index 0ef1d4b81acadffe2782c65fdb9c0ff7fa37a33f..c235e4b5c38996b11d5df7d67ef70d81c3c064a3 100644 (file)
@@ -25,7 +25,7 @@
 use syntax::codemap::{DUMMY_SP, Span};
 use syntax::parse::token::{special_idents};
 use syntax::visit;
-use syntax::visit::Visitor;
+use syntax::visit::{FnKind, Visitor};
 
 pub struct CheckTypeWellFormedVisitor<'ccx, 'tcx:'ccx> {
     ccx: &'ccx CrateCtxt<'ccx, 'tcx>,
@@ -425,11 +425,11 @@ fn visit_item(&mut self, i: &ast::Item) {
     }
 
     fn visit_fn(&mut self,
-                fk: visit::FnKind<'v>, fd: &'v ast::FnDecl,
+                fk: FnKind<'v>, fd: &'v ast::FnDecl,
                 b: &'v ast::Block, span: Span, id: ast::NodeId) {
         match fk {
-            visit::FkClosure | visit::FkItemFn(..) => {}
-            visit::FkMethod(..) => {
+            FnKind::Closure | FnKind::ItemFn(..) => {}
+            FnKind::Method(..) => {
                 match self.tcx().impl_or_trait_item(DefId::local(id)) {
                     ty::ImplOrTraitItem::MethodTraitItem(ty_method) => {
                         reject_shadowing_type_parameters(self.tcx(), span, &ty_method.generics)
index 9f811eda4417d83ed55d5e35618ce07d05b1e2a6..a7c1fbb2719ab91583dec59c5d4d4e86e8f839a4 100644 (file)
@@ -3018,7 +3018,34 @@ struct Foo<'a, T: 'a> {
 parameters. You can read more about it in the API documentation:
 
 https://doc.rust-lang.org/std/marker/struct.PhantomData.html
-"##
+"##,
+
+E0444: r##"
+A platform-specific intrinsic function has wrong number of arguments.
+Erroneous code example:
+
+```
+#[repr(simd)]
+struct f64x2(f64, f64);
+
+extern "platform-intrinsic" {
+    fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32;
+    // error: platform-specific intrinsic has invalid number of arguments
+}
+```
+
+Please refer to the function declaration to see if it corresponds
+with yours. Example:
+
+```
+#[repr(simd)]
+struct f64x2(f64, f64);
+
+extern "platform-intrinsic" {
+    fn x86_mm_movemask_pd(x: f64x2) -> i32; // ok!
+}
+```
+"##,
 
 }
 
index 33902363e0a258a1bb89dfc3ba7f7c8407cd5c2a..933f9cab7f70640d4998e3b25a46dabfef7476ed 100644 (file)
@@ -65,6 +65,7 @@
 use serialize::Decodable;
 use serialize::json::{self, Json};
 use rustc::session::search_paths::SearchPaths;
+use syntax::diagnostic;
 
 // reexported from `clean` so it can be easily updated with the mod itself
 pub use clean::SCHEMA_VERSION;
@@ -227,7 +228,7 @@ pub fn main_args(args: &[String]) -> isize {
 
     let mut libs = SearchPaths::new();
     for s in &matches.opt_strs("L") {
-        libs.add_path(s);
+        libs.add_path(s, diagnostic::Auto);
     }
     let externs = match parse_externs(&matches) {
         Ok(ex) => ex,
@@ -362,7 +363,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
     // First, parse the crate and extract all relevant information.
     let mut paths = SearchPaths::new();
     for s in &matches.opt_strs("L") {
-        paths.add_path(s);
+        paths.add_path(s, diagnostic::Auto);
     }
     let cfgs = matches.opt_strs("cfg");
     let triple = matches.opt_str("target");
index 66faa1227e6d6914707513d6dc5168c101fd17b1..25a3540c7436cc61dbac361f72e4537dcdfc0e66 100644 (file)
@@ -1372,8 +1372,6 @@ pub struct TypeBinding {
     pub span: Span,
 }
 
-
-// NB PartialEq method appears below.
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
 pub struct Ty {
     pub id: NodeId,
index 61c182f638f40bc628223735c091f838e9057b05..43476df3a8e777d6384a78b6c2964bc2018db77b 100644 (file)
@@ -17,7 +17,7 @@
 use parse::token;
 use print::pprust;
 use ptr::P;
-use visit::Visitor;
+use visit::{FnKind, Visitor};
 use visit;
 
 use std::cmp;
@@ -423,8 +423,8 @@ fn visit_fn(&mut self,
                 node_id: NodeId) {
         if !self.pass_through_items {
             match function_kind {
-                visit::FkMethod(..) if self.visited_outermost => return,
-                visit::FkMethod(..) => self.visited_outermost = true,
+                FnKind::Method(..) if self.visited_outermost => return,
+                FnKind::Method(..) => self.visited_outermost = true,
                 _ => {}
             }
         }
@@ -432,13 +432,13 @@ fn visit_fn(&mut self,
         self.operation.visit_id(node_id);
 
         match function_kind {
-            visit::FkItemFn(_, generics, _, _, _, _) => {
+            FnKind::ItemFn(_, generics, _, _, _, _) => {
                 self.visit_generics_helper(generics)
             }
-            visit::FkMethod(_, sig, _) => {
+            FnKind::Method(_, sig, _) => {
                 self.visit_generics_helper(&sig.generics)
             }
-            visit::FkClosure => {}
+            FnKind::Closure => {}
         }
 
         for argument in &function_declaration.inputs {
@@ -452,7 +452,7 @@ fn visit_fn(&mut self,
                        span);
 
         if !self.pass_through_items {
-            if let visit::FkMethod(..) = function_kind {
+            if let FnKind::Method(..) = function_kind {
                 self.visited_outermost = false;
             }
         }
@@ -518,7 +518,7 @@ fn visit_id(&mut self, id: NodeId) {
 }
 
 /// Computes the id range for a single fn body, ignoring nested items.
-pub fn compute_id_range_for_fn_body(fk: visit::FnKind,
+pub fn compute_id_range_for_fn_body(fk: FnKind,
                                     decl: &FnDecl,
                                     body: &Block,
                                     sp: Span,
index 3fa55df7594db2493c3835773e27358fee3d34d5..78234a8efced3fe9568bee413146a9f962ce8f5e 100644 (file)
@@ -34,7 +34,7 @@
 use codemap::{CodeMap, Span};
 use diagnostic::SpanHandler;
 use visit;
-use visit::Visitor;
+use visit::{FnKind, Visitor};
 use parse::token::{self, InternedString};
 
 use std::ascii::AsciiExt;
@@ -833,14 +833,14 @@ fn visit_pat(&mut self, pattern: &ast::Pat) {
     }
 
     fn visit_fn(&mut self,
-                fn_kind: visit::FnKind<'v>,
+                fn_kind: FnKind<'v>,
                 fn_decl: &'v ast::FnDecl,
                 block: &'v ast::Block,
                 span: Span,
                 _node_id: NodeId) {
         // check for const fn declarations
         match fn_kind {
-            visit::FkItemFn(_, _, _, ast::Constness::Const, _, _) => {
+            FnKind::ItemFn(_, _, _, ast::Constness::Const, _, _) => {
                 self.gate_feature("const_fn", span, "const fn is unstable");
             }
             _ => {
@@ -852,13 +852,13 @@ fn visit_fn(&mut self,
         }
 
         match fn_kind {
-            visit::FkItemFn(_, _, _, _, abi, _) if abi == Abi::RustIntrinsic => {
+            FnKind::ItemFn(_, _, _, _, abi, _) if abi == Abi::RustIntrinsic => {
                 self.gate_feature("intrinsics",
                                   span,
                                   "intrinsics are subject to change")
             }
-            visit::FkItemFn(_, _, _, _, abi, _) |
-            visit::FkMethod(_, &ast::MethodSig { abi, .. }, _) if abi == Abi::RustCall => {
+            FnKind::ItemFn(_, _, _, _, abi, _) |
+            FnKind::Method(_, &ast::MethodSig { abi, .. }, _) if abi == Abi::RustCall => {
                 self.gate_feature("unboxed_closures",
                                   span,
                                   "rust-call ABI is subject to change")
index e6242690ac0d097a5c9d1adb9fb1be18a18ecf4f..4966215a9f2d3c830bad14fe4efa28cf81591b22 100644 (file)
@@ -2142,7 +2142,6 @@ pub fn parse_bottom_expr(&mut self) -> PResult<P<Expr>> {
                     return self.parse_loop_expr(None, lo);
                 }
                 if try!(self.eat_keyword(keywords::Continue) ){
-                    let lo = self.span.lo;
                     let ex = if self.token.is_lifetime() {
                         let lifetime = self.get_lifetime();
                         try!(self.bump());
index 824aee74ce5a6734ea638d5d97c5c3ce78c2f61f..8365a7375c68dbed3911b4d036db1f2665a52dd7 100644 (file)
@@ -23,8 +23,6 @@
 //! instance, a walker looking for item names in a module will miss all of
 //! those that are created by the expansion of a macro.
 
-pub use self::FnKind::*;
-
 use abi::Abi;
 use ast::*;
 use ast;
 #[derive(Copy, Clone, PartialEq, Eq)]
 pub enum FnKind<'a> {
     /// fn foo() or extern "Abi" fn foo()
-    FkItemFn(Ident, &'a Generics, Unsafety, Constness, Abi, Visibility),
+    ItemFn(Ident, &'a Generics, Unsafety, Constness, Abi, Visibility),
 
     /// fn foo(&self)
-    FkMethod(Ident, &'a MethodSig, Option<Visibility>),
+    Method(Ident, &'a MethodSig, Option<Visibility>),
 
     /// |x, y| {}
-    FkClosure,
+    Closure,
 }
 
 /// Each method of the Visitor trait is a hook to be potentially
@@ -247,8 +245,8 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
             visitor.visit_expr(&**expr);
         }
         ItemFn(ref declaration, unsafety, constness, abi, ref generics, ref body) => {
-            visitor.visit_fn(FkItemFn(item.ident, generics, unsafety,
-                                      constness, abi, item.vis),
+            visitor.visit_fn(FnKind::ItemFn(item.ident, generics, unsafety,
+                                            constness, abi, item.vis),
                              &**declaration,
                              &**body,
                              item.span,
@@ -608,14 +606,14 @@ pub fn walk_fn<'v, V: Visitor<'v>>(visitor: &mut V,
     walk_fn_decl(visitor, function_declaration);
 
     match function_kind {
-        FkItemFn(_, generics, _, _, _, _) => {
+        FnKind::ItemFn(_, generics, _, _, _, _) => {
             visitor.visit_generics(generics);
         }
-        FkMethod(_, sig, _) => {
+        FnKind::Method(_, sig, _) => {
             visitor.visit_generics(&sig.generics);
             visitor.visit_explicit_self(&sig.explicit_self);
         }
-        FkClosure(..) => {}
+        FnKind::Closure(..) => {}
     }
 
     visitor.visit_block(function_body)
@@ -639,7 +637,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
             walk_fn_decl(visitor, &sig.decl);
         }
         MethodTraitItem(ref sig, Some(ref body)) => {
-            visitor.visit_fn(FkMethod(trait_item.ident, sig, None), &sig.decl,
+            visitor.visit_fn(FnKind::Method(trait_item.ident, sig, None), &sig.decl,
                              body, trait_item.span, trait_item.id);
         }
         TypeTraitItem(ref bounds, ref default) => {
@@ -660,7 +658,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
             visitor.visit_expr(expr);
         }
         MethodImplItem(ref sig, ref body) => {
-            visitor.visit_fn(FkMethod(impl_item.ident, sig, Some(impl_item.vis)), &sig.decl,
+            visitor.visit_fn(FnKind::Method(impl_item.ident, sig, Some(impl_item.vis)), &sig.decl,
                              body, impl_item.span, impl_item.id);
         }
         TypeImplItem(ref ty) => {
@@ -816,7 +814,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
             }
         }
         ExprClosure(_, ref function_declaration, ref body) => {
-            visitor.visit_fn(FkClosure,
+            visitor.visit_fn(FnKind::Closure,
                              &**function_declaration,
                              &**body,
                              expression.span,
diff --git a/src/test/compile-fail/intrinsic-invalid-number-of-arguments.rs b/src/test/compile-fail/intrinsic-invalid-number-of-arguments.rs
new file mode 100644 (file)
index 0000000..a224690
--- /dev/null
@@ -0,0 +1,24 @@
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test number of arguments in platform-specific intrinsic function
+// This is the error E0444
+
+#![feature(repr_simd, platform_intrinsics)]
+
+#[repr(simd)]
+struct f64x2(f64, f64);
+
+extern "platform-intrinsic" {
+    fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ platform-specific intrinsic
+}
+
+pub fn main() {
+}
diff --git a/src/test/compile-fail/issue-28105.rs b/src/test/compile-fail/issue-28105.rs
new file mode 100644 (file)
index 0000000..6ae6358
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2012-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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Make sure that a continue span actually contains the keyword.
+
+fn main() {
+    'a: loop {
+        if false {
+            continue //~ ERROR use of undeclared label
+            'b;
+        } else {
+            break //~ ERROR use of undeclared label
+            'c;
+        }
+    }
+}
index 0805bc5dcb35955b1ca833d9c0cc62f5180d4cd5..8850f6e6d2a6e5863db91511efd4438bba2925d5 100644 (file)
@@ -23,7 +23,7 @@
 use rustc::session::Session;
 use rustc::session::config::{self, Input};
 use rustc_driver::{driver, CompilerCalls, Compilation};
-use syntax::diagnostics;
+use syntax::{diagnostics, diagnostic};
 
 use std::path::PathBuf;
 
@@ -34,7 +34,8 @@ struct TestCalls {
 impl<'a> CompilerCalls<'a> for TestCalls {
     fn early_callback(&mut self,
                       _: &getopts::Matches,
-                      _: &diagnostics::registry::Registry)
+                      _: &diagnostics::registry::Registry,
+                      _: diagnostic::ColorConfig)
                       -> Compilation {
         self.count *= 2;
         Compilation::Continue