Skip to content

Wrong spans for transmute argument errors #115688

Open
@chenyukang

Description

@chenyukang

Code

#![crate_type = "lib"]
#![feature(transmutability)]
mod assert {
    use std::mem::BikeshedIntrinsicFrom;
    struct Context;

    pub fn is_maybe_transmutable<Src, Dst>()
    where
        Dst: BikeshedIntrinsicFrom<Src, Context>,
    {
    }
}

fn main() {
    pub union Uninit {
        a: [u8; usize::MAX],
    }

    #[repr(C)]
    struct ExplicitlyPadded(Uninit);

    assert::is_maybe_transmutable::<ExplicitlyPadded, ()>();
}

Current output

error[E0277]: `ExplicitlyPadded` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
  --> src/lib.rs:22:55
   |
22 |     assert::is_maybe_transmutable::<ExplicitlyPadded, ()>();
   |                                                       ^^ values of the type `ExplicitlyPadded` are too big for the current architecture
   |
note: required by a bound in `is_maybe_transmutable`
  --> src/lib.rs:9:14
   |
7  |     pub fn is_maybe_transmutable<Src, Dst>()
   |            --------------------- required by a bound in this function
8  |     where
9  |         Dst: BikeshedIntrinsicFrom<Src, Context>,
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` (lib) due to previous error

Desired output

22 |     assert::is_maybe_transmutable::<ExplicitlyPadded, ()>();
   |                                     ^^^^^^^^^^^^^^^^ values of the type `ExplicitlyPadded` are too big for the current architecture

Rationale and extra context

seems adjust_fulfillment_error_for_expr_obligation fix wrong span for the arguments.

Other cases

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.F-transmutability`#![feature(transmutability)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions