Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
librustc: Forbid duplicate name bindings in the same parameter or type
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. [breaking-change]
- Loading branch information
Showing
3 changed files
with
83 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
fn f(a: int, a: int) {} | ||
//~^ ERROR identifier `a` is bound more than once in this parameter list | ||
|
||
fn main() { | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
type Foo<T,T> = Option<T>; | ||
//~^ ERROR the name `T` is already used | ||
|
||
struct Bar<T,T>(T); | ||
//~^ ERROR the name `T` is already used | ||
|
||
struct Baz<T,T> { | ||
//~^ ERROR the name `T` is already used | ||
x: T, | ||
} | ||
|
||
enum Boo<T,T> { | ||
//~^ ERROR the name `T` is already used | ||
A(T), | ||
B, | ||
} | ||
|
||
fn quux<T,T>(x: T) {} | ||
//~^ ERROR the name `T` is already used | ||
|
||
trait Qux<T,T> {} | ||
//~^ ERROR the name `T` is already used | ||
|
||
impl<T,T> Qux<T,T> for Option<T> {} | ||
//~^ ERROR the name `T` is already used | ||
|
||
fn main() { | ||
} | ||
|
1498814
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from alexcrichton
at pcwalton@1498814
1498814
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging pcwalton/rust/duplicate-bindings-in-parameter-list = 1498814 into auto
1498814
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pcwalton/rust/duplicate-bindings-in-parameter-list = 1498814 merged ok, testing candidate = df0f9fce
1498814
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No active merge of candidate 1498814 found, likely manual push to master
1498814
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging pcwalton/rust/duplicate-bindings-in-parameter-list = 1498814 into auto
1498814
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pcwalton/rust/duplicate-bindings-in-parameter-list = 1498814 merged ok, testing candidate = eb04229
1498814
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/1727
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/1724
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/1718
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/1724
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/1721
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/1720
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/1720
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/1724
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/1718
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/1717
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/1720
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/1378
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/1374
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/1378
success: http://buildbot.rust-lang.org/builders/auto-win-64-opt/builds/211
success: http://buildbot.rust-lang.org/builders/auto-win-64-nopt-t/builds/211
success: http://buildbot.rust-lang.org/builders/auto-win-64-nopt-c/builds/209
1498814
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = eb04229