rust/compiler/rustc_borrowck/src
bors ed49386d3a 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)
2025-02-19 07:49:08 +00:00
..
constraints Reduce visibilities. 2024-11-04 15:43:45 +11:00
diagnostics Rollup merge of #137213 - nnethercote:rm-rustc_middle-mir-tcx, r=compiler-errors 2025-02-19 01:30:13 +01:00
polonius Rollup merge of #136299 - lqd:polonius-next-episode-9, r=jackh726 2025-02-03 21:11:34 +01:00
region_infer eval_outlives: bail out early if both regions are in the same SCC 2025-02-18 13:02:05 +01:00
type_check Auto merge of #136539 - matthewjasper:late-normalize-errors, r=compiler-errors 2025-02-19 07:49:08 +00:00
borrow_set.rs rename BitSet to DenseBitSet 2025-01-11 11:34:01 +00:00
borrowck_errors.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
consumers.rs rename AllFacts to PoloniusFacts 2025-01-08 13:23:54 +00:00
dataflow.rs move out of scope precomputer code 2025-01-12 07:39:20 +00:00
def_use.rs Rollup merge of #126013 - nnethercote:unreachable_pub, r=Urgau 2024-08-27 00:41:57 +02:00
lib.rs Rollup merge of #137213 - nnethercote:rm-rustc_middle-mir-tcx, r=compiler-errors 2025-02-19 01:30:13 +01:00
member_constraints.rs remove non-borrowck member constraints 2024-12-20 10:04:01 +01:00
nll.rs record boring locals in polonius context 2025-01-31 11:04:50 +00:00
path_utils.rs remove borrowck duplicate of std::ops::ControlFlow 2025-01-01 12:13:33 +00:00
place_ext.rs Remove #[macro_use] extern crate tracing from rustc_borrowck. 2024-08-30 17:14:53 +10:00
places_conflict.rs Implement MIR, CTFE, and codegen for unsafe binders 2025-01-31 17:19:53 +00:00
prefixes.rs Implement MIR, CTFE, and codegen for unsafe binders 2025-01-31 17:19:53 +00:00
renumber.rs mir borrowck: cleanup late-bound region handling 2025-01-14 14:16:12 +01:00
session_diagnostics.rs Rework "long type names" printing logic 2025-01-31 20:39:01 +00:00
universal_regions.rs Rollup merge of #135711 - estebank:issue-135649, r=davidtwco 2025-02-18 18:40:49 +01:00
used_muts.rs Remove unnecessary lifetimes in dataflow structs. 2024-09-09 16:14:18 +10:00