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

Shifts shouldn't be tied to pointer-size integers #20288

Closed
pcwalton opened this issue Dec 29, 2014 · 10 comments
Closed

Shifts shouldn't be tied to pointer-size integers #20288

pcwalton opened this issue Dec 29, 2014 · 10 comments
Labels
A-trait-system Area: Trait system

Comments

@pcwalton
Copy link
Contributor

Let's fix this. Backwards-incompatible language/library change.

@tbu-
Copy link
Contributor

tbu- commented Dec 29, 2014

@pcwalton Thank you for filing this bug, I totally forgot about the option of just filing a bug.

@nagisa
Copy link
Member

nagisa commented Jan 6, 2015

Seems like this was introduced, at least in part, by #15407.

Shifting by an arbitrary unsigned integer sounds nice.

@nagisa
Copy link
Member

nagisa commented Jan 8, 2015

Should be fixed by nikomatsakis@d803e22, which is part of #20754.

@tbu-
Copy link
Contributor

tbu- commented Jan 9, 2015

@nagisa Doesn't look like it, this commit only touches the << syntax for primitive types, not their Shl implementation.

@nagisa
Copy link
Member

nagisa commented Jan 9, 2015

@tbu- @nikomatsakis claims that traits are bypassed for primitive integer shifting, so I suppose the traits are there for documentation purposes. If you look at the tests added in the linked commit, shift operations should indeed support using any-sized integer as a right-hand size now.

We only need to update documentation to match the implemented behaviour.

@tbu-
Copy link
Contributor

tbu- commented Jan 9, 2015

@nagisa It's true that they're bypassed for primitive integer shifting, but only as long as they aren't passed to generic code. The traits aren't a doc only issue in this regard.

@nikomatsakis
Copy link
Contributor

Fixed in #20754

@nikomatsakis
Copy link
Contributor

Specifically nikomatsakis@20744c6

@nikomatsakis nikomatsakis reopened this Jan 10, 2015
@nikomatsakis
Copy link
Contributor

On IRC, simukis points out that without suitable impls this is not 100% fixed, since shifts can't be as naturally used in generic code:

[09:18:08] <simukis> nikomatsakis: tbu- argues that your fix doesn’t apply for, uhm, generic code
[09:18:39] <simukis> something like fn `magic(a : T) where T: Shr { a << 10i8 }`
[09:18:59] <simukis> nmatsakis: ^
[09:19:15] <simukis> nmatsakis: this is re issue you just closed
[09:20:10] <simukis> though I have no idea how that would be implemented.
[09:21:03] <nmatsakis> simukis: ah, well, he's not wrong. we should probably add more impls.

@nikomatsakis
Copy link
Contributor

Therefore re-opening the issue, though I believe the biggest part of this issue is fixed.

@bors bors closed this as completed in 348d833 Jan 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system
Projects
None yet
Development

No branches or pull requests

4 participants