Skip to content

Commit f02bbbc

Browse files
authored
Rollup merge of #99433 - cjgillot:erase-foreign-sig, r=compiler-errors
Erase regions before comparing signatures of foreign fns. Fixes #99276 The version with explicit lifetimes is probably tracked in another bug, but I could not find it.
2 parents 8039567 + 0065929 commit f02bbbc

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

Diff for: compiler/rustc_lint/src/builtin.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -2858,9 +2858,10 @@ impl ClashingExternDeclarations {
28582858
let a_poly_sig = a.fn_sig(tcx);
28592859
let b_poly_sig = b.fn_sig(tcx);
28602860

2861-
// As we don't compare regions, skip_binder is fine.
2862-
let a_sig = a_poly_sig.skip_binder();
2863-
let b_sig = b_poly_sig.skip_binder();
2861+
// We don't compare regions, but leaving bound regions around ICEs, so
2862+
// we erase them.
2863+
let a_sig = tcx.erase_late_bound_regions(a_poly_sig);
2864+
let b_sig = tcx.erase_late_bound_regions(b_poly_sig);
28642865

28652866
(a_sig.abi, a_sig.unsafety, a_sig.c_variadic)
28662867
== (b_sig.abi, b_sig.unsafety, b_sig.c_variadic)
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Check that we do not ICE when structurally comparing types with lifetimes present.
2+
// check-pass
3+
4+
pub struct Record<'a> {
5+
pub args: &'a [(usize, &'a str)],
6+
}
7+
8+
mod a {
9+
extern "Rust" {
10+
fn foo<'a, 'b>(record: &'a super::Record<'b>);
11+
12+
fn bar<'a, 'b>(record: &'a super::Record<'b>);
13+
}
14+
}
15+
16+
mod b {
17+
extern "Rust" {
18+
fn foo<'a, 'b>(record: &'a super::Record<'b>);
19+
20+
fn bar<'a, 'b>(record: &'a super::Record<'b>);
21+
}
22+
}
23+
24+
fn main() {}

0 commit comments

Comments
 (0)