Skip to content

Commit 5bc2e65

Browse files
committed
Auto merge of rust-lang#18162 - ChayimFriedman2:gat-object-safe, r=Veykril
fix: Consider lifetime GATs object unsafe Fixes rust-lang#18156.
2 parents f75aebe + 393f9cc commit 5bc2e65

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/tools/rust-analyzer/crates/hir-ty/src/object_safety.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ where
349349
ControlFlow::Continue(())
350350
} else {
351351
let generic_params = db.generic_params(item.into());
352-
if generic_params.len_type_or_consts() > 0 {
352+
if !generic_params.is_empty() {
353353
cb(ObjectSafetyViolation::GAT(it))
354354
} else {
355355
ControlFlow::Continue(())

src/tools/rust-analyzer/crates/hir-ty/src/object_safety/tests.rs

+13
Original file line numberDiff line numberDiff line change
@@ -378,3 +378,16 @@ pub trait Error: core::fmt::Debug + core::fmt::Display {
378378
[("Error", vec![])],
379379
);
380380
}
381+
382+
#[test]
383+
fn lifetime_gat_is_object_unsafe() {
384+
check_object_safety(
385+
r#"
386+
//- minicore: dispatch_from_dyn
387+
trait Foo {
388+
type Bar<'a>;
389+
}
390+
"#,
391+
[("Foo", vec![ObjectSafetyViolationKind::GAT])],
392+
);
393+
}

0 commit comments

Comments
 (0)