about summary refs log tree commit diff
path: root/src/librustc/hir
AgeCommit message (Collapse)AuthorLines
2019-04-26Auto merge of #60167 - varkor:tidy-filelength, r=matthewjasperbors-0/+2
Add a tidy check for files with over 3,000 lines Files with a large number of lines can cause issues in GitHub (e.g. https://github.com/rust-lang/rust/issues/60015) and also tend to be indicative of opportunities to refactor into less monolithic structures. This adds a new check to tidy to warn against files that have more than 3,000 lines, as suggested in https://github.com/rust-lang/rust/issues/60015#issuecomment-483868594. (This number was chosen fairly arbitrarily as a reasonable indicator of size.) This check can be ignored with `// ignore-tidy-filelength`. Existing files with greater than 3,000 lines currently ignore the check, but this helps us spot when files are getting too large. (We might try to split up all files larger than this in the future, as in https://github.com/rust-lang/rust/issues/60015).
2019-04-25ignore-tidy-filelength on all files with greater than 3000 linesvarkor-0/+2
2019-04-25Introduce hir::ExprKind::Use and employ in for loop desugaring.Mazdak Farrokhzad-42/+65
Here, ExprKind::Use(P<Expr>) tweaks the drop order to act the same way as '{ let _tmp = expr; _tmp }' does.
2019-04-25Auto merge of #59042 - ljedrz:HirIdification_rework_map, r=Zoxcbors-175/+160
HirIdification: rework Map The next iteration of HirIdification (#57578). - remove `NodeId` from `Entry` - change `Map::map` to an `FxHashMap<HirId, Entry>` - base the `NodeId` `Map` methods on `HirId` ones (reverses the current state) - HirIdify `librustdoc` a little bit (some `NodeId` `Map` methods were converted to work on `HirId`s) The second change might have performance implications, so I'd do a perf run to be sure it's fine; it simplifies the codebase and shouldn't have an impact as long as the `Map` searches are cached (which is now possible thanks to using `HirId`s). r? @Zoxc
2019-04-24hir: make NodeId methods depend on HirId onesljedrz-118/+102
2019-04-24hir: remove NodeId from Entry & simplify Mapljedrz-78/+79
2019-04-23Rollup merge of #59823 - davidtwco:issue-54716, r=cramertjMazdak Farrokhzad-64/+206
[wg-async-await] Drop `async fn` arguments in async block Fixes #54716. This PR modifies the HIR lowering (and some other places to make this work) so that unused arguments to a async function are always dropped inside the async move block and not at the end of the function body. ``` async fn foo(<pattern>: <type>) { async move { } } // <-- dropped as you "exit" the fn // ...becomes... fn foo(__arg0: <ty>) { async move { let <pattern>: <ty> = __arg0; } // <-- dropped as you "exit" the async block } ``` However, the exact ordering of drops is not the same as a regular function, [as visible in this playground example](https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=be39af1a58e5d430be1eb3c722cb1ec3) - I believe this to be an unrelated issue. There is a [Zulip topic](https://rust-lang.zulipchat.com/#narrow/stream/187312-t-compiler.2Fwg-async-await/topic/.2354716.20drop.20order) for this. r? @cramertj cc @nikomatsakis
2019-04-21Correct lowering order to avoid ICE after rebase.David Wood-11/+17
This commit changes the order that arguments and bodies of async functions are lowered so that when the body attempts to `lower_def` of a upvar then the id has already been assigned by lowering the argument first.
2019-04-21Introduce `ArgSource` for diagnostics.David Wood-0/+39
This commit introduces an `ArgSource` enum that is lowered into the HIR so that diagnostics can correctly refer to the argument pattern's original name rather than the generated pattern.
2019-04-21Enforce consistent drop order w/ async methods.David Wood-9/+27
This commit extends the previous commit to apply to trait methods as well as free functions.
2019-04-21Move `async fn` arguments into closure.David Wood-31/+91
This commit takes advantage of `AsyncArgument` type that was added in a previous commit to replace the arguments of the `async fn` in the HIR and add statements to move the bindings from the new arguments to the pattern from the old argument. For example, the async function `foo` below: async fn foo((x, _y): (T, V)) { async move { } } becomes: async fn foo(__arg0: (T, V)) { async move { let (x, _y) = __arg0; } }
2019-04-21Add `AsyncArgument` to AST.David Wood-17/+18
This commit adds an `AsyncArgument` struct to the AST that contains the generated argument and statement that will be used in HIR lowering, name resolution and def collection.
2019-04-21AST/HIR: Use `Mutability` instead of bool in foreign staticsVadim Petrochenkov-5/+4
2019-04-21Remove mutability from `Def::Static`Vadim Petrochenkov-5/+5
2019-04-21Introduce `LocalSource` into the AST.David Wood-1/+19
This will be used to keep track of the origin of a local in the AST. In particular, it will be used by `async fn` lowering for the locals in `let <pat>: <ty> = __arg0;` statements.
2019-04-20Refactor some existing methodsvarkor-15/+3
2019-04-20Add a `header` method to `FnKind`varkor-0/+8
2019-04-17Point at try `?` on errors affecting the err match arm of the desugared codeEsteban Küber-7/+15
2019-04-14HirIdify hir::Defljedrz-52/+203
2019-04-11Auto merge of #59227 - Zoxc:fix-get, r=eddybbors-3/+3
Fix lifetime on LocalInternedString::get function cc @eddyb @nnethercote
2019-04-05Move match_path from DefId to lint::LateContextflip1995-104/+2
2019-04-03Uplift match_def_path from Clippyflip1995-3/+104
2019-04-01Refactor async fn return type loweringTaylor Cramer-285/+394
async fn now lowers directly to an existential type declaration rather than reusing the `impl Trait` return type lowering. As part of this, it lowers all argument-position elided lifetimes using the in-band-lifetimes machinery, creating fresh parameter names for each of them, using each lifetime parameter as a generic argument to the generated existential type. This doesn't currently successfully allow multiple argument-position elided lifetimes since `existential type` doesn't yet support multiple lifetimes where neither outlive the other. This requires a separate fix.
2019-03-31Convert symbols to strings for pretty printingJohn Kåre Alsaker-3/+3
2019-03-29Rollup merge of #59510 - varkor:rename-type_parameters, r=eddybMazdak Farrokhzad-8/+8
Rename `type_parameters` to `generics` and so on Some old variable names had fallen through the generics generalisation pull requests.
2019-03-29Rename `type_parameters` to `generics` and so onvarkor-8/+8
2019-03-28Rollup merge of #59091 - Zoxc:eval_always, r=michaelwoeristerMazdak Farrokhzad-1/+1
Combine input and eval_always query types Hardcoding `Krate` as a dependency of `eval_always` queries doesn't really make sense if we want to use the query system before HIR lowering / hashing. Without that hardcoding they become pretty much identical to `input` queries, so I combined them to a single type. This will regress the `clean` incremental scenario, but that isn't terribly common. r? @michaelwoerister
2019-03-28Rollup merge of #59413 - Zoxc:hirid, r=oli-obkMazdak Farrokhzad-59/+84
HirIdify hir::ItemId Version of https://github.com/rust-lang/rust/pull/59092. r? @oli-obk
2019-03-26Combine input and eval_always query typesJohn Kåre Alsaker-1/+1
2019-03-25Make more lints incrementalJohn Kåre Alsaker-1/+2
2019-03-25Make some lints incrementalJohn Kåre Alsaker-4/+4
2019-03-25Allocate HIR id counters on demandJohn Kåre Alsaker-18/+13
2019-03-25Allocate HIR id counters for use trees in MiscCollectorJohn Kåre Alsaker-15/+42
2019-03-25Auto merge of #59256 - petrochenkov:derval2, r=Zoxcbors-10/+2
Make meta-item API compatible with `LocalInternedString::get` soundness fix r? @Zoxc
2019-03-25hir: replace NodeId with HirId in ItemIdljedrz-35/+38
2019-03-25Auto merge of #59195 - estebank:for-loop-move, r=petrochenkovbors-1/+2
When moving out of a for loop head, suggest borrowing it When encountering code like the following, suggest borrowing the for loop head to avoid moving it into the for loop pattern: ``` fn main() { let a = vec![1, 2, 3]; for i in &a { for j in a { println!("{} * {} = {}", i, j, i * j); } } } ``` Fix #25534.
2019-03-24When moving out of a for loop head, suggest borrowing itEsteban Küber-1/+2
When encountering code like the following, suggest borrowing the for loop head to avoid moving it into the for loop pattern: ``` fn main() { let a = vec![1, 2, 3]; for i in &a { for j in a { println!("{} * {} = {}", i, j, i * j); } } } ```
2019-03-24Re-order fields in `Def::Ctor`.David Wood-10/+10
This commit moves the `DefId` field of `Def::Ctor` to be the first field.
2019-03-24Move `CtorOf` into `hir::def`.David Wood-20/+20
This commit moves the definition of `CtorOf` from `rustc::hir` to `rustc::hir::def` and adds imports wherever it is used.
2019-03-24Remove `CtorOf` from `Node::Ctor`.David Wood-14/+16
This commit removes `CtorOf` from `Node::Ctor` as the parent of the constructor can be determined by looking at the node's parent in the few places where knowing this is necessary.
2019-03-24Merge `DefPathData::VariantCtor` and `DefPathData::StructCtor`Vadim Petrochenkov-16/+6
2019-03-24Slightly more uniform treatment of struct and variant constructorsVadim Petrochenkov-5/+3
2019-03-24Remove methods is_struct/is_tuple/is_unit from VariantDataVadim Petrochenkov-59/+35
2019-03-24Separate variant id and variant constructor id.David Wood-77/+121
This commit makes two changes - separating the `NodeId` that identifies an enum variant from the `NodeId` that identifies the variant's constructor; and no longer creating a `NodeId` for `Struct`-style enum variants and structs. Separation of the variant id and variant constructor id will allow the rest of RFC 2008 to be implemented by lowering the visibility of the variant's constructor without lowering the visbility of the variant itself. No longer creating a `NodeId` for `Struct`-style enum variants and structs mostly simplifies logic as previously this `NodeId` wasn't used. There were various cases where the `NodeId` wouldn't be used unless there was an unit or tuple struct or enum variant but not all uses of this `NodeId` had that condition, by removing this `NodeId`, this must be explicitly dealt with. This change mostly applied cleanly, but there were one or two cases in name resolution and one case in type check where the existing logic required a id for `Struct`-style enum variants and structs.
2019-03-23Auto merge of #59068 - ljedrz:kill_off_NodeId_stragglers, r=Zoxcbors-21/+6
HirIdification: kill off NodeId stragglers The final stages of HirIdification (#57578). This PR, along with https://github.com/rust-lang/rust/pull/59042, should finalize the HirIdification process (at least the more straightforward bits). - replace `NodeId` with `HirId` in `trait_impls` - remove all `NodeId`s from `borrowck` - remove all `NodeId`s from `typeck` - remove all `NodeId`s from `mir` - remove `trait_auto_impl` (unused) I would be cool to also remove `NodeId` from `hir::def::Def`, `middle::privacy::AccessLevel` and `hir::ItemId`, but I don't know if this is feasible. I'll be happy to do more if I've missed anything.
2019-03-22Rollup merge of #59273 - llogiq:hir-docs, r=matthewjasperMazdak Farrokhzad-1/+12
some small HIR doc improvements
2019-03-22Rollup merge of #59266 - estebank:struct-parse-recovery, r=petrochenkovMazdak Farrokhzad-3/+4
Do not complain about non-existing fields after parse recovery When failing to parse struct-like enum variants, the ADT gets recorded as having no fields. Record that we have actually recovered during parsing of this variant to avoid complaing about non-existing fields when actually using it. Fix #57361.
2019-03-19review commentsEsteban Küber-1/+1
2019-03-19Update src/librustc/hir/mod.rsMazdak Farrokhzad-1/+1
Co-Authored-By: llogiq <bogusandre@gmail.com>
2019-03-18Rename typarams to param_namesvarkor-2/+2
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>