about summary refs log tree commit diff
path: root/src/librustc
AgeCommit message (Collapse)AuthorLines
2020-03-23add macro to reduce boilerplate and keep readable messagesRalf Jung-1/+1
2020-03-23Rollup merge of #70286 - RalfJung:no-experiments, r=petrochenkovMazdak Farrokhzad-5/+2
Miri error type: remove UbExperimental variant In https://github.com/rust-lang/miri/pull/1250, I will move Miri away from that variant, and use a custom `MachineStop` exception instead.
2020-03-23Rollup merge of #69968 - eddyb:tupled-closure-captures, r=nikomatsakisMazdak Farrokhzad-156/+160
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-23add err_machine_stop macroRalf Jung-3/+8
2020-03-23Auto merge of #70296 - Centril:rollup-wvfmb3n, r=Centrilbors-16/+7
Rollup of 9 pull requests Successful merges: - #69251 (#[track_caller] in traits) - #69880 (miri engine: turn error sanity checks into assertions) - #70207 (Use getentropy(2) on macos) - #70227 (Only display definition when suggesting a typo) - #70236 (resolve: Avoid "self-confirming" import resolutions in one more case) - #70248 (parser: simplify & remove unused field) - #70249 (handle ConstKind::Unresolved after monomorphizing) - #70269 (remove redundant closures (clippy::redundant_closure)) - #70270 (Clean up E0449 explanation) Failed merges: r? @ghost
2020-03-23Rollup merge of #70269 - matthiaskrgr:clippy_closures, r=Dylan-DPCMazdak Farrokhzad-2/+2
remove redundant closures (clippy::redundant_closure)
2020-03-23Rollup merge of #69251 - anp:track-caller-in-traits, r=eddybMazdak Farrokhzad-14/+5
#[track_caller] in traits Per https://github.com/rust-lang/rust/issues/47809#issuecomment-572791760, this allows the `#[track_caller]` attribute on trait methods. Includes tests for `#[track_caller]` with: * "regular" trait impls * default trait impls * "blanket-tracked" trait impls, where the annotation is in the trait definition and is inherited by "regular" impls of the trait
2020-03-23Auto merge of #70204 - Centril:unshackled-lowering, r=Zoxcbors-823/+7
Liberate `rustc_ast_lowering` from `rustc` The whole point of this PR is the very last commit, in which we remove `rustc` as one of `rustc_ast_lowering`'s dependencies, thereby improving `./x.py` parallelism and working towards https://github.com/rust-lang/rust/issues/65031. Noteworthy: - From `rustc::arena` we move logic into `arena`, in particular `declare_arena!`. This is then used in `rustc_ast_lowering` so that lowering has its own separate arena. - Some linting code is unfortunately moved to `rustc_session::lint` cause its used both in `rustc_lint` and `rustc_ast_lowering`, and this is their common dependency. - `rustc_session::CrateDisambiguator` is moved into `rustc_ast` so that `rustc::hir::map::definitions` can be moved into `rustc_hir`, so that `rustc_ast_lowering` can stop referring to `rustc::hir`. r? @Zoxc
2020-03-22Remove special-casing from TyCtxt::impl_of_method.Adam Perry-12/+2
We can do this now that opt_associated_item doesn't have any panicking paths.
2020-03-22Allow #[track_caller] in traits.Adam Perry-2/+3
The codegen implementation already works for this, so we're: * propagating track_caller attr from trait def to impl * relaxing errors * adding tests Approved in a recent lang team meeting: https://github.com/rust-lang/lang-team/blob/master/minutes/2020-01-09.md
2020-03-22Auto merge of #69778 - Marwes:dep_graph, r=davidtwcobors-11/+24
perf(dep_graph): Avoid allocating a set on when the number reads are … …small `reserve_and_rehash` takes up 1.4% of the runtime on the `packed-simd` benchmark which I believe is due to the number of reads are very low in many cases (see https://github.com/rust-lang/rust/pull/50565 for instance). This avoids allocating the set until we start allocating the `reads` `SmallVec` but it is possible that a lower limit might be better (not tested since the improvement will be hard to spot either way).
2020-03-22remove UbExperimental variantRalf Jung-5/+2
2020-03-22avoid unsafe code, use upcasting-trait instead (trick by oli)Ralf Jung-25/+16
2020-03-22Rename `TimeLimitReached` -> `StepLimitReached`Dylan MacKenzie-2/+4
2020-03-22Rollup merge of #70254 - matthiaskrgr:cl4ppy, r=CentrilDylan DPC-3/+1
couple more clippy fixes (let_and_return, if_same_then_else) * summarize if-else-code with identical blocks (clippy::if_same_then_else) * don't create variable bindings just to return the bound value immediately (clippy::let_and_return)
2020-03-22Rollup merge of #70229 - matthiaskrgr:cl3ppy, r=Mark-SimulacrumDylan DPC-30/+26
more clippy fixes * remove unused unit values (clippy::unused_unit) * make some let-if-bindings more idiomatic (clippy::useless_let_if_seq) * clarify when we pass () to functions (clippy::unit_arg) * don't redundantly repeat field names (clippy::redundant_field_names) * remove redundant returns (clippy::needless_return) * use let instead of match for matches with single bindings (clippy::match_single_binding) * don't convert results to options just for matching (clippy::if_let_some_result)
2020-03-22remove redundant closures (clippy::redundant_closure)Matthias Krüger-2/+2
2020-03-22get rid of ConstPropUnsupported; use ZST marker structs insteadRalf Jung-13/+40
2020-03-22don't create variable bindings just to return the bound value immediately ↵Matthias Krüger-3/+1
(clippy::let_and_return)
2020-03-21Rollup merge of #70051 - Zoxc:opt-find, r=eddybDylan DPC-19/+24
Allow `hir().find` to return `None` Fixes https://github.com/rust-lang/rust/issues/70041 r? @eddyb
2020-03-21Rollup merge of #70003 - eddyb:symbol-mangling-reify-shims, r=nikomatsakisDylan DPC-4/+0
symbol_names: treat ReifyShim like VtableShim. Without this, the `#[track_caller]` tests don't pass with `-Zsymbol-mangling-version=v0`, because there is a symbol name collision between the `ReifyShim` and the original definition. cc @anp
2020-03-21{rustc::hir::map -> rustc_hir}::definitionsMazdak Farrokhzad-552/+4
2020-03-21move CrateDisambiguator -> rustc_astMazdak Farrokhzad-3/+2
2020-03-21add_elided_lifetime_in_path_suggestion -> rustc_sessionMazdak Farrokhzad-43/+1
2020-03-21separate out an arena for HIRMazdak Farrokhzad-34/+1
2020-03-21move move stuff into declare_arena!Mazdak Farrokhzad-102/+1
2020-03-21move more logic into declare_arena!Mazdak Farrokhzad-62/+62
2020-03-21merge impl_arena_allocatable & declare_arenaMazdak Farrokhzad-16/+10
2020-03-21move DropArena -> libarenaMazdak Farrokhzad-86/+1
2020-03-21remove unused unit values (clippy::unused_unit)Matthias Krüger-1/+1
2020-03-21make some let-if-bindings more idiomatic (clippy::useless_let_if_seq)Matthias Krüger-29/+25
2020-03-21Allow `hir().find` to return `None`John Kåre Alsaker-19/+24
2020-03-21symbol_names: treat ReifyShim like VtableShim.Eduard-Mihai Burtescu-4/+0
2020-03-21rustc: make {Closure,Generator}Substs::split as cheap as possible.Eduard-Mihai Burtescu-67/+31
2020-03-21rustc: keep upvars tupled in {Closure,Generator}Substs.Eduard-Mihai Burtescu-124/+164
2020-03-21Rollup merge of #70119 - eddyb:typeck-tables-local-def-id, r=petrochenkovDylan DPC-77/+50
rustc: use LocalDefId instead of DefId in TypeckTables. The logic in `TypeckTables`' implementation of `HashStable`, which created `DefId`s by combining a `CrateNum` from a `DefId` and a `DefIndex` from a `LocalDefId`, bothered me a bit. I don't know how much this matters, but it works so might as well submit it.
2020-03-21Rollup merge of #69910 - cjgillot:polym, r=ZoxcDylan DPC-201/+226
Avoid query type in generics There are at the moment roughly 170 queries in librustc. The way ty::query is structured, a lot of code is duplicated for each query. I suspect this to be responsible for a part of librustc'c compile time. This PR reduces the amount of code generic on the query, replacing it by code generic on the key-value types. This is split out of #69808, and should not contain the perf regression. cc #65031
2020-03-21Rollup merge of #70138 - RalfJung:throw-not-return, r=oli-obkMazdak Farrokhzad-5/+6
do not 'return' in 'throw_' macros In https://github.com/rust-lang/rust/pull/69839 we turned a closure into a `try` block, but it turns out that does not work with our `throw_` macros, which `return` so they skip the `try`. Here we fix that. For some reason that means we also have to remove some `;`. r? @oli-obk
2020-03-21Rollup merge of #70092 - eddyb:hir-items-are-just-nodes, r=ZoxcMazdak Farrokhzad-36/+39
hir: replace "items" terminology with "nodes" where appropriate. The newly added `HirOwnerItems` confused me before I realized that "items" there actually referred to HIR nodes, not `hir:Item` or "item-like" (which we should IMO replace with "owner"). I suspect the naming had something to do with `ItemLocalId`'s use of "item". That is, `ItemLocalId` could be interpreted to mean one of two things: * `IntraItemNodeId` i.e. `IntraOwnerNodeId` * this is IMO correct, and I'd even like to rename it, but I didn't want to throw that into this PR * `IntraOwnerItemId` * this is what `HirOwnerItems` would seem to imply r? @Zoxc cc @michaelwoerister @nikomatsakis
2020-03-21Rollup merge of #70089 - eddyb:closure-sig-infer, r=nikomatsakisMazdak Farrokhzad-20/+14
rustc_infer: remove InferCtxt::closure_sig as the FnSig is always shallowly known. That is, `ClosureSubsts` is always created (in `rustc_typeck::check::closure`) with a `FnSig`, as the number of inputs is known, even if they might all have inference types. The only useful thing `InferCtxt::closure_sig` was doing is resolving an inference variable used just to get the `ty::FnPtr` containing that `FnSig` into `ClosureSubsts`. The ideal way to solve this would be to add a constructor for `ClosureSubsts`, that combines the parent `Substs`, the closure kind, the signature, and capture types together, but for now I've went with resolving the inference types just after unifying them with the real types. r? @nikomatsakis
2020-03-21Rollup merge of #69965 - mark-i-m:codegen-utils, r=eddybMazdak Farrokhzad-1/+16
Refactorings to get rid of rustc_codegen_utils r? @eddyb cc #45276 After this, the only modules left in `rustc_codegen_utils` are - `link`: a bunch of linking-related functions (many dealing with file names). These are mostly consumed by save analysis, rustc_driver, rustc_interface, and of course codegen. I assume they live here because we don't want a dependency of save analysis on codegen... Perhaps they can be moved to librustc? - ~`symbol_names` and `symbol_names_test`: honestly it seems odd that `symbol_names_test` is not a submodule of `symbol_names`. It seems like these could honestly live in their own crate or move to librustc. Already name mangling is exported as the `symbol_name` query.~ (move it to its own crate) I don't mind doing either of the above as part of this PR or a followup if you want.
2020-03-21Rollup merge of #67888 - Zoxc:metadata-prefetch, r=matthewjasperMazdak Farrokhzad-1/+1
Prefetch some queries used by the metadata encoder This brings the time for `metadata encoding and writing` for `syntex_syntax` from 1.338s to 0.997s with 6 threads in non-incremental debug mode. r? @Mark-Simulacrum
2020-03-20more type annotations to help inferenceRalf Jung-5/+5
2020-03-20remove redundant returns (clippy::needless_return)Matthias Krüger-10/+10
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-20Rollup merge of #69768 - oli-obk:union_field_ice, r=eddyb,RalfJungYuki Okushi-3/+11
Compute the correct layout for variants of uninhabited enums r? @eddyb cc @RalfJung fixes #69191 cc #69763
2020-03-19Refactorings to begin getting rid of rustc_codegen_utilsMark Mansi-1/+16
2020-03-19rustc/query: tweak comments on hir_owner{,_nodes}.Eduard-Mihai Burtescu-4/+5
2020-03-19Make the timer more verboseJohn Kåre Alsaker-1/+1
2020-03-19hir: replace "items" terminology with "nodes" where appropriate.Eduard-Mihai Burtescu-35/+37