Skip to content
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

librustc: Forbid .. in range patterns. #17584

Merged
merged 1 commit into from
Oct 1, 2014

Conversation

pcwalton
Copy link
Contributor

This breaks code that looks like:

match foo {
    1..3 => { ... }
}

Instead, write:

match foo {
    1...3 => { ... }
}

Closes #17295.

r? @nick29581

@pcwalton pcwalton force-pushed the range-patterns-dotdotdot branch from 7a908d5 to 4bbb7a9 Compare September 27, 2014 04:17
kennytm added a commit to kennytm/qrcode-rust that referenced this pull request Sep 27, 2014
* Use ... instead of .. when matching a range, in preparation for
  rust-lang/rust#17584 (may not be complete).
* Use the new slicing syntax (a[], a[x..y]) if possible. (Currently
  String::as_slice() is blocked by rust-lang/rust#17502.)
* Change deprecated String::push_char() to String::push().
self.look_ahead(2, |t| {
*t != token::COMMA && *t != token::RBRACKET
}) {
let start = self.parse_expr_res(RestrictionNoBarOp);
// FIXME(#17295) remove the DOTDOT option (self.eat(&token::DOTDOTDOT)).
if self.token == token::DOTDOTDOT || self.token == token::DOTDOT {
if self.token == token::DOTDOTDOT {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be self.eat(&token::DOTDOTDOT)

@nrc
Copy link
Member

nrc commented Sep 28, 2014

I also have a patch for this, so this is a lot of wasted effort. I filed the bug and it was a follow-up to code I had written, so it would have been good to check I didn't have a patch in the works. I am working on the other follow ups btw.

r=me with the one comment fixed.

@pcwalton pcwalton force-pushed the range-patterns-dotdotdot branch from 4bbb7a9 to 11271a0 Compare September 29, 2014 15:20
This breaks code that looks like:

    match foo {
        1..3 => { ... }
    }

Instead, write:

    match foo {
        1...3 => { ... }
    }

Closes rust-lang#17295.

[breaking-change]
@pcwalton pcwalton force-pushed the range-patterns-dotdotdot branch from 11271a0 to 416144b Compare September 30, 2014 16:11
bors added a commit that referenced this pull request Oct 1, 2014
…29581

This breaks code that looks like:

    match foo {
        1..3 => { ... }
    }

Instead, write:

    match foo {
        1...3 => { ... }
    }

Closes #17295.

r? @nick29581
@bors bors closed this Oct 1, 2014
@bors bors merged commit 416144b into rust-lang:master Oct 1, 2014
drbawb added a commit to drbawb/uuid that referenced this pull request Oct 1, 2014
Ranges must use the `...` syntax as of [rust PR #17584](rust-lang/rust#17584)
@nodakai
Copy link
Contributor

nodakai commented Oct 3, 2014

@pcwalton I found a remaining two-dots range pattern in reference.md.

A range of values may be specified with ...

I think we can also supply a clarifying phrase "(three dots)" there.

lnicola pushed a commit to lnicola/rust that referenced this pull request Jul 28, 2024
Implement symbol interning infra

Will fix rust-lang/rust-analyzer#15590

My unsafe-fu is not the best but it does satisfy miri.

There is still some follow up work to do, notably a lot of places using strings instead of symbols/names, most notably the token tree.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Restrict range patterns to ...
4 participants