Skip to content

Commit d05b86c

Browse files
nikomatsakisalexcrichton
authored andcommitted
---
yaml --- r: 184183 b: refs/heads/beta c: 63f51ee h: refs/heads/master i: 184181: a739049 184179: 0cf1831 184175: fc0e7d7 v: v3
1 parent d2e0415 commit d05b86c

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
3232
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
34-
refs/heads/beta: d6e939a2df16338e9cf63ad19d1025a15069387c
34+
refs/heads/beta: 63f51ee90ccc1b7ab3a749ba7dbd4a3c76961c16
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
3737
refs/heads/tmp: c65fb1a81e5dc58cf171cc47f65de9e6e2119247

branches/beta/src/librustc/middle/traits/object_safety.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,11 @@ fn supertraits_reference_self<'tcx>(tcx: &ty::ctxt<'tcx>,
138138
match predicate {
139139
ty::Predicate::Trait(ref data) => {
140140
// In the case of a trait predicate, we can skip the "self" type.
141-
data.0.trait_ref.substs.types.get_slice(TypeSpace)
142-
.iter()
143-
.cloned()
144-
.any(is_self)
141+
Some(data.def_id()) != tcx.lang_items.phantom_fn() &&
142+
data.0.trait_ref.substs.types.get_slice(TypeSpace)
143+
.iter()
144+
.cloned()
145+
.any(is_self)
145146
}
146147
ty::Predicate::Projection(..) |
147148
ty::Predicate::TypeOutlives(..) |
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
// Check that `Self` appearing in a phantom fn does not make a trait not object safe.
12+
13+
#![feature(rustc_attrs)]
14+
15+
trait Baz : PhantomFn<Self> {
16+
}
17+
18+
fn make_bar<T:Bar<u32>>(t: &T) -> &Bar<u32> {
19+
t
20+
}
21+
22+
fn make_baz<T:Baz>(t: &T) -> &Baz {
23+
t
24+
}
25+
26+
#[rustc_error]
27+
fn main() { //~ ERROR compilation successful
28+
}

0 commit comments

Comments
 (0)