Skip to content

Commit 0400d92

Browse files
committed
Auto merge of #32001 - Manishearth:rollup, r=Manishearth
- Successful merges: #31919, #31982, #31985, #31989, #31999 - Failed merges:
2 parents 339a409 + b515bb3 commit 0400d92

File tree

15 files changed

+163
-190
lines changed

15 files changed

+163
-190
lines changed

src/libcollectionstest/str.rs

+13
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,19 @@ generate_iterator_test! {
15081508
with str::rsplitn;
15091509
}
15101510

1511+
#[test]
1512+
fn different_str_pattern_forwarding_lifetimes() {
1513+
use std::str::pattern::Pattern;
1514+
1515+
fn foo<'a, P>(p: P) where for<'b> &'b P: Pattern<'a> {
1516+
for _ in 0..3 {
1517+
"asdf".find(&p);
1518+
}
1519+
}
1520+
1521+
foo::<&str>("x");
1522+
}
1523+
15111524
mod bench {
15121525
use test::{Bencher, black_box};
15131526

src/libcore/cell.rs

+6
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ impl<T:Copy> Cell<T> {
241241
#[stable(feature = "rust1", since = "1.0.0")]
242242
unsafe impl<T> Send for Cell<T> where T: Send {}
243243

244+
#[stable(feature = "rust1", since = "1.0.0")]
245+
impl<T> !Sync for Cell<T> {}
246+
244247
#[stable(feature = "rust1", since = "1.0.0")]
245248
impl<T:Copy> Clone for Cell<T> {
246249
#[inline]
@@ -461,6 +464,9 @@ impl<T: ?Sized> RefCell<T> {
461464
#[stable(feature = "rust1", since = "1.0.0")]
462465
unsafe impl<T: ?Sized> Send for RefCell<T> where T: Send {}
463466

467+
#[stable(feature = "rust1", since = "1.0.0")]
468+
impl<T: ?Sized> !Sync for RefCell<T> {}
469+
464470
#[stable(feature = "rust1", since = "1.0.0")]
465471
impl<T: Clone> Clone for RefCell<T> {
466472
#[inline]

src/libcore/slice.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,12 @@ impl<T> SliceExt for [T] {
285285

286286
#[inline]
287287
unsafe fn get_unchecked(&self, index: usize) -> &T {
288-
&*(self.repr().data.offset(index as isize))
288+
&*(self.as_ptr().offset(index as isize))
289289
}
290290

291291
#[inline]
292292
fn as_ptr(&self) -> *const T {
293-
self.repr().data
293+
self as *const [T] as *const T
294294
}
295295

296296
fn binary_search_by<F>(&self, mut f: F) -> Result<usize, usize> where
@@ -448,12 +448,12 @@ impl<T> SliceExt for [T] {
448448

449449
#[inline]
450450
unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T {
451-
&mut *(self.repr().data as *mut T).offset(index as isize)
451+
&mut *self.as_mut_ptr().offset(index as isize)
452452
}
453453

454454
#[inline]
455455
fn as_mut_ptr(&mut self) -> *mut T {
456-
self.repr().data as *mut T
456+
self as *mut [T] as *mut T
457457
}
458458

459459
#[inline]

src/libcore/str/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1894,7 +1894,7 @@ impl StrExt for str {
18941894

18951895
#[inline]
18961896
fn as_ptr(&self) -> *const u8 {
1897-
self.repr().data
1897+
self as *const str as *const u8
18981898
}
18991899

19001900
#[inline]

src/libcore/str/pattern.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ impl<'a, F> Pattern<'a> for F where F: FnMut(char) -> bool {
492492
/////////////////////////////////////////////////////////////////////////////
493493

494494
/// Delegates to the `&str` impl.
495-
impl<'a, 'b> Pattern<'a> for &'b &'b str {
495+
impl<'a, 'b, 'c> Pattern<'a> for &'c &'b str {
496496
pattern_methods!(StrSearcher<'a, 'b>, |&s| s, |s| s);
497497
}
498498

src/librustc_privacy/lib.rs

+15-70
Original file line numberDiff line numberDiff line change
@@ -1129,43 +1129,19 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
11291129

11301130
struct SanePrivacyVisitor<'a, 'tcx: 'a> {
11311131
tcx: &'a ty::ctxt<'tcx>,
1132-
in_block: bool,
11331132
}
11341133

11351134
impl<'a, 'tcx, 'v> Visitor<'v> for SanePrivacyVisitor<'a, 'tcx> {
1136-
/// We want to visit items in the context of their containing
1137-
/// module and so forth, so supply a crate for doing a deep walk.
1138-
fn visit_nested_item(&mut self, item: hir::ItemId) {
1139-
self.visit_item(self.tcx.map.expect_item(item.id))
1140-
}
1141-
11421135
fn visit_item(&mut self, item: &hir::Item) {
11431136
self.check_sane_privacy(item);
1144-
if self.in_block {
1145-
self.check_all_inherited(item);
1146-
}
1147-
1148-
let orig_in_block = self.in_block;
1149-
1150-
// Modules turn privacy back on, otherwise we inherit
1151-
self.in_block = if let hir::ItemMod(..) = item.node { false } else { orig_in_block };
1152-
11531137
intravisit::walk_item(self, item);
1154-
self.in_block = orig_in_block;
1155-
}
1156-
1157-
fn visit_block(&mut self, b: &'v hir::Block) {
1158-
let orig_in_block = replace(&mut self.in_block, true);
1159-
intravisit::walk_block(self, b);
1160-
self.in_block = orig_in_block;
11611138
}
11621139
}
11631140

11641141
impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
1165-
/// Validates all of the visibility qualifiers placed on the item given. This
1166-
/// ensures that there are no extraneous qualifiers that don't actually do
1167-
/// anything. In theory these qualifiers wouldn't parse, but that may happen
1168-
/// later on down the road...
1142+
/// Validate that items that shouldn't have visibility qualifiers don't have them.
1143+
/// Such qualifiers can be set by syntax extensions even if the parser doesn't allow them,
1144+
/// so we check things like variant fields too.
11691145
fn check_sane_privacy(&self, item: &hir::Item) {
11701146
let check_inherited = |sp, vis, note: &str| {
11711147
if vis != hir::Inherited {
@@ -1179,13 +1155,12 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
11791155
};
11801156

11811157
match item.node {
1182-
// implementations of traits don't need visibility qualifiers because
1183-
// that's controlled by having the trait in scope.
11841158
hir::ItemImpl(_, _, _, Some(..), _, ref impl_items) => {
11851159
check_inherited(item.span, item.vis,
11861160
"visibility qualifiers have no effect on trait impls");
11871161
for impl_item in impl_items {
1188-
check_inherited(impl_item.span, impl_item.vis, "");
1162+
check_inherited(impl_item.span, impl_item.vis,
1163+
"visibility qualifiers have no effect on trait impl items");
11891164
}
11901165
}
11911166
hir::ItemImpl(_, _, _, None, _, _) => {
@@ -1200,41 +1175,15 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
12001175
check_inherited(item.span, item.vis,
12011176
"place qualifiers on individual functions instead");
12021177
}
1203-
hir::ItemStruct(..) | hir::ItemEnum(..) | hir::ItemTrait(..) |
1204-
hir::ItemConst(..) | hir::ItemStatic(..) | hir::ItemFn(..) |
1205-
hir::ItemMod(..) | hir::ItemExternCrate(..) |
1206-
hir::ItemUse(..) | hir::ItemTy(..) => {}
1207-
}
1208-
}
1209-
1210-
/// When inside of something like a function or a method, visibility has no
1211-
/// control over anything so this forbids any mention of any visibility
1212-
fn check_all_inherited(&self, item: &hir::Item) {
1213-
let check_inherited = |sp, vis| {
1214-
if vis != hir::Inherited {
1215-
span_err!(self.tcx.sess, sp, E0447,
1216-
"visibility has no effect inside functions or block expressions");
1217-
}
1218-
};
1219-
1220-
check_inherited(item.span, item.vis);
1221-
match item.node {
1222-
hir::ItemImpl(_, _, _, _, _, ref impl_items) => {
1223-
for impl_item in impl_items {
1224-
check_inherited(impl_item.span, impl_item.vis);
1225-
}
1226-
}
1227-
hir::ItemForeignMod(ref fm) => {
1228-
for fi in &fm.items {
1229-
check_inherited(fi.span, fi.vis);
1230-
}
1231-
}
1232-
hir::ItemStruct(ref vdata, _) => {
1233-
for f in vdata.fields() {
1234-
check_inherited(f.span, f.node.kind.visibility());
1178+
hir::ItemEnum(ref def, _) => {
1179+
for variant in &def.variants {
1180+
for field in variant.node.data.fields() {
1181+
check_inherited(field.span, field.node.kind.visibility(),
1182+
"visibility qualifiers have no effect on variant fields");
1183+
}
12351184
}
12361185
}
1237-
hir::ItemDefaultImpl(..) | hir::ItemEnum(..) | hir::ItemTrait(..) |
1186+
hir::ItemStruct(..) | hir::ItemTrait(..) |
12381187
hir::ItemConst(..) | hir::ItemStatic(..) | hir::ItemFn(..) |
12391188
hir::ItemMod(..) | hir::ItemExternCrate(..) |
12401189
hir::ItemUse(..) | hir::ItemTy(..) => {}
@@ -1821,13 +1770,9 @@ pub fn check_crate(tcx: &ty::ctxt,
18211770

18221771
let krate = tcx.map.krate();
18231772

1824-
// Sanity check to make sure that all privacy usage and controls are
1825-
// reasonable.
1826-
let mut visitor = SanePrivacyVisitor {
1827-
tcx: tcx,
1828-
in_block: false,
1829-
};
1830-
intravisit::walk_crate(&mut visitor, krate);
1773+
// Sanity check to make sure that all privacy usage is reasonable.
1774+
let mut visitor = SanePrivacyVisitor { tcx: tcx };
1775+
krate.visit_all_items(&mut visitor);
18311776

18321777
// Figure out who everyone's parent is
18331778
let mut visitor = ParentVisitor {

src/libstd/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn main() {
2323

2424
let target = env::var("TARGET").unwrap();
2525
let host = env::var("HOST").unwrap();
26-
if !target.contains("apple") && !target.contains("msvc") {
26+
if !target.contains("apple") && !target.contains("msvc") && !target.contains("emscripten"){
2727
build_libbacktrace(&host, &target);
2828
}
2929

src/libstd/sync/mpsc/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ pub struct Receiver<T> {
299299
#[stable(feature = "rust1", since = "1.0.0")]
300300
unsafe impl<T: Send> Send for Receiver<T> { }
301301

302+
#[stable(feature = "rust1", since = "1.0.0")]
303+
impl<T> !Sync for Receiver<T> { }
304+
302305
/// An iterator over messages on a receiver, this iterator will block
303306
/// whenever `next` is called, waiting for a new message, and `None` will be
304307
/// returned when the corresponding channel has hung up.
@@ -327,6 +330,9 @@ pub struct Sender<T> {
327330
#[stable(feature = "rust1", since = "1.0.0")]
328331
unsafe impl<T: Send> Send for Sender<T> { }
329332

333+
#[stable(feature = "rust1", since = "1.0.0")]
334+
impl<T> !Sync for Sender<T> { }
335+
330336
/// The sending-half of Rust's synchronous channel type. This half can only be
331337
/// owned by one thread, but it can be cloned to send to other threads.
332338
#[stable(feature = "rust1", since = "1.0.0")]

src/test/compile-fail/comm-not-freeze-receiver.rs

-17
This file was deleted.

src/test/compile-fail/comm-not-freeze.rs

-17
This file was deleted.

src/test/compile-fail/no_share-rc.rs

-20
This file was deleted.

src/test/compile-fail/not-sync.rs

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use std::cell::{Cell, RefCell};
12+
use std::rc::{Rc, Weak};
13+
use std::sync::mpsc::{Receiver, Sender, SyncSender};
14+
15+
fn test<T: Sync>() {}
16+
17+
fn main() {
18+
test::<Cell<i32>>();
19+
//~^ ERROR marker::Sync` is not implemented for the type `core::cell::Cell<i32>`
20+
test::<RefCell<i32>>();
21+
//~^ ERROR marker::Sync` is not implemented for the type `core::cell::RefCell<i32>`
22+
23+
test::<Rc<i32>>();
24+
//~^ ERROR marker::Sync` is not implemented for the type `alloc::rc::Rc<i32>`
25+
test::<Weak<i32>>();
26+
//~^ ERROR marker::Sync` is not implemented for the type `alloc::rc::Weak<i32>`
27+
28+
test::<Receiver<i32>>();
29+
//~^ ERROR marker::Sync` is not implemented for the type `std::sync::mpsc::Receiver<i32>`
30+
test::<Sender<i32>>();
31+
//~^ ERROR marker::Sync` is not implemented for the type `std::sync::mpsc::Sender<i32>`
32+
test::<SyncSender<i32>>();
33+
//~^ ERROR marker::Sync` is not implemented for the type `std::sync::mpsc::SyncSender<i32>`
34+
}

0 commit comments

Comments
 (0)