Skip to content

panic with "Layout mismatch when copying!" #58742

Closed
@mattheww

Description

@mattheww

Running yesterday's nightly rustdoc on the following file panics for me:

const fn one(arr: &[u8; 1]) -> u8 {
    arr[0]
}

const fn two(byte: u8) -> [u8; 1] {[
    byte
]}

const fn three(data: u8) -> u8 {
    one(&two(data))
}

const FOO: u8 = three(0x0);

It says thread 'rustc' panicked at 'Layout mismatch when copying!.

The version is rustdoc 1.34.0-nightly (097c04cf4 2019-02-24).

There isn't a problem compiling the file.

Output including backtrace:

% RUST_BACKTRACE=1 rustdoc +nightly --color=never src/lib.rs
thread 'rustc' panicked at 'Layout mismatch when copying!
src: OpTy {
    op: Indirect(
        MemPlace {
            ptr: Ptr(
                Pointer {
                    alloc_id: AllocId(
                        4
                    ),
                    offset: Size {
                        raw: 0
                    },
                    tag: ()
                }
            ),
            align: Align {
                pow2: 0
            },
            meta: None
        }
    ),
    layout: TyLayout {
        ty: [u8; 1],
        details: LayoutDetails {
            variants: Single {
                index: 0
            },
            fields: Array {
                stride: Size {
                    raw: 1
                },
                count: 1
            },
            abi: Aggregate {
                sized: true
            },
            align: AbiAndPrefAlign {
                abi: Align {
                    pow2: 0
                },
                pref: Align {
                    pow2: 0
                }
            },
            size: Size {
                raw: 1
            }
        }
    }
}
dest: PlaceTy {
    place: Local {
        frame: 0,
        local: _2
    },
    layout: TyLayout {
        ty: u8,
        details: LayoutDetails {
            variants: Single {
                index: 0
            },
            fields: Union(
                0
            ),
            abi: Scalar(
                Scalar {
                    value: Int(
                        I8,
                        false
                    ),
                    valid_range: 0..=255
                }
            ),
            align: AbiAndPrefAlign {
                abi: Align {
                    pow2: 0
                },
                pref: Align {
                    pow2: 0
                }
            },
            size: Size {
                raw: 1
            }
        }
    }
}', src/librustc_mir/interpret/place.rs:826:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:70
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:58
             at src/libstd/panicking.rs:200
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:215
   4: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:478
   5: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:385
   6: std::panicking::begin_panic_fmt
             at src/libstd/panicking.rs:340
   7: rustc_mir::interpret::place::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::copy_op_no_validate
   8: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::run
   9: rustc_mir::const_eval::eval_body_using_ecx
  10: rustc_mir::const_eval::const_eval_raw_provider
  11: rustc::ty::query::__query_compute::const_eval_raw
  12: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::const_eval_raw<'tcx>>::compute
  13: rustc::dep_graph::graph::DepGraph::with_task_impl
  14: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  15: <rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::const_eval_raw
  16: rustc_mir::interpret::place::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::eval_place_to_mplace
  17: rustc_mir::interpret::place::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::eval_place
  18: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::run
  19: rustc_mir::const_eval::eval_body_using_ecx
  20: rustc_mir::const_eval::const_eval_raw_provider
  21: rustc::ty::query::__query_compute::const_eval_raw
  22: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::const_eval_raw<'tcx>>::compute
  23: rustc::dep_graph::graph::DepGraph::with_task_impl
  24: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  25: rustc_mir::const_eval::const_eval_provider
  26: rustc::ty::query::__query_compute::const_eval
  27: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::const_eval<'tcx>>::compute
  28: rustc::dep_graph::graph::DepGraph::with_task_impl
  29: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  30: rustc_lint::builtin::check_const
  31: <rustc_lint::register_builtins::BuiltinCombinedLateLintPass as rustc::lint::LateLintPass<'a, 'tcx>>::check_item
  32: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  33: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  34: rustc::hir::intravisit::walk_crate
  35: rustc::lint::context::check_crate
  36: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::{{closure}}
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc_driver/driver.rs:1333
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc/util/common.rs:150
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc/util/common.rs:144
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc_driver/driver.rs:1333
  37: rustc::util::common::time
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc/util/common.rs:150
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc/util/common.rs:144
  38: <std::thread::local::LocalKey<T>>::with
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc_driver/driver.rs:1321
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc/ty/context.rs:2000
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc/ty/context.rs:1966
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc/ty/context.rs:1899
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc/ty/context.rs:1965
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc/ty/context.rs:1999
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc/ty/context.rs:1954
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/libstd/thread/local.rs:300
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/libstd/thread/local.rs:246
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc/ty/context.rs:1946
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/libstd/thread/local.rs:300
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/libstd/thread/local.rs:246
  39: rustc::ty::context::TyCtxt::create_and_enter
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc/ty/context.rs:1938
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc/ty/context.rs:1977
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc/ty/context.rs:1290
  40: rustc_driver::driver::phase_3_run_analysis_passes
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc_driver/driver.rs:1213
  41: <scoped_tls::ScopedKey<T>>::set
             at src/librustdoc/core.rs:494
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc_driver/driver.rs:65
             at /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
  42: <scoped_tls::ScopedKey<T>>::set
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/librustc_driver/driver.rs:64
             at src/librustdoc/core.rs:400
             at src/librustdoc/lib.rs:434
             at /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/libsyntax/lib.rs:100
             at /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
  43: syntax::with_globals
             at /rustc/097c04cf433048585dd9e3f63b30e03cc3509e4b/src/libsyntax/lib.rs:99

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.34.0-nightly (097c04cf4 2019-02-24) running on i686-unknown-linux-gnu

Metadata

Metadata

Assignees

Labels

A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions