Skip to content

Commit 5772401

Browse files
committed
auto merge of #11111 : alexcrichton/rust/issue-11039, r=brson
None of these primitives should be Freeze because sharing them in an Arc is a very bad idea. Closes #11039
2 parents 1b4bbc8 + 67c0222 commit 5772401

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/libstd/comm/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ impl<T: Send> Consumer<T>{
292292

293293
/// The receiving-half of Rust's channel type. This half can only be owned by
294294
/// one task
295+
#[no_freeze] // can't share ports in an arc
295296
pub struct Port<T> {
296297
priv queue: Consumer<T>,
297298
}
@@ -305,12 +306,15 @@ pub struct PortIterator<'a, T> {
305306

306307
/// The sending-half of Rust's channel type. This half can only be owned by one
307308
/// task
309+
#[no_freeze] // can't share chans in an arc
308310
pub struct Chan<T> {
309311
priv queue: spsc::Producer<T, Packet>,
310312
}
311313

312314
/// The sending-half of Rust's channel type. This half can be shared among many
313315
/// tasks by creating copies of itself through the `clone` method.
316+
#[no_freeze] // technically this implementation is shareable, but it shouldn't
317+
// be required to be shareable in an arc
314318
pub struct SharedChan<T> {
315319
priv queue: mpsc::Producer<T, Packet>,
316320
}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2013 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+
fn test<T: Freeze>() {}
12+
13+
fn main() {
14+
test::<Chan<int>>(); //~ ERROR: does not fulfill `Freeze`
15+
test::<Port<int>>(); //~ ERROR: does not fulfill `Freeze`
16+
test::<SharedChan<int>>(); //~ ERROR: does not fulfill `Freeze`
17+
}

0 commit comments

Comments
 (0)