-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustc: added a check for builtin bounds to vtable search
Closes #10751
- Loading branch information
Showing
3 changed files
with
77 additions
and
7 deletions.
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
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,47 @@ | ||
// 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. | ||
|
||
// Test that builtin bounds are checked when searching for an | ||
// implementation of a trait | ||
use std::cell::Cell; | ||
|
||
trait A {} | ||
trait B {} | ||
trait C {} | ||
trait D {} | ||
impl<T: 'static> A for T {} | ||
impl<T: Send> B for T {} | ||
impl<T: Copy> C for T {} | ||
impl<T: Share> D for T {} | ||
|
||
fn main() { | ||
let a = 3; | ||
let b = &a; | ||
let c = &b as &A; //~ ERROR instantiating a type parameter with an incompatible type `&int` | ||
let d: &A = &b; //~ ERROR instantiating a type parameter with an incompatible type `&int` | ||
let e = &b as &B; //~ ERROR instantiating a type parameter with an incompatible type `&int` | ||
let f: &B = &b; //~ ERROR instantiating a type parameter with an incompatible type `&int` | ||
let g = &~b as &C; //~ ERROR instantiating a type parameter with an incompatible type `~&int` | ||
let h: &C = &~b; //~ ERROR instantiating a type parameter with an incompatible type `~&int` | ||
let i = &Cell::new(b) as &D; | ||
//~^ ERROR instantiating a type parameter with an incompatible type `std::cell::Cell<&int>` | ||
let j: &D = &Cell::new(b); | ||
//~^ ERROR instantiating a type parameter with an incompatible type `std::cell::Cell<&int>` | ||
|
||
// These are all ok: int is 'static + Send + Copy + Share | ||
let k: &A = b; | ||
let l: &B = b; | ||
let m: &C = b; | ||
let n: &D = b; | ||
let o = b as &A; | ||
let p = b as &B; | ||
let q = b as &C; | ||
let r = b as &D; | ||
} |
d3f05f4
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 brson
at dmski@d3f05f4
d3f05f4
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 dmski/rust/trait-static-bound = d3f05f4 into auto
d3f05f4
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.
dmski/rust/trait-static-bound = d3f05f4 merged ok, testing candidate = e4b13cf
d3f05f4
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.
some tests failed:
failure: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/4510
exception: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/5319
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/5315
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/4408
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/4421
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/5417
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/4504
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/4512
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/5419
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/4504
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android/builds/4574
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/2304
exception: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/5414
exception: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/4511
exception: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/4524