1
Fork 0

Auto merge of #122119 - estebank:issue-117846, r=Nadrieril

Silence unecessary !Sized binding error

When gathering locals, we introduce a `Sized` obligation for each
binding in the pattern. *After* doing so, we typecheck the init
expression. If this has a type failure, we store `{type error}`, for
both the expression and the pattern. But later we store an inference
variable for the pattern.

We now avoid any override of an existing type on a hir node when they've
already been marked as `{type error}`, and on E0277, when it comes from
`VariableType` we silence the error in support of the type error.

Fix https://github.com/rust-lang/rust/issues/117846
This commit is contained in:
bors 2024-03-20 02:36:37 +00:00
commit b7dcabe55e
6 changed files with 94 additions and 1 deletions

View file

@ -568,6 +568,11 @@ impl<'a, V> LocalTableInContextMut<'a, V> {
self.data.get_mut(&id.local_id)
}
pub fn get(&mut self, id: hir::HirId) -> Option<&V> {
validate_hir_id_for_typeck_results(self.hir_owner, id);
self.data.get(&id.local_id)
}
pub fn entry(&mut self, id: hir::HirId) -> Entry<'_, hir::ItemLocalId, V> {
validate_hir_id_for_typeck_results(self.hir_owner, id);
self.data.entry(id.local_id)