Skip to content

tuples with unsized tails cause an error when compiled #33241

Closed
@arielb1

Description

@arielb1

STR

use std::fmt;

// CoerceUnsized is not implemented for tuples. You can still create
// an unsized tuple by transmuting a trait object.
fn any<T>() -> T { unreachable!() }

fn main() {
    let t: &(u8, fmt::Debug) = any();
    println!("{:?}", &t.1);
}

Actual Results

Before #32939, this caused an LLVM error

Stored value type does not match pointer operand type!
  store i8 %17, void (i8*)*** %18
 void (i8*)**LLVM ERROR: Broken function found, compilation aborted!

Afterwards, this causes an ICE (the rustc size is the correct one):

error: internal compiler error: ../src/librustc_trans/type_of.rs:142: size differs (rustc: 1, llvm: 24) for type `(u8, std::fmt::Debug + 'static)` / Univariant {
    variant: Struct {
        align: Align {
            raw: 48
        },
        packed: false,
        sized: false,
        offset_after_field: [
            Size {
                raw: 1
            },
            Size {
                raw: 1
            }
        ]
    },
    non_zero: false
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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