-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
use std::ptr::NonNull;
trait Bar {}
struct Foo;
impl Foo {
fn get_mut(&mut self, i: usize) -> Option<&mut (dyn Bar)> {
None
}
fn foo(&mut self) {
unsafe {
let i1 = self
.get_mut(0)
.map(|val| NonNull::new_unchecked(val as *mut dyn Bar));
if let Some(mut i1) = i1 {
let mut i2 = self
.get_mut(1)
.map(|val| NonNull::new_unchecked(val as *mut dyn Bar));
if let Some(mut i2) = i2 {
let r1 = i1.as_mut();
let r2 = i2.as_mut();
}
}
}
}
}
fn main() {}
This compiles under 1.34.2, but shouldn't. This doesn't compile in 1.34.0. It appears that the lifetime bounds where assumed to be 'static
in 1.34.2. Option<&mut (dyn Bar +'static)>
.
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.