-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specialize kinds inference for
Unsafe<T>
This patch adds a special rule for `Unsafe<T>` and makes it `Share` regardless of whether T is `Share`. [breaking-change] Closes #13125
- Loading branch information
Showing
2 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// Verify that Unsafe is *always* share regardles `T` is share. | ||
|
||
// ignore-tidy-linelength | ||
|
||
use std::ty::Unsafe; | ||
use std::kinds::marker; | ||
|
||
struct MyShare<T> { | ||
u: Unsafe<T> | ||
} | ||
|
||
struct NoShare { | ||
m: marker::NoShare | ||
} | ||
|
||
fn test<T: Share>(s: T){ | ||
|
||
} | ||
|
||
fn main() { | ||
let us = Unsafe::new(MyShare{u: Unsafe::new(0)}); | ||
test(us); | ||
|
||
let uns = Unsafe::new(NoShare{m: marker::NoShare}); | ||
test(uns); | ||
|
||
let ms = MyShare{u: uns}; | ||
test(ms); | ||
|
||
let ns = NoShare{m: marker::NoShare}; | ||
test(ns); | ||
//~^ ERROR instantiating a type parameter with an incompatible type `NoShare`, which does not fulfill `Share` | ||
} |
5b4d54e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from nikomatsakis
at flaper87@5b4d54e
5b4d54e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging FlaPer87/rust/special-unsafe = 5b4d54e into auto
5b4d54e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FlaPer87/rust/special-unsafe = 5b4d54e merged ok, testing candidate = 7730310
5b4d54e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/5379
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/5375
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/4468
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/4481
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/5477
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/4565
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/4573
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/5479
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/4564
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/4570
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android/builds/4633
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/2364
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/5474
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/4569
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/4584
5b4d54e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = 7730310