about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src
AgeCommit message (Collapse)AuthorLines
2022-06-14Separate `source_span` and `expn_that_defined` from `Definitions`.Camille GILLOT-50/+17
2022-06-14Do not modify the resolver outputs.Camille GILLOT-75/+83
2022-06-14Make ResolverAstLowering a struct.Camille GILLOT-160/+228
2022-06-13remove unnecessary `to_string` and `String::new`Takayuki Maeda-2/+2
2022-06-11Address commentsMichael Goulet-4/+0
2022-06-11Handle empty where-clause betterMichael Goulet-4/+8
2022-06-12Make `ExprKind::Closure` a struct variant.Camille GILLOT-20/+20
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-6/+18
2022-06-04Compute lifetimes in scope at diagnostic time.Camille GILLOT-0/+7
2022-06-04Auto merge of #97717 - matthiaskrgr:rollup-lalaii2, r=matthiaskrgrbors-25/+49
Rollup of 5 pull requests Successful merges: - #97446 (Make hir().get_generics and generics_of consistent.) - #97656 (Add a suggestion to replace parentheses with angle brackets on associated trait constraint) - #97692 (Add `#T-types/nominated` zulip notification) - #97696 (Do not ICE when failing to normalize during inlining.) - #97702 (Remove useless LocalDefId in ImplTraitContext::Universal.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-06-03Auto merge of #97670 - spastorino:simplify-universal-impl-trait-lowering2, ↵bors-1/+2
r=Dylan-DPC Make params be SmallVec as originally was r? `@cjgillot` It was originally a [`SmallVec`](https://github.com/rust-lang/rust/pull/97598/files#diff-0a61b538a3cec072c76fecae4635af6a12ec3256860029ac70549c2aa53ab394L1497), I've mistakenly changed it [here](https://github.com/rust-lang/rust/pull/97598/files#diff-0a61b538a3cec072c76fecae4635af6a12ec3256860029ac70549c2aa53ab394R1377) to a `Vec`
2022-06-04Rollup merge of #97702 - cjgillot:no-universal-did, r=spastorinoMatthias Krüger-17/+11
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-17/+11
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-02Make params be SmallVec as originally wasSantiago Pastorino-1/+2
2022-06-02Auto merge of #97598 - spastorino:simplify-universal-impl-trait-lowering, ↵bors-267/+194
r=cjgillot Simplify universal impl trait lowering Closes #96644 r? `@cjgillot`
2022-06-01Always assert that impl_trait_def|bounds are empty at startSantiago Pastorino-7/+2
2022-06-01instrument lower_fn_declSantiago Pastorino-9/+1
2022-06-01Split extend + inner chain into to extend callsSantiago Pastorino-8/+5
2022-06-01Add debug_assert commentSantiago Pastorino-0/+1
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2022-06-01Remove #[rustc_box] attr during loweringest31-3/+6
2022-06-01Add #[rustc_box]est31-1/+13
This commit adds an alternative content boxing syntax, and uses it inside alloc. The usage inside the very performance relevant code in liballoc is the only remaining relevant usage of box syntax in the compiler (outside of tests, which are comparatively easy to port). box syntax was originally designed to be used by all Rust developers. This introduces a replacement syntax more tailored to only being used inside the Rust compiler, and with it, lays the groundwork for eventually removing box syntax.
2022-05-31Fix lower_generics rustdocsSantiago Pastorino-3/+2
2022-05-31Inline lower_generics_mut and remove GenericsCtorSantiago Pastorino-54/+29
2022-05-31Remove ImplTraitContext::reborrowSantiago Pastorino-42/+21
2022-05-31derive Copy, Clone, PartialEq, Eq for ImplTraitContextSantiago Pastorino-1/+1
2022-05-31Move lower_generics definition to item.rsSantiago Pastorino-38/+38
2022-05-31Rename add_implicit_generics to lower_genericsSantiago Pastorino-18/+17
2022-05-31Replace calls to lower_generics with calls to add_implicit_genericsSantiago Pastorino-89/+87
2022-05-31Add itctx: ImplTraitContext arg to add_implicit_genericsSantiago Pastorino-9/+22
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-87/+60
2022-05-22rustc_parse: Move AST -> TokenStream conversion logic to `rustc_ast`Vadim Petrochenkov-38/+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-11/+14
2022-05-18Auto merge of #96863 - SparrowLii:let, r=michaelwoeristerbors-2/+8
use `hir::Let` in `hir::Guard::IfLet` This PR fixes the FIXME about using `hir::Let` in `hir::Guard::IfLet`
2022-05-09use hir::Let in hir::GuardSparrowLii-2/+8
2022-05-08Auto merge of #96770 - flip1995:fix-trait-type-in-bounds, r=cjgillotbors-3/+12
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-3/+12
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-4/+4
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-03Auto merge of #95380 - compiler-errors:unit-destructure-assign, r=nikomatsakisbors-0/+37
Fix unit struct/enum variant in destructuring assignment See https://github.com/rust-lang/rfcs/blob/master/text/2909-destructuring-assignment.md#guide-level-explanation, "including **unit** and tuple structs" Fixes #94319