about summary refs log tree commit diff
path: root/src/librustc_middle/ty
AgeCommit message (Collapse)AuthorLines
2020-08-30mv compiler to compiler/mark-26130/+0
2020-08-27Auto merge of #75933 - Aaron1011:feature/closure-move-err, r=oli-obkbors-1/+7
Point to a move-related span when pointing to closure upvars Fixes #75904 When emitting move/borrow errors, we may point into a closure to indicate why an upvar is used in the closure. However, we use the 'upvar span', which is just an arbitrary usage of the upvar. If the upvar is used in multiple places (e.g. a borrow and a move), we may end up pointing to the borrow. If the overall error is a move error, this can be confusing. This PR tracks the span that caused an upvar to become captured by-value instead of by-ref (assuming that it's not a `move` closure). We use this span instead of the 'upvar' span when we need to point to an upvar usage during borrow checking.
2020-08-26Point to a move-related span when pointing to closure upvarsAaron Hill-1/+7
Fixes #75904 When emitting move/borrow errors, we may point into a closure to indicate why an upvar is used in the closure. However, we use the 'upvar span', which is just an arbitrary usage of the upvar. If the upvar is used in multiple places (e.g. a borrow and a move), we may end up pointing to the borrow. If the overall error is a move error, this can be confusing. This PR tracks the span that caused an upvar to become captured by-value instead of by-ref (assuming that it's not a `move` closure). We use this span instead of the 'upvar' span when we need to point to an upvar usage during borrow checking.
2020-08-25VariantDef: move recovered into VariantFlagsBastian Kauschke-4/+13
2020-08-24hir: consistent use and naming of lang itemsDavid Wood-18/+18
This commit adjusts the naming of various lang items so that they are consistent and don't include prefixes containing the target or "LangItem". In addition, lang item variants are no longer exported from the `lang_items` module. Signed-off-by: David Wood <david@davidtw.co>
2020-08-23Prefer https link for wikipedia URLsLzu Tao-1/+1
2020-08-22Lazy decoding of DefPathTable from crate metadata (non-incremental case)Aaron Hill-13/+6
2020-08-20Auto merge of #75562 - oli-obk:const_prop_no_aggregates, r=wesleywiserbors-1/+1
Check that we don't use `Rvalue::Aggregate` after the deaggregator fixes #75481 r? @wesleywiser cc @RalfJung (modified the validator)
2020-08-20Add missing tick for docLzu Tao-1/+1
2020-08-19Auto merge of #75563 - richkadel:llvm-coverage-map-gen-5.4, r=wesleywiserbors-0/+5
Moved coverage counter injection from BasicBlock to Statement. As discussed on Zulip: https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Implement.20LLVM-compatible.20source-based.20cod.20compiler-team.23278
2020-08-19Use CopyTaggedPtr for ParamEnvMark Rousskov-60/+47
2020-08-18Moved coverage counter injection from BasicBlock to Statement.Rich Kadel-0/+5
2020-08-18Validate the MIR of all optimizations in the mir-opt directoryOliver Scherer-1/+1
2020-08-17Auto merge of #75120 - JulianKnodt:rm_reps, r=oli-obkbors-17/+15
rust_ast::ast => rustc_ast Rework of #71199 which is a rework #70621 Still working on this but just made the PR to track progress r? @Dylan-DPC
2020-08-17Auto merge of #75145 - ↵bors-1/+1
davidtwco:issue-60607-preallocate-defid-for-lang-items, r=petrochenkov Reference lang items during AST lowering Fixes #60607 and fixes #61019. This PR introduces `QPath::LangItem` to the HIR and uses it in AST lowering instead of constructing a `hir::Path` from a slice of symbols: - Credit for much of this work goes to @matthewjasper, I basically just [rebased their earlier work](https://github.com/matthewjasper/rust/commit/a227c706b7809ff07021baf3856b7540d5b57f8a#diff-c0f791ead38d2d02916faaad0f56f41d). - ~~Changes to Clippy might not be correct, they compile but attempting to run tests through `./x.py` produced failures which appeared spurious, so I didn't run any clippy tests.~~ - Changes to save analysis might not be correct - tests pass but I don't have a lot of confidence in those changes being correct. - I've used `GenericBounds::LangItemTrait` rather than changing `PolyTraitRef`, as suggested by @matthewjasper [in this comment](https://github.com/matthewjasper/rust/commit/a227c706b7809ff07021baf3856b7540d5b57f8a#r40107992) but I'd prefer that be left for a follow-up. - I've split things into smaller commits fairly arbitrarily to make the diff easier to review, each commit should compile but might not pass tests until the final commit. r? @oli-obk cc @matthewjasper
2020-08-17rust_ast::ast => rustc_astUjjwal Sharma-17/+15
2020-08-16Rollup merge of #74399 - mark-i-m:ty-err-4, r=eddybTyler Mandry-15/+12
Move DelaySpanBugEmitted to ty::context This makes it even hard to abuse. r? @eddyb cc @LeSeulArtichaut as this will probably conflict with your PR :/
2020-08-16Rollup merge of #74346 - eddyb:reachable-defs, r=nikomatsakisTyler Mandry-1/+1
Use LocalDefId instead of HirId for reachable_set elements. The only `HirId`s being tracked there that don't have matching `DefId`s are local variables, and that's an accident from #44316 (where I preserved the old behavior, even if nothing relied on reachability tracking local variables).
2020-08-16Rollup merge of #74314 - eddyb:closure-substs-direct, r=nikomatsakisTyler Mandry-27/+68
rustc_typeck: construct {Closure,Generator}Substs more directly. We've previously not had a way to create `{Closure,Generator}Substs` other than instantiating all generics as inference variables and unifying the inference types (extracted using the regular `{Closure,Generator}Substs` accessors), with the actual types. With this PR, those hacks, and assumptions about the order of closure/generator-specific components, are replaced with a simple API where the base `Substs` are combined with the additional information into a `{Closure,Generator}Substs`. This might also be faster than relying inference, although probably not by much. r? @nikomatsakis cc #53488 @blitzerr
2020-08-16move DelaySpanBugEmitted to ty::contextmark-15/+12
2020-08-16Auto merge of #73176 - LeSeulArtichaut:tyctxtat-err, r=eddybbors-3/+19
Add `TyCtxtAt::{ty_error, ty_error_with_message}` ~~Only e2d957d was added, the rest comes from #70551.~~ I was unsure where to put the implementation for those methods, please tell me if there is a better place for it. Closes #72619, ~~blocked on #70551~~. r? @eddyb cc @mark-i-m, maybe this should be part of #70551? If so feel free to cherry-pick or ask me to file a PR against your fork.
2020-08-16rustc_typeck: construct {Closure,Generator}Substs more directly.Eduard-Mihai Burtescu-27/+68
2020-08-16Use LocalDefId instead of HirId for reachable_set elements.Eduard-Mihai Burtescu-1/+1
2020-08-16hir: introduce `QPath::LangItem`David Wood-1/+1
This commit introduces `QPath::LangItem` to the HIR and uses it in AST lowering instead of constructing a `hir::Path` from a slice of symbols. This might be better for performance, but is also much cleaner as the previous approach is fragile. In addition, it resolves a bug (#61019) where an extern crate imported as "std" would result in the paths created during AST lowering being resolved incorrectly (or not at all). Co-authored-by: Matthew Jasper <mjjasper1@gmail.com> Signed-off-by: David Wood <david@davidtw.co>
2020-08-14Rollup merge of #75448 - lcnr:rn-as_local_hir_id, r=davidtwcoTyler Mandry-17/+18
merge `as_local_hir_id` with `local_def_id_to_hir_id` `as_local_hir_id` was defined as just calling `local_def_id_to_hir_id` and I think that having two different ways to call the same method is somewhat confusing. Don't really care about which of these 2 methods we want to keep. Does this require an MCP, considering that these methods are fairly frequently used?
2020-08-14Fix tests and address review commentsMatthew Jasper-2/+2
2020-08-14Add some documentation for (De|En)codableMatthew Jasper-0/+11
2020-08-14Simplify arena_types macrosMatthew Jasper-1/+1
2020-08-14Rework `rustc_serialize`Matthew Jasper-631/+463
- Move the type parameter from `encode` and `decode` methods to the trait. - Remove `UseSpecialized(En|De)codable` traits. - Remove blanket impls for references. - Add `RefDecodable` trait to allow deserializing to arena-allocated references safely. - Remove ability to (de)serialize HIR. - Create proc-macros `(Ty)?(En|De)codable` to help implement these new traits.
2020-08-13merge `as_local_hir_id` with `local_def_id_to_hir_id`Bastian Kauschke-17/+18
2020-08-13self-profile: Cache more query key strings when doing self-profiling.Michael Woerister-1/+45
2020-08-11Auto merge of #74802 - Mark-Simulacrum:reland-74069, r=nnethercotebors-4/+22
Reland #74069 Investigation in #74716 has concluded that this PR is indeed not a regression (and in fact the rollup itself is not either). This reverts the revert in #74611. r? @nnethercote cc @eddyb
2020-08-11Rollup merge of #75226 - pnadon:miri-undef-uninit, r=RalfJungYuki Okushi-2/+2
Miri: Renamed "undef" to "uninit" Renamed remaining references to "undef" to "uninit" when referring to Miri. Impacted directories are: - `src/librustc_codegen_llvm/consts.rs` - `src/librustc_middle/mir/interpret/` - `src/librustc_middle/ty/print/pretty.rs` - `src/librustc_mir/` - `src/tools/clippy/clippy_lints/src/consts.rs` Upon building Miri based on the new changes it was verified that no changes needed to be made with the Miri project. Related issue #71193
2020-08-11Rollup merge of #75337 - davidtwco:polymorphization-75255-fixes, r=eddybDylan DPC-36/+33
instance: only polymorphize upvar substs This PR restricts the substitution polymorphization added in #75255 to only apply to the tupled upvar substitution, rather than all substitutions, fixing a bunch of regressions when polymorphization is enabled. Due to an oversight on my part, when landing #75260 and #75255, some tests started failing when polymorphization was enabled that I didn't notice until after landing - this PR fixes the regressions from #75255. #75336 has been filed to make sure that we don't forget to try make this change again in future, as it does enable some optimisations. r? @lcnr
2020-08-09rustc_middle: use IndexSet in OnDiskCacheJosh Stone-17/+5
2020-08-09instance: only polymorphize upvar substsDavid Wood-36/+33
This commit restricts the substitution polymorphization added in #75255 to only apply to the tupled upvar substitution, rather than all substitutions, fixing a bunch of regressions when polymorphization is enabled. Signed-off-by: David Wood <david@davidtw.co>
2020-08-08Miri: Renamed "undef" to "uninit"Philippe Nadon-2/+2
Renamed remaining references to "undef" to "uninit" when referring to Miri. Impacted directories are: - src/librustc_codegen_llvm/consts.rs - src/librustc_middle/mir/interpret/ - src/librustc_middle/ty/print/pretty.rs - src/librustc_mir/ - src/tools/clippy/clippy_lints/src/consts.rs Upon building Miri based on the new changes it was verified that no changes needed to be made with the Miri project. Related issue #71193
2020-08-08Auto merge of #74932 - nnethercote:rm-ast-session-globals, r=petrochenkovbors-14/+10
Remove `librustc_ast` session globals By moving the data onto `Session`. r? @petrochenkov
2020-08-08Eliminate the `SessionGlobals` from `librustc_ast`.Nicholas Nethercote-14/+10
By moving `{known,used}_attrs` from `SessionGlobals` to `Session`. This means they are accessed via the `Session`, rather than via TLS. A few `Attr` methods and `librustc_ast` functions are now methods of `Session`. All of this required passing a `Session` to lots of functions that didn't already have one. Some of these functions also had arguments removed, because those arguments could be accessed directly via the `Session` argument. `contains_feature_attr()` was dead, and is removed. Some functions were moved from `librustc_ast` elsewhere because they now need to access `Session`, which isn't available in that crate. - `entry_point_type()` --> `librustc_builtin_macros` - `global_allocator_spans()` --> `librustc_metadata` - `is_proc_macro_attr()` --> `Session`
2020-08-08Auto merge of #74877 - lcnr:min_const_generics, r=oli-obkbors-1/+3
Implement the `min_const_generics` feature gate Implements both https://github.com/rust-lang/lang-team/issues/37 and https://github.com/rust-lang/compiler-team/issues/332. Adds the new feature gate `#![feature(min_const_generics)]`. This feature gate adds the following limitations to using const generics: - generic parameters must only be used in types if they are trivial. (either `N` or `{ N }`) - generic parameters must be either integers, `bool` or `char`. We do allow arbitrary expressions in associated consts though, meaning that the following is allowed, even if `<[u8; 0] as Foo>::ASSOC` is not const evaluatable. ```rust trait Foo { const ASSOC: usize; } impl<const N: usize> Foo for [u8; N] { const ASSOC: usize = 64 / N; } ``` r? @varkor cc @eddyb @withoutboats
2020-08-07instance: polymorphize `FnDef` substsDavid Wood-2/+12
This commit extends previous polymorphization of substs to polymorphize `FnDef`. Signed-off-by: David Wood <david@davidtw.co>
2020-08-07instance: avoid unnecessary `mk_` callsDavid Wood-2/+10
This commit avoids unnecessary calls to `mk_closure` and `mk_generator` by checking if the polymorphized substs match the original substs. Signed-off-by: David Wood <david@davidtw.co>
2020-08-07ty: add `MAY_POLYMORPHIZE` flagDavid Wood-1/+19
This commit adds a `MAY_POLYMORPHIZE` which checks for closures and generators so that polymorphization of substs does not need to traverse every substs. Signed-off-by: David Wood <david@davidtw.co>
2020-08-07instance: always polymorphize substsDavid Wood-38/+8
By always polymorphizing substitutions, functions which take closures as arguments (e.g. `impl Fn()`) can have fewer mono items when some of the argument closures can be polymorphized. Signed-off-by: David Wood <david@davidtw.co>
2020-08-07instance: polymorphize upvar closures/generatorsDavid Wood-20/+87
This commit modifies how instances are polymorphized so that closures and generators have any closures or generators captured within their upvars also polymorphized - this avoids symbol clashes with the new symbol mangling scheme. Signed-off-by: David Wood <david@davidtw.co>
2020-08-06Auto merge of #75008 - eddyb:rmeta-indexed-trait-impls, r=nikomatsakisbors-22/+28
rustc_metadata: track the simplified Self type for every trait impl. For the `traits_impls_of` query, we index the impls by `fast_reject::SimplifiedType` (a "shallow type"), which allows some simple cases like `impl Trait<..> for Foo<..>` to be efficiently iterated over, by e.g. `for_each_relevant_impl`. This PR encodes the `fast_reject::SimplifiedType` cross-crate to avoid needing to deserialize the `Self` type of every `impl` in order to simplify it - the simplification itself should be cheap, but the deserialization is less so. We could go further from here and make loading the list of impls lazy, for a given simplified `Self` type, but that would have more complicated implications for performance, and this PR doesn't do anything in that regard. r? @nikomatsakis cc @Mark-Simulacrum
2020-08-05add min_const_generics feature gateBastian Kauschke-1/+3
2020-08-04Add `TyCtxtAt::{ty_error, ty_error_with_message}`LeSeulArtichaut-3/+19
2020-08-04Remove two fields from `SubstFolder`.Nicholas Nethercote-31/+6
They're only used in error messages printed if there's an internal compiler error, and the cost of maintaining them is high enough to show up in profiles.
2020-08-03Auto merge of #75055 - cjgillot:clean-cache, r=oli-obkbors-0/+2
Introduce an abstraction for EvaluationCache and SelectionCache The small duplicated code has been moved to librustc_query_system. The remaining changes are some cleanups of structural impls.