diff options
Diffstat (limited to 'compiler/rustc_hir_analysis/src/check/check.rs')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/check.rs | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 8413a1cc0db..6bef57a3084 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -38,7 +38,7 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) { Some(true) => (), Some(false) => { struct_span_err!( - tcx.sess, + tcx.dcx(), span, E0570, "`{abi}` is not a supported ABI for the current target", @@ -59,7 +59,7 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) { // This ABI is only allowed on function pointers if abi == Abi::CCmseNonSecureCall { struct_span_err!( - tcx.sess, + tcx.dcx(), span, E0781, "the `\"C-cmse-nonsecure-call\"` ABI is only allowed on function pointers" @@ -126,7 +126,7 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b for field in &def.non_enum_variant().fields { let Ok(field_ty) = tcx.try_normalize_erasing_regions(param_env, field.ty(tcx, args)) else { - tcx.sess.span_delayed_bug(span, "could not normalize field type"); + tcx.dcx().span_delayed_bug(span, "could not normalize field type"); continue; }; @@ -136,7 +136,7 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b Some(Node::Field(field)) => (field.span, field.ty.span), _ => unreachable!("mir field has to correspond to hir field"), }; - tcx.sess.emit_err(errors::InvalidUnionField { + tcx.dcx().emit_err(errors::InvalidUnionField { field_span, sugg: errors::InvalidUnionFieldSuggestion { lo: ty_span.shrink_to_lo(), @@ -147,7 +147,7 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b return false; } else if field_ty.needs_drop(tcx, param_env) { // This should never happen. But we can get here e.g. in case of name resolution errors. - tcx.sess + tcx.dcx() .span_delayed_bug(span, "we should never accept maybe-dropping union fields"); } } @@ -173,12 +173,12 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) { if matches!(tcx.def_kind(def_id), DefKind::Static(_) if tcx.def_kind(tcx.local_parent(def_id)) == DefKind::ForeignMod) => { - tcx.sess.emit_err(errors::TooLargeStatic { span }); + tcx.dcx().emit_err(errors::TooLargeStatic { span }); return; } // Generic statics are rejected, but we still reach this case. Err(e) => { - tcx.sess.span_delayed_bug(span, format!("{e:?}")); + tcx.dcx().span_delayed_bug(span, format!("{e:?}")); return; } }; @@ -201,7 +201,7 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) { fn check_opaque(tcx: TyCtxt<'_>, id: hir::ItemId) { let item = tcx.hir().item(id); let hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) = item.kind else { - tcx.sess.span_delayed_bug(item.span, "expected opaque item"); + tcx.dcx().span_delayed_bug(item.span, "expected opaque item"); return; }; @@ -310,7 +310,7 @@ fn check_opaque_meets_bounds<'tcx>( Ok(()) => {} Err(ty_err) => { let ty_err = ty_err.to_string(tcx); - return Err(tcx.sess.span_delayed_bug( + return Err(tcx.dcx().span_delayed_bug( span, format!("could not unify `{hidden_ty}` with revealed type:\n{ty_err}"), )); @@ -435,7 +435,7 @@ fn check_static_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) { ty::Adt(adt_def, args) => !is_enum_of_nonnullable_ptr(tcx, *adt_def, *args), _ => true, } { - tcx.sess.emit_err(LinkageType { span: tcx.def_span(def_id) }); + tcx.dcx().emit_err(LinkageType { span: tcx.def_span(def_id) }); } } } @@ -554,7 +554,7 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) { _ => ("type or const", "types or consts", None), }; struct_span_err!( - tcx.sess, + tcx.dcx(), item.span, E0044, "foreign items may not have {kinds} parameters", @@ -652,7 +652,7 @@ pub(super) fn check_specialization_validity<'tcx>( if !tcx.is_impl_trait_in_trait(impl_item) { report_forbidden_specialization(tcx, impl_item, parent_impl); } else { - tcx.sess.span_delayed_bug( + tcx.dcx().span_delayed_bug( DUMMY_SP, format!("parent item: {parent_impl:?} not marked as default"), ); @@ -681,7 +681,7 @@ fn check_impl_items_against_trait<'tcx>( if let [first_item_ref, ..] = impl_item_refs { let first_item_span = tcx.def_span(first_item_ref); struct_span_err!( - tcx.sess, + tcx.dcx(), first_item_span, E0749, "negative impls cannot have any items" @@ -700,7 +700,7 @@ fn check_impl_items_against_trait<'tcx>( tcx.associated_item(trait_item_id) } else { // Checked in `associated_item`. - tcx.sess.span_delayed_bug(tcx.def_span(impl_item), "missing associated item in trait"); + tcx.dcx().span_delayed_bug(tcx.def_span(impl_item), "missing associated item in trait"); continue; }; match ty_impl_item.kind { @@ -795,7 +795,7 @@ fn check_impl_items_against_trait<'tcx>( "return position `impl Trait` in traits", ) }; - tcx.sess + tcx.dcx() .struct_span_err(tcx.def_span(def_id), msg) .note(format!( "specialization behaves in inconsistent and \ @@ -833,12 +833,12 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) { { let fields = &def.non_enum_variant().fields; if fields.is_empty() { - struct_span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty").emit(); + struct_span_err!(tcx.dcx(), sp, E0075, "SIMD vector cannot be empty").emit(); return; } let e = fields[FieldIdx::from_u32(0)].ty(tcx, args); if !fields.iter().all(|f| f.ty(tcx, args) == e) { - struct_span_err!(tcx.sess, sp, E0076, "SIMD vector should be homogeneous") + struct_span_err!(tcx.dcx(), sp, E0076, "SIMD vector should be homogeneous") .span_label(sp, "SIMD elements must have the same type") .emit(); return; @@ -851,11 +851,11 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) { }; if let Some(len) = len { if len == 0 { - struct_span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty").emit(); + struct_span_err!(tcx.dcx(), sp, E0075, "SIMD vector cannot be empty").emit(); return; } else if len > MAX_SIMD_LANES { struct_span_err!( - tcx.sess, + tcx.dcx(), sp, E0075, "SIMD vector cannot have more than {MAX_SIMD_LANES} elements", @@ -878,7 +878,7 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) { { /* struct([f32; 4]) is ok */ } _ => { struct_span_err!( - tcx.sess, + tcx.dcx(), sp, E0077, "SIMD vector element type should be a \ @@ -901,7 +901,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) { && pack as u64 != repr_pack.bytes() { struct_span_err!( - tcx.sess, + tcx.dcx(), sp, E0634, "type has conflicting packed representation hints" @@ -912,7 +912,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) { } if repr.align.is_some() { struct_span_err!( - tcx.sess, + tcx.dcx(), sp, E0587, "type has conflicting packed and align representation hints" @@ -921,7 +921,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) { } else { if let Some(def_spans) = check_packed_inner(tcx, def.did(), &mut vec![]) { let mut err = struct_span_err!( - tcx.sess, + tcx.dcx(), sp, E0588, "packed type cannot transitively contain a `#[repr(align)]` type" @@ -1111,7 +1111,7 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) { if def.variants().is_empty() { if let Some(attr) = tcx.get_attrs(def_id, sym::repr).next() { struct_span_err!( - tcx.sess, + tcx.dcx(), attr.span, E0084, "unsupported representation for zero-variant enum" @@ -1150,7 +1150,7 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) { if disr_non_unit || (disr_units && has_non_units) { let mut err = struct_span_err!( - tcx.sess, + tcx.dcx(), tcx.def_span(def_id), E0732, "`#[repr(inttype)]` must be specified" @@ -1236,7 +1236,7 @@ fn detect_discriminant_duplicate<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>) if discrs[i].1.val == discrs[o].1.val { let err = error.get_or_insert_with(|| { let mut ret = struct_span_err!( - tcx.sess, + tcx.dcx(), tcx.def_span(adt.did()), E0081, "discriminant value `{}` assigned more than once", @@ -1302,7 +1302,7 @@ pub(super) fn check_type_params_are_used<'tcx>( && let ty::GenericParamDefKind::Type { .. } = param.kind { let span = tcx.def_span(param.def_id); - struct_span_err!(tcx.sess, span, E0091, "type parameter `{}` is unused", param.name,) + struct_span_err!(tcx.dcx(), span, E0091, "type parameter `{}` is unused", param.name,) .span_label(span, "unused type parameter") .emit(); } @@ -1320,7 +1320,7 @@ pub(super) fn check_mod_item_types(tcx: TyCtxt<'_>, module_def_id: LocalModDefId } fn async_opaque_type_cycle_error(tcx: TyCtxt<'_>, span: Span) -> ErrorGuaranteed { - struct_span_err!(tcx.sess, span, E0733, "recursion in an `async fn` requires boxing") + struct_span_err!(tcx.dcx(), span, E0733, "recursion in an `async fn` requires boxing") .span_label(span, "recursive `async fn`") .note("a recursive `async fn` must be rewritten to return a boxed `dyn Future`") .note( @@ -1342,7 +1342,7 @@ fn opaque_type_cycle_error( opaque_def_id: LocalDefId, span: Span, ) -> ErrorGuaranteed { - let mut err = struct_span_err!(tcx.sess, span, E0720, "cannot resolve opaque type"); + let mut err = struct_span_err!(tcx.dcx(), span, E0720, "cannot resolve opaque type"); let mut label = false; if let Some((def_id, visitor)) = get_owner_return_paths(tcx, opaque_def_id) { |
