Skip to content

Change default type parameters to match the behavior specified in the RFC #27761

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

Conversation

jroesch
Copy link
Member

@jroesch jroesch commented Aug 12, 2015

This addresses the issues raised by some members of the community about default priorities, and matches the behavior specified in the RFC.

You can also see the related internals discussion here

r? @nikomatsakis

.collect()
&TypeVariableValue::Bounded { .. } => Some(ty::TyVid { index: i as u32 }),
&TypeVariableValue::Known(v) => match v.sty {
ty::TyInfer(ty::FloatVar(_)) | ty::TyInfer(ty::IntVar(_)) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: the behavior of this fn merits a comment. Also, ty::TyInfer(_) seems more "forward compatible" to me (or else adding the other cases with a call to bug, since I think they are impossible)

@nikomatsakis
Copy link
Contributor

After some discussion over IRC, @jroesch and I agreed current code isn't quite right -- in particular, the reason that user defaults wind up being preferred over integral defaults is because unsolved_variables just happens to return them in that order, which is quite non-obvious. My suggestion is to split the unbound_tyvars set into multiple sets, one for user-defined defaults, one for integral defaults, and one for diverges defaults, and then apply them in that order, making the relative precedence very clear.

We must be sure to apply the user-defined defaults indiscriminantly (whether or not variable has since been bound) because otherwise conflicting defaults will go undetected.

@nikomatsakis
Copy link
Contributor

I also THINK that first loop could be simplified to something like this https://gist.github.com/nikomatsakis/a54823f42f8546436e7a, though naturally we'd want to use distinct sets as discussed in previous comment

@jroesch jroesch force-pushed the default-typaram-user-defaults branch 2 times, most recently from 7cefd00 to f9aff1e Compare August 24, 2015 20:18
@nikomatsakis
Copy link
Contributor

Tidy is still unhappy. This looks good, modulo the question of what semantics we want. Can we rename things so that all the test cases have some common prefix, like "default-type-param-fallback"?

@jroesch jroesch force-pushed the default-typaram-user-defaults branch from 0984c08 to c9ecb8c Compare September 4, 2015 18:39
@jroesch
Copy link
Member Author

jroesch commented Sep 4, 2015

@bors r=nikomatsakis

@bors
Copy link
Collaborator

bors commented Sep 4, 2015

📌 Commit c9ecb8c has been approved by nikomatsakis

@jroesch jroesch force-pushed the default-typaram-user-defaults branch from c9ecb8c to 2f5df9e Compare September 4, 2015 18:55
@jroesch
Copy link
Member Author

jroesch commented Sep 4, 2015

@bors r=nikomatsakis

@bors
Copy link
Collaborator

bors commented Sep 4, 2015

📌 Commit 2f5df9e has been approved by nikomatsakis

@bors
Copy link
Collaborator

bors commented Sep 4, 2015

⌛ Testing commit 2f5df9e with merge b180375...

@sfackler
Copy link
Member

sfackler commented Sep 4, 2015

@jroesch
Copy link
Member Author

jroesch commented Sep 4, 2015

@sfackler thanks! looks like I broke the error message formatting on my last commit, will fix and try again

@bors
Copy link
Collaborator

bors commented Sep 4, 2015

💔 Test failed - auto-mac-64-opt

@bors
Copy link
Collaborator

bors commented Sep 15, 2015

☔ The latest upstream changes (presumably #28274) made this pull request unmergeable. Please resolve the merge conflicts.

The previous implementation was not very clear, this commit attempts to clarify and clean up the code that
applies all defaults.
Thanks to @eddyb for bringing this bug to my attention.
@jroesch jroesch force-pushed the default-typaram-user-defaults branch from 2f5df9e to bbcc665 Compare September 16, 2015 20:50
@bors
Copy link
Collaborator

bors commented Oct 9, 2015

☔ The latest upstream changes (presumably #28900) made this pull request unmergeable. Please resolve the merge conflicts.

@steveklabnik
Copy link
Member

Any updates on this PR?

@jroesch
Copy link
Member Author

jroesch commented Dec 31, 2015

@steveklabnik this is my fault, things got a little busy with my move and starting my PhD, Niko was going to rebase this, but I assume he never found time. I'll get in contact with Niko and figure it out.

@nikomatsakis
Copy link
Contributor

Bah, I really ought to rebase this indeed.

@nikomatsakis
Copy link
Contributor

OK, so I pulled a copy of this branch locally and am going to close the PR. I'll follow up with @jroesch privately with a few questions.

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.

5 participants