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

1u32 << 1u32 doesn't work #15223

Closed
stepancheg opened this issue Jun 27, 2014 · 3 comments
Closed

1u32 << 1u32 doesn't work #15223

stepancheg opened this issue Jun 27, 2014 · 3 comments

Comments

@stepancheg
Copy link
Contributor

Code:

1u32 << 1u32

results in:

tmp.rs:2:13: 2:17 error: mismatched types: expected `uint` but found `u32` (expected uint but found u32)
tmp.rs:2     1u32 << 1u32;
                     ^~~~
error: aborting due to previous error

Not sure it is a bug, at least it worked several days ago.

@brson
Copy link
Contributor

brson commented Jun 27, 2014

Indeed, this changed as part of the removal of integer inference fallback. I believe all shifts now are int sized now in order to provide stronger type checking hints.

@brson brson closed this as completed Jun 27, 2014
@stepancheg
Copy link
Contributor Author

@brson Weird thing is that this code works:

fn foo<A : Shl<A, A>>(a: A) -> A {
    a << a
}

fn main() {
    foo(1u32);
}

@alexcrichton
Copy link
Member

As a language item, the << operator on integral types requires a uint shift value. This helps to drive inference with the removal of the int fallback.

As a library feature, Shl specifies its type to shift by. In your first example you were invoking the language operator while in the second example you're invoking the library operator.

bors added a commit to rust-lang-ci/rust that referenced this issue Jul 17, 2023
…ssing, r=HKalbasi

Don't show `unresolved-field` diagnostic for missing names

I don't think reporting ``"no field `[missing name]` on type `SomeType`"`` makes much sense because it's a syntax error rather than a semantic error. We already report a syntax error for it and I find it sufficient.
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

No branches or pull requests

3 participants