about summary refs log tree commit diff
path: root/src/librustc_middle
AgeCommit message (Collapse)AuthorLines
2020-07-22Erase regions in try_eval_bitsAaron Hill-0/+1
2020-07-22Normalize opaque types when converting `ParamEnv` to `Reveal::All`Aaron Hill-75/+127
Fixes #65918
2020-07-21Revert "Compare tagged/niche-filling layout and pick the best one"Mark Rousskov-23/+4
2020-07-21fetch -> lookupBastian Kauschke-1/+1
2020-07-21`try_update` -> `try_upgrade`Bastian Kauschke-1/+1
2020-07-21remove some const arg in ty dep path boilerplateBastian Kauschke-0/+21
2020-07-22[AVR] Ensure that function pointers stored within aggregates are annotated ↵Dylan McKay-4/+29
with the correct space Before this patch, a function pointer stored within an aggregate like a struct or an enum would always have the default address space `0`. This patch removes this assumption and instead, introspects the inner type being pointed at, storing the target address space in the PointeeInfo struct so that downstream users may query it.
2020-07-21Auto merge of #69749 - davidtwco:issue-46477-polymorphization, r=eddybbors-59/+151
Polymorphization This PR implements an analysis to detect when functions could remain polymorphic during code generation. Fixes #46477 r? @eddyb cc @rust-lang/wg-mir-opt @nikomatsakis @pnkfelix
2020-07-20Migrate rustc_depr uses to use deprecation attributeMark Rousskov-30/+41
This should not be a change in behavior.
2020-07-20Rollup merge of #74376 - lcnr:type-dependent-path-cleanup, r=eddybManish Goregaokar-1/+5
test caching opt_const_param_of on disc Followup to #74113, implements parts of #74360 Tried caching `opt_const_param_of` on disk and adding an early exit if `tcx.dep_kind(def_id) != DefKind::AnonConst`. Ended up causing a perf regression instead, so we just remove the FIXME and a short note to `opt_const_param_of`. r? @eddyb
2020-07-20index: introduce and use `FiniteBitSet`David Wood-6/+6
This commit introduces a `FiniteBitSet` type which replaces the manual bit manipulation which was being performed in polymorphization. Signed-off-by: David Wood <david@davidtw.co>
2020-07-20ty: normalize fn sigs before substDavid Wood-17/+26
This commit normalizes function signatures for instances before substituting, a workaround for polymorphization considering parameters unused when they show up in the signature, but not the body (due to being normalized). Unfortunately, this causes test output to change with the parallel compiler only. Signed-off-by: David Wood <david@davidtw.co>
2020-07-20mir: `unused_generic_params` queryDavid Wood-29/+52
This commit implements the `unused_generic_params` query, an initial version of polymorphization which detects when an item does not use generic parameters and is being needlessly monomorphized as a result. Signed-off-by: David Wood <david@davidtw.co>
2020-07-20ty: add doc comments to `Generics` methodsDavid Wood-1/+3
This commit adds doc comments to the `param_at`, `region_param` and `const_param` methods on the `Generics` struct. Signed-off-by: David Wood <david@davidtw.co>
2020-07-20trait_sel: only test predicates w/ no substsDavid Wood-3/+3
This commit modifies the `substitute_normalize_and_test_predicates` query, renaming it to `impossible_predicates` and only checking predicates which do not require substs. By making this change, polymorphization doesn't have to explicitly support vtables. Signed-off-by: David Wood <david@davidtw.co>
2020-07-20ty: `STILL_FURTHER_SPECIALIZABLE` w/out prnt substDavid Wood-8/+66
This commit modifies the `STILL_FURTHER_SPECIALIZABLE` flag so that the flag isn't set by the parent substs of closures or generators. Signed-off-by: David Wood <david@davidtw.co>
2020-07-19Rollup merge of #74516 - lcnr:min-specialization-ice, r=matthewjasperManish Goregaokar-1/+3
do not try fetching the ancestors of errored trait impls fixes #74483 While building the specialization graph, we use `tcx.all_impls` which discards impls with incorrect self types, we do however call `trait_def.ancestors` with these impls which caused an ICE as they aren't part of the specialization graph.
2020-07-19do not try fetching the ancestors of errored trait implsBastian Kauschke-1/+3
2020-07-19Auto merge of #74091 - richkadel:llvm-coverage-map-gen-4, r=tmandrybors-9/+8
Generating the coverage map @tmandry @wesleywiser rustc now generates the coverage map and can support (limited) coverage report generation, at the function level. Example commands to generate a coverage report: ```shell $ BUILD=$HOME/rust/build/x86_64-unknown-linux-gnu $ $BUILD/stage1/bin/rustc -Zinstrument-coverage \ $HOME/rust/src/test/run-make-fulldeps/instrument-coverage/main.rs $ LLVM_PROFILE_FILE="main.profraw" ./main called $ $BUILD/llvm/bin/llvm-profdata merge -sparse main.profraw -o main.profdata $ $BUILD/llvm/bin/llvm-cov show --instr-profile=main.profdata main ``` ![rust coverage report only 20200706](https://user-images.githubusercontent.com/3827298/86697299-1cbe8f80-bfc3-11ea-8955-451b48626991.png) r? @wesleywiser Rust compiler MCP rust-lang/compiler-team#278 Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation
2020-07-18add note to `opt_const_param_of`Bastian Kauschke-1/+5
2020-07-17Rollup merge of #74069 - erikdesjardins:bad-niche, r=nikomatsakisManish Goregaokar-4/+23
Compare tagged/niche-filling layout and pick the best one Finishes up #71045, and so fixes #63866. cc @eddyb r? @nikomatsakis (since @eddyb wrote the first commit)
2020-07-17Rollup merge of #74424 - sexxi-goose:move_hir_place, r=nikomatsakisManish Goregaokar-0/+116
Move hir::Place to librustc_middle/hir Needed to support https://github.com/rust-lang/project-rfc-2229/issues/7 Currently rustc_typeck depends on rustc_middle for definition TypeckTables, etc. For supporting project-rfc-2229#7, rustc_middle would've to depend on rustc_typeck for Place -- introducing a circular dependency. This resembles the MIR equivalent of `Place` located in `lbrustc_middle/mir`. Separate PR for this move will make the actual PR for using Places to represent captures cleaner/more focused. r? @nikomatsakis @matthewjasper
2020-07-17Rollup merge of #74169 - ecstatic-morse:dataflow-unreachable, r=pnkfelixManish Goregaokar-0/+17
Stop processing unreachable blocks when solving dataflow ...instead we `debug_assert` that the user is not checking the dataflow state for an unreachable block. This resolves a FIXME in the dataflow engine. The old behavior was an artifact of the previous dataflow framework. Things should run a tiny bit faster now, but I suspect not enough to show up in benchmarks. AFAIK, only the generator transform runs dataflow on MIR with unreachable basic blocks. This PR also adds some utility methods to `mir::traversal`. r? @pnkfelix
2020-07-17Generating the coverage mapRich Kadel-9/+8
rustc now generates the coverage map and can support (limited) coverage report generation, at the function level. Example: $ BUILD=$HOME/rust/build/x86_64-unknown-linux-gnu $ $BUILD/stage1/bin/rustc -Zinstrument-coverage \ $HOME/rust/src/test/run-make-fulldeps/instrument-coverage/main.rs $ LLVM_PROFILE_FILE="main.profraw" ./main called $ $BUILD/llvm/bin/llvm-profdata merge -sparse main.profraw -o main.profdata $ $BUILD/llvm/bin/llvm-cov show --instr-profile=main.profdata main 1| 1|pub fn will_be_called() { 2| 1| println!("called"); 3| 1|} 4| | 5| 0|pub fn will_not_be_called() { 6| 0| println!("should not have been called"); 7| 0|} 8| | 9| 1|fn main() { 10| 1| let less = 1; 11| 1| let more = 100; 12| 1| 13| 1| if less < more { 14| 1| will_be_called(); 15| 1| } else { 16| 1| will_not_be_called(); 17| 1| } 18| 1|}
2020-07-17Auto merge of #72983 - Lezzz:rename-typeck, r=nikomatsakisbors-43/+43
Rename TypeckTables to TypeckResults. Originally suggested by @eddyb.
2020-07-17compare tagged/niche-filling layout and pick the best oneErik Desjardins-1/+16
2020-07-17[experiment] ty/layout: compute both niche-filling and tagged layouts for enums.Eduard-Mihai Burtescu-4/+8
2020-07-17Rename TypeckTables to TypeckResults.Valentin Lazureanu-43/+43
2020-07-17Auto merge of #74395 - Mark-Simulacrum:stage0-next, r=pietroalbinibors-3/+1
Bump version to 1.47 This also bumps to a more recent rustfmt version, just to keep us relatively up to date (though almost nothing has changed in rustfmt we use beyond bumps to the parser infra). No formatting changes as a result of this. r? @pietroalbini
2020-07-16apply bootstrap cfgsMark Rousskov-3/+1
2020-07-16Move hir::Place to librustc_middle/hirAman Arora-0/+116
Needed to support https://github.com/rust-lang/project-rfc-2229/issues/7 Currently rustc_typeck depends on rustc_middle for definition TypeckTables, etc. For supporting project-rfc-2229#7, rustc_middle would've to depend on rustc_typeck for Place -- introducing a circular dependcy. This resembles the MIR equivalent of `Place` located in `lbrustc_middle/mir`. Co-authored-by: Aman Arora <me@aman-arora.com> Co-authored-by: Jennifer Wills <wills.jenniferg@gmail.com> Co-authored-by: Logan Mosier <logmosier@gmail.com>
2020-07-17Remove some `Symbol:as_str()` calls.Nicholas Nethercote-6/+7
2020-07-17Add `UnsafetyViolationDetails`.Nicholas Nethercote-4/+88
This replaces the need for the `description` and `details` symbols in `UnsafetyViolation`, which are static. As a result some `Symbol::as_str()` calls are no longer necessary, which is nice.
2020-07-16Auto merge of #74202 - oli-obk:mir_const, r=RalfJungbors-385/+457
Reduce the amount of interning and `layout_of` calls in const eval. r? @ghost If we just want to get at some bits of a constant, we don't need to intern it before extracting those bits. Also, if we want to read a `usize` or `bool`, we can fetch the size without invoking a query.
2020-07-16Group the try_eval functions before the eval functionsOliver Scherer-10/+10
2020-07-16Make `try_eval` privateOliver Scherer-2/+2
2020-07-16Move `ty::Const` and `ty::ConstKind` into their own modulesOliver Scherer-426/+445
2020-07-15Rollup merge of #74353 - pierwill:pierwill-edit-dep-node, r=jonas-schievinkManish Goregaokar-6/+8
Edit docs for rustc_middle::dep_graph::dep_node Fixes some missing punctuation, and adds a blank line for a more concise summary.
2020-07-15s/try_to_usize/try_to_machine_usize/Oliver Scherer-4/+4
2020-07-15Reduce the amount of interning and `layout_of` calls in const eval.Oliver Scherer-17/+70
2020-07-15Auto merge of #74113 - lcnr:type-dependent-consts-2, r=eddybbors-74/+407
Support const args in type dependent paths (Take 2) once more, except it is sound this time :smiling_face_with_three_hearts: previously #71154 ----- ```rust #![feature(const_generics)] struct A; impl A { fn foo<const N: usize>(&self) -> usize { N } } struct B; impl B { fn foo<const N: usize>(&self) -> usize { 42 } } fn main() { let a = A; a.foo::<7>(); } ``` When calling `type_of` for generic const arguments, we now use the `TypeckTables` of the surrounding body to get the expected type. This alone causes cycle errors though, as we now have `typeck_tables_of(main)` -> `...` -> `type_of(main_ANON0 := 7)` -> `typeck_tables_of(main)` :zap: (see https://github.com/rust-lang/rust/issues/68400#issuecomment-611760290) To prevent this we must not call `type_of(const_arg)` during `typeck_tables_of`. This is achieved by calling `type_of(param_def_id)` instead. We have to somehow remember the `DefId` of the param through all of typeck, which is done using the struct `ty::WithOptConstParam<DefId>`, which replaces `DefId` where needed and contains an `Option<DefId>` to be able to store the const parameter in case it exists. Queries which are currently cached on disk are split into two variants: `query_name`(cached) and `query_name_(of|for)_const_arg`(not cached), with `query_name_of_const_arg` taking a pair `(did, param_did): (LocalDefId, DefId)`. For some queries a method `query_name_of_opt_const_arg` is added to `TyCtxt` which takes a `ty::WithOptConstParam` and either calls `query_name` or `query_name_of_const_arg` depending on the value of `const_param_did`. r? @eddyb @varkor
2020-07-15unify Instance::resolveBastian Kauschke-12/+15
2020-07-15unsafety_check_result_for_const_argBastian Kauschke-1/+1
2020-07-15WithOptConstParam::dummy -> WithOptConstParam::unknownBastian Kauschke-4/+5
2020-07-15ty_def_id -> def_id_for_type_ofBastian Kauschke-3/+3
2020-07-15improve namingBastian Kauschke-42/+47
2020-07-15cleanupBastian Kauschke-6/+46
2020-07-15update promoted_mirBastian Kauschke-2/+14
2020-07-15update const arg queriesBastian Kauschke-32/+91
2020-07-15only call `typeck_tables_of_const_arg` for const argsBastian Kauschke-2/+13