Skip to content

Commit

Permalink
Auto merge of #18162 - ChayimFriedman2:gat-object-safe, r=Veykril
Browse files Browse the repository at this point in the history
fix: Consider lifetime GATs object unsafe

Fixes #18156.
  • Loading branch information
bors committed Sep 24, 2024
2 parents f75aebe + 393f9cc commit 5bc2e65
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/hir-ty/src/object_safety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
13 changes: 13 additions & 0 deletions src/tools/rust-analyzer/crates/hir-ty/src/object_safety/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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])],
);
}

0 comments on commit 5bc2e65

Please sign in to comment.