]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #27317 - midinastasurazz:patch-1, r=Gankro
authorbors <bors@rust-lang.org>
Mon, 27 Jul 2015 14:59:27 +0000 (14:59 +0000)
committerbors <bors@rust-lang.org>
Mon, 27 Jul 2015 14:59:27 +0000 (14:59 +0000)
r? @steveklabnik

configure
src/libcore/result.rs
src/librustc/diagnostics.rs
src/librustc_lint/builtin.rs
src/libstd/rand/os.rs
src/test/compile-fail/lint-ctypes.rs

index 652b0b477664f45e57499237210a7cb5c6f03af0..542d829e2cd638cbd9afe53666662b3a89070289 100755 (executable)
--- a/configure
+++ b/configure
@@ -283,7 +283,7 @@ opt_core() {
             fi
         done
     else
-        if [ ! -z "$META" ]
+        if [ -n "$META" ]
         then
             OP="$OP=<$META>"
         fi
@@ -317,7 +317,7 @@ envopt() {
     fi
 
     # If script or environment provided a value, save it.
-    if [ ! -z "$VV" ]
+    if [ -n "$VV" ]
     then
         putvar $V
     fi
@@ -767,7 +767,7 @@ probe CFG_LLDB             lldb
 # On MacOS X, invoking `javac` pops up a dialog if the JDK is not
 # installed. Since `javac` is only used if `antlr4` is available,
 # probe for it only in this case.
-if [ ! -z "$CFG_ANTLR4" ]
+if [ -n "$CFG_ANTLR4" ]
 then
    probe CFG_JAVAC            javac
 fi
@@ -786,14 +786,14 @@ then
     fi
 fi
 
-if [ ! -z "$CFG_GDB" ]
+if [ -n "$CFG_GDB" ]
 then
     # Store GDB's version
     CFG_GDB_VERSION=$($CFG_GDB --version 2>/dev/null | head -1)
     putvar CFG_GDB_VERSION
 fi
 
-if [ ! -z "$CFG_LLDB" ]
+if [ -n "$CFG_LLDB" ]
 then
     # Store LLDB's version
     CFG_LLDB_VERSION=$($CFG_LLDB --version 2>/dev/null | head -1)
@@ -819,7 +819,7 @@ step_msg "looking for target specific programs"
 
 probe CFG_ADB        adb
 
-if [ ! -z "$CFG_PANDOC" ]
+if [ -n "$CFG_PANDOC" ]
 then
     # Extract "MAJOR MINOR" from Pandoc's version number
     PV_MAJOR_MINOR=$(pandoc --version | grep '^pandoc' |
@@ -845,7 +845,7 @@ then
     BIN_SUF=.exe
 fi
 
-if [ ! -z "$CFG_ENABLE_LOCAL_RUST" ]
+if [ -n "$CFG_ENABLE_LOCAL_RUST" ]
 then
     system_rustc=$(which rustc)
     if [ -f ${CFG_LOCAL_RUST_ROOT}/bin/rustc${BIN_SUF} ]
@@ -930,18 +930,18 @@ fi
 
 # Okay, at this point, we have made up our minds about whether we are
 # going to force CFG_ENABLE_CLANG or not; save the setting if so.
-if [ ! -z "$CFG_ENABLE_CLANG" ]
+if [ -n "$CFG_ENABLE_CLANG" ]
 then
     putvar CFG_ENABLE_CLANG
 fi
 
 # Same with jemalloc.  save the setting here.
-if [ ! -z "$CFG_DISABLE_JEMALLOC" ]
+if [ -n "$CFG_DISABLE_JEMALLOC" ]
 then
     putvar CFG_DISABLE_JEMALLOC
 fi
 
-if [ ! -z "$CFG_LLVM_ROOT" -a -z "$CFG_DISABLE_LLVM_VERSION_CHECK" -a -e "$CFG_LLVM_ROOT/bin/llvm-config" ]
+if [ -n "$CFG_LLVM_ROOT" -a -z "$CFG_DISABLE_LLVM_VERSION_CHECK" -a -e "$CFG_LLVM_ROOT/bin/llvm-config" ]
 then
     step_msg "using custom LLVM at $CFG_LLVM_ROOT"
 
@@ -970,7 +970,7 @@ fi
 # CFG_ENABLE_CLANG is set, that indicates that we are opting into
 # running such safeguards.
 
-if [ ! -z "$CC" ]
+if [ -n "$CC" ]
 then
     msg "skipping compiler inference steps; using provided CC=$CC"
     CFG_CC="$CC"
@@ -983,7 +983,7 @@ then
         putvar CFG_USING_CLANG
     fi
 else
-    if [ ! -z "$CFG_ENABLE_CLANG" ]
+    if [ -n "$CFG_ENABLE_CLANG" ]
     then
         if [ -z "$CFG_CLANG" ]
         then
@@ -997,7 +997,7 @@ else
     fi
 fi
 
-if [ ! -z "$CFG_ENABLE_CLANG" ]
+if [ -n "$CFG_ENABLE_CLANG" ]
 then
     case "$CC" in
         (''|*clang)
@@ -1013,7 +1013,7 @@ then
             CFG_CLANG_VERSION=$(echo $CFG_CLANG_REPORTED_VERSION | sed 's/.*version \(.*\) .*/\1/')
         fi
 
-        if [ ! -z "$CFG_OSX_CLANG_VERSION" ]
+        if [ -n "$CFG_OSX_CLANG_VERSION" ]
         then
             case $CFG_OSX_CLANG_VERSION in
                 (7.0*)
@@ -1042,7 +1042,7 @@ then
     esac
 fi
 
-if [ ! -z "$CFG_ENABLE_CCACHE" ]
+if [ -n "$CFG_ENABLE_CCACHE" ]
 then
     if [ -z "$CFG_CCACHE" ]
     then
@@ -1199,7 +1199,7 @@ do
                     ;;
             esac
             bindir="${CFG_MSVC_ROOT}/VC/bin"
-            if [ ! -z "$msvc_part" ]; then
+            if [ -n "$msvc_part" ]; then
                 bindir="$bindir/$msvc_part"
             fi
             eval CFG_MSVC_BINDIR_$bits="\"$bindir\""
@@ -1229,7 +1229,7 @@ do
     esac
 done
 
-if [ ! -z "$CFG_PERF" ]
+if [ -n "$CFG_PERF" ]
 then
     HAVE_PERF_LOGFD=`$CFG_PERF stat --log-fd 2>&1 | grep 'unknown option'`
     if [ -z "$HAVE_PERF_LOGFD" ];
@@ -1339,11 +1339,11 @@ then
     "${CFG_GIT}" submodule init
 
     # Disable submodules that we're not using
-    if [ ! -z "${CFG_LLVM_ROOT}" ]; then
+    if [ -n "${CFG_LLVM_ROOT}" ]; then
         msg "git: submodule deinit src/llvm"
         "${CFG_GIT}" submodule deinit src/llvm
     fi
-    if [ ! -z "${CFG_JEMALLOC_ROOT}" ]; then
+    if [ -n "${CFG_JEMALLOC_ROOT}" ]; then
         msg "git: submodule deinit src/jemalloc"
         "${CFG_GIT}" submodule deinit src/jemalloc
     fi
@@ -1390,7 +1390,7 @@ do
     if [ -z $CFG_LLVM_ROOT ]
     then
         LLVM_BUILD_DIR=${CFG_BUILD_DIR}$t/llvm
-        if [ ! -z "$CFG_DISABLE_OPTIMIZE_LLVM" ]
+        if [ -n "$CFG_DISABLE_OPTIMIZE_LLVM" ]
         then
             LLVM_DBG_OPTS="--enable-debug-symbols --disable-optimized"
             # Just use LLVM straight from its build directory to
@@ -1446,7 +1446,7 @@ do
         msg "configuring LLVM for $t with cmake"
 
         CMAKE_ARGS="-DLLVM_INCLUDE_TESTS=OFF"
-        if [ ! -z "$CFG_DISABLE_OPTIMIZE_LLVM" ]; then
+        if [ -n "$CFG_DISABLE_OPTIMIZE_LLVM" ]; then
             CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug"
         else
             CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release"
@@ -1538,7 +1538,7 @@ do
 
             (*)
             msg "inferring LLVM_CXX/CC from CXX/CC = $CXX/$CC"
-            if [ ! -z "$CFG_ENABLE_CCACHE" ]
+            if [ -n "$CFG_ENABLE_CCACHE" ]
             then
                 if [ -z "$CFG_CCACHE" ]
                 then
@@ -1672,20 +1672,20 @@ putvar CFG_MANDIR
 
 # Avoid spurious warnings from clang by feeding it original source on
 # ccache-miss rather than preprocessed input.
-if [ ! -z "$CFG_ENABLE_CCACHE" ] && [ ! -z "$CFG_USING_CLANG" ]
+if [ -n "$CFG_ENABLE_CCACHE" ] && [ -n "$CFG_USING_CLANG" ]
 then
     CFG_CCACHE_CPP2=1
     putvar CFG_CCACHE_CPP2
 fi
 
-if [ ! -z "$CFG_ENABLE_CCACHE" ]
+if [ -n "$CFG_ENABLE_CCACHE" ]
 then
     CFG_CCACHE_BASEDIR=${CFG_SRC_DIR}
     putvar CFG_CCACHE_BASEDIR
 fi
 
 
-if [ ! -z $BAD_PANDOC ]
+if [ -n $BAD_PANDOC ]
 then
     CFG_PANDOC=
     putvar CFG_PANDOC
index d87c1020dcc2f99e58e9ec0d4de3649e2a7744bf..2b33b1f83d24cfc6eeb692ae1350eddf5f7a7dd3 100644 (file)
@@ -744,7 +744,7 @@ pub fn unwrap(self) -> T {
     /// x.expect("Testing expect"); // panics with `Testing expect: emergency failure`
     /// ```
     #[inline]
-    #[unstable(feature = "result_expect", reason = "newly introduced")]
+    #[unstable(feature = "result_expect", reason = "newly introduced", issue = "27277")]
     pub fn expect(self, msg: &str) -> T {
         match self {
             Ok(t) => t,
index 879a2d740cb0b2b5a928095c664531646a30d62b..768f792d269a8cd7cf52c2d9808a2cb78ee0d5a9 100644 (file)
@@ -766,6 +766,9 @@ enum Enum {
 ```
 type X = u32; // this compiles
 ```
+
+Note that type parameters for enum-variant constructors go after the variant,
+not after the enum (Option::None::<u32>, not Option::<u32>::None).
 "##,
 
 E0110: r##"
index 6289d50588104bbffa0baf63dd9379b38862e535..751224e72864ba9abcc3d15ad1d0e918928f774b 100644 (file)
@@ -436,6 +436,16 @@ fn is_repr_nullable_ptr<'tcx>(variants: &Vec<Rc<ty::VariantInfo<'tcx>>>) -> bool
     false
 }
 
+fn ast_ty_to_normalized<'tcx>(tcx: &ty::ctxt<'tcx>,
+                              id: ast::NodeId)
+                              -> Ty<'tcx> {
+    let tty = match tcx.ast_ty_to_ty_cache.borrow().get(&id) {
+        Some(&t) => t,
+        None => panic!("ast_ty_to_ty_cache was incomplete after typeck!")
+    };
+    infer::normalize_associated_type(tcx, &tty)
+}
+
 impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
     /// Check if the given type is "ffi-safe" (has a stable, well-defined
     /// representation which can be exported to C code).
@@ -638,11 +648,7 @@ fn check_type_for_ffi(&self,
     }
 
     fn check_def(&mut self, sp: Span, id: ast::NodeId) {
-        let tty = match self.cx.tcx.ast_ty_to_ty_cache.borrow().get(&id) {
-            Some(&t) => t,
-            None => panic!("ast_ty_to_ty_cache was incomplete after typeck!")
-        };
-        let tty = infer::normalize_associated_type(self.cx.tcx, &tty);
+        let tty = ast_ty_to_normalized(self.cx.tcx, id);
 
         match ImproperCTypesVisitor::check_type_for_ffi(self, &mut FnvHashSet(), tty) {
             FfiResult::FfiSafe => {}
@@ -707,7 +713,10 @@ fn check_foreign_fn(cx: &Context, decl: &ast::FnDecl) {
                 check_ty(cx, &*input.ty);
             }
             if let ast::Return(ref ret_ty) = decl.output {
-                check_ty(cx, &**ret_ty);
+                let tty = ast_ty_to_normalized(cx.tcx, ret_ty.id);
+                if !tty.is_nil() {
+                    check_ty(cx, &ret_ty);
+                }
             }
         }
 
index d881acba94ea33b8732de6785f669207550529ba..3f75c8bca83ba51ba5b48ac15c889068850546f0 100644 (file)
@@ -41,8 +41,10 @@ fn getrandom(buf: &mut [u8]) -> libc::c_long {
         const NR_GETRANDOM: libc::c_long = 318;
         #[cfg(target_arch = "x86")]
         const NR_GETRANDOM: libc::c_long = 355;
-        #[cfg(any(target_arch = "arm", target_arch = "aarch64", target_arch = "powerpc"))]
+        #[cfg(any(target_arch = "arm", target_arch = "powerpc"))]
         const NR_GETRANDOM: libc::c_long = 384;
+        #[cfg(any(target_arch = "aarch64"))]
+        const NR_GETRANDOM: libc::c_long = 278;
 
         unsafe {
             syscall(NR_GETRANDOM, buf.as_mut_ptr(), buf.len(), 0)
index 614f8e6fde81a966cd2244471a062024e07b3922..4daba86679d5d13fdfefc745335d181f9b1cffe9 100644 (file)
@@ -26,6 +26,7 @@ pub struct StructWithProjectionAndLifetime<'a>(
 pub struct ZeroSize;
 pub type RustFn = fn();
 pub type RustBadRet = extern fn() -> Box<u32>;
+pub type CVoidRet = ();
 
 extern {
     pub fn bare_type1(size: isize); //~ ERROR: found Rust type
@@ -52,6 +53,8 @@ pub struct StructWithProjectionAndLifetime<'a>(
     pub fn good6(s: StructWithProjectionAndLifetime);
     pub fn good7(fptr: extern fn() -> ());
     pub fn good8(fptr: extern fn() -> !);
+    pub fn good9() -> ();
+    pub fn good10() -> CVoidRet;
 }
 
 fn main() {