diff options
| author | bors <bors@rust-lang.org> | 2024-12-14 06:44:05 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-12-14 06:44:05 +0000 |
| commit | ed141926048597e3649bb238ca3dc417904cd56c (patch) | |
| tree | e57fc49671ca6275c543e6fc7e5c12932a3b45b4 /compiler/rustc_hir_analysis/src | |
| parent | a1740a9c3568e856f6aa12d83e008d38c9749d4b (diff) | |
| parent | 4efa98cf2d1659468d01e97a9c42c51b6f6ac44b (diff) | |
| download | rust-ed141926048597e3649bb238ca3dc417904cd56c.tar.gz rust-ed141926048597e3649bb238ca3dc417904cd56c.zip | |
Auto merge of #134294 - matthiaskrgr:rollup-anh6io8, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #134252 (Fix `Path::is_absolute` on Hermit) - #134254 (Fix building `std` for Hermit after `c_char` change) - #134255 (Update includes in `/library/core/src/error.rs`.) - #134261 (Document the symbol Visibility enum) - #134262 (Arbitrary self types v2: adjust diagnostic.) - #134265 (Rename `ty_def_id` so people will stop using it by accident) - #134271 (Arbitrary self types v2: better feature gate test) - #134274 (Add check-pass test for `&raw`) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_hir_analysis/src')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/wfcheck.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/errors.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs | 5 |
3 files changed, 19 insertions, 4 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 57264d0bd2a..e6ef29de965 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -1748,9 +1748,15 @@ fn check_method_receiver<'tcx>( // Report error; would not have worked with `arbitrary_self_types[_pointers]`. { match receiver_validity_err { - ReceiverValidityError::DoesNotDeref => { + ReceiverValidityError::DoesNotDeref if arbitrary_self_types_level.is_some() => { tcx.dcx().emit_err(errors::InvalidReceiverTy { span, receiver_ty }) } + ReceiverValidityError::DoesNotDeref => { + tcx.dcx().emit_err(errors::InvalidReceiverTyNoArbitrarySelfTypes { + span, + receiver_ty, + }) + } ReceiverValidityError::MethodGenericParamUsed => { tcx.dcx().emit_err(errors::InvalidGenericReceiverTy { span, receiver_ty }) } diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs index 7f62ccc91f0..5ab6faf3b7c 100644 --- a/compiler/rustc_hir_analysis/src/errors.rs +++ b/compiler/rustc_hir_analysis/src/errors.rs @@ -1656,6 +1656,16 @@ pub(crate) struct NonConstRange { } #[derive(Diagnostic)] +#[diag(hir_analysis_invalid_receiver_ty_no_arbitrary_self_types, code = E0307)] +#[note] +#[help(hir_analysis_invalid_receiver_ty_help_no_arbitrary_self_types)] +pub(crate) struct InvalidReceiverTyNoArbitrarySelfTypes<'tcx> { + #[primary_span] + pub span: Span, + pub receiver_ty: Ty<'tcx>, +} + +#[derive(Diagnostic)] #[diag(hir_analysis_invalid_receiver_ty, code = E0307)] #[note] #[help(hir_analysis_invalid_receiver_ty_help)] diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs index 2e227ead14a..6e10450313c 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs @@ -9,7 +9,6 @@ use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_middle::bug; -use rustc_middle::query::Key; use rustc_middle::ty::print::{PrintPolyTraitRefExt as _, PrintTraitRefExt as _}; use rustc_middle::ty::{ self, AdtDef, Binder, GenericParamDefKind, TraitRef, Ty, TyCtxt, TypeVisitableExt, @@ -1007,8 +1006,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { )), .. }) = node - && let Some(ty_def_id) = qself_ty.ty_def_id() - && let [inherent_impl] = tcx.inherent_impls(ty_def_id) + && let Some(adt_def) = qself_ty.ty_adt_def() + && let [inherent_impl] = tcx.inherent_impls(adt_def.did()) && let name = format!("{ident2}_{ident3}") && let Some(ty::AssocItem { kind: ty::AssocKind::Fn, .. }) = tcx .associated_items(inherent_impl) |
