diff --git a/src/test/ui/mir/auxiliary/issue_76375_aux.rs b/src/test/ui/mir/auxiliary/issue_76375_aux.rs new file mode 100644 index 00000000000..f8b318d58ba --- /dev/null +++ b/src/test/ui/mir/auxiliary/issue_76375_aux.rs @@ -0,0 +1,14 @@ +// edition:2018 +// compile-flags: -Z mir-opt-level=2 -Z unsound-mir-opts + +#[inline(always)] +pub fn f(s: bool) -> String { + let a = "Hello world!".to_string(); + let b = a; + let c = b; + if s { + c + } else { + String::new() + } +} diff --git a/src/test/ui/mir/issue-68841.rs b/src/test/ui/mir/issue-68841.rs new file mode 100644 index 00000000000..14884a97fab --- /dev/null +++ b/src/test/ui/mir/issue-68841.rs @@ -0,0 +1,15 @@ +// compile-flags: -Z mir-opt-level=2 +// edition:2018 +// build-pass + +#![feature(async_closure)] + +use std::future::Future; + +fn async_closure() -> impl Future { + (async move || -> u8 { 42 })() +} + +fn main() { + let _fut = async_closure(); +} diff --git a/src/test/ui/mir/issue-75053.rs b/src/test/ui/mir/issue-75053.rs new file mode 100644 index 00000000000..6e7211c2ee6 --- /dev/null +++ b/src/test/ui/mir/issue-75053.rs @@ -0,0 +1,48 @@ +// compile-flags: -Z mir-opt-level=2 +// build-pass + +#![feature(type_alias_impl_trait)] + +use std::marker::PhantomData; + +trait MyIndex { + type O; + fn my_index(self) -> Self::O; +} +trait MyFrom: Sized { + type Error; + fn my_from(value: T) -> Result; +} + +trait F {} +impl F for () {} +type DummyT = impl F; +fn _dummy_t() -> DummyT {} + +struct Phantom1(PhantomData); +struct Phantom2(PhantomData); +struct Scope(Phantom2>); + +impl Scope { + fn new() -> Self { + unimplemented!() + } +} + +impl MyFrom> for Phantom1 { + type Error = (); + fn my_from(_: Phantom2) -> Result { + unimplemented!() + } +} + +impl>>, U> MyIndex> for Scope { + type O = T; + fn my_index(self) -> Self::O { + MyFrom::my_from(self.0).ok().unwrap() + } +} + +fn main() { + let _pos: Phantom1> = Scope::new().my_index(); +} diff --git a/src/test/ui/mir/issue-76375.rs b/src/test/ui/mir/issue-76375.rs new file mode 100644 index 00000000000..ef459f6a28e --- /dev/null +++ b/src/test/ui/mir/issue-76375.rs @@ -0,0 +1,15 @@ +// edition:2018 +// build-pass +// compile-flags: -Z mir-opt-level=2 -L. +// aux-build:issue_76375_aux.rs + +#![crate_type = "lib"] + +extern crate issue_76375_aux; + +pub async fn g() { + issue_76375_aux::f(true); + h().await; +} + +pub async fn h() {} diff --git a/src/test/ui/mir/issue-77911.rs b/src/test/ui/mir/issue-77911.rs new file mode 100644 index 00000000000..b24faa6f885 --- /dev/null +++ b/src/test/ui/mir/issue-77911.rs @@ -0,0 +1,16 @@ +// compile-flags: -Z mir-opt-level=2 +// ignore-cloudabi no std::fs +// build-pass + +use std::fs::File; +use std::io::{BufRead, BufReader}; + +fn file_lines() -> impl Iterator { + BufReader::new(File::open("").unwrap()) + .lines() + .map(Result::unwrap) +} + +fn main() { + for _ in file_lines() {} +}