Commit 3dc22a3
authored
Rollup merge of #158617 - khyperia:gca-syntax-flip, r=BoxyUwU
allow mGCA const arguments to fall back to anon consts
makes good progress on rust-lang/project-const-generics#108
`min_generic_const_args` (mGCA) is all about "is this const lowered to a const item with a body, or, is it "directly" represented and visible in the type system?"
Here's various answers to the question of "can we represent this const arg directly?" - if we answer "no", then we fall back to an anon const (or error, sometimes, depending on context)
on **stable**, the full list of things can be directly represented is (... it's just the one thing)
- paths to generic const parameters
on `main`, under mGCA, **before** this PR:
- absolutely everything, if something cannot be represented directly, compiler error
- `const { }` gives you an escape hatch to go back to being an anon const
on macro**ful** gca, the directly represented things will be:
- paths to const parameters
- `direct_const_arg!` macro
on macro**less** gca, the directly represented things will be:
- paths to const parameters
- `direct_const_arg!` macro (not *particularly* useful under macro**less** gca)
- struct expressions, arrays, blah blah
- currently, paths to *anything*, even if that produces a compiler error later down the line (potential followup work here...)
this PR implements macro**less** gca, with the intent of a quick follow-up introducing a "macroless gca" feature and transitioning `#[feature(min_generic_const_args)]` to be macro**ful** gca
Also of note is that this PR removes the logic to skip generating "fake" DefIds for directly represented AnonConsts under mGCA, we now always generate a DefId when encountering an AnonConst. This lines up with stable, which has a fake AnonConst DefId for a directly represented plain path generic parameter (i.e. the bullet point under the "stable" entry above).
r? @BoxyUwU73 files changed
Lines changed: 672 additions & 359 deletions
File tree
- compiler
- rustc_ast_lowering/src
- rustc_ast_pretty/src/pprust
- state
- rustc_ast/src
- util
- rustc_builtin_macros/src
- assert
- rustc_expand/src
- rustc_hir_analysis/src/collect
- rustc_metadata/src/rmeta
- rustc_parse/src/parser
- rustc_passes/src
- rustc_resolve/src
- rustc_span/src
- library/core/src
- src/tools
- clippy/clippy_utils/src
- rustfmt
- src
- tests
- source
- target
- tests
- pretty
- ui
- const-generics
- generic_const_exprs/assoc_const_unification
- mgca
- auxiliary
- delegation
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1378 | 1378 | | |
1379 | 1379 | | |
1380 | 1380 | | |
1381 | | - | |
1382 | | - | |
1383 | | - | |
1384 | | - | |
1385 | | - | |
1386 | | - | |
1387 | | - | |
1388 | | - | |
1389 | | - | |
1390 | 1381 | | |
1391 | 1382 | | |
1392 | 1383 | | |
| |||
1396 | 1387 | | |
1397 | 1388 | | |
1398 | 1389 | | |
1399 | | - | |
1400 | 1390 | | |
1401 | 1391 | | |
1402 | 1392 | | |
| |||
1627 | 1617 | | |
1628 | 1618 | | |
1629 | 1619 | | |
| 1620 | + | |
1630 | 1621 | | |
1631 | 1622 | | |
1632 | 1623 | | |
| |||
1920 | 1911 | | |
1921 | 1912 | | |
1922 | 1913 | | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
1923 | 1917 | | |
1924 | 1918 | | |
1925 | 1919 | | |
| |||
2566 | 2560 | | |
2567 | 2561 | | |
2568 | 2562 | | |
| 2563 | + | |
| 2564 | + | |
2569 | 2565 | | |
2570 | 2566 | | |
2571 | 2567 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
158 | 159 | | |
159 | 160 | | |
160 | 161 | | |
| |||
240 | 241 | | |
241 | 242 | | |
242 | 243 | | |
| 244 | + | |
243 | 245 | | |
244 | 246 | | |
245 | 247 | | |
| |||
301 | 303 | | |
302 | 304 | | |
303 | 305 | | |
| 306 | + | |
| 307 | + | |
304 | 308 | | |
305 | | - | |
306 | | - | |
| 309 | + | |
307 | 310 | | |
308 | 311 | | |
309 | 312 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
421 | | - | |
422 | 421 | | |
423 | 422 | | |
424 | 423 | | |
| |||
1074 | 1073 | | |
1075 | 1074 | | |
1076 | 1075 | | |
| 1076 | + | |
| 1077 | + | |
1077 | 1078 | | |
1078 | 1079 | | |
1079 | 1080 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
498 | 498 | | |
499 | 499 | | |
500 | 500 | | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
501 | 513 | | |
502 | 514 | | |
503 | 515 | | |
| |||
599 | 611 | | |
600 | 612 | | |
601 | 613 | | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
| 614 | + | |
607 | 615 | | |
608 | 616 | | |
609 | 617 | | |
| |||
0 commit comments