Don't ICE when codegen_select returns ambiguity in new solver
This commit is contained in:
parent
1c84675e1f
commit
cc606174a6
4 changed files with 22 additions and 19 deletions
|
@ -101,18 +101,11 @@ fn resolve_associated_item<'tcx>(
|
||||||
|
|
||||||
let vtbl = match tcx.codegen_select_candidate((param_env, trait_ref)) {
|
let vtbl = match tcx.codegen_select_candidate((param_env, trait_ref)) {
|
||||||
Ok(vtbl) => vtbl,
|
Ok(vtbl) => vtbl,
|
||||||
Err(CodegenObligationError::Ambiguity) => {
|
Err(
|
||||||
let reported = tcx.dcx().span_delayed_bug(
|
CodegenObligationError::Ambiguity
|
||||||
tcx.def_span(trait_item_id),
|
| CodegenObligationError::Unimplemented
|
||||||
format!(
|
| CodegenObligationError::FulfillmentError,
|
||||||
"encountered ambiguity selecting `{trait_ref:?}` during codegen, presuming due to \
|
) => return Ok(None),
|
||||||
overflow or prior type error",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return Err(reported);
|
|
||||||
}
|
|
||||||
Err(CodegenObligationError::Unimplemented) => return Ok(None),
|
|
||||||
Err(CodegenObligationError::FulfillmentError) => return Ok(None),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Now that we know which impl is being used, we can dispatch to
|
// Now that we know which impl is being used, we can dispatch to
|
||||||
|
|
|
@ -19,5 +19,4 @@ impl TraitB for B { //~ ERROR not all trait items implemented, missing: `MyA`
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = [0; B::VALUE];
|
let _ = [0; B::VALUE];
|
||||||
//~^ constant
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,6 @@ LL | type MyA: TraitA;
|
||||||
LL | impl TraitB for B {
|
LL | impl TraitB for B {
|
||||||
| ^^^^^^^^^^^^^^^^^ missing `MyA` in implementation
|
| ^^^^^^^^^^^^^^^^^ missing `MyA` in implementation
|
||||||
|
|
||||||
note: erroneous constant encountered
|
|
||||||
--> $DIR/issue-69602-type-err-during-codegen-ice.rs:21:17
|
|
||||||
|
|
|
||||||
LL | let _ = [0; B::VALUE];
|
|
||||||
| ^^^^^^^^
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0046, E0437.
|
Some errors have detailed explanations: E0046, E0437.
|
||||||
|
|
17
tests/ui/traits/next-solver/ambiguous-impl-in-resolve.rs
Normal file
17
tests/ui/traits/next-solver/ambiguous-impl-in-resolve.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
//@ check-pass
|
||||||
|
//@ compile-flags: -Znext-solver
|
||||||
|
|
||||||
|
trait Local {}
|
||||||
|
|
||||||
|
trait Overlap { fn f(); }
|
||||||
|
impl<T> Overlap for Option<T> where Self: Clone, { fn f() {} }
|
||||||
|
impl<T> Overlap for Option<T> where Self: Local, { fn f() {} }
|
||||||
|
|
||||||
|
fn test<T>()
|
||||||
|
where
|
||||||
|
Option<T>: Clone + Local,
|
||||||
|
{
|
||||||
|
<Option<T> as Overlap>::f();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
Add table
Add a link
Reference in a new issue