Dont strip const blocks in array lengths #152234
Open
+61
−88
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
r? oli-obk
mGCA now handles const blocks by always handling them during
lower_expr_to_const_arg_directinstead of sometimes stripping them out at parse time. This is just generally a lot clearer/nicer but also means parsing isn't lossy which is just straight up wrong.We now use
MgcaDisambiguation::Directfor const blocks because we "directly" represent a const block ashir::ConstArgKind::Anon:> The only time that an anon const for const generics usesMgcaDisambiguation::AnonConstis for unbraced literals.Once we properly support literals in
hir::ConstArgKind(see #152139 #152001) thenMgcaDisambiguationcan be renamed toAnonConstKindwithTypeSystemandNonTypeSystemvariants. We can also get rid ofmgca_direct_lit_hack. I expect this to be a very nice cleanup :)Fixes rust-lang/rustfmt#6788
The diff relating to passing spans around is to avoid a bunch of mGCA diagnostics changing from
const {}to{}. I'm not entirely sure why this was happening.cc @rust-lang/rustfmt
How do I run the tests in the rustfmt repo from here?
x test rustfmtonly seems to run like 100 tests and doesn't result in atarget/issue-6788.rsgetting created. I've verified locally that this formats correctly though