Skip to content

Commit 3fcd4dc

Browse files
pcwaltonemberian
authored andcommitted
libsyntax: Remove "copy" pattern bindings from the language
1 parent 8cd40f9 commit 3fcd4dc

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/libsyntax/parse/obsolete.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ pub enum ObsoleteSyntax {
6363
ObsoleteNamedExternModule,
6464
ObsoleteMultipleLocalDecl,
6565
ObsoleteMutWithMultipleBindings,
66+
ObsoletePatternCopyKeyword,
6667
}
6768

6869
impl to_bytes::IterBytes for ObsoleteSyntax {
@@ -229,6 +230,10 @@ impl Parser {
229230
"use multiple local declarations instead of e.g. `let mut \
230231
(x, y) = ...`."
231232
),
233+
ObsoletePatternCopyKeyword => (
234+
"`copy` in patterns",
235+
"`copy` in patterns no longer has any effect"
236+
),
232237
};
233238

234239
self.report(sp, kind, kind_str, desc);

src/libsyntax/parse/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ use parse::obsolete::{ObsoletePurity, ObsoleteStaticMethod};
8484
use parse::obsolete::{ObsoleteConstItem, ObsoleteFixedLengthVectorType};
8585
use parse::obsolete::{ObsoleteNamedExternModule, ObsoleteMultipleLocalDecl};
8686
use parse::obsolete::{ObsoleteMutWithMultipleBindings};
87+
use parse::obsolete::{ObsoletePatternCopyKeyword};
8788
use parse::token::{can_begin_expr, get_ident_interner, ident_to_str, is_ident};
8889
use parse::token::{is_ident_or_path};
8990
use parse::token::{is_plain_ident, INTERPOLATED, keywords, special_idents};
@@ -2445,8 +2446,7 @@ impl Parser {
24452446
pat = self.parse_pat_ident(bind_by_ref(mutbl));
24462447
} else if self.eat_keyword(keywords::Copy) {
24472448
// parse copy pat
2448-
self.warn("copy keyword in patterns no longer has any effect, \
2449-
remove it");
2449+
self.obsolete(*self.span, ObsoletePatternCopyKeyword);
24502450
pat = self.parse_pat_ident(bind_infer);
24512451
} else {
24522452
let can_be_enum_or_struct;

src/test/compile-fail/rcmut-not-const-and-not-owned.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
extern mod extra;
1212

13-
fn o<T: Owned>(_: &T) {}
14-
fn c<T: Const>(_: &T) {}
13+
fn o<T: Send>(_: &T) {}
14+
fn c<T: Freeze>(_: &T) {}
1515

1616
fn main() {
1717
let x = extra::rc::rc_mut_from_owned(0);
18-
o(&x); //~ ERROR instantiating a type parameter with an incompatible type `extra::rc::RcMut<int>`, which does not fulfill `Owned`
19-
c(&x); //~ ERROR instantiating a type parameter with an incompatible type `extra::rc::RcMut<int>`, which does not fulfill `Const`
18+
o(&x); //~ ERROR instantiating a type parameter with an incompatible type `extra::rc::RcMut<int>`, which does not fulfill `Send`
19+
c(&x); //~ ERROR instantiating a type parameter with an incompatible type `extra::rc::RcMut<int>`, which does not fulfill `Freeze`
2020
}

0 commit comments

Comments
 (0)