libsyntax: Remove "copy" pattern bindings from the language

This commit is contained in:
Patrick Walton 2013-06-10 19:42:28 -07:00 committed by Corey Richardson
parent 8cd40f9032
commit 3fcd4dca30
3 changed files with 11 additions and 6 deletions

View File

@ -63,6 +63,7 @@ pub enum ObsoleteSyntax {
ObsoleteNamedExternModule,
ObsoleteMultipleLocalDecl,
ObsoleteMutWithMultipleBindings,
ObsoletePatternCopyKeyword,
}
impl to_bytes::IterBytes for ObsoleteSyntax {
@ -229,6 +230,10 @@ impl Parser {
"use multiple local declarations instead of e.g. `let mut \
(x, y) = ...`."
),
ObsoletePatternCopyKeyword => (
"`copy` in patterns",
"`copy` in patterns no longer has any effect"
),
};
self.report(sp, kind, kind_str, desc);

View File

@ -84,6 +84,7 @@ use parse::obsolete::{ObsoletePurity, ObsoleteStaticMethod};
use parse::obsolete::{ObsoleteConstItem, ObsoleteFixedLengthVectorType};
use parse::obsolete::{ObsoleteNamedExternModule, ObsoleteMultipleLocalDecl};
use parse::obsolete::{ObsoleteMutWithMultipleBindings};
use parse::obsolete::{ObsoletePatternCopyKeyword};
use parse::token::{can_begin_expr, get_ident_interner, ident_to_str, is_ident};
use parse::token::{is_ident_or_path};
use parse::token::{is_plain_ident, INTERPOLATED, keywords, special_idents};
@ -2445,8 +2446,7 @@ impl Parser {
pat = self.parse_pat_ident(bind_by_ref(mutbl));
} else if self.eat_keyword(keywords::Copy) {
// parse copy pat
self.warn("copy keyword in patterns no longer has any effect, \
remove it");
self.obsolete(*self.span, ObsoletePatternCopyKeyword);
pat = self.parse_pat_ident(bind_infer);
} else {
let can_be_enum_or_struct;

View File

@ -10,11 +10,11 @@
extern mod extra;
fn o<T: Owned>(_: &T) {}
fn c<T: Const>(_: &T) {}
fn o<T: Send>(_: &T) {}
fn c<T: Freeze>(_: &T) {}
fn main() {
let x = extra::rc::rc_mut_from_owned(0);
o(&x); //~ ERROR instantiating a type parameter with an incompatible type `extra::rc::RcMut<int>`, which does not fulfill `Owned`
c(&x); //~ ERROR instantiating a type parameter with an incompatible type `extra::rc::RcMut<int>`, which does not fulfill `Const`
o(&x); //~ ERROR instantiating a type parameter with an incompatible type `extra::rc::RcMut<int>`, which does not fulfill `Send`
c(&x); //~ ERROR instantiating a type parameter with an incompatible type `extra::rc::RcMut<int>`, which does not fulfill `Freeze`
}