Closed
Description
This is a use-after-free that compiles with 1.74.0-nightly (2023-09-13 8142a31):
#![feature(return_position_impl_trait_in_trait)]
trait Extend {
fn extend(_: &str) -> (impl Sized + '_, &'static str);
}
impl Extend for () {
fn extend(s: &str) -> (Option<&'static &'_ ()>, &'static str) {
(None, s)
}
}
// This indirection is not necessary for reproduction,
// but it makes this test future-proof against #114936.
fn extend<T: Extend>(s: &str) -> &'static str {
<T as Extend>::extend(s).1
}
fn main() {
let use_after_free = extend::<()>(&String::from("temporary"));
println!("{}", use_after_free);
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done