Auto merge of #136429 - fmease:gci-fix-def-site-checks, r= · rust-lang/rust@6f11489 (original) (raw)

`@@ -306,9 +306,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()

`

306

306

` hir::ItemKind::Static(ty, ..) => {

`

307

307

`check_item_type(tcx, def_id, ty.span, UnsizedHandling::Forbid)

`

308

308

`}

`

309

``

`-

hir::ItemKind::Const(ty, ..) => {

`

310

``

`-

check_item_type(tcx, def_id, ty.span, UnsizedHandling::Forbid)

`

311

``

`-

}

`

``

309

`+

hir::ItemKind::Const(ty, ..) => check_const_item(tcx, def_id, ty.span, item.span),

`

312

310

` hir::ItemKind::Struct(_, hir_generics) => {

`

313

311

`let res = check_type_defn(tcx, item, false);

`

314

312

`check_variances_for_type_defn(tcx, item, hir_generics);

`

`@@ -1280,6 +1278,7 @@ enum UnsizedHandling {

`

1280

1278

`AllowIfForeignTail,

`

1281

1279

`}

`

1282

1280

``

``

1281

`+

// FIXME(fmease): Rename to check_static_item once LTAs don't use it anymore (#136432)

`

1283

1282

`fn check_item_type(

`

1284

1283

`tcx: TyCtxt<'_>,

`

1285

1284

`item_id: LocalDefId,

`

`@@ -1338,6 +1337,34 @@ fn check_item_type(

`

1338

1337

`})

`

1339

1338

`}

`

1340

1339

``

``

1340

`+

fn check_const_item(

`

``

1341

`+

tcx: TyCtxt<'_>,

`

``

1342

`+

def_id: LocalDefId,

`

``

1343

`+

ty_span: Span,

`

``

1344

`+

item_span: Span,

`

``

1345

`+

) -> Result<(), ErrorGuaranteed> {

`

``

1346

`+

enter_wf_checking_ctxt(tcx, ty_span, def_id, |wfcx| {

`

``

1347

`+

let ty = tcx.type_of(def_id).instantiate_identity();

`

``

1348

`+

let ty = wfcx.normalize(ty_span, Some(WellFormedLoc::Ty(def_id)), ty);

`

``

1349

+

``

1350

`+

wfcx.register_wf_obligation(ty_span, Some(WellFormedLoc::Ty(def_id)), ty.into());

`

``

1351

`+

wfcx.register_bound(

`

``

1352

`+

traits::ObligationCause::new(

`

``

1353

`+

ty_span,

`

``

1354

`+

wfcx.body_def_id,

`

``

1355

`+

ObligationCauseCode::WellFormed(None),

`

``

1356

`+

),

`

``

1357

`+

wfcx.param_env,

`

``

1358

`+

ty,

`

``

1359

`+

tcx.require_lang_item(LangItem::Sized, None),

`

``

1360

`+

);

`

``

1361

+

``

1362

`+

check_where_clauses(wfcx, item_span, def_id);

`

``

1363

+

``

1364

`+

Ok(())

`

``

1365

`+

})

`

``

1366

`+

}

`

``

1367

+

1341

1368

`#[instrument(level = "debug", skip(tcx, hir_self_ty, hir_trait_ref))]

`

1342

1369

`fn check_impl<'tcx>(

`

1343

1370

`tcx: TyCtxt<'tcx>,

`