Closed
Description
rustc 1.36.0-nightly (3991285f5 2019-04-25)
binary: rustc
commit-hash: 3991285f55a4b7cd92b7ffcdc396a3023076f5cb
commit-date: 2019-04-25
host: x86_64-unknown-linux-gnu
release: 1.36.0-nightly
LLVM version: 8.0
rustc src/test/run-pass/unsized-locals/autoderef.rs -C passes=lint -C opt-level=3
Pessimization: Static alloca outside of entry block
%95 = alloca i8, i64 20, align 16
Pessimization: Static alloca outside of entry block
%290 = alloca i8, i64 0, align 16
Pessimization: Static alloca outside of entry block
%295 = alloca i8, i64 0, align 16
Pessimization: Static alloca outside of entry block
%338 = alloca i8, i64 0, align 16
Undefined behavior: Call argument type mismatches callee parameter type
call void bitcast (void (%"main::{{closure}}"*)* @_ZN4core3ptr18real_drop_in_place17h74dade2e05fed3c8E to void ({}*)*)({}* align 1 %292) #9
code:
#![feature(unsized_locals)]
pub trait Foo {
fn foo(self) -> String;
}
impl Foo for [char] {
fn foo(self) -> String {
self.iter().collect()
}
}
impl Foo for str {
fn foo(self) -> String {
self.to_owned()
}
}
impl Foo for dyn FnMut() -> String {
fn foo(mut self) -> String {
self()
}
}
fn main() {
let x = *(Box::new(['h', 'e', 'l', 'l', 'o']) as Box<[char]>);
assert_eq!(&x.foo() as &str, "hello");
let x = Box::new(['h', 'e', 'l', 'l', 'o']) as Box<[char]>;
assert_eq!(&x.foo() as &str, "hello");
let x = "hello".to_owned().into_boxed_str();
assert_eq!(&x.foo() as &str, "hello");
let x = *("hello".to_owned().into_boxed_str());
assert_eq!(&x.foo() as &str, "hello");
let x = "hello".to_owned().into_boxed_str();
assert_eq!(&x.foo() as &str, "hello");
let x = *(Box::new(|| "hello".to_owned()) as Box<dyn FnMut() -> String>);
assert_eq!(&x.foo() as &str, "hello");
let x = Box::new(|| "hello".to_owned()) as Box<dyn FnMut() -> String>;
assert_eq!(&x.foo() as &str, "hello");
}
cc #7463