mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 08:41:06 +01:00
Remove caching of return slot usage. (#4163)
The caching isn't buying us much, and is adding complexity and divergence between the codepaths for generic and non-generic functions. This means we no longer suppress diagnostics for the second or subsequent time we call a function with an incomplete return type. If we want to add that back, it might be worth considering moving the suppression to `TryToCompleteType` and only diagnosing that a type is incomplete once, regardless of why we're requiring it to be complete.
This commit is contained in:
@@ -51,4 +51,20 @@ auto Function::GetDeclaredReturnType(const File& file,
|
||||
file.insts().Get(return_storage_id).type_id());
|
||||
}
|
||||
|
||||
auto ReturnInfo::ForType(const File& file, TypeId type_id) -> ReturnInfo {
|
||||
if (!type_id.is_valid()) {
|
||||
// Implicit `-> ()` has no return slot.
|
||||
return {.type_id = type_id, .return_slot = ReturnSlot::Absent};
|
||||
}
|
||||
|
||||
if (!file.types().IsComplete(type_id)) {
|
||||
return {.type_id = type_id, .return_slot = ReturnSlot::Incomplete};
|
||||
}
|
||||
|
||||
return {.type_id = type_id,
|
||||
.return_slot = GetInitRepr(file, type_id).has_return_slot()
|
||||
? SemIR::ReturnSlot::Present
|
||||
: SemIR::ReturnSlot::Absent};
|
||||
}
|
||||
|
||||
} // namespace Carbon::SemIR
|
||||
|
||||
Reference in New Issue
Block a user