diff options
| author | bors <bors@rust-lang.org> | 2023-11-21 02:02:30 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-11-21 02:02:30 +0000 |
| commit | baf4abff314cad946a3b7335024e3e2756e3828b (patch) | |
| tree | 19a553460a6cd9a47777ac907d56e9be2fbcdc49 /compiler/rustc_lint/src | |
| parent | 853492329c70d5604fa4d791ac08a812222dfd94 (diff) | |
| parent | 6c62b42347cbbe4aec3d09491591b7ecb30546e6 (diff) | |
| download | rust-baf4abff314cad946a3b7335024e3e2756e3828b.tar.gz rust-baf4abff314cad946a3b7335024e3e2756e3828b.zip | |
Auto merge of #118107 - matthiaskrgr:rollup-k5bfkfr, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #117327 (Add documentation for some queries) - #117835 (Note about object lifetime defaults in does not live long enough error) - #117851 (Uplift `InferConst` to `rustc_type_ir`) - #117973 (test: Add test for async-move in 2015 Rust proc macro) - #117992 (Don't require intercrate mode for negative coherence) - #118010 (Typeck break expr even if break is illegal) - #118026 (Don't consider regions in `deref_into_dyn_supertrait` lint) - #118089 (intercrate_ambiguity_causes: handle self ty infer + reservation impls) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_lint/src')
| -rw-r--r-- | compiler/rustc_lint/src/deref_into_dyn_supertrait.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs b/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs index d2d99bc0da8..d3e2d5c7646 100644 --- a/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs +++ b/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs @@ -50,7 +50,7 @@ declare_lint! { Warn, "`Deref` implementation usage with a supertrait trait object for output might be shadowed in the future", @future_incompatible = FutureIncompatibleInfo { - reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps, + reason: FutureIncompatibilityReason::FutureReleaseSemanticsChange, reference: "issue #89460 <https://github.com/rust-lang/rust/issues/89460>", }; } @@ -59,12 +59,13 @@ declare_lint_pass!(DerefIntoDynSupertrait => [DEREF_INTO_DYN_SUPERTRAIT]); impl<'tcx> LateLintPass<'tcx> for DerefIntoDynSupertrait { fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) { + let tcx = cx.tcx; // `Deref` is being implemented for `t` if let hir::ItemKind::Impl(impl_) = item.kind && let Some(trait_) = &impl_.of_trait - && let t = cx.tcx.type_of(item.owner_id).instantiate_identity() + && let t = tcx.type_of(item.owner_id).instantiate_identity() && let opt_did @ Some(did) = trait_.trait_def_id() - && opt_did == cx.tcx.lang_items().deref_trait() + && opt_did == tcx.lang_items().deref_trait() // `t` is `dyn t_principal` && let ty::Dynamic(data, _, ty::Dyn) = t.kind() && let Some(t_principal) = data.principal() @@ -73,9 +74,14 @@ impl<'tcx> LateLintPass<'tcx> for DerefIntoDynSupertrait { && let ty::Dynamic(data, _, ty::Dyn) = target.kind() && let Some(target_principal) = data.principal() // `target_principal` is a supertrait of `t_principal` - && supertraits(cx.tcx, t_principal.with_self_ty(cx.tcx, cx.tcx.types.trait_object_dummy_self)) - .any(|sup| sup.map_bound(|x| ty::ExistentialTraitRef::erase_self_ty(cx.tcx, x)) == target_principal) + && supertraits(tcx, t_principal.with_self_ty(tcx, tcx.types.trait_object_dummy_self)) + .any(|sup| { + tcx.erase_regions( + sup.map_bound(|x| ty::ExistentialTraitRef::erase_self_ty(tcx, x)), + ) == tcx.erase_regions(target_principal) + }) { + let t = tcx.erase_regions(t); let label = impl_ .items .iter() @@ -83,7 +89,7 @@ impl<'tcx> LateLintPass<'tcx> for DerefIntoDynSupertrait { .map(|label| SupertraitAsDerefTargetLabel { label }); cx.emit_spanned_lint( DEREF_INTO_DYN_SUPERTRAIT, - cx.tcx.def_span(item.owner_id.def_id), + tcx.def_span(item.owner_id.def_id), SupertraitAsDerefTarget { t, target_principal, label }, ); } |
