Skip to content

Commit 377d752

Browse files
committed
auto merge of #19250 : kmcallister/rust/atomicoption, r=alexcrichton
Fixes #19247.
2 parents 4334d3c + 26c9343 commit 377d752

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

src/libsync/atomic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696

9797
use alloc::boxed::Box;
9898
use core::mem;
99-
use core::prelude::{Drop, None, Option, Some};
99+
use core::prelude::{Send, Drop, None, Option, Some};
100100

101101
pub use core::atomic::{AtomicBool, AtomicInt, AtomicUint, AtomicPtr};
102102
pub use core::atomic::{Ordering, Relaxed, Release, Acquire, AcqRel, SeqCst};
@@ -114,7 +114,7 @@ pub struct AtomicOption<T> {
114114
p: AtomicUint,
115115
}
116116

117-
impl<T> AtomicOption<T> {
117+
impl<T: Send> AtomicOption<T> {
118118
/// Create a new `AtomicOption`
119119
pub fn new(p: Box<T>) -> AtomicOption<T> {
120120
unsafe { AtomicOption { p: AtomicUint::new(mem::transmute(p)) } }
@@ -170,7 +170,7 @@ impl<T> AtomicOption<T> {
170170
}
171171

172172
#[unsafe_destructor]
173-
impl<T> Drop for AtomicOption<T> {
173+
impl<T: Send> Drop for AtomicOption<T> {
174174
fn drop(&mut self) {
175175
let _ = self.take(SeqCst);
176176
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2014 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::sync::atomic::AtomicOption;
12+
13+
fn main() {
14+
let x = 0u;
15+
AtomicOption::new(box &x); //~ ERROR `x` does not live long enough
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2014 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::kinds::marker;
12+
use std::sync::atomic::AtomicOption;
13+
14+
fn main() {
15+
AtomicOption::new(box marker::NoSend); //~ ERROR `core::kinds::Send` is not implemented
16+
}

0 commit comments

Comments
 (0)