Skip to content

Commit e847f30

Browse files
committed
Auto merge of #45532 - kennytm:rollup, r=kennytm
Rollup of 7 pull requests - Successful merges: #45059, #45212, #45398, #45483, #45496, #45508, #45526 - Failed merges:
2 parents f9d2416 + 851d1c7 commit e847f30

20 files changed

+101
-32
lines changed

src/bootstrap/compile.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -860,10 +860,18 @@ fn run_cargo(build: &Build, cargo: &mut Command, stamp: &Path) {
860860
// have a hash in the name, but there's a version of this file in
861861
// the `deps` folder which *does* have a hash in the name. That's
862862
// the one we'll want to we'll probe for it later.
863-
toplevel.push((filename.file_stem().unwrap()
864-
.to_str().unwrap().to_string(),
865-
filename.extension().unwrap().to_owned()
866-
.to_str().unwrap().to_string()));
863+
//
864+
// We do not use `Path::file_stem` or `Path::extension` here,
865+
// because some generated files may have multiple extensions e.g.
866+
// `std-<hash>.dll.lib` on Windows. The aforementioned methods only
867+
// split the file name by the last extension (`.lib`) while we need
868+
// to split by all extensions (`.dll.lib`).
869+
let filename = filename.file_name().unwrap().to_str().unwrap();
870+
let mut parts = filename.splitn(2, '.');
871+
let file_stem = parts.next().unwrap().to_owned();
872+
let extension = parts.next().unwrap().to_owned();
873+
874+
toplevel.push((file_stem, extension));
867875
}
868876
}
869877

src/ci/docker/asmjs/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ ENV TARGETS=asmjs-unknown-emscripten
3131

3232
ENV RUST_CONFIGURE_ARGS --target=$TARGETS
3333

34-
ENV SCRIPT python2.7 ../x.py test --target $TARGETS src/test/run-pass
34+
ENV SCRIPT python2.7 ../x.py test --target $TARGETS

src/libcore/hash/mod.rs

+24-4
Original file line numberDiff line numberDiff line change
@@ -665,16 +665,36 @@ mod impls {
665665
}
666666

667667
#[stable(feature = "rust1", since = "1.0.0")]
668-
impl<T> Hash for *const T {
668+
impl<T: ?Sized> Hash for *const T {
669669
fn hash<H: Hasher>(&self, state: &mut H) {
670-
state.write_usize(*self as usize)
670+
if mem::size_of::<Self>() == mem::size_of::<usize>() {
671+
// Thin pointer
672+
state.write_usize(*self as *const () as usize);
673+
} else {
674+
// Fat pointer
675+
let (a, b) = unsafe {
676+
*(self as *const Self as *const (usize, usize))
677+
};
678+
state.write_usize(a);
679+
state.write_usize(b);
680+
}
671681
}
672682
}
673683

674684
#[stable(feature = "rust1", since = "1.0.0")]
675-
impl<T> Hash for *mut T {
685+
impl<T: ?Sized> Hash for *mut T {
676686
fn hash<H: Hasher>(&self, state: &mut H) {
677-
state.write_usize(*self as usize)
687+
if mem::size_of::<Self>() == mem::size_of::<usize>() {
688+
// Thin pointer
689+
state.write_usize(*self as *const () as usize);
690+
} else {
691+
// Fat pointer
692+
let (a, b) = unsafe {
693+
*(self as *const Self as *const (usize, usize))
694+
};
695+
state.write_usize(a);
696+
state.write_usize(b);
697+
}
678698
}
679699
}
680700
}

src/libcore/tests/hash/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ fn test_writer_hasher() {
7979

8080
let ptr = 5_usize as *mut i32;
8181
assert_eq!(hash(&ptr), 5);
82+
83+
let cs: &mut [u8] = &mut [1, 2, 3];
84+
let ptr = cs.as_ptr();
85+
let slice_ptr = cs as *const [u8];
86+
assert_eq!(hash(&slice_ptr), hash(&ptr) + cs.len() as u64);
87+
88+
let slice_ptr = cs as *mut [u8];
89+
assert_eq!(hash(&slice_ptr), hash(&ptr) + cs.len() as u64);
8290
}
8391

8492
struct Custom { hash: u64 }

src/librustc_back/target/sparcv9_sun_solaris.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub fn target() -> TargetResult {
1717
// llvm calls this "v9"
1818
base.cpu = "v9".to_string();
1919
base.max_atomic_width = Some(64);
20+
base.exe_allocation_crate = None;
2021

2122
Ok(Target {
2223
llvm_target: "sparcv9-sun-solaris".to_string(),

src/librustc_borrowck/borrowck/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
744744
let mut err = self.cannot_reassign_immutable(span,
745745
&self.loan_path_to_string(lp),
746746
Origin::Ast);
747-
err.span_label(span, "re-assignment of immutable variable");
747+
err.span_label(span, "cannot assign twice to immutable variable");
748748
if span != assign.span {
749749
err.span_label(assign.span, format!("first assignment to `{}`",
750750
self.loan_path_to_string(lp)));

src/librustc_mir/borrow_check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx>
11611161
self.tcx.cannot_reassign_immutable(span,
11621162
&self.describe_lvalue(lvalue),
11631163
Origin::Mir)
1164-
.span_label(span, "re-assignment of immutable variable")
1164+
.span_label(span, "cannot assign twice to immutable variable")
11651165
.span_label(assigned_span, format!("first assignment to `{}`",
11661166
self.describe_lvalue(lvalue)))
11671167
.emit();

src/librustc_mir/util/borrowck_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ pub trait BorrowckErrors {
232232
-> DiagnosticBuilder
233233
{
234234
struct_span_err!(self, span, E0384,
235-
"re-assignment of immutable variable `{}`{OGN}",
235+
"cannot assign twice to immutable variable `{}`{OGN}",
236236
desc, OGN=o)
237237
}
238238

src/librustdoc/html/static/rustdoc.css

+3-2
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,11 @@ nav.sub {
171171

172172
.sidebar {
173173
width: 200px;
174-
position: absolute;
174+
position: fixed;
175175
left: 0;
176176
top: 0;
177-
min-height: 100%;
177+
height: 100vh;
178+
overflow: auto;
178179
}
179180

180181
.sidebar .current {

src/libstd/process.rs

+19
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,25 @@ pub fn abort() -> ! {
13101310
unsafe { ::sys::abort_internal() };
13111311
}
13121312

1313+
/// Returns the OS-assigned process identifier associated with this process.
1314+
///
1315+
/// # Examples
1316+
///
1317+
/// Basic usage:
1318+
///
1319+
/// ```no_run
1320+
/// #![feature(getpid)]
1321+
/// use std::process;
1322+
///
1323+
/// println!("My pid is {}", process::id());
1324+
/// ```
1325+
///
1326+
///
1327+
#[unstable(feature = "getpid", issue = "44971", reason = "recently added")]
1328+
pub fn id() -> u32 {
1329+
::sys::os::getpid()
1330+
}
1331+
13131332
#[cfg(all(test, not(target_os = "emscripten")))]
13141333
mod tests {
13151334
use io::prelude::*;

src/libstd/sys/redox/os.rs

+4
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,7 @@ pub fn exit(code: i32) -> ! {
209209
let _ = syscall::exit(code as usize);
210210
unreachable!();
211211
}
212+
213+
pub fn getpid() -> u32 {
214+
syscall::getpid().unwrap() as u32
215+
}

src/libstd/sys/unix/os.rs

+4
Original file line numberDiff line numberDiff line change
@@ -511,3 +511,7 @@ pub fn home_dir() -> Option<PathBuf> {
511511
pub fn exit(code: i32) -> ! {
512512
unsafe { libc::exit(code as c_int) }
513513
}
514+
515+
pub fn getpid() -> u32 {
516+
unsafe { libc::getpid() as u32 }
517+
}

src/libstd/sys/windows/os.rs

+4
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,10 @@ pub fn exit(code: i32) -> ! {
318318
unsafe { c::ExitProcess(code as c::UINT) }
319319
}
320320

321+
pub fn getpid() -> u32 {
322+
unsafe { c::GetCurrentProcessId() as u32 }
323+
}
324+
321325
#[cfg(test)]
322326
mod tests {
323327
use io::Error;

src/test/compile-fail/asm-out-assign-imm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ pub fn main() {
2727
foo(x);
2828
unsafe {
2929
asm!("mov $1, $0" : "=r"(x) : "r"(5));
30-
//~^ ERROR re-assignment of immutable variable `x`
31-
//~| NOTE re-assignment of immutable
30+
//~^ ERROR cannot assign twice to immutable variable `x`
31+
//~| NOTE cannot assign twice to immutable
3232
}
3333
foo(x);
3434
}

src/test/compile-fail/assign-imm-local-twice.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ fn test() {
1212
let v: isize;
1313
v = 1; //~ NOTE first assignment
1414
println!("v={}", v);
15-
v = 2; //~ ERROR re-assignment of immutable variable
16-
//~| NOTE re-assignment of immutable
15+
v = 2; //~ ERROR cannot assign twice to immutable variable
16+
//~| NOTE cannot assign twice to immutable
1717
println!("v={}", v);
1818
}
1919

src/test/compile-fail/borrowck/borrowck-match-binding-is-assignment.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,39 +26,39 @@ struct S {
2626
pub fn main() {
2727
match 1 {
2828
x => {
29-
x += 1; //[ast]~ ERROR re-assignment of immutable variable `x`
29+
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
3030
//[mir]~^ ERROR (Mir) [E0384]
3131
//[mir]~| ERROR (Ast) [E0384]
3232
}
3333
}
3434

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

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

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

5959
match [1,2,3] {
6060
[x,_,_] => {
61-
x += 1; //[ast]~ ERROR re-assignment of immutable variable `x`
61+
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
6262
//[mir]~^ ERROR (Mir) [E0384]
6363
//[mir]~| ERROR (Ast) [E0384]
6464
}

src/test/compile-fail/liveness-assign-imm-local-in-loop.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
fn test() {
1212
let v: isize;
1313
loop {
14-
v = 1; //~ ERROR re-assignment of immutable variable
15-
//~^ NOTE re-assignment of immutable variable
14+
v = 1; //~ ERROR cannot assign twice to immutable variable
15+
//~^ NOTE cannot assign twice to immutable variable
1616
v.clone(); // just to prevent liveness warnings
1717
}
1818
}

src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
fn test() {
1212
let v: isize;
1313
v = 2; //~ NOTE first assignment
14-
v += 1; //~ ERROR re-assignment of immutable variable
15-
//~| NOTE re-assignment of immutable
14+
v += 1; //~ ERROR cannot assign twice to immutable variable
15+
//~| NOTE cannot assign twice to immutable
1616
v.clone();
1717
}
1818

src/test/compile-fail/liveness-assign-imm-local-with-init.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
fn test() {
1212
let v: isize = 1; //~ NOTE first assignment
1313
v.clone();
14-
v = 2; //~ ERROR re-assignment of immutable variable
15-
//~| NOTE re-assignment of immutable
14+
v = 2; //~ ERROR cannot assign twice to immutable variable
15+
//~| NOTE cannot assign twice to immutable
1616
v.clone();
1717
}
1818

src/test/compile-fail/mut-pattern-internal-mutability.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ fn main() {
1515
let foo = &mut 1;
1616

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

2222
// explicitly mut-ify internals
2323
let &mut mut x = foo;

0 commit comments

Comments
 (0)