From f5bae722be1f81f70d92e30cec1930f7cefc6313 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Mon, 12 Aug 2024 22:57:14 +0000 Subject: Point at explicit `'static` obligations on a trait Given `trait Any: 'static` and a `struct` with a `Box` field, point at the `'static` bound in `Any` to explain why `'a: 'static`. ``` error[E0478]: lifetime bound not satisfied --> f202.rs:2:12 | 2 | value: Box, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lifetime parameter instantiated with the lifetime `'a` as defined here --> f202.rs:1:14 | 1 | struct Hello<'a> { | ^^ note: but lifetime parameter must outlive the static lifetime --> /home/gh-estebank/rust/library/core/src/any.rs:113:16 | 113 | pub trait Any: 'static { | ^^^^^^^ ``` Partially address #33652. --- compiler/rustc_hir_analysis/src/check/wfcheck.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'compiler/rustc_hir_analysis/src') diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index bdf2914fc50..6e6e0e90219 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -747,7 +747,7 @@ fn region_known_to_outlive<'tcx>( region_b: ty::Region<'tcx>, ) -> bool { test_region_obligations(tcx, id, param_env, wf_tys, |infcx| { - infcx.sub_regions(infer::RelateRegionParamBound(DUMMY_SP), region_b, region_a); + infcx.sub_regions(infer::RelateRegionParamBound(DUMMY_SP, None), region_b, region_a); }) } -- cgit 1.4.1-3-g733a5