Skip to content

Commit aa415d9

Browse files
committed
---
yaml --- r: 162298 b: refs/heads/auto c: a16f60b h: refs/heads/master v: v3
1 parent 8b53f83 commit aa415d9

File tree

4 files changed

+67
-4
lines changed

4 files changed

+67
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 096a28607fb80c91e6e2ca64d9ef44c4e550e96c
13+
refs/heads/auto: a16f60b1173fae1b971b41780288e2dbe005569d
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/middle/traits/select.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
924924
Some(ty::BoundCopy) => {
925925
debug!("obligation self ty is {}",
926926
obligation.self_ty().repr(self.tcx()));
927-
try!(self.assemble_candidates_from_impls(obligation, &mut candidates));
927+
928+
// If the user has asked for the older, compatibility
929+
// behavior, ignore user-defined impls here. This will
930+
// go away by the time 1.0 is released.
931+
if !self.tcx().sess.features.borrow().opt_out_copy {
932+
try!(self.assemble_candidates_from_impls(obligation, &mut candidates));
933+
}
934+
928935
try!(self.assemble_builtin_bound_candidates(ty::BoundCopy,
929936
stack,
930937
&mut candidates));
@@ -1533,8 +1540,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
15331540
}
15341541

15351542
ty::BoundCopy => {
1536-
// This is an Opt-In Built-In Trait.
1537-
return Ok(ParameterBuiltin)
1543+
// This is an Opt-In Built-In Trait. So, unless
1544+
// the user is asking for the old behavior, we
1545+
// don't supply any form of builtin impl.
1546+
if !this.tcx().sess.features.borrow().opt_out_copy {
1547+
return Ok(ParameterBuiltin)
1548+
}
15381549
}
15391550

15401551
ty::BoundSync => {

branches/auto/src/libsyntax/feature_gate.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
7575
// to bootstrap fix for #5723.
7676
("issue_5723_bootstrap", Accepted),
7777

78+
// A way to temporary opt out of opt in copy. This will *never* be accepted.
79+
("opt_out_copy", Active),
80+
7881
// These are used to test this portion of the compiler, they don't actually
7982
// mean anything
8083
("test_accepted_feature", Accepted),
@@ -101,6 +104,7 @@ pub struct Features {
101104
pub import_shadowing: bool,
102105
pub visible_private_types: bool,
103106
pub quote: bool,
107+
pub opt_out_copy: bool,
104108
}
105109

106110
impl Copy for Features {}
@@ -114,6 +118,7 @@ impl Features {
114118
import_shadowing: false,
115119
visible_private_types: false,
116120
quote: false,
121+
opt_out_copy: false,
117122
}
118123
}
119124
}
@@ -441,6 +446,7 @@ pub fn check_crate(span_handler: &SpanHandler, krate: &ast::Crate) -> (Features,
441446
import_shadowing: cx.has_feature("import_shadowing"),
442447
visible_private_types: cx.has_feature("visible_private_types"),
443448
quote: cx.has_feature("quote"),
449+
opt_out_copy: cx.has_feature("opt_out_copy"),
444450
},
445451
unknown_features)
446452
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
#![feature(opt_out_copy)]
12+
13+
// Test the opt-out-copy feature guard. This is the same as the
14+
// "opt-in-copy.rs" test from compile-fail, except that it is using
15+
// the feature guard, and hence the structureds in this file are
16+
// implicitly copyable, and hence we get no errors. This test can be
17+
// safely removed once the opt-out-copy "feature" is rejected.
18+
19+
struct CantCopyThis;
20+
21+
struct IWantToCopyThis {
22+
but_i_cant: CantCopyThis,
23+
}
24+
25+
impl Copy for IWantToCopyThis {}
26+
27+
enum CantCopyThisEither {
28+
A,
29+
B,
30+
}
31+
32+
enum IWantToCopyThisToo {
33+
ButICant(CantCopyThisEither),
34+
}
35+
36+
impl Copy for IWantToCopyThisToo {}
37+
38+
fn is_copy<T:Copy>() { }
39+
40+
fn main() {
41+
is_copy::<CantCopyThis>();
42+
is_copy::<CantCopyThisEither>();
43+
is_copy::<IWantToCopyThis>();
44+
is_copy::<IWantToCopyThisToo>();
45+
}
46+

0 commit comments

Comments
 (0)