Auto merge of #96806 - cjgillot:codegen-fulfill-nice, r=oli-obk
Gracefully fail to resolve associated items instead of `delay_span_bug`. `codegen_fulfill_obligation` is used during instance resolution for trait items. In case of insufficient normalization issues during MIR inlining, it caused ICEs. It's better to gracefully refuse to resolve the associated item, and let the caller decide what to do with this. Split from https://github.com/rust-lang/rust/pull/91743 Closes #69121 Closes #73021 Closes #88599 Closes #93008 Closes #93248 Closes #94680 Closes #96170 r? `@oli-obk`
This commit is contained in:
commit
cb9cb4d4e1
12 changed files with 108 additions and 88 deletions
|
@ -1145,7 +1145,7 @@ rustc_queries! {
|
|||
|
||||
query codegen_fulfill_obligation(
|
||||
key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)
|
||||
) -> Result<&'tcx ImplSource<'tcx, ()>, ErrorGuaranteed> {
|
||||
) -> Result<&'tcx ImplSource<'tcx, ()>, traits::CodegenObligationError> {
|
||||
cache_on_disk_if { true }
|
||||
desc { |tcx|
|
||||
"checking if `{}` fulfills its obligations",
|
||||
|
|
|
@ -963,3 +963,21 @@ pub enum MethodViolationCode {
|
|||
/// the method's receiver (`self` argument) can't be dispatched on
|
||||
UndispatchableReceiver,
|
||||
}
|
||||
|
||||
/// These are the error cases for `codegen_fulfill_obligation`.
|
||||
#[derive(Copy, Clone, Debug, Hash, HashStable, Encodable, Decodable)]
|
||||
pub enum CodegenObligationError {
|
||||
/// Ambiguity can happen when monomorphizing during trans
|
||||
/// expands to some humongous type that never occurred
|
||||
/// statically -- this humongous type can then overflow,
|
||||
/// leading to an ambiguous result. So report this as an
|
||||
/// overflow bug, since I believe this is the only case
|
||||
/// where ambiguity can result.
|
||||
Ambiguity,
|
||||
/// This can trigger when we probe for the source of a `'static` lifetime requirement
|
||||
/// on a trait object: `impl Foo for dyn Trait {}` has an implicit `'static` bound.
|
||||
/// This can also trigger when we have a global bound that is not actually satisfied,
|
||||
/// but was included during typeck due to the trivial_bounds feature.
|
||||
Unimplemented,
|
||||
FulfillmentError,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue