Auto merge of #22796 - Manishearth:rollup, r=Manishearth
This commit is contained in:
commit
4db0b32467
139 changed files with 1692 additions and 1087 deletions
22
src/test/compile-fail/borrowck-fn-in-const-a.rs
Normal file
22
src/test/compile-fail/borrowck-fn-in-const-a.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// 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.
|
||||
|
||||
// Check that we check fns appearing in constant declarations.
|
||||
// Issue #22382.
|
||||
|
||||
const MOVE: fn(&String) -> String = {
|
||||
fn broken(x: &String) -> String {
|
||||
return *x //~ ERROR cannot move
|
||||
}
|
||||
broken
|
||||
};
|
||||
|
||||
fn main() {
|
||||
}
|
||||
24
src/test/compile-fail/borrowck-fn-in-const-b.rs
Normal file
24
src/test/compile-fail/borrowck-fn-in-const-b.rs
Normal file
|
|
@ -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.
|
||||
|
||||
// Check that we check fns appearing in constant declarations.
|
||||
// Issue #22382.
|
||||
|
||||
// How about mutating an immutable vector?
|
||||
const MUTATE: fn(&Vec<String>) = {
|
||||
fn broken(x: &Vec<String>) {
|
||||
x.push(format!("this is broken"));
|
||||
//~^ ERROR cannot borrow
|
||||
}
|
||||
broken
|
||||
};
|
||||
|
||||
fn main() {
|
||||
}
|
||||
33
src/test/compile-fail/borrowck-fn-in-const-c.rs
Normal file
33
src/test/compile-fail/borrowck-fn-in-const-c.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// 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.
|
||||
|
||||
// Check that we check fns appearing in constant declarations.
|
||||
// Issue #22382.
|
||||
|
||||
// Returning local references?
|
||||
struct DropString {
|
||||
inner: String
|
||||
}
|
||||
impl Drop for DropString {
|
||||
fn drop(&mut self) {
|
||||
self.inner.clear();
|
||||
self.inner.push_str("dropped");
|
||||
}
|
||||
}
|
||||
const LOCAL_REF: fn() -> &'static str = {
|
||||
fn broken() -> &'static str {
|
||||
let local = DropString { inner: format!("Some local string") };
|
||||
return &local.inner; //~ ERROR does not live long enough
|
||||
}
|
||||
broken
|
||||
};
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
@ -15,6 +15,8 @@
|
|||
use std::marker::PhantomFn;
|
||||
|
||||
struct Bar;
|
||||
struct Bar2;
|
||||
struct Bar3;
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
mod allowed_unsafe {
|
||||
|
|
@ -46,6 +48,53 @@ impl Baz for Bar {
|
|||
unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method
|
||||
}
|
||||
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
trait A {
|
||||
unsafe fn allowed_unsafe(&self);
|
||||
unsafe fn allowed_unsafe_provided(&self) {}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl Baz for Bar2 {
|
||||
unsafe fn baz(&self) {}
|
||||
unsafe fn provided_override(&self) {}
|
||||
}
|
||||
|
||||
impl Baz for Bar3 {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn baz(&self) {}
|
||||
unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe trait B {
|
||||
fn dummy(&self) {}
|
||||
}
|
||||
|
||||
trait C {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn baz(&self);
|
||||
unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method
|
||||
}
|
||||
|
||||
impl C for Bar {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn baz(&self) {}
|
||||
unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method
|
||||
}
|
||||
|
||||
impl C for Bar2 {
|
||||
unsafe fn baz(&self) {} //~ ERROR: implementation of an `unsafe` method
|
||||
}
|
||||
|
||||
trait D {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn unsafe_provided(&self) {}
|
||||
}
|
||||
|
||||
impl D for Bar {}
|
||||
|
||||
fn main() {
|
||||
unsafe {} //~ ERROR: usage of an `unsafe` block
|
||||
|
||||
|
|
|
|||
23
src/test/compile-fail/unsafe_no_drop_flag-gate.rs
Normal file
23
src/test/compile-fail/unsafe_no_drop_flag-gate.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// 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 <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.
|
||||
|
||||
pub struct T;
|
||||
|
||||
#[unsafe_no_drop_flag]
|
||||
//~^ ERROR unsafe_no_drop_flag has unstable semantics and may be removed
|
||||
pub struct S {
|
||||
pub x: T,
|
||||
}
|
||||
|
||||
impl Drop for S {
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
|
|
@ -23,5 +23,5 @@ pub fn main() {
|
|||
let mut v = vec!(1);
|
||||
v.push_val(2);
|
||||
v.push_val(3);
|
||||
assert_eq!(v, vec!(1, 2, 3));
|
||||
assert_eq!(v, [1, 2, 3]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,5 +22,5 @@ fn bar(v: &mut [uint]) {
|
|||
pub fn main() {
|
||||
let mut the_vec = vec!(1, 2, 3, 100);
|
||||
bar(&mut the_vec);
|
||||
assert_eq!(the_vec, vec!(100, 3, 2, 1));
|
||||
assert_eq!(the_vec, [100, 3, 2, 1]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,5 +18,5 @@ fn bar(v: &mut [uint]) {
|
|||
pub fn main() {
|
||||
let mut the_vec = vec!(1, 2, 3, 100);
|
||||
bar(&mut the_vec);
|
||||
assert_eq!(the_vec, vec!(100, 3, 2, 1));
|
||||
assert_eq!(the_vec, [100, 3, 2, 1]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,13 +9,14 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::env::*;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[cfg(unix)]
|
||||
fn main() {
|
||||
let oldhome = var("HOME");
|
||||
|
||||
set_var("HOME", "/home/MountainView");
|
||||
assert!(home_dir() == Some(Path::new("/home/MountainView")));
|
||||
assert!(home_dir() == Some(PathBuf::new("/home/MountainView")));
|
||||
|
||||
remove_var("HOME");
|
||||
if cfg!(target_os = "android") {
|
||||
|
|
@ -36,14 +37,14 @@ fn main() {
|
|||
assert!(home_dir().is_some());
|
||||
|
||||
set_var("HOME", "/home/MountainView");
|
||||
assert!(home_dir() == Some(Path::new("/home/MountainView")));
|
||||
assert!(home_dir() == Some(PathBuf::new("/home/MountainView")));
|
||||
|
||||
remove_var("HOME");
|
||||
|
||||
set_var("USERPROFILE", "/home/MountainView");
|
||||
assert!(home_dir() == Some(Path::new("/home/MountainView")));
|
||||
assert!(home_dir() == Some(PathBuf::new("/home/MountainView")));
|
||||
|
||||
set_var("HOME", "/home/MountainView");
|
||||
set_var("USERPROFILE", "/home/PaloAlto");
|
||||
assert!(home_dir() == Some(Path::new("/home/MountainView")));
|
||||
assert!(home_dir() == Some(PathBuf::new("/home/MountainView")));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,5 +24,5 @@ impl<T> vec_utils<T> for Vec<T> {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
assert_eq!(vec_utils::map_(&vec!(1,2,3), |&x| x+1), vec!(2,3,4));
|
||||
assert_eq!(vec_utils::map_(&vec!(1,2,3), |&x| x+1), [2,3,4]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
// no-prefer-dynamic
|
||||
|
||||
// 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.
|
||||
|
|
@ -10,12 +8,15 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::slice::SliceExt;
|
||||
use std::old_io::{fs, USER_RWX};
|
||||
use std::process;
|
||||
// no-prefer-dynamic
|
||||
|
||||
#![feature(fs, process, env, path, rand)]
|
||||
|
||||
use std::env;
|
||||
use std::old_path::BytesContainer;
|
||||
use std::fs;
|
||||
use std::process;
|
||||
use std::rand::random;
|
||||
use std::str;
|
||||
|
||||
fn main() {
|
||||
// If we're the child, make sure we were invoked correctly
|
||||
|
|
@ -34,21 +35,20 @@ fn main() {
|
|||
fn test() {
|
||||
// If we're the parent, copy our own binary to a new directory.
|
||||
let my_path = env::current_exe().unwrap();
|
||||
let my_dir = my_path.dir_path();
|
||||
let my_dir = my_path.parent().unwrap();
|
||||
|
||||
let random_u32: u32 = random();
|
||||
let child_dir = Path::new(my_dir.join(format!("issue-15149-child-{}",
|
||||
random_u32)));
|
||||
fs::mkdir(&child_dir, USER_RWX).unwrap();
|
||||
let child_dir = my_dir.join(&format!("issue-15149-child-{}", random_u32));
|
||||
fs::create_dir(&child_dir).unwrap();
|
||||
|
||||
let child_path = child_dir.join(format!("mytest{}",
|
||||
env::consts::EXE_SUFFIX));
|
||||
let child_path = child_dir.join(&format!("mytest{}",
|
||||
env::consts::EXE_SUFFIX));
|
||||
fs::copy(&my_path, &child_path).unwrap();
|
||||
|
||||
// Append the new directory to our own PATH.
|
||||
let path = {
|
||||
let mut paths: Vec<_> = env::split_paths(&env::var_os("PATH").unwrap()).collect();
|
||||
paths.push(child_dir.clone());
|
||||
paths.push(child_dir.to_path_buf());
|
||||
env::join_paths(paths.iter()).unwrap()
|
||||
};
|
||||
|
||||
|
|
@ -58,9 +58,9 @@ fn test() {
|
|||
|
||||
assert!(child_output.status.success(),
|
||||
format!("child assertion failed\n child stdout:\n {}\n child stderr:\n {}",
|
||||
child_output.stdout.container_as_str().unwrap(),
|
||||
child_output.stderr.container_as_str().unwrap()));
|
||||
str::from_utf8(&child_output.stdout).unwrap(),
|
||||
str::from_utf8(&child_output.stderr).unwrap()));
|
||||
|
||||
fs::rmdir_recursive(&child_dir).unwrap();
|
||||
fs::remove_dir_all(&child_dir).unwrap();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::old_io::{process, Command};
|
||||
use std::process::Command;
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
|
|
@ -22,10 +22,8 @@ fn main() {
|
|||
}
|
||||
|
||||
fn test() {
|
||||
let status = Command::new(env::current_exe().unwrap())
|
||||
let status = Command::new(&env::current_exe().unwrap())
|
||||
.arg("foo").arg("")
|
||||
.stdout(process::InheritFd(1))
|
||||
.stderr(process::InheritFd(2))
|
||||
.status().unwrap();
|
||||
assert!(status.success());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,14 +8,19 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// ignore-windows currently windows requires UTF-8 for spawning processes
|
||||
|
||||
use std::old_io::Command;
|
||||
use std::env;
|
||||
|
||||
#[cfg(unix)]
|
||||
fn main() {
|
||||
use std::process::Command;
|
||||
use std::env;
|
||||
use std::os::unix::prelude::*;
|
||||
use std::ffi::OsStr;
|
||||
|
||||
if env::args().len() == 1 {
|
||||
assert!(Command::new(env::current_exe().unwrap()).arg(b"\xff")
|
||||
assert!(Command::new(&env::current_exe().unwrap())
|
||||
.arg(<OsStr as OsStrExt>::from_bytes(b"\xff"))
|
||||
.status().unwrap().success())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,6 @@ pub fn main() {
|
|||
let mut table = HashMap::new();
|
||||
table.insert("one".to_string(), 1);
|
||||
table.insert("two".to_string(), 2);
|
||||
assert!(check_strs(&format!("{:?}", table), "HashMap {\"one\": 1, \"two\": 2}") ||
|
||||
check_strs(&format!("{:?}", table), "HashMap {\"two\": 2, \"one\": 1}"));
|
||||
assert!(check_strs(&format!("{:?}", table), "{\"one\": 1, \"two\": 2}") ||
|
||||
check_strs(&format!("{:?}", table), "{\"two\": 2, \"one\": 1}"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,11 +44,11 @@ fn transform(x: Option<int>) -> Option<String> {
|
|||
pub fn main() {
|
||||
assert_eq!(transform(Some(10)), Some("11".to_string()));
|
||||
assert_eq!(transform(None), None);
|
||||
assert!((vec!("hi".to_string()))
|
||||
assert_eq!((vec!("hi".to_string()))
|
||||
.bind(|x| vec!(x.clone(), format!("{}!", x)) )
|
||||
.bind(|x| vec!(x.clone(), format!("{}?", x)) ) ==
|
||||
vec!("hi".to_string(),
|
||||
"hi?".to_string(),
|
||||
"hi!".to_string(),
|
||||
"hi!?".to_string()));
|
||||
.bind(|x| vec!(x.clone(), format!("{}?", x)) ),
|
||||
["hi".to_string(),
|
||||
"hi?".to_string(),
|
||||
"hi!".to_string(),
|
||||
"hi!?".to_string()]);
|
||||
}
|
||||
|
|
|
|||
27
src/test/run-pass/std-sync-right-kind-impls.rs
Normal file
27
src/test/run-pass/std-sync-right-kind-impls.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// 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 <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.
|
||||
|
||||
use std::sync;
|
||||
|
||||
fn assert_both<T: Sync + Send>() {}
|
||||
|
||||
fn main() {
|
||||
assert_both::<sync::StaticMutex>();
|
||||
assert_both::<sync::StaticCondvar>();
|
||||
assert_both::<sync::StaticRwLock>();
|
||||
assert_both::<sync::Mutex<()>>();
|
||||
assert_both::<sync::Condvar>();
|
||||
assert_both::<sync::RwLock<()>>();
|
||||
assert_both::<sync::Semaphore>();
|
||||
assert_both::<sync::Barrier>();
|
||||
assert_both::<sync::Arc<()>>();
|
||||
assert_both::<sync::Weak<()>>();
|
||||
assert_both::<sync::Once>();
|
||||
}
|
||||
|
|
@ -44,9 +44,9 @@ fn bar<U:to_str,T:map<U>>(x: T) -> Vec<String> {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
assert_eq!(foo(vec!(1)), vec!("hi".to_string()));
|
||||
assert_eq!(bar::<int, Vec<int> >(vec!(4, 5)), vec!("4".to_string(), "5".to_string()));
|
||||
assert_eq!(foo(vec!(1)), ["hi".to_string()]);
|
||||
assert_eq!(bar::<int, Vec<int> >(vec!(4, 5)), ["4".to_string(), "5".to_string()]);
|
||||
assert_eq!(bar::<String, Vec<String> >(vec!("x".to_string(), "y".to_string())),
|
||||
vec!("x".to_string(), "y".to_string()));
|
||||
assert_eq!(bar::<(), Vec<()>>(vec!(())), vec!("()".to_string()));
|
||||
["x".to_string(), "y".to_string()]);
|
||||
assert_eq!(bar::<(), Vec<()>>(vec!(())), ["()".to_string()]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,5 +18,5 @@ fn f<F: FnMut()>(mut f: F) {
|
|||
fn main() {
|
||||
let mut v: Vec<_> = vec![];
|
||||
f(|| v.push(0));
|
||||
assert_eq!(v, vec![0]);
|
||||
assert_eq!(v, [0]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue