about summary refs log tree commit diff
path: root/src/librustc/ty/instance.rs
AgeCommit message (Collapse)AuthorLines
2020-03-30rustc -> rustc_middle part 1Mazdak Farrokhzad-460/+0
2020-03-24normalize some imports, prefer direct ones.Mazdak Farrokhzad-1/+1
2020-03-23Rollup merge of #69968 - eddyb:tupled-closure-captures, r=nikomatsakisMazdak Farrokhzad-2/+2
rustc: keep upvars tupled in {Closure,Generator}Substs. Previously, each closure/generator capture's (aka "upvar") type was tracked as one "synthetic" type parameter in the closure/generator substs, and figuring out where the parent `fn`'s generics end and the synthetics start involved slicing at `tcx.generics_of(def_id).parent_count`. Needing to query `generics_of` limited @davidtwco (who wants to compute some `TypeFlags` differently for parent generics vs upvars, and `TyCtxt` is not available there), which is how I got started on this, but it's also possible that the `generics_of` queries are slowing down `{Closure,Generator}Substs` methods. To give an example, for a `foo::<T, U>::{closure#0}` with captures `x: X` and `y: Y`, substs are: * before this PR: `[T, U, /*kind*/, /*signature*/, X, Y]` * after this PR: `[T, U, /*kind*/, /*signature*/, (X, Y)]` You can see that, with this PR, no matter how many captures, the last 3 entries in the substs (or 5 for a generator) are always the "synthetic" ones, with the last one being the tuple of capture types. r? @nikomatsakis cc @Zoxc
2020-03-21symbol_names: treat ReifyShim like VtableShim.Eduard-Mihai Burtescu-4/+0
2020-03-21rustc: keep upvars tupled in {Closure,Generator}Substs.Eduard-Mihai Burtescu-2/+2
2020-03-20Rollup merge of #69935 - davidtwco:issue-69925, r=eddybYuki Okushi-0/+26
codegen/mir: support polymorphic `InstanceDef`s cc #69925 This PR modifies the use of `subst_and_normalize_erasing_regions` on parts of the MIR bodies returned from `instance_mir`, so that `InstanceDef::CloneShim` and `InstanceDef::DropGlue` (where there is a type) do not perform substitutions. This avoids double substitutions and enables polymorphic `InstanceDef`s. r? @eddyb cc @nikomatsakis
2020-03-15rustc: tweak comments on InstanceDef.Ana-Maria Mihalache-12/+9
2020-03-15rustc: don't resolve Instances which would produce malformed shims.Eduard-Mihai Burtescu-0/+15
2020-03-12codegen/mir: support polymorphic `InstanceDef`sDavid Wood-0/+26
This commit modifies the use of `subst_and_normalize_erasing_regions` on parts of the MIR bodies returned from `instance_mir`, so that `InstanceDef::CloneShim` and `InstanceDef::DropGlue` (where there is a type) do not perform substitutions. This avoids double substitutions and enables polymorphic `InstanceDef`s. Signed-off-by: David Wood <david@davidtw.co>
2020-03-06Don't redundantly repeat field names (clippy::redundant_field_names)Matthias Krüger-1/+1
2020-03-03use question mark operator in a few places.Matthias Krüger-3/+1
2020-02-28use is_empty() instead of len() == x to determine if structs are empty.Matthias Krüger-1/+1
2020-02-27Auto merge of #67332 - matthewjasper:drop-in-place-cgus, r=michaelwoeristerbors-4/+21
Don't instantiate so many copies of drop_in_place Split out from #66703. r? @ghost
2020-02-19Make lookup of associated item by name O(log n)Dylan MacKenzie-1/+1
2020-02-13Don't instantiate so many copies of `drop_in_place`Matthew Jasper-4/+21
2020-02-13Move resolve_instance to rustc_ty.Camille GILLOT-123/+20
2020-02-12Auto merge of #68679 - matthewjasper:needs-type-op, r=varkorbors-1/+1
Improve `ty.needs_drop` * Handle cycles in `needs_drop` correctly * Normalize types when computing `needs_drop` * Move queries from rustc to rustc_ty * Avoid query in simple cases reopens #65918
2020-02-11Review comments.Camille GILLOT-1/+1
2020-02-11Move lang_items definitions to librustc_lang_items.Camille GILLOT-1/+1
2020-02-08Make `associated_items` query return a sliceJonas Schievink-0/+1
2020-02-02Use correct `ParamEnv` in `Instance::resolve`Matthew Jasper-1/+1
2020-01-23Add projection query for upstream drop-glue instances.Michael Woerister-1/+35
This reduces the amount of invalidated data when new types are add to upstream crates.
2020-01-23Clarify some methods around instance instantiation via comments and clearer ↵Michael Woerister-3/+15
names.
2020-01-19InstanceDef::requires_caller_location limited to items.Adam Perry-1/+6
2020-01-07Make traits::util::* free functions.Camille GILLOT-1/+1
2020-01-06Auto merge of #67886 - Centril:rustc_hir_canon_imports, r=nagisabors-2/+2
Nix `rustc_hir` reexports in rustc::hir r? @Zoxc cc @Mark-Simulacrum
2020-01-05Fix typoAaron Hill-1/+1
2020-01-05Rename Instance.ty to Instance.monomorphic_tyAaron Hill-6/+2
2020-01-05s/projections/params/Aaron Hill-1/+1
2020-01-05Run rustfmtAaron Hill-1/+2
2020-01-05Change 'panic!' to 'bug!'Aaron Hill-1/+1
Co-Authored-By: Wesley Wiser <wwiser@gmail.com>
2020-01-05Fix ICE involving calling `Instance.ty` during const evaluationAaron Hill-0/+28
Fixes #67639 `Instance.ty` assumes that we are in a fully monomorphic context (e.g. codegen), and can therefore use an empty `ParamEnv` when performing normalization. Howver, the MIR constant evaluator code ends up calling `Instance.ty` as a result of us attemptign to 'speculatively' const-evaluate generic functions during const propagation. As a result, we may end up with projections involving type parameters (e.g. <T as MyTrait>::Bar>) in the type we are trying to normalize. Normalization expects us to have proper predicates in the `ParamEnv` for such projections, and will ICE if we don't. This commit adds a new method `Instance.ty_env`, which takes a `ParamEnv` for use during normalization. The MIR const-evaluator code is changed to use this method, passing in the proper `ParamEnv` for the context at hand.
2020-01-05Remove rustc_hir reexports in rustc::hir.Mazdak Farrokhzad-2/+2
2020-01-04extract rustc::middle::codegen_fn_attrsMazdak Farrokhzad-1/+1
2019-12-27Fix `Instance::resolve()` incorrectly returning specialized instancesWesley Wiser-0/+19
We only want to return specializations when `Reveal::All` is passed, not when `Reveal::UserFacing` is. Resolving this fixes several issues with the `ConstProp`, `SimplifyBranches`, and `Inline` MIR optimization passes. Fixes #66901
2019-12-22Format the worldMark Rousskov-127/+93
2019-12-05Implement #[track_caller] in const.Adam Perry-4/+5
2019-12-03rustc: add docs to FnAbi::{of_fn_ptr,of_instance} and InstanceDef::Virtual.Eduard-Mihai Burtescu-1/+5
2019-12-03rustc: move Instance::fn_sig to ty::layout and privatize it.Eduard-Mihai Burtescu-65/+1
2019-12-03rustc: use ReifyShim for reifying Virtual call instances.Eduard-Mihai Burtescu-12/+20
2019-12-03rustc: combine Instance::fn_sig_noadjust and Instance::fn_sig.Eduard-Mihai Burtescu-17/+15
2019-11-21Aggregation of drive-by cosmetic changes.Alexander Regueiro-3/+3
2019-11-18Retire BraceStructLiftImpl.Camille GILLOT-1/+2
2019-10-11resolve_for_fn_ptr checks that the instance is an Item before returning shim.Adam Perry-10/+12
2019-10-10Instance::resolve_for_fn_ptr unconditionally resolves first.Adam Perry-9/+13
Per review feedback.
2019-10-10Improve docs for InstanceDef::ReifyShim.Adam Perry-1/+4
2019-10-09Clarify comment, dedupe match arms in shim.rs.Adam Perry-1/+3
Also add a missing terminal newline to a test.
2019-10-09Return ReifyShim from Instance::resolve_for_fn_ptr when track_caller present.Adam Perry-2/+2
This ICEs in MIR currently, which I think is to be expected since none of the MIR plumbing is set up. I added a test which confirms that the shim is being used for reifying a track_caller function.
2019-10-09Reifying callers of Instance::resolve use resolve_for_fn_ptr.Adam Perry-6/+3
2019-10-09Add Instance::resolve_for_fn_ptrAdam Perry-1/+23