mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
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
This commit is contained in:
commit
b080a1a4fc
@ -89,6 +89,20 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
|
|||||||
ecx: &mut EvalCtxt<'_, 'tcx>,
|
ecx: &mut EvalCtxt<'_, 'tcx>,
|
||||||
goal: Goal<'tcx, Self>,
|
goal: Goal<'tcx, Self>,
|
||||||
) -> QueryResult<'tcx> {
|
) -> 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(
|
ecx.probe_and_evaluate_goal_for_constituent_tys(
|
||||||
goal,
|
goal,
|
||||||
structural_traits::instantiate_constituent_tys_for_auto_trait,
|
structural_traits::instantiate_constituent_tys_for_auto_trait,
|
||||||
|
8
tests/ui/traits/new-solver/unsafe-auto-trait-impl.rs
Normal file
8
tests/ui/traits/new-solver/unsafe-auto-trait-impl.rs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// compile-flags: -Ztrait-solver=next
|
||||||
|
// check-pass
|
||||||
|
|
||||||
|
struct Foo(*mut ());
|
||||||
|
|
||||||
|
unsafe impl Sync for Foo {}
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
Reference in New Issue
Block a user