mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Auto merge of #18162 - ChayimFriedman2:gat-object-safe, r=Veykril
fix: Consider lifetime GATs object unsafe Fixes #18156.
This commit is contained in:
commit
dfee4c8690
2 changed files with 14 additions and 1 deletions
|
@ -349,7 +349,7 @@ where
|
|||
ControlFlow::Continue(())
|
||||
} else {
|
||||
let generic_params = db.generic_params(item.into());
|
||||
if generic_params.len_type_or_consts() > 0 {
|
||||
if !generic_params.is_empty() {
|
||||
cb(ObjectSafetyViolation::GAT(it))
|
||||
} else {
|
||||
ControlFlow::Continue(())
|
||||
|
|
|
@ -378,3 +378,16 @@ pub trait Error: core::fmt::Debug + core::fmt::Display {
|
|||
[("Error", vec![])],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lifetime_gat_is_object_unsafe() {
|
||||
check_object_safety(
|
||||
r#"
|
||||
//- minicore: dispatch_from_dyn
|
||||
trait Foo {
|
||||
type Bar<'a>;
|
||||
}
|
||||
"#,
|
||||
[("Foo", vec![ObjectSafetyViolationKind::GAT])],
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue