Skip to content

Comment on shadowing with patterns #28893

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

Merged
merged 1 commit into from
Oct 8, 2015
Merged

Conversation

steveklabnik
Copy link
Member

Fixes #28687

@rust-highfive
Copy link
Contributor

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@@ -23,6 +23,31 @@ match x {

This prints `one`.

There’s one pitfall with patterns: like anything that introduces a new binding,
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it's worth having a section on shadowing? It is interesting to point out that Rust typically allows shadowing, and patterns are just a special case.

It's ALSO interesting (perhaps) to point out that you cannot shadow a constant or enum variant name.

Copy link
Member Author

Choose a reason for hiding this comment

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

We talk about it in the variable bindings section, but this is a question that people ask about with patterns specifically, so I felt it was worth re-calling it out.

@nikomatsakis
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Oct 8, 2015

📌 Commit bbc2056 has been approved by nikomatsakis

steveklabnik added a commit to steveklabnik/rust that referenced this pull request Oct 8, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this pull request Oct 8, 2015
bors added a commit that referenced this pull request Oct 8, 2015
@bors bors merged commit bbc2056 into rust-lang:master Oct 8, 2015
@steveklabnik steveklabnik deleted the gh28687 branch June 19, 2016 20:32
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.

4 participants