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 duplicate name bindings in the same parameter or type #17880

Merged

Conversation

pcwalton
Copy link
Contributor

@pcwalton pcwalton commented Oct 9, 2014

parameter list.

This breaks code like:

fn f(a: int, a: int) { ... }
fn g<T,T>(a: T) { ... }

Change this code to not use the same name for a parameter. For example:

fn f(a: int, b: int) { ... }
fn g<T,U>(a: T) { ... }

Code like this is not affected, since _ is not an identifier:

fn f(_: int, _: int) { ... } // OK

Closes #17568.

r? @alexcrichton
[breaking-change]

parameter list.

This breaks code like:

    fn f(a: int, a: int) { ... }
    fn g<T,T>(a: T) { ... }

Change this code to not use the same name for a parameter. For example:

    fn f(a: int, b: int) { ... }
    fn g<T,U>(a: T) { ... }

Code like this is *not* affected, since `_` is not an identifier:

    fn f(_: int, _: int) { ... } // OK

Closes rust-lang#17568.

[breaking-change]
for (index, type_parameter) in generics.ty_params.iter().enumerate() {
let ident = type_parameter.ident;
debug!("with_type_parameter_rib: {} {}", node_id,
type_parameter.id);

if seen_bindings.contains(&ident) {
Copy link
Member

Choose a reason for hiding this comment

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

This could just be if !seen_bindings.insert(ident) { ... }

bors added a commit that referenced this pull request Oct 9, 2014
…list, r=alexcrichton

parameter list.

This breaks code like:

    fn f(a: int, a: int) { ... }
    fn g<T,T>(a: T) { ... }

Change this code to not use the same name for a parameter. For example:

    fn f(a: int, b: int) { ... }
    fn g<T,U>(a: T) { ... }

Code like this is *not* affected, since `_` is not an identifier:

    fn f(_: int, _: int) { ... } // OK

Closes #17568.

r? @alexcrichton 
[breaking-change]
@bors bors closed this Oct 9, 2014
@bors bors merged commit 1498814 into rust-lang:master Oct 9, 2014
lnicola pushed a commit to lnicola/rust that referenced this pull request Aug 13, 2024
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.

Multiple params in the same param list with the same name are accepted
3 participants