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

tests: add test for empty <> #32023

Merged
merged 1 commit into from Mar 9, 2016
Merged

Conversation

matklad
Copy link
Member

@matklad matklad commented Mar 3, 2016

Rust allows to specify an empty list of type and lifetime parameters, but there are no tests for it:

user@UNIT-326 [12:53:45] [~/projects/rust] [diamonds-and-rust]
-> % grep "<>" -R src/test
src/test/compile-fail/generic-type-params-name-repr.rs:    // And don't print <> at all when there's just defaults.
src/test/debuginfo/issue22656.rs:// when trying to handle a Vec<> or anything else that contains zero-sized

So let's add them! Besides it's such a wonderful opportunity to put a reference to Judas Priest band into the branch name ;)

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

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

let _ = S;
let _ = S::<>;
let _ = E::V;
let _ = E::<>::V;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is interesting because non-empty parameter lists are not currently allowed in this position.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, may be they should not be allowed, but this code compiles on stable, beta and nightly:

https://play.rust-lang.org/?gist=764dd4bd1d5c230a60e4&version=stable

@bluss
Copy link
Member

bluss commented Mar 3, 2016

let x: i32<>; compiles too. All of these seem unfortunate, unwanted?

@nikomatsakis
Copy link
Contributor

Personally I find it ok that i32<> works -- seems like any other type name that takes no parameters.

@nikomatsakis
Copy link
Contributor

cc @rust-lang/lang -- merge the test, or call these cases (or some of these cases) a bug? :)

@aturon
Copy link
Member

aturon commented Mar 7, 2016

@nikomatsakis I tend to agree -- I don't see value in being pedantic here, and it reminds me a bit of the unit struct/empty struct braces situation. I say we add the test.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Mar 8, 2016

📌 Commit 4844f01 has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Mar 9, 2016

⌛ Testing commit 4844f01 with merge e1704f7...

bors added a commit that referenced this pull request Mar 9, 2016
tests: add test for empty <>

Rust allows to specify an empty list of type and lifetime parameters, but there are no tests for it:

```
user@UNIT-326 [12:53:45] [~/projects/rust] [diamonds-and-rust]
-> % grep "<>" -R src/test
src/test/compile-fail/generic-type-params-name-repr.rs:    // And don't print <> at all when there's just defaults.
src/test/debuginfo/issue22656.rs:// when trying to handle a Vec<> or anything else that contains zero-sized
```

So let's add them! Besides it's such a wonderful opportunity to put a reference to Judas Priest band into the branch name ;)
@bors bors merged commit 4844f01 into rust-lang:master Mar 9, 2016
matklad added a commit to intellij-rust/intellij-rust that referenced this pull request Mar 9, 2016
@matklad matklad deleted the diamonds-and-rust branch July 9, 2019 12:34
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.

None yet

7 participants