Skip to content

Commit 6a55f4f

Browse files
committed
Auto merge of #32787 - Manishearth:rollup, r=Manishearth
Rollup of 11 pull requests - Successful merges: #32016, #32583, #32699, #32729, #32731, #32738, #32741, #32745, #32748, #32757, #32786 - Failed merges: #32773
2 parents a9f34c8 + 903b4c2 commit 6a55f4f

File tree

189 files changed

+1307
-800
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+1307
-800
lines changed

configure

-12
Original file line numberDiff line numberDiff line change
@@ -717,18 +717,6 @@ if [ -n "$CFG_ENABLE_DEBUG_JEMALLOC" ]; then putvar CFG_ENABLE_DEBUG_JEMALLOC; f
717717

718718
if [ -n "$CFG_ENABLE_ORBIT" ]; then putvar CFG_ENABLE_ORBIT; fi
719719

720-
# A magic value that allows the compiler to use unstable features
721-
# during the bootstrap even when doing so would normally be an error
722-
# because of feature staging or because the build turns on
723-
# warnings-as-errors and unstable features default to warnings. The
724-
# build has to match this key in an env var. Meant to be a mild
725-
# deterrent from users just turning on unstable features on the stable
726-
# channel.
727-
# Basing CFG_BOOTSTRAP_KEY on CFG_BOOTSTRAP_KEY lets it get picked up
728-
# during a Makefile reconfig.
729-
CFG_BOOTSTRAP_KEY="${CFG_BOOTSTRAP_KEY-`date +%H:%M:%S`}"
730-
putvar CFG_BOOTSTRAP_KEY
731-
732720
step_msg "looking for build programs"
733721

734722
probe_need CFG_CURLORWGET curl wget

mk/main.mk

+11
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ CFG_PRERELEASE_VERSION=.1
2424
# versions in the same place
2525
CFG_FILENAME_EXTRA=$(shell printf '%s' $(CFG_RELEASE)$(CFG_EXTRA_FILENAME) | $(CFG_HASH_COMMAND))
2626

27+
# A magic value that allows the compiler to use unstable features during the
28+
# bootstrap even when doing so would normally be an error because of feature
29+
# staging or because the build turns on warnings-as-errors and unstable features
30+
# default to warnings. The build has to match this key in an env var.
31+
#
32+
# This value is keyed off the release to ensure that all compilers for one
33+
# particular release have the same bootstrap key. Note that this is
34+
# intentionally not "secure" by any definition, this is largely just a deterrent
35+
# from users enabling unstable features on the stable compiler.
36+
CFG_BOOTSTRAP_KEY=$(CFG_FILENAME_EXTRA)
37+
2738
ifeq ($(CFG_RELEASE_CHANNEL),stable)
2839
# This is the normal semver version string, e.g. "0.12.0", "0.12.0-nightly"
2940
CFG_RELEASE=$(CFG_RELEASE_NUM)

src/bootstrap/build/check.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,18 @@ pub fn linkcheck(build: &Build, stage: u32, host: &str) {
1818
}
1919

2020
pub fn cargotest(build: &Build, stage: u32, host: &str) {
21+
2122
let ref compiler = Compiler::new(stage, host);
23+
24+
// Configure PATH to find the right rustc. NB. we have to use PATH
25+
// and not RUSTC because the Cargo test suite has tests that will
26+
// fail if rustc is not spelled `rustc`.
27+
let path = build.sysroot(compiler).join("bin");
28+
let old_path = ::std::env::var("PATH").expect("");
29+
let sep = if cfg!(windows) { ";" } else {":" };
30+
let ref newpath = format!("{}{}{}", path.display(), sep, old_path);
31+
2232
build.run(build.tool_cmd(compiler, "cargotest")
23-
.env("RUSTC", build.compiler_path(compiler))
24-
.env("RUSTDOC", build.rustdoc(compiler))
33+
.env("PATH", newpath)
2534
.arg(&build.cargo));
2635
}

src/bootstrap/build/step.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ impl<'a> Step<'a> {
319319
vec![self.librustc(self.compiler(stage))]
320320
}
321321
Source::ToolCargoTest { stage } => {
322-
vec![self.libstd(self.compiler(stage))]
322+
vec![self.libtest(self.compiler(stage))]
323323
}
324324

325325
Source::DistDocs { stage } => vec![self.doc(stage)],

src/build_helper/lib.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,16 @@ pub fn cc2ar(cc: &Path, target: &str) -> PathBuf {
4343
if target.contains("musl") || target.contains("msvc") {
4444
PathBuf::from("ar")
4545
} else {
46+
let parent = cc.parent().unwrap();
4647
let file = cc.file_name().unwrap().to_str().unwrap();
47-
cc.parent().unwrap().join(file.replace("gcc", "ar")
48-
.replace("cc", "ar")
49-
.replace("clang", "ar"))
48+
for suffix in &["gcc", "cc", "clang"] {
49+
if let Some(idx) = file.rfind(suffix) {
50+
let mut file = file[..idx].to_owned();
51+
file.push_str("ar");
52+
return parent.join(&file);
53+
}
54+
}
55+
parent.join(file)
5056
}
5157
}
5258

src/doc/book/closures.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -371,14 +371,13 @@ assert_eq!(6, answer);
371371
This gives us these long, related errors:
372372

373373
```text
374-
error: the trait `core::marker::Sized` is not implemented for the type
375-
`core::ops::Fn(i32) -> i32` [E0277]
374+
error: the trait bound `core::ops::Fn(i32) -> i32 : core::marker::Sized` is not satisfied [E0277]
376375
fn factory() -> (Fn(i32) -> i32) {
377376
^~~~~~~~~~~~~~~~
378377
note: `core::ops::Fn(i32) -> i32` does not have a constant size known at compile-time
379378
fn factory() -> (Fn(i32) -> i32) {
380379
^~~~~~~~~~~~~~~~
381-
error: the trait `core::marker::Sized` is not implemented for the type `core::ops::Fn(i32) -> i32` [E0277]
380+
error: the trait bound `core::ops::Fn(i32) -> i32 : core::marker::Sized` is not satisfied [E0277]
382381
let f = factory();
383382
^
384383
note: `core::ops::Fn(i32) -> i32` does not have a constant size known at compile-time

src/doc/book/concurrency.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ fn main() {
234234
This won't work, however, and will give us the error:
235235

236236
```text
237-
13:9: 13:22 error: the trait `core::marker::Send` is not
238-
implemented for the type `alloc::rc::Rc<collections::vec::Vec<i32>>`
237+
13:9: 13:22 error: the trait bound `alloc::rc::Rc<collections::vec::Vec<i32>> : core::marker::Send`
238+
is not satisfied
239239
...
240240
13:9: 13:22 note: `alloc::rc::Rc<collections::vec::Vec<i32>>`
241241
cannot be sent between threads safely

src/doc/book/traits.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ print_area(5);
154154
We get a compile-time error:
155155

156156
```text
157-
error: the trait `HasArea` is not implemented for the type `_` [E0277]
157+
error: the trait bound `_ : HasArea` is not satisfied [E0277]
158158
```
159159

160160
## Trait bounds on generic structs
@@ -496,7 +496,7 @@ impl FooBar for Baz {
496496
If we forget to implement `Foo`, Rust will tell us:
497497

498498
```text
499-
error: the trait `main::Foo` is not implemented for the type `main::Baz` [E0277]
499+
error: the trait bound `main::Baz : main::Foo` is not satisfied [E0277]
500500
```
501501

502502
# Deriving

src/doc/book/vectors.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ v[j];
5656
Indexing with a non-`usize` type gives an error that looks like this:
5757

5858
```text
59-
error: the trait `core::ops::Index<i32>` is not implemented for the type
60-
`collections::vec::Vec<_>` [E0277]
59+
error: the trait bound `collections::vec::Vec<_> : core::ops::Index<i32>`
60+
is not satisfied [E0277]
6161
v[j];
6262
^~~~
6363
note: the type `collections::vec::Vec<_>` cannot be indexed by `i32`

src/doc/nomicon/coercions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn main() {
6464
```
6565

6666
```text
67-
<anon>:10:5: 10:8 error: the trait `Trait` is not implemented for the type `&mut i32` [E0277]
67+
<anon>:10:5: 10:8 error: the trait bound `&mut i32 : Trait` is not satisfied [E0277]
6868
<anon>:10 foo(t);
6969
^~~
7070
```

src/liballoc/arc.rs

+21-24
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize;
124124
#[unsafe_no_drop_flag]
125125
#[stable(feature = "rust1", since = "1.0.0")]
126126
pub struct Arc<T: ?Sized> {
127-
// FIXME #12808: strange name to try to avoid interfering with
128-
// field accesses of the contained type via Deref
129-
_ptr: Shared<ArcInner<T>>,
127+
ptr: Shared<ArcInner<T>>,
130128
}
131129

132130
#[stable(feature = "rust1", since = "1.0.0")]
@@ -144,9 +142,7 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Arc<U>> for Arc<T> {}
144142
#[unsafe_no_drop_flag]
145143
#[stable(feature = "arc_weak", since = "1.4.0")]
146144
pub struct Weak<T: ?Sized> {
147-
// FIXME #12808: strange name to try to avoid interfering with
148-
// field accesses of the contained type via Deref
149-
_ptr: Shared<ArcInner<T>>,
145+
ptr: Shared<ArcInner<T>>,
150146
}
151147

152148
#[stable(feature = "arc_weak", since = "1.4.0")]
@@ -198,7 +194,7 @@ impl<T> Arc<T> {
198194
weak: atomic::AtomicUsize::new(1),
199195
data: data,
200196
};
201-
Arc { _ptr: unsafe { Shared::new(Box::into_raw(x)) } }
197+
Arc { ptr: unsafe { Shared::new(Box::into_raw(x)) } }
202198
}
203199

204200
/// Unwraps the contained value if the `Arc<T>` has exactly one strong reference.
@@ -230,11 +226,11 @@ impl<T> Arc<T> {
230226
atomic::fence(Acquire);
231227

232228
unsafe {
233-
let ptr = *this._ptr;
229+
let ptr = *this.ptr;
234230
let elem = ptr::read(&(*ptr).data);
235231

236232
// Make a weak pointer to clean up the implicit strong-weak reference
237-
let _weak = Weak { _ptr: this._ptr };
233+
let _weak = Weak { ptr: this.ptr };
238234
mem::forget(this);
239235

240236
Ok(elem)
@@ -263,6 +259,7 @@ impl<T: ?Sized> Arc<T> {
263259
loop {
264260
// check if the weak counter is currently "locked"; if so, spin.
265261
if cur == usize::MAX {
262+
cur = this.inner().weak.load(Relaxed);
266263
continue;
267264
}
268265

@@ -274,7 +271,7 @@ impl<T: ?Sized> Arc<T> {
274271
// synchronize with the write coming from `is_unique`, so that the
275272
// events prior to that write happen before this read.
276273
match this.inner().weak.compare_exchange_weak(cur, cur + 1, Acquire, Relaxed) {
277-
Ok(_) => return Weak { _ptr: this._ptr },
274+
Ok(_) => return Weak { ptr: this.ptr },
278275
Err(old) => cur = old,
279276
}
280277
}
@@ -303,13 +300,13 @@ impl<T: ?Sized> Arc<T> {
303300
// `ArcInner` structure itself is `Sync` because the inner data is
304301
// `Sync` as well, so we're ok loaning out an immutable pointer to these
305302
// contents.
306-
unsafe { &**self._ptr }
303+
unsafe { &**self.ptr }
307304
}
308305

309306
// Non-inlined part of `drop`.
310307
#[inline(never)]
311308
unsafe fn drop_slow(&mut self) {
312-
let ptr = *self._ptr;
309+
let ptr = *self.ptr;
313310

314311
// Destroy the data at this time, even though we may not free the box
315312
// allocation itself (there may still be weak pointers lying around).
@@ -367,7 +364,7 @@ impl<T: ?Sized> Clone for Arc<T> {
367364
}
368365
}
369366

370-
Arc { _ptr: self._ptr }
367+
Arc { ptr: self.ptr }
371368
}
372369
}
373370

@@ -435,15 +432,15 @@ impl<T: Clone> Arc<T> {
435432

436433
// Materialize our own implicit weak pointer, so that it can clean
437434
// up the ArcInner as needed.
438-
let weak = Weak { _ptr: this._ptr };
435+
let weak = Weak { ptr: this.ptr };
439436

440437
// mark the data itself as already deallocated
441438
unsafe {
442439
// there is no data race in the implicit write caused by `read`
443440
// here (due to zeroing) because data is no longer accessed by
444441
// other threads (due to there being no more strong refs at this
445442
// point).
446-
let mut swap = Arc::new(ptr::read(&(**weak._ptr).data));
443+
let mut swap = Arc::new(ptr::read(&(**weak.ptr).data));
447444
mem::swap(this, &mut swap);
448445
mem::forget(swap);
449446
}
@@ -456,7 +453,7 @@ impl<T: Clone> Arc<T> {
456453
// As with `get_mut()`, the unsafety is ok because our reference was
457454
// either unique to begin with, or became one upon cloning the contents.
458455
unsafe {
459-
let inner = &mut **this._ptr;
456+
let inner = &mut **this.ptr;
460457
&mut inner.data
461458
}
462459
}
@@ -488,7 +485,7 @@ impl<T: ?Sized> Arc<T> {
488485
// the Arc itself to be `mut`, so we're returning the only possible
489486
// reference to the inner data.
490487
unsafe {
491-
let inner = &mut **this._ptr;
488+
let inner = &mut **this.ptr;
492489
Some(&mut inner.data)
493490
}
494491
} else {
@@ -557,7 +554,7 @@ impl<T: ?Sized> Drop for Arc<T> {
557554
// This structure has #[unsafe_no_drop_flag], so this drop glue may run
558555
// more than once (but it is guaranteed to be zeroed after the first if
559556
// it's run more than once)
560-
let thin = *self._ptr as *const ();
557+
let thin = *self.ptr as *const ();
561558

562559
if thin as usize == mem::POST_DROP_USIZE {
563560
return;
@@ -638,7 +635,7 @@ impl<T: ?Sized> Weak<T> {
638635

639636
// Relaxed is valid for the same reason it is on Arc's Clone impl
640637
match inner.strong.compare_exchange_weak(n, n + 1, Relaxed, Relaxed) {
641-
Ok(_) => return Some(Arc { _ptr: self._ptr }),
638+
Ok(_) => return Some(Arc { ptr: self.ptr }),
642639
Err(old) => n = old,
643640
}
644641
}
@@ -647,7 +644,7 @@ impl<T: ?Sized> Weak<T> {
647644
#[inline]
648645
fn inner(&self) -> &ArcInner<T> {
649646
// See comments above for why this is "safe"
650-
unsafe { &**self._ptr }
647+
unsafe { &**self.ptr }
651648
}
652649
}
653650

@@ -681,7 +678,7 @@ impl<T: ?Sized> Clone for Weak<T> {
681678
}
682679
}
683680

684-
return Weak { _ptr: self._ptr };
681+
return Weak { ptr: self.ptr };
685682
}
686683
}
687684

@@ -713,7 +710,7 @@ impl<T: ?Sized> Drop for Weak<T> {
713710
/// } // implicit drop
714711
/// ```
715712
fn drop(&mut self) {
716-
let ptr = *self._ptr;
713+
let ptr = *self.ptr;
717714
let thin = ptr as *const ();
718715

719716
// see comments above for why this check is here
@@ -885,7 +882,7 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for Arc<T> {
885882
#[stable(feature = "rust1", since = "1.0.0")]
886883
impl<T: ?Sized> fmt::Pointer for Arc<T> {
887884
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
888-
fmt::Pointer::fmt(&*self._ptr, f)
885+
fmt::Pointer::fmt(&*self.ptr, f)
889886
}
890887
}
891888

@@ -930,7 +927,7 @@ impl<T> Weak<T> {
930927
issue = "30425")]
931928
pub fn new() -> Weak<T> {
932929
unsafe {
933-
Weak { _ptr: Shared::new(Box::into_raw(box ArcInner {
930+
Weak { ptr: Shared::new(Box::into_raw(box ArcInner {
934931
strong: atomic::AtomicUsize::new(0),
935932
weak: atomic::AtomicUsize::new(1),
936933
data: uninitialized(),

0 commit comments

Comments
 (0)