Skip to content

Do not permit type parameters on builtin bounds. #21549

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

Closed
wants to merge 1 commit into from
Closed

Do not permit type parameters on builtin bounds. #21549

wants to merge 1 commit into from

Conversation

ahmedcharles
Copy link
Contributor

Fixes #20302.

r? @flaper87

// except according to those terms.

fn foo<T:Copy<U>, U>(x: T) {
//~^ ERROR: wrong number of type arguments: expected 0 found 1
Copy link
Contributor

Choose a reason for hiding this comment

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

is that span correct? shouldn't it be on the Copy or just on the ?

Copy link
Contributor

Choose a reason for hiding this comment

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

The ERROR match doesn't check on span positions. The ^ means the line above (L12) should raise this error. You can just remove the spaces in this ERROR line and it'll just work.

Copy link
Contributor

Choose a reason for hiding this comment

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

i don't know how i misread that :/

@flaper87
Copy link
Contributor

Other than that tiny nit about the error message, this looks good to me. @nikomatsakis thoughts on the error message?

@flaper87
Copy link
Contributor

Also, great work and thanks for the patch. 🍰

// option. This file may not be copied, modified, or distributed
// except according to those terms.

fn foo<T:Copy<U>, U>(x: T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You may also want some other tests for things like:

trait Trait: Copy<Send> {}

struct MyStruct<T: Copy<T>>;

@ahmedcharles
Copy link
Contributor Author

Ok, changed the message and added the tests.

if parameters.is_empty() {
continue; // success
}
span_fatal!(tcx.sess, b.trait_ref.path.span, E0316,
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be span_err, not span_fatal

Copy link
Contributor

Choose a reason for hiding this comment

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

mmh, do you think we should make the other span_fatal! errors too? We currently consider this kind of errors as fatal errors for other types.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ahmedcharles when changing this to span_error you should be able to merge the tests in a single test file.

Copy link
Contributor

Choose a reason for hiding this comment

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

In general, every span_fatal is a bug imo, though sometimes there are good reasons. In this particular case, I think those other errors are holdovers and could be made span_err with some effort. (span_err can be trickier because you have to have some kind of intelligent fallback behavior...)

Copy link
Contributor

Choose a reason for hiding this comment

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

I fully agree with you. @ahmedcharles if you want to take a stab and make the other span_fatal! errors, it'd be great. Otherwise, I'll do it in a separate patch. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't mind changing them, though I'd rather do it in a separate patch.

@nikomatsakis
Copy link
Contributor

Sorry for the delay! I forgot about this PR since I'm accustomed to just skimming what's assigned to me. :( Assigning to myself.

@nikomatsakis
Copy link
Contributor

@ahmedcharles ping, this looks almost ready to go, any chance you can address the various nits?

@ahmedcharles
Copy link
Contributor Author

I've been busy this week and haven't had time to figure out the issues I've had with the tests that were suggested, some of them seem to produce multiple errors, instead of just the one I added. I need some more time to investigate.

@flaper87
Copy link
Contributor

flaper87 commented Feb 2, 2015

@ahmedcharles no worries at all. If you feel you won't have time, we can take the patch over and add the tests ourselves in a separate commit.

Also, I wonder if you read my last comment. I explained there what the issues with the tests you tried were. Let me know!

@pnkfelix
Copy link
Member

@ahmedcharles hey there, do you think you'll have time to look at this pull request again?

If not, one of us can happily take over the patch for you; just let us know so we don't duplicate effort.

(I assume if we don't hear back, then we'll just take the patch over.)

@ahmedcharles
Copy link
Contributor Author

I'll either have it fixed today or pass it off.

@ahmedcharles
Copy link
Contributor Author

I'm not sure how to get the tests passing, but the current diff builds and mostly works as expected.

@flaper87
Copy link
Contributor

I spoke with @ahmedcharles on IRC, I'll take this over and fix the tests preserving the existing commits.

@flaper87
Copy link
Contributor

superseded by #22680

@flaper87 flaper87 closed this Feb 22, 2015
@ahmedcharles ahmedcharles deleted the builtin-bound-type-parameters branch April 17, 2015 21:21
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.

We permit type parameters and so forth on builtin bounds
5 participants