about summary refs log tree commit diff
path: root/compiler/rustc_error_codes
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-02-19 07:49:08 +0000
committerbors <bors@rust-lang.org>2025-02-19 07:49:08 +0000
commited49386d3aa3a445a9889707fd405df01723eced (patch)
tree81435484cd94e7394c9ba062ee513709d64540d8 /compiler/rustc_error_codes
parent5986ff05d8480da038dd161b3a6aa79ff364a851 (diff)
parent49cf00c7c04e24bb27a09fbcfe9bac9278075608 (diff)
downloadrust-ed49386d3aa3a445a9889707fd405df01723eced.tar.gz
rust-ed49386d3aa3a445a9889707fd405df01723eced.zip
Auto merge of #136539 - matthewjasper:late-normalize-errors, r=compiler-errors
Emit dropck normalization errors in borrowck

Borrowck generally assumes that any queries it runs for type checking will succeed, thinking that HIR typeck will have errored first if there was a problem. However as of #98641, dropck isn't run on HIR, so there's no direct guarantee that it doesn't error. While a type being well-formed might be expected to ensure that its fields are well-formed, this is not the case for types containing a type projection:

```rust
pub trait AuthUser {
    type Id;
}

pub trait AuthnBackend {
    type User: AuthUser;
}

pub struct AuthSession<Backend: AuthnBackend> {
    data: Option<<<Backend as AuthnBackend>::User as AuthUser>::Id>,
}

pub trait Authz: Sized {
    type AuthnBackend: AuthnBackend<User = Self>;
}

pub fn run_query<User: Authz>(auth: AuthSession<User::AuthnBackend>) {}
// ^ No User: AuthUser bound is required or inferred.
```

While improvements to trait solving might fix this in the future, for now we go for a pragmatic solution of emitting an error from borrowck (by rerunning dropck outside of a query) and making drop elaboration check if an error has been emitted previously before panicking for a failed normalization.

Closes #103899
Closes #135039

r? `@compiler-errors` (feel free to re-assign)
Diffstat (limited to 'compiler/rustc_error_codes')
0 files changed, 0 insertions, 0 deletions