Skip to content

Commit 1a6aa4b

Browse files
committed
libsyntax: Remove "copy" pattern bindings from the language
1 parent b2816c7 commit 1a6aa4b

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/libsyntax/parse/obsolete.rs

+5
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ pub enum ObsoleteSyntax {
6666
ObsoleteNamedExternModule,
6767
ObsoleteMultipleLocalDecl,
6868
ObsoleteMutWithMultipleBindings,
69+
ObsoletePatternCopyKeyword,
6970
}
7071

7172
impl to_bytes::IterBytes for ObsoleteSyntax {
@@ -236,6 +237,10 @@ impl Parser {
236237
"use multiple local declarations instead of e.g. `let mut \
237238
(x, y) = ...`."
238239
),
240+
ObsoletePatternCopyKeyword => (
241+
"`copy` in patterns",
242+
"`copy` in patterns no longer has any effect"
243+
),
239244
};
240245

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

src/libsyntax/parse/parser.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ use parse::obsolete::{ObsoletePurity, ObsoleteStaticMethod};
8686
use parse::obsolete::{ObsoleteConstItem, ObsoleteFixedLengthVectorType};
8787
use parse::obsolete::{ObsoleteNamedExternModule, ObsoleteMultipleLocalDecl};
8888
use parse::obsolete::{ObsoleteMutWithMultipleBindings};
89+
use parse::obsolete::{ObsoletePatternCopyKeyword};
8990
use parse::token::{can_begin_expr, get_ident_interner, ident_to_str, is_ident};
9091
use parse::token::{is_ident_or_path};
9192
use parse::token::{is_plain_ident, INTERPOLATED, keywords, special_idents};
@@ -2435,8 +2436,7 @@ impl Parser {
24352436
pat = self.parse_pat_ident(bind_by_ref(mutbl));
24362437
} else if self.eat_keyword(keywords::Copy) {
24372438
// parse copy pat
2438-
self.warn("copy keyword in patterns no longer has any effect, \
2439-
remove it");
2439+
self.obsolete(*self.span, ObsoletePatternCopyKeyword);
24402440
pat = self.parse_pat_ident(bind_infer);
24412441
} else {
24422442
let can_be_enum_or_struct;

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

+4-4
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)