Skip to content

const_eval::cast_const should use target's int/uint types for isize/usize #23890

Closed
@pnkfelix

Description

@pnkfelix
Member

Spawned off of PR #23863, see discussion here

    define_casts!{
        // FIXME: This should probably be using the target's int-type, not he host's.
        ty::ty_int(ast::TyIs) => (isize, const_int, i64),
        ty::ty_int(ast::TyI8) => (i8, const_int, i64),
        ty::ty_int(ast::TyI16) => (i16, const_int, i64),
        ty::ty_int(ast::TyI32) => (i32, const_int, i64),
        ty::ty_int(ast::TyI64) => (i64, const_int, i64),
        // FIXME: This should probably be using the target's uint-type, not he host's.
        ty::ty_uint(ast::TyUs) => (usize, const_uint, u64),
        ty::ty_uint(ast::TyU8) => (u8, const_uint, u64),
        ty::ty_uint(ast::TyU16) => (u16, const_uint, u64),
        ty::ty_uint(ast::TyU32) => (u32, const_uint, u64),
        ty::ty_uint(ast::TyU64) => (u64, const_uint, u64),
        ty::ty_float(ast::TyF32) => (f32, const_float, f64),
        ty::ty_float(ast::TyF64) => (f64, const_float, f64)
    }

Activity

pnkfelix

pnkfelix commented on Mar 31, 2015

@pnkfelix
MemberAuthor

(I think the only tricky part about this is determining if there is a good regression test to catch this bug; obviously it will only be caught in cross-compilation contexts.)

pnkfelix

pnkfelix commented on Mar 31, 2015

@pnkfelix
MemberAuthor

Semi-ironically, I think this bug might be what is blocking PR #23841 from landing.

(If true, then the only "tricky part" referenced above has actually already been accomplished.)

pnkfelix

pnkfelix commented on Mar 31, 2015

@pnkfelix
MemberAuthor

see also #13768 (which #23863 does not completely address; there is clearly still some corner cases to address in the ExprCast logic).

pnkfelix

pnkfelix commented on Mar 31, 2015

@pnkfelix
MemberAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @steveklabnik@pnkfelix

        Issue actions

          const_eval::cast_const should use target's int/uint types for isize/usize · Issue #23890 · rust-lang/rust