Skip to content

Rollup of 7 pull requests #45532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Oct 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,10 +860,18 @@ fn run_cargo(build: &Build, cargo: &mut Command, stamp: &Path) {
// have a hash in the name, but there's a version of this file in
// the `deps` folder which *does* have a hash in the name. That's
// the one we'll want to we'll probe for it later.
toplevel.push((filename.file_stem().unwrap()
.to_str().unwrap().to_string(),
filename.extension().unwrap().to_owned()
.to_str().unwrap().to_string()));
//
// We do not use `Path::file_stem` or `Path::extension` here,
// because some generated files may have multiple extensions e.g.
// `std-<hash>.dll.lib` on Windows. The aforementioned methods only
// split the file name by the last extension (`.lib`) while we need
// to split by all extensions (`.dll.lib`).
let filename = filename.file_name().unwrap().to_str().unwrap();
let mut parts = filename.splitn(2, '.');
let file_stem = parts.next().unwrap().to_owned();
let extension = parts.next().unwrap().to_owned();

toplevel.push((file_stem, extension));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/asmjs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ ENV TARGETS=asmjs-unknown-emscripten

ENV RUST_CONFIGURE_ARGS --target=$TARGETS

ENV SCRIPT python2.7 ../x.py test --target $TARGETS src/test/run-pass
ENV SCRIPT python2.7 ../x.py test --target $TARGETS
28 changes: 24 additions & 4 deletions src/libcore/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,16 +665,36 @@ mod impls {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Hash for *const T {
impl<T: ?Sized> Hash for *const T {
fn hash<H: Hasher>(&self, state: &mut H) {
state.write_usize(*self as usize)
if mem::size_of::<Self>() == mem::size_of::<usize>() {
// Thin pointer
state.write_usize(*self as *const () as usize);
} else {
// Fat pointer
let (a, b) = unsafe {
*(self as *const Self as *const (usize, usize))
};
state.write_usize(a);
state.write_usize(b);
}
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Hash for *mut T {
impl<T: ?Sized> Hash for *mut T {
fn hash<H: Hasher>(&self, state: &mut H) {
state.write_usize(*self as usize)
if mem::size_of::<Self>() == mem::size_of::<usize>() {
// Thin pointer
state.write_usize(*self as *const () as usize);
} else {
// Fat pointer
let (a, b) = unsafe {
*(self as *const Self as *const (usize, usize))
};
state.write_usize(a);
state.write_usize(b);
}
}
}
}
8 changes: 8 additions & 0 deletions src/libcore/tests/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ fn test_writer_hasher() {

let ptr = 5_usize as *mut i32;
assert_eq!(hash(&ptr), 5);

let cs: &mut [u8] = &mut [1, 2, 3];
let ptr = cs.as_ptr();
let slice_ptr = cs as *const [u8];
assert_eq!(hash(&slice_ptr), hash(&ptr) + cs.len() as u64);

let slice_ptr = cs as *mut [u8];
assert_eq!(hash(&slice_ptr), hash(&ptr) + cs.len() as u64);
}

struct Custom { hash: u64 }
Expand Down
1 change: 1 addition & 0 deletions src/librustc_back/target/sparcv9_sun_solaris.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn target() -> TargetResult {
// llvm calls this "v9"
base.cpu = "v9".to_string();
base.max_atomic_width = Some(64);
base.exe_allocation_crate = None;

Ok(Target {
llvm_target: "sparcv9-sun-solaris".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_borrowck/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
let mut err = self.cannot_reassign_immutable(span,
&self.loan_path_to_string(lp),
Origin::Ast);
err.span_label(span, "re-assignment of immutable variable");
err.span_label(span, "cannot assign twice to immutable variable");
if span != assign.span {
err.span_label(assign.span, format!("first assignment to `{}`",
self.loan_path_to_string(lp)));
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx>
self.tcx.cannot_reassign_immutable(span,
&self.describe_lvalue(lvalue),
Origin::Mir)
.span_label(span, "re-assignment of immutable variable")
.span_label(span, "cannot assign twice to immutable variable")
.span_label(assigned_span, format!("first assignment to `{}`",
self.describe_lvalue(lvalue)))
.emit();
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/util/borrowck_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ pub trait BorrowckErrors {
-> DiagnosticBuilder
{
struct_span_err!(self, span, E0384,
"re-assignment of immutable variable `{}`{OGN}",
"cannot assign twice to immutable variable `{}`{OGN}",
desc, OGN=o)
}

Expand Down
5 changes: 3 additions & 2 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,11 @@ nav.sub {

.sidebar {
width: 200px;
position: absolute;
position: fixed;
left: 0;
top: 0;
min-height: 100%;
height: 100vh;
overflow: auto;
}

.sidebar .current {
Expand Down
19 changes: 19 additions & 0 deletions src/libstd/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,25 @@ pub fn abort() -> ! {
unsafe { ::sys::abort_internal() };
}

/// Returns the OS-assigned process identifier associated with this process.
///
/// # Examples
///
/// Basic usage:
///
/// ```no_run
/// #![feature(getpid)]
/// use std::process;
///
/// println!("My pid is {}", process::id());
/// ```
///
///
#[unstable(feature = "getpid", issue = "44971", reason = "recently added")]
pub fn id() -> u32 {
::sys::os::getpid()
}

#[cfg(all(test, not(target_os = "emscripten")))]
mod tests {
use io::prelude::*;
Expand Down
4 changes: 4 additions & 0 deletions src/libstd/sys/redox/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,7 @@ pub fn exit(code: i32) -> ! {
let _ = syscall::exit(code as usize);
unreachable!();
}

pub fn getpid() -> u32 {
syscall::getpid().unwrap() as u32
}
4 changes: 4 additions & 0 deletions src/libstd/sys/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,3 +511,7 @@ pub fn home_dir() -> Option<PathBuf> {
pub fn exit(code: i32) -> ! {
unsafe { libc::exit(code as c_int) }
}

pub fn getpid() -> u32 {
unsafe { libc::getpid() as u32 }
}
4 changes: 4 additions & 0 deletions src/libstd/sys/windows/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ pub fn exit(code: i32) -> ! {
unsafe { c::ExitProcess(code as c::UINT) }
}

pub fn getpid() -> u32 {
unsafe { c::GetCurrentProcessId() as u32 }
}

#[cfg(test)]
mod tests {
use io::Error;
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/asm-out-assign-imm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ pub fn main() {
foo(x);
unsafe {
asm!("mov $1, $0" : "=r"(x) : "r"(5));
//~^ ERROR re-assignment of immutable variable `x`
//~| NOTE re-assignment of immutable
//~^ ERROR cannot assign twice to immutable variable `x`
//~| NOTE cannot assign twice to immutable
}
foo(x);
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/assign-imm-local-twice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ fn test() {
let v: isize;
v = 1; //~ NOTE first assignment
println!("v={}", v);
v = 2; //~ ERROR re-assignment of immutable variable
//~| NOTE re-assignment of immutable
v = 2; //~ ERROR cannot assign twice to immutable variable
//~| NOTE cannot assign twice to immutable
println!("v={}", v);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,39 +26,39 @@ struct S {
pub fn main() {
match 1 {
x => {
x += 1; //[ast]~ ERROR re-assignment of immutable variable `x`
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
//[mir]~^ ERROR (Mir) [E0384]
//[mir]~| ERROR (Ast) [E0384]
}
}

match E::Foo(1) {
E::Foo(x) => {
x += 1; //[ast]~ ERROR re-assignment of immutable variable `x`
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
//[mir]~^ ERROR (Mir) [E0384]
//[mir]~| ERROR (Ast) [E0384]
}
}

match (S { bar: 1 }) {
S { bar: x } => {
x += 1; //[ast]~ ERROR re-assignment of immutable variable `x`
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
//[mir]~^ ERROR (Mir) [E0384]
//[mir]~| ERROR (Ast) [E0384]
}
}

match (1,) {
(x,) => {
x += 1; //[ast]~ ERROR re-assignment of immutable variable `x`
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
//[mir]~^ ERROR (Mir) [E0384]
//[mir]~| ERROR (Ast) [E0384]
}
}

match [1,2,3] {
[x,_,_] => {
x += 1; //[ast]~ ERROR re-assignment of immutable variable `x`
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
//[mir]~^ ERROR (Mir) [E0384]
//[mir]~| ERROR (Ast) [E0384]
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/liveness-assign-imm-local-in-loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
fn test() {
let v: isize;
loop {
v = 1; //~ ERROR re-assignment of immutable variable
//~^ NOTE re-assignment of immutable variable
v = 1; //~ ERROR cannot assign twice to immutable variable
//~^ NOTE cannot assign twice to immutable variable
v.clone(); // just to prevent liveness warnings
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
fn test() {
let v: isize;
v = 2; //~ NOTE first assignment
v += 1; //~ ERROR re-assignment of immutable variable
//~| NOTE re-assignment of immutable
v += 1; //~ ERROR cannot assign twice to immutable variable
//~| NOTE cannot assign twice to immutable
v.clone();
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/liveness-assign-imm-local-with-init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
fn test() {
let v: isize = 1; //~ NOTE first assignment
v.clone();
v = 2; //~ ERROR re-assignment of immutable variable
//~| NOTE re-assignment of immutable
v = 2; //~ ERROR cannot assign twice to immutable variable
//~| NOTE cannot assign twice to immutable
v.clone();
}

Expand Down
6 changes: 3 additions & 3 deletions src/test/compile-fail/mut-pattern-internal-mutability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ fn main() {
let foo = &mut 1;

let &mut x = foo;
x += 1; //[ast]~ ERROR re-assignment of immutable variable
//[mir]~^ ERROR re-assignment of immutable variable `x` (Ast)
//[mir]~| ERROR re-assignment of immutable variable `x` (Mir)
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable
//[mir]~^ ERROR cannot assign twice to immutable variable `x` (Ast)
//[mir]~| ERROR cannot assign twice to immutable variable `x` (Mir)

// explicitly mut-ify internals
let &mut mut x = foo;
Expand Down