Skip to content

Obsolete message for capture clauses. #5102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/libsyntax/parse/obsolete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub enum ObsoleteSyntax {
ObsoleteUnenforcedBound,
ObsoleteImplSyntax,
ObsoleteTraitBoundSeparator,
ObsoleteCaptureClause,
}

pub impl to_bytes::IterBytes for ObsoleteSyntax {
Expand Down Expand Up @@ -126,6 +127,10 @@ pub impl Parser {
"space-separated trait bounds",
"write `+` between trait bounds"
),
ObsoleteCaptureClause => (
"capture clause",
"referenced variables are now captured implicitly"
),
};

self.report(sp, kind, kind_str, desc);
Expand Down
8 changes: 6 additions & 2 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ use parse::obsolete::{ObsoleteMoveInit, ObsoleteBinaryMove};
use parse::obsolete::{ObsoleteStructCtor, ObsoleteWith};
use parse::obsolete::{ObsoleteSyntax, ObsoleteLowerCaseKindBounds};
use parse::obsolete::{ObsoleteUnsafeBlock, ObsoleteImplSyntax};
use parse::obsolete::{ObsoleteTraitBoundSeparator};
use parse::obsolete::{ObsoleteTraitBoundSeparator, ObsoleteCaptureClause};
use parse::prec::{as_prec, token_to_binop};
use parse::token::{can_begin_expr, is_ident, is_ident_or_path};
use parse::token::{is_plain_ident, INTERPOLATED, special_idents};
Expand Down Expand Up @@ -751,8 +751,12 @@ pub impl Parser {
fn parse_capture_item_or(parse_arg_fn: fn(Parser) -> arg_or_capture_item)
-> arg_or_capture_item
{
if self.eat_keyword(~"copy") {
if self.token_is_keyword(~"copy", *self.token) ||
self.token_is_word(~"move", *self.token) {

// XXX outdated syntax now that moves-based-on-type has gone in
self.obsolete(*self.span, ObsoleteCaptureClause);
self.bump(); // eat move/copy
self.parse_ident();
either::Right(())
} else {
Expand Down
10 changes: 10 additions & 0 deletions src/test/compile-fail/obsolete-syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,14 @@ fn obsolete_moves() {
//~^ ERROR obsolete syntax: binary move
}

fn obsolete_capture() {
let a = 5;
let b = ~"abc";

let x = |copy a| { };
//~^ ERROR obsolete syntax: capture clause
let y = |move b| { };
//~^ ERROR obsolete syntax: capture clause
}

fn main() { }
15 changes: 0 additions & 15 deletions src/test/run-pass/cap-clause-not-used.rs

This file was deleted.