rust/compiler
Guillaume Gomez f4d06256d8
Rollup merge of #119721 - compiler-errors:constness-implication, r=fee1-dead
`~const` trait and projection bounds do not imply their non-const counterparts

This PR removes the hack where we install a non-const trait and projection bound for every `const_trait` and `~const` projection bound we have in the AST. It ends up messing up more things than it fixes, see words below.

Fixes #119718

cc `@fmease` `@fee1-dead` `@oli-obk`
r? fee1-dead or one of y'all i don't care

---

My understanding is that this hack was added to support the following code:

```rust
pub trait Owo<X = <Self as Uwu>::T> {}

#[const_trait]
pub trait Uwu: Owo {}
```

Which is concretely lifted from in the `FromResidual` and `Try` traits. Since within the param-env of `trait Uwu`, we only know that `Self: ~const Uwu` and not `Self: Uwu`, the projection `<Self as Uwu>::T` is not satsifyable.

This causes problems such as #119718, since instantiations of `FnDef` types coming from `const fn` really do **only** implement one of `FnOnce` or `const FnOnce`!

---

In the long-term, I believe that such code should really look something more like:

```rust
#[const_trait]
pub trait Owo<X = <Self as ~const Uwu>::T> {}

#[const_trait]
pub trait Uwu: Owo {}
```

... and that we should introduce some sort of `<T as ~const Foo>::Bar` bound syntax, since due to the fact that `~const` bounds can be present in item bounds, e.g.

```rust
#[const_trait] trait Foo { type Bar: ~const Destruct; }
```

It's easy to see that `<T as Foo>::Bar` and `<T as ~const Foo>::Bar` (or `<T as const Foo>::Bar`) can be distinct types with distinct item bounds!

**Admission**: I know I've said before that I don't like `~const` projection syntax, I do at this point believe they're necessary to fully express bounds and types in a maybe-const world.
2024-01-09 17:52:21 +01:00
..
rustc Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_abi Avoid specialization for the Span Encodable and Decodable impls 2023-12-31 20:42:17 +00:00
rustc_arena rustc_arena: add alloc_str 2023-12-05 17:52:51 -08:00
rustc_ast Auto merge of #119478 - bjorn3:no_serialize_specialization, r=wesleywiser 2024-01-06 09:56:00 +00:00
rustc_ast_lowering Rollup merge of #119705 - fmease:tilde-const-assoc-fns-trait-impls, r=compiler-errors 2024-01-08 00:38:35 +01:00
rustc_ast_passes Make DiagnosticBuilder::emit consuming. 2024-01-08 15:24:49 +11:00
rustc_ast_pretty Auto merge of #119105 - dtolnay:paren, r=WaffleLapkin 2023-12-27 21:27:26 +00:00
rustc_attr Use chaining in DiagnosticBuilder construction. 2024-01-08 15:43:07 +11:00
rustc_baked_icu_data Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_borrowck Use chaining in DiagnosticBuilder construction. 2024-01-08 15:43:07 +11:00
rustc_builtin_macros Use chaining for DiagnosticBuilder construction and emit. 2024-01-08 15:45:29 +11:00
rustc_codegen_cranelift Rollup merge of #117556 - obeis:static-mut-ref-lint, r=davidtwco 2024-01-09 13:23:15 +01:00
rustc_codegen_gcc Update test for E0796 and static_mut_ref lint 2024-01-07 17:29:25 +03:00
rustc_codegen_llvm Rollup merge of #117744 - quininer:add-z-sync-uw, r=bjorn3 2024-01-09 05:33:20 +01:00
rustc_codegen_ssa Rollup merge of #118903 - azhogin:azhogin/skip_second_stmt_debuginfo.rs, r=petrochenkov 2024-01-09 00:19:32 +01:00
rustc_const_eval Rollup merge of #119668 - cjgillot:transform-promote, r=oli-obk 2024-01-09 13:23:17 +01:00
rustc_data_structures Rollup merge of #119527 - klensy:ordering, r=compiler-errors 2024-01-09 13:23:17 +01:00
rustc_driver Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_driver_impl Rollup merge of #118680 - djkoloski:shell_argfiles, r=compiler-errors 2024-01-09 17:52:21 +01:00
rustc_error_codes Rollup merge of #117556 - obeis:static-mut-ref-lint, r=davidtwco 2024-01-09 13:23:15 +01:00
rustc_error_messages Remove rustc_error_messages/messages.ftl. 2023-11-26 08:37:27 +11:00
rustc_errors Remove -Zdont-buffer-diagnostics. 2024-01-09 09:47:36 +11:00
rustc_expand Rollup merge of #119740 - Mark-Simulacrum:drop-crossbeam, r=davidtwco 2024-01-09 00:19:36 +01:00
rustc_feature Rollup merge of #119354 - fmease:negative_bounds-fixes, r=compiler-errors 2024-01-05 20:39:51 +01:00
rustc_fluent_macro Add a useful comment. 2023-11-26 08:38:02 +11:00
rustc_fs_util Clean up rustc_*/Cargo.toml. 2023-10-30 08:46:02 +11:00
rustc_graphviz remove unused pub fn 2023-11-23 14:11:02 +03:00
rustc_hir Auto merge of #117703 - compiler-errors:recursive-async, r=lcnr 2024-01-09 07:20:50 +00:00
rustc_hir_analysis Rollup merge of #119721 - compiler-errors:constness-implication, r=fee1-dead 2024-01-09 17:52:21 +01:00
rustc_hir_pretty Remove hir::Guard 2024-01-05 10:56:59 +00:00
rustc_hir_typeck Rollup merge of #119725 - compiler-errors:has_effect_param, r=fmease 2024-01-09 00:19:36 +01:00
rustc_incremental Split StableCompare trait out of StableOrd trait. 2024-01-04 13:32:42 +01:00
rustc_index Auto merge of #119499 - cjgillot:dtm-opt, r=nnethercote 2024-01-06 11:54:15 +00:00
rustc_index_macros Put backticks around some attributes in doc comments. 2023-11-27 09:37:01 +11:00
rustc_infer Auto merge of #118968 - aliemjay:canon-static, r=lcnr 2024-01-09 09:20:33 +00:00
rustc_interface Rollup merge of #118680 - djkoloski:shell_argfiles, r=compiler-errors 2024-01-09 17:52:21 +01:00
rustc_lexer Rename some unescaping functions. 2023-12-13 14:17:50 +11:00
rustc_lint Rollup merge of #118649 - compiler-errors:coherence-ambig, r=lcnr 2024-01-09 05:33:21 +01:00
rustc_lint_defs Rollup merge of #117556 - obeis:static-mut-ref-lint, r=davidtwco 2024-01-09 13:23:15 +01:00
rustc_llvm Rollup merge of #118941 - krasimirgg:llvm-cov, r=nikic 2023-12-18 17:03:11 +01:00
rustc_log rustc_log: provide a way to init logging based on the values, not names, of the env vars 2023-11-11 15:24:33 +01:00
rustc_macros Auto merge of #119478 - bjorn3:no_serialize_specialization, r=wesleywiser 2024-01-06 09:56:00 +00:00
rustc_metadata Auto merge of #119478 - bjorn3:no_serialize_specialization, r=wesleywiser 2024-01-06 09:56:00 +00:00
rustc_middle Rollup merge of #119699 - cjgillot:simplify-unreachable, r=oli-obk 2024-01-09 13:23:18 +01:00
rustc_mir_build Don't populate yield and resume types after the fact 2024-01-06 18:03:01 +00:00
rustc_mir_dataflow Remove movability from TyKind::Coroutine 2023-12-28 16:35:01 +00:00
rustc_mir_transform Rollup merge of #119699 - cjgillot:simplify-unreachable, r=oli-obk 2024-01-09 13:23:18 +01:00
rustc_monomorphize Rollup merge of #119538 - nnethercote:cleanup-errors-5, r=compiler-errors 2024-01-05 10:57:21 -05:00
rustc_next_trait_solver Remove movability from TyKind::Coroutine 2023-12-28 16:35:01 +00:00
rustc_parse Remove DiagnosticBuilder::delay_as_bug_without_consuming. 2024-01-08 16:07:14 +11:00
rustc_parse_format Removing redudant note from parse error 2024-01-08 19:41:01 +01:00
rustc_passes Remove DiagnosticBuilder::delay_as_bug_without_consuming. 2024-01-08 16:07:14 +11:00
rustc_pattern_analysis Reuse ctor_sub_tys when we have one around 2024-01-06 18:03:13 +01:00
rustc_privacy Remove Session methods that duplicate DiagCtxt methods. 2023-12-24 08:05:28 +11:00
rustc_query_impl Rollup merge of #119527 - klensy:ordering, r=compiler-errors 2024-01-09 13:23:17 +01:00
rustc_query_system Rollup merge of #119527 - klensy:ordering, r=compiler-errors 2024-01-09 13:23:17 +01:00
rustc_resolve Remove all eight DiagnosticBuilder::*_with_code methods. 2024-01-08 16:00:34 +11:00
rustc_serialize Avoid specialization for the Span Encodable and Decodable impls 2023-12-31 20:42:17 +00:00
rustc_session Rollup merge of #118680 - djkoloski:shell_argfiles, r=compiler-errors 2024-01-09 17:52:21 +01:00
rustc_smir Movability doesn't need to be a query anymore 2023-12-28 16:35:01 +00:00
rustc_span Rollup merge of #118903 - azhogin:azhogin/skip_second_stmt_debuginfo.rs, r=petrochenkov 2024-01-09 00:19:32 +01:00
rustc_symbol_mangling Use chaining in DiagnosticBuilder construction. 2024-01-08 15:43:07 +11:00
rustc_target GNU/Hurd: unconditionally use inline stack probes 2024-01-08 21:36:02 -05:00
rustc_trait_selection Auto merge of #118968 - aliemjay:canon-static, r=lcnr 2024-01-09 09:20:33 +00:00
rustc_traits add unused NormalizesTo predicate 2023-12-07 17:52:51 +01:00
rustc_transmute Update itertools to 0.11. 2023-11-22 08:13:21 +11:00
rustc_ty_utils Movability doesn't need to be a query anymore 2023-12-28 16:35:01 +00:00
rustc_type_ir Fix tidy error 2023-12-31 20:58:36 +00:00
stable_mir Restore movability to SMIR 2023-12-28 16:35:01 +00:00