about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2022-06-14Make ResolverAstLowering a struct.Camille GILLOT-149/+206
2022-06-11Address commentsMichael Goulet-2/+0
2022-06-11Handle empty where-clause betterMichael Goulet-2/+4
2022-06-07Extract lower_generic_and_bounds functionSantiago Pastorino-32/+47
2022-06-07Extract lower_generic_param_kindSantiago Pastorino-12/+19
2022-06-07Instrument important fns in AST loweringSantiago Pastorino-2/+13
2022-06-04Rollup merge of #97702 - cjgillot:no-universal-did, r=spastorinoMatthias Krüger-13/+7
Remove useless LocalDefId in ImplTraitContext::Universal.
2022-06-04Rollup merge of #97656 - EdwinRy:error_ast_low_type_contraint_parentheses, ↵Matthias Krüger-8/+38
r=cjgillot Add a suggestion to replace parentheses with angle brackets on associated trait constraint This implements a requested suggestion FIXME in [`compiler/rustc_ast_lowering/src/lib.rs` ](https://github.com/rust-lang/rust/blob/9598b4b594c97dff66feb93522e22db500deea07/compiler/rustc_ast_lowering/src/lib.rs#L921) The suggestion asks for the parentheses to either be replaced with angle brackets or removed completely depending on whether there are arguments provided within. ![image](https://user-images.githubusercontent.com/20026256/171770414-ab60bfe2-ae27-44b0-964d-9ffcc32a7475.png) ![image](https://user-images.githubusercontent.com/20026256/171770383-ca8a2766-b3aa-43e3-8ba4-ae18874886ce.png) r? `@oli-obk`
2022-06-03Remove useless LocalDefId in ImplTraitContext::Universal.Camille GILLOT-13/+7
2022-06-03Suggest replace parentheses with angle bracketsEdwinRy-8/+38
2022-06-03Manipulate lifetimes by LocalDefId for region resolution.Camille GILLOT-24/+17
2022-06-03Auto merge of #96296 - cjgillot:remove-label-lt-shadow, r=petrochenkovbors-12/+9
Remove label/lifetime shadowing warnings This PR removes some pre-1.0 shadowing warnings for labels and lifetimes. The current behaviour of the compiler is to warn * labels that shadow unrelated labels in the same function --> removed ```rust 'a: loop {} 'a: loop {} // STOP WARNING ``` * labels that shadow enclosing labels --> kept, but only if shadowing is hygienic ```rust 'a: loop { 'a: loop {} // KEEP WARNING } ``` * labels that shadow lifetime --> removed ```rust fn foo<'a>() { 'a: loop {} // STOP WARNING } ``` * lifetimes that shadow labels --> removed ```rust 'a: loop { let b = Box::new(|x: &i8| *x) as Box<dyn for <'a> Fn(&'a i8) -> i8>; // STOP WARNING } ``` * lifetimes that shadow lifetimes --> kept ```rust fn foo<'a>() { let b = Box::new(|x: &i8| *x) as Box<dyn for <'a> Fn(&'a i8) -> i8>; // KEEP WARNING } ``` Closes https://github.com/rust-lang/rust/issues/31745. ----- From `@petrochenkov` in https://github.com/rust-lang/rust/pull/95781#issuecomment-1105199014 > I think we should remove these silly checks entirely. > They were introduced long time ago in case some new language features appear and require this space. > Now we have another mechanism for such language changes - editions, and if "lifetimes in expressions" or something like that needs to be introduced it could be introduced as an edition change. > However, there was no plans to introduce anything like for years, so it's unlikely that even the edition mechanism will be necessary. r? rust-lang/lang
2022-06-03Do not lower generic lifetime params when AST resolution emitted an error.Camille GILLOT-12/+9
2022-06-01instrument lower_fn_declSantiago Pastorino-9/+1
2022-06-01Add debug_assert commentSantiago Pastorino-0/+1
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2022-05-31Remove ImplTraitContext::reborrowSantiago Pastorino-31/+12
2022-05-31derive Copy, Clone, PartialEq, Eq for ImplTraitContextSantiago Pastorino-1/+1
2022-05-31Move lower_generics definition to item.rsSantiago Pastorino-38/+0
2022-05-31Rename add_implicit_generics to lower_genericsSantiago Pastorino-1/+1
2022-05-31Add itctx: ImplTraitContext arg to add_implicit_genericsSantiago Pastorino-2/+10
2022-05-31Take and restore fields in with_hir_id_owner callsSantiago Pastorino-0/+6
2022-05-31Move defs and bounds from Universal to LoweringContextSantiago Pastorino-68/+45
2022-05-22rustc_parse: Move AST -> TokenStream conversion logic to `rustc_ast`Vadim Petrochenkov-35/+3
2022-05-22Rollup merge of #97236 - cjgillot:recover-lifetime-res, r=jackh726Yuki Okushi-11/+9
Recover when resolution did not resolve lifetimes. This can happen for items inside a foreign fn's body, which are not visited at all. Fixes https://github.com/rust-lang/rust/issues/97193 Fixes https://github.com/rust-lang/rust/issues/97194
2022-05-21Recover when resolution did not resolve lifetimes.Camille GILLOT-11/+9
2022-05-20Remove `crate` visibility usage in compilerJacob Pratt-1/+0
2022-05-08Auto merge of #96770 - flip1995:fix-trait-type-in-bounds, r=cjgillotbors-0/+1
Track if a where bound comes from a impl Trait desugar With https://github.com/rust-lang/rust/pull/93803 `impl Trait` function arguments get desugared to hidden where bounds. However, Clippy needs to know if a bound was originally a `impl Trait` or an actual bound. This adds a field to the `WhereBoundPredicate` struct to keep track of this information during AST->HIR lowering. r? `@cjgillot` cc `@estebank` (as the reviewer of #93803)
2022-05-07Track if a where bound comes from a impl Trait desugarflip1995-0/+1
With #93803 `impl Trait` function arguments get desugared to hidden where bounds. However, Clippy needs to know if a bound was originally a impl Trait or an actual bound. This adds a field to the `WhereBoundPredicate` struct to keep track of this information during HIR lowering.
2022-05-07Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errorsbors-1/+1
Begin fixing all the broken doctests in `compiler/` Begins to fix #95994. All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are. There are also a few that I marked `ignore` that could maybe be made to work but seem less important. Each `ignore` has a rough "reason" for ignoring after it parentheses, with - `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax" - `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy. - `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR. - `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup. Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful. I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-04Auto merge of #96546 - nnethercote:overhaul-MacArgs, r=petrochenkovbors-32/+18
Overhaul `MacArgs` Motivation: - Clarify some code that I found hard to understand. - Eliminate one use of three places where `TokenKind::Interpolated` values are created. r? `@petrochenkov`
2022-05-05Overhaul `MacArgs::Eq`.Nicholas Nethercote-16/+16
The value in `MacArgs::Eq` is currently represented as a `Token`. Because of `TokenKind::Interpolated`, `Token` can be either a token or an arbitrary AST fragment. In practice, a `MacArgs::Eq` starts out as a literal or macro call AST fragment, and then is later lowered to a literal token. But this is very non-obvious. `Token` is a much more general type than what is needed. This commit restricts things, by introducing a new type `MacArgsEqKind` that is either an AST expression (pre-lowering) or an AST literal (post-lowering). The downside is that the code is a bit more verbose in a few places. The benefit is that makes it much clearer what the possibilities are (though also shorter in some other places). Also, it removes one use of `TokenKind::Interpolated`, taking us a step closer to removing that variant, which will let us make `Token` impl `Copy` and remove many "handle Interpolated" code paths in the parser. Things to note: - Error messages have improved. Messages like this: ``` unexpected token: `"bug" + "found"` ``` now say "unexpected expression", which makes more sense. Although arbitrary expressions can exist within tokens thanks to `TokenKind::Interpolated`, that's not obvious to anyone who doesn't know compiler internals. - In `parse_mac_args_common`, we no longer need to collect tokens for the value expression.
2022-05-02fix most compiler/ doctestsElliot Roberts-1/+1
2022-04-30Save colon span to suggest bounds.Camille GILLOT-0/+5
2022-04-30Store all generic bounds as where predicates.Camille GILLOT-38/+50
2022-04-30Inline WhereClause into Generics.Camille GILLOT-2/+4
2022-04-30Box HIR Generics and Impl.Camille GILLOT-5/+5
2022-04-29Simplify `lower_mac_args`.Nicholas Nethercote-28/+14
The `token` is always an interpolated non-terminal expression, and always a literal in valid code. This commit simplifies the processing accordingly, by directly extracting and using the literal.
2022-04-28rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`Vadim Petrochenkov-2/+2
2022-04-27Auto merge of #91557 - cjgillot:ast-lifetimes-named, r=petrochenkovbors-738/+426
Perform lifetime resolution on the AST for lowering Lifetime resolution is currently implemented several times. Once during lowering in order to introduce in-band lifetimes, and once in the resolve_lifetimes query. However, due to the global nature of lifetime resolution and how it interferes with hygiene, it is better suited on the AST. This PR implements a first draft of lifetime resolution on the AST. For now, we specifically target named lifetimes and everything we need to remove lifetime resolution from lowering. Some diagnostics have already been ported, and sometimes made more precise using available hygiene information. Follow-up PRs will address in particular the resolution of anonymous lifetimes on the AST. We reuse the rib design of the current resolution framework. Specific `LifetimeRib` and `LifetimeRibKind` types are introduced. The most important variant is `LifetimeRibKind::Generics`, which happens each time we encounter something which may introduce generic lifetime parameters. It can be an item or a `for<...>` binder. The `LifetimeBinderKind` specifies how this rib behaves with respect to in-band lifetimes. r? `@petrochenkov`
2022-04-27Collect extra lifetime parameters during late resolution.Camille GILLOT-150/+72
2022-04-27Refactor generic collection.Camille GILLOT-52/+33
2022-04-27Create a specific struct for lifetime capture.Camille GILLOT-112/+147
2022-04-27Handle TAIT.Camille GILLOT-83/+18
2022-04-27Use LifetimeRes during lowering.Camille GILLOT-594/+409
2022-04-23Drop vis in Item.Camille GILLOT-2/+2
2022-04-17Lint elided lifetimes in path on the AST.Camille GILLOT-10/+9
2022-04-17Report undeclared lifetimes on AST.Camille GILLOT-19/+6
2022-04-04diagnostics: use correct span for const genericsMichael Howell-1/+1
Fixes #95616
2022-03-31Record item-likes in ItemLowerer.Camille GILLOT-13/+12
2022-03-31Create a new LoweringContext for each item-like.Camille GILLOT-37/+13