summary refs log tree commit diff
path: root/tests/ui/polymorphization/abi_mismatch.rs
blob: 22c2c162d1c162552fb129105498b53c8524e5a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//! This test used to ICE: #123917
//! The reason was that while the AST knows about two fields
//! named `ptr`, only one exists at the layout level, so accessing
//! `_extra_field` would use an oob index
//@ compile-flags: -Zmir-opt-level=5 -Zpolymorphize=on

struct NonNull<T>(*mut T);

struct Token<T> {
    ptr: *mut T,
    ptr: NonNull<T>,
    //~^ ERROR: `ptr` is already declared
    _extra_field: (),
}

fn tokenize<T>(item: *mut T) -> Token<T> {
    Token { ptr: NonNull(item), _extra_field: () }
}

fn main() {}