about summary refs log tree commit diff
path: root/src/librustc/middle
AgeCommit message (Collapse)AuthorLines
2018-06-20Fix NodeLifetime/NodeGenericParam confusionvarkor-34/+32
2018-06-20Take advantage of the lifetime refactoringvarkor-6/+5
2018-06-20Lift name into GenericParamvarkor-15/+15
2018-06-20Use ParamBounds in WhereRegionPredicatevarkor-9/+7
2018-06-20Lift bounds into GenericParamvarkor-45/+44
2018-06-20Refactor counting methodsvarkor-10/+7
2018-06-20Refactor generic parameters in rustdoc/cleanvarkor-70/+47
2018-06-20Remove all traces of lifetimes() and types() methodsvarkor-162/+155
2018-06-20Remove hir::GenericParam::is_*_paramvarkor-43/+57
2018-06-20Remove specific parameter iterators from hir::Genericsvarkor-45/+97
2018-06-20Refactor hir::GenericParam as a structvarkor-117/+178
2018-06-20Make method and variable names more consistentvarkor-9/+10
2018-06-20Rename "parameter" to "arg"varkor-18/+16
2018-06-20Rename PathParameter(s) to GenericArg(s)varkor-6/+6
2018-06-20Consolidate PathParameters and AngleBracketedParameterDatavarkor-8/+10
2018-06-18Auto merge of #51248 - fabric-and-ink:newtype_index_debrujin, r=nikomatsakisbors-3/+3
Declare DebruijnIndex via newtype_index macro Part of #49887 Declare `DebruijnIndex` via the `newtype_index` macro.
2018-06-18Auto merge of #51414 - oli-obk:impl_trait_type_def, r=pnkfelixbors-5/+15
Add existential type definitions Note: this does not allow creating named existential types, it just desugars `impl Trait` to a less (but still very) hacky version of actual `existential type` items. r? @nikomatsakis
2018-06-14Declare DebruijnIndex via newtype_index macroFabian Drinck-3/+3
2018-06-14rustc: rename ty::maps to ty::query.Eduard-Mihai Burtescu-5/+5
2018-06-08Rollup merge of #51394 - nnethercote:NCA-depths, r=nikomatsakisMark Rousskov-60/+70
Use scope tree depths to speed up `nearest_common_ancestor`. This patch adds depth markings to all entries in the `ScopeTree`'s `parent_map`. This change increases memory usage somewhat, but permits a much faster algorithm to be used: - If one scope has a greater depth than the other, the deeper scope is moved upward until they are at equal depths. - Then we move the two scopes upward in lockstep until they match. This avoids the need to keep track of which scopes have already been seen, which was the major part of the cost of the old algorithm. It also reduces the number of child-to-parent moves (which are hash table lookups) when the scopes start at different levels, because it never goes past the nearest common ancestor the way the old algorithm did. Finally, the case where one of the scopes is the root is now handled in advance, because that is moderately common and lets us skip everything. This change speeds up runs of several rust-perf benchmarks, the best by 6%. A selection of the bigger improvements: ``` clap-rs-check avg: -2.6% min: -6.6% max: 0.0% syn-check avg: -2.2% min: -5.0% max: 0.0% style-servo-check avg: -2.9%? min: -4.8%? max: 0.0%? cargo-check avg: -1.3% min: -2.8% max: 0.0% sentry-cli-check avg: -1.0% min: -2.1% max: 0.0% webrender-check avg: -0.9% min: -2.0% max: 0.0% style-servo avg: -0.9%? min: -1.8%? max: -0.0%? ripgrep-check avg: -0.7% min: -1.8% max: 0.1% clap-rs avg: -0.9% min: -1.6% max: -0.2% regex-check avg: -0.2% min: -1.3% max: 0.1% syn avg: -0.6% min: -1.3% max: 0.1% hyper-check avg: -0.5% min: -1.1% max: 0.0% ``` The idea came from multiple commenters on my blog and on Reddit. Thank you! r? @nikomatsakis
2018-06-08Suggestion for 'static impl Trait returnEsteban Küber-1/+1
When encountering a named or anonymous sup requirement (for example, `&'a self`) and a `'static` impl Trait return type, suggest adding the `'_` lifetime constraing to the return type.
2018-06-07Add existential type definitonsOliver Schneider-5/+15
2018-06-06Use scope tree depths to speed up `nearest_common_ancestor`.Nicholas Nethercote-60/+70
This patch adds depth markings to all entries in the `ScopeTree`'s `parent_map`. This change increases memory usage somewhat, but permits a much faster algorithm to be used: - If one scope has a greater depth than the other, the deeper scope is moved upward until they are at equal depths. - Then we move the two scopes upward in lockstep until they match. This avoids the need to keep track of which scopes have already been seen, which was the major part of the cost of the old algorithm. It also reduces the number of child-to-parent moves (which are hash table lookups) when the scopes start at different levels, because it never goes past the nearest common ancestor the way the old algorithm did. Finally, the case where one of the scopes is the root is now handled in advance, because that is moderately common and lets us skip everything. This change speeds up runs of several rust-perf benchmarks, the best by 6%.
2018-06-05Remove another unused error variantOliver Schneider-2/+0
2018-06-05Remove unused IndexOutOfBounds variantOliver Schneider-7/+0
2018-06-05Properly report transitive errorsOliver Schneider-11/+10
2018-06-05Refactor the const eval diagnostic APIOliver Schneider-43/+68
2018-06-03implement #[panic_implementation]Jorge Aparicio-3/+6
2018-06-01also check `let` arms and nested patterns for mutable borrowsNiko Matsakis-0/+16
2018-05-31Auto merge of #51235 - nikomatsakis:issue-51117-borrowck-implicit-deref, r=eddybbors-47/+54
remove notion of Implicit derefs from mem-cat `PointerKind` is included in `LoanPath` and hence forms part of the equality check; this led to having two unequal paths that both represent `*x`, depending on whether the `*` was inserted automatically or explicitly. Bad mojo. Fixes #51117 r? @eddyb
2018-05-31change `PointerKind::Implicit` to a noteNiko Matsakis-47/+54
`PointerKind` is included in `LoanPath` and hence forms part of the equality check; this led to having two unequal paths that both represent `*x`, depending on whether the `*` was inserted automatically or explicitly. Bad mojo. The `note` field, in contrast, is intended more-or-less primarily for this purpose of adding extra data.
2018-05-31Auto merge of #51220 - ↵bors-0/+7
nikomatsakis:issue-51008-false-positive-lifetime-must-be-declared, r=cramertj reset anonymous-lifetime-mode as we enter `()` scopes Background: The anonymous lifetime mode is used to prohibit elided lifetimes where they didn't used to be permitted, and instead require that `'_` be used. For example: ```rust impl Trait for Ref<T> { .. } // ^^^^^^ ERROR: should be `Ref<'_, T>` ``` When we are parsing the parts of the impl header, we enter into an alternate mode called `CreateParameter`. In this mode, we give an error for things like `Ref<T>`, but for elided lifetimes in a reference type like `&T` we make the elided lifetime into an in-band lifetime: https://github.com/rust-lang/rust/blob/4f99f37b7e213d69a489884f651adfc6d217cef5/src/librustc/hir/lowering.rs#L4017-L4035 This was not intended to change behavior because we only enter into that mode in contexts where elision was not historically permitted. However, the problem is that we fail to reset the mode when we enter into bounds like `Fn(&u32)`, where elision *was* allowed -- the same occurs for fn types like `fn(&u32`). This PR restores the original mode in those contexts. Fixes #51008 r? @cramertj
2018-05-30reset the "anonymous lifetime mode" for parenthesized where clausesNiko Matsakis-0/+7
Background: The anonymous lifetime mode is used to prohibit elided lifetimes where they didn't used to be permitted, and instead require that `'_` be used. For example: ```rust impl Trait for Ref<T> { .. } // ^^^^^^ ERROR: should be `Ref<'_, T>` ``` When we are parsing the parts of the impl header, we enter into an alternate mode called `CreateParameter`. In this mode, we give an error for things like `Ref<T>`, but for elided lifetimes in a reference type like `&T` we make the elided lifetime into an in-band lifetime: https://github.com/rust-lang/rust/blob/4f99f37b7e213d69a489884f651adfc6d217cef5/src/librustc/hir/lowering.rs#L4017-L4035 This was not intended to change behavior because we only enter into that mode in contexts where elision was not historically permitted. However, the problem is that we fail to reset the mode when we enter into bounds like `Fn(&u32)`, where elision *was* allowed -- the same occurs for fn types like `fn(&u32`). This PR restores the original mode in those contexts.
2018-05-30rustc: don't visit lifetime parameters through visit_lifetime.Eduard-Mihai Burtescu-63/+37
2018-05-29Auto merge of #50475 - csmoe:debr, r=nikomatsakisbors-21/+17
Refactor DebruijnIndex to be 0-based Fixes #49813
2018-05-28refactor `resolve_lifetime` to track outer-index, not depthNiko Matsakis-15/+11
Co-authored-by: csmoe <35686186+csmoe@users.noreply.github.com>
2018-05-28stop invoking `DebruijnIndex::new` directlyNiko Matsakis-2/+2
Co-authored-by: csmoe <35686186+csmoe@users.noreply.github.com>
2018-05-28introduce `shifted_in`, `shifted_out` and friendsNiko Matsakis-4/+4
Co-authored-by: csmoe <35686186+csmoe@users.noreply.github.com>
2018-05-28scrap `find_node_for_hir_id` in favor of `hir_to_node_id`Zack M. Davis-3/+2
Michael Woerister pointed out that `hir_to_node_id` (introduced in August 2017's 28ddd7a4e) supersedes the functionality of `find_node_for_hir_id` (just a hash lookup compared to that linear search).
2018-05-28operate on `HirId` in `hir::Pat::each_binding`, and consequences of thatZack M. Davis-84/+81
Changing the `each_binding` utility method to take the `HirId` of a binding pattern rather than its `NodeId` seems like a modest first step in support of the `HirId`ification initiative #50928. (The inspiration for choosing this in particular came from the present author's previous work on diagnostics issued during liveness analysis, which is the most greatly affected module in this change.)
2018-05-28Auto merge of #50724 - zackmdavis:applicability_rush, r=Manishearthbors-4/+9
add suggestion applicabilities to librustc and libsyntax A down payment on #50723. Interested in feedback on whether my `MaybeIncorrect` vs. `MachineApplicable` judgement calls are well-calibrated (and that we have a consensus on what this means). r? @Manishearth cc @killercup @estebank
2018-05-26Use `Ident`s for fields in HIRVadim Petrochenkov-8/+9
2018-05-25Fix naming conventions for new lintsVadim Petrochenkov-3/+3
2018-05-24Auto merge of #50930 - toidiu:ak-ordOutlivesPredicate, r=nikomatsakisbors-1/+1
implement Ord for OutlivesPredicate and other types It became necessary while implementing https://github.com/rust-lang/rust/pull/50070 to have `Ord` implemented for `OutlivesPredicate`. This PR implements `Ord` for `OutlivesPredicate` as well as other types needed for the implementation.
2018-05-24Rollup merge of #50981 - nnethercote:shrink-LiveNode, r=nikomatsakiskennytm-20/+14
Shrink `LiveNode`. `Liveness::users` is a vector that is occasionally enormous. For example, doing a "clean incremental" check build of `inflate`, there is one instance that represents 5,499 live nodes and 1087 vars, which requires 5,977,413 entries. At 24 bytes per entry, that is 143MB. This patch changes LiveNode from a usize to a u32. On 64-bit machines that halves the size of these entries, significantly reducing peak memory usage and memory traffic, and speeding up "clean incremental" builds of `inflate` by about 10%.
2018-05-24implement Ord for OutlivesPredicate and other typestoidiu-1/+1
2018-05-23Shrink `LiveNode`.Nicholas Nethercote-20/+14
`Liveness::users` is a vector that is occasionally enormous. For example, doing a "clean incremental" check build of `inflate`, there is one instance that represents 5,499 live nodes and 1087 vars, which requires 5,977,413 entries. At 24 bytes per entry, that is 143MB. This patch changes LiveNode from a usize to a u32. On 64-bit machines that halves the size of these entries, significantly reducing peak memory usage and memory traffic, and speeding up "clean incremental" builds of `inflate` by about 10%.
2018-05-21rustc: move TypeParamDef's fields into GenericParamDefKind::Type.Eduard-Mihai Burtescu-11/+7
2018-05-20suggestion applicabilities for libsyntax and librustc, run-rustfix testsZack M. Davis-4/+9
Consider this a down payment on #50723. To recap, an `Applicability` enum was recently (#50204) added, to convey to Rustfix and other tools whether we think it's OK for them to blindly apply the suggestion, or whether to prompt a human for guidance (because the suggestion might contain placeholders that we can't infer, or because we think it has a sufficiently high probability of being wrong even though it's— presumably—right often enough to be worth emitting in the first place). When a suggestion is marked as `MaybeIncorrect`, we try to use comments to indicate precisely why (although there are a few places where we just say `// speculative` because the present author's subjective judgement balked at the idea that the suggestion has no false positives). The `run-rustfix` directive is opporunistically set on some relevant UI tests (and a couple tests that were in the `test/ui/suggestions` directory, even if the suggestions didn't originate in librustc or libsyntax). This is less trivial than it sounds, because a surprising number of test files aren't equipped to be tested as fixed even when they contain successfully fixable errors, because, e.g., there are more, not-directly-related errors after fixing. Some test files need an attribute or underscore to avoid unused warnings tripping up the "fixed code is still producing diagnostics" check despite the fixes being correct; this is an interesting contrast-to/inconsistency-with the behavior of UI tests (which secretly pass `-A unused`), a behavior which we probably ought to resolve one way or the other (filed issue #50926). A few suggestion labels are reworded (e.g., to avoid phrasing it as a question, which which is discouraged by the style guidelines listed in `.span_suggestion`'s doc-comment).
2018-05-20Rollup merge of #50854 - ↵kennytm-56/+50
zackmdavis:and_the_case_of_the_unused_field_pattern_3_straight_to_video, r=estebank in which the unused shorthand field pattern debacle/saga continues In e4b1a79 (#47922), we corrected erroneous suggestions for unused shorthand field pattern bindings, suggesting `field: _` where the previous suggestion of `_field` wouldn't even have compiled (#47390). Soon, it was revealed that this was insufficient (#50303), and the fix was extended to references, slices, &c. (#50327) But even this proved inadequate, as the erroneous suggestions were still being issued for patterns in local (`let`) bindings (#50804). Here, we yank the shorthand-detection and variable/node registration code into a new common function that can be called while visiting both match arms and `let` bindings. Resolves #50804. r? @estebank