diff options
| author | 许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com> | 2025-08-19 19:45:40 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-19 19:45:40 +0800 |
| commit | 4090d98b6729714d58de5d73588a103fffc8ad4e (patch) | |
| tree | e5ac4f9ca3170bb265588326eaea5a72bd9b167b /compiler/rustc_attr_parsing/src/session_diagnostics.rs | |
| parent | e39295235c0a0fa1cea9d554121f47d9ee1a9163 (diff) | |
| parent | c7cd1b3b9da1ffce791ec33dbcad82559dbc4447 (diff) | |
| download | rust-4090d98b6729714d58de5d73588a103fffc8ad4e.tar.gz rust-4090d98b6729714d58de5d73588a103fffc8ad4e.zip | |
Rollup merge of #145537 - zachs18:metasized-negative-bound-fix, r=davidtwco
Do not consider a `T: !Sized` candidate to satisfy a `T: !MetaSized` obligation.
This example should fail to compile (and does under this PR, with the old and new solvers), but currently compiles successfully ([playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=6e0e5d0ae0cdf0571dea97938fb4a86d)), because (IIUC) the old solver's `lazily_elaborate_sizedness_candidate`/callers and the new solver's `TraitPredicate::fast_reject_assumption`/`match_assumption` consider a `T: _ Sized` candidate to satisfy a `T: _ MetaSized` obligation, for either polarity `_`, when that should only hold for positive polarity.
```rs
#![feature(negative_bounds)]
#![feature(sized_hierarchy)]
use std::marker::MetaSized;
fn foo<T: !MetaSized>() {}
fn bar<T: !Sized + MetaSized>() {
foo::<T>();
//~^ ERROR the trait bound `T: !MetaSized` is not satisfied // error under this PR
}
```
Only observable with the internal-only `feature(negative_bounds)`, so might just be "wontfix".
This example is added as a test in this PR (as well as testing that `foo<()>` and `foo<str>` are disallowed for `fn foo<T: !MetaSized`).
cc `@davidtwco` for `feature(sized_hierarchy)`
Maybe similar to 91c53c9 from <https://github.com/rust-lang/rust/pull/143307>
Diffstat (limited to 'compiler/rustc_attr_parsing/src/session_diagnostics.rs')
0 files changed, 0 insertions, 0 deletions
