diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2023-02-09 23:18:37 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-09 23:18:37 +0530 |
| commit | b080a1a4fc68bc6150a281f21012b79b9f1ee57f (patch) | |
| tree | 1e54719a1d3b2d503d76ad2c7f4bc77d6c51ff45 /compiler/rustc_trait_selection/src | |
| parent | 16a413838720fb1159d9e69f863e48c9184c069e (diff) | |
| parent | 68e27b305290352a21dfec9c6ce2e2e48323f528 (diff) | |
| download | rust-b080a1a4fc68bc6150a281f21012b79b9f1ee57f.tar.gz rust-b080a1a4fc68bc6150a281f21012b79b9f1ee57f.zip | |
Rollup merge of #107815 - compiler-errors:new-solver-no-auto-if-impl, r=lcnr
Disqualify `auto trait` built-in impl in new solver if explicit `impl` exists
Diffstat (limited to 'compiler/rustc_trait_selection/src')
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/trait_goals.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/trait_goals.rs b/compiler/rustc_trait_selection/src/solve/trait_goals.rs index abb69476cae..6554c739b3f 100644 --- a/compiler/rustc_trait_selection/src/solve/trait_goals.rs +++ b/compiler/rustc_trait_selection/src/solve/trait_goals.rs @@ -89,6 +89,20 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> { ecx: &mut EvalCtxt<'_, 'tcx>, goal: Goal<'tcx, Self>, ) -> QueryResult<'tcx> { + // This differs from the current stable behavior and + // fixes #84857. Due to breakage found via crater, we + // currently instead lint patterns which can be used to + // exploit this unsoundness on stable, see #93367 for + // more details. + if let Some(def_id) = ecx.tcx().find_map_relevant_impl( + goal.predicate.def_id(), + goal.predicate.self_ty(), + Some, + ) { + debug!(?def_id, ?goal, "disqualified auto-trait implementation"); + return Err(NoSolution); + } + ecx.probe_and_evaluate_goal_for_constituent_tys( goal, structural_traits::instantiate_constituent_tys_for_auto_trait, |
