Skip to content

Can't cast char to char #12655

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
veddan opened this issue Mar 2, 2014 · 2 comments
Closed

Can't cast char to char #12655

veddan opened this issue Mar 2, 2014 · 2 comments

Comments

@veddan
Copy link
Contributor

veddan commented Mar 2, 2014

All other types can be cast to themselves just fine, but trying to compile

fn main() {
    let a = 'c';
    let b = a as char;
}

gives

bug.rs:3:13: 3:22 error: only `u8` can be cast as `char`, not `char`
bug.rs:3     let b = a as char;
                     ^~~~~~~~~
error: aborting due to previous error
@thestinger
Copy link
Contributor

This also gives an error for any type that's not one of the numeric built-in types. I don't think it needs to be supported. Making as smaller rather than larger would be nice as it's one of the ugly special cases in the language.

@thestinger
Copy link
Contributor

I think allowing T as T would need to go through an RFC now. I only see as as a temporary hack that's necessary due to constant expressions being crippled though.

bors added a commit to rust-lang-ci/rust that referenced this issue Jul 25, 2022
…n-target, r=flodiebold

Ignore the `bin` artifact for `bench` targets

Just like `test`.

Fixes rust-lang#12645.

I don't know how to test that.
flip1995 pushed a commit to flip1995/rust that referenced this issue Jun 27, 2024
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

2 participants