about summary refs log tree commit diff
path: root/src/librustc
AgeCommit message (Collapse)AuthorLines
2019-10-01Rollup merge of #64840 - michaelwoerister:self-profiling-raii-refactor, ↵Tyler Mandry-125/+255
r=wesleywiser SelfProfiler API refactoring and part one of event review This PR refactors the `SelfProfiler` a little bit so that most profiling methods are RAII-based. The codegen backend code already had something similar, this refactoring pulls this functionality up into `SelfProfiler` itself, for general use. The second commit of this PR is a review and update of the existing events we are already recording. Names have been made more consistent. CGU names have been removed from event names. They will be added back in when function parameter recording is implemented. There is still some work to be done for adding new events, especially around trait resolution and the incremental system. r? @wesleywiser
2019-10-01Rollup merge of #64722 - Mark-Simulacrum:alt-parallel, r=alexcrichtonTyler Mandry-10/+17
Make all alt builders produce parallel-enabled compilers We're not quite ready to ship parallel compilers by default, but the alt builders are not used too much (in theory), so we believe that shipping a possibly-broken compiler there is not too problematic. r? @nikomatsakis
2019-10-02typo fix in the codeGuanqun Lu-1/+1
2019-10-01Rename to `was_placeholder` to `from_forall`Aaron Hill-1/+11
2019-10-02comment fixesGuanqun Lu-0/+4
2019-10-01Improve HRTB error span when -Zno-leak-check is usedAaron Hill-4/+6
As described in #57374, NLL currently produces unhelpful higher-ranked trait bound (HRTB) errors when '-Zno-leak-check' is enabled. This PR tackles one half of this issue - making the error message point at the proper span. The error message itself is still the very generic "higher-ranked subtype error", but this can be improved in a follow-up PR. The root cause of the bad spans lies in how NLL attempts to compute the 'blamed' region, for which it will retrieve a span for. Consider the following code, which (correctly) does not compile: ```rust let my_val: u8 = 25; let a: &u8 = &my_val; let b = a; let c = b; let d: &'static u8 = c; ``` This will cause NLL to generate the following subtype constraints: d :< c c :< b b <: a Since normal Rust lifetimes are covariant, this results in the following region constraints (I'm using 'd to denote the lifetime of 'd', 'c to denote the lifetime of 'c, etc.): 'c: 'd 'b: 'c 'a: 'b From this, we can derive that 'a: 'd holds, which implies that 'a: 'static must hold. However, this is not the case, since 'a refers to 'my_val', which does not outlive the current function. When NLL attempts to infer regions for this code, it will see that the region 'a has grown 'too large' - it will be inferred to outlive 'static, despite the fact that is not declared as outliving 'static We can find the region responsible, 'd, by starting at the *end* of the 'constraint chain' we generated above. This works because for normal (non-higher-ranked) lifetimes, we generally build up a 'chain' of lifetime constraints *away* from the original variable/lifetime. That is, our original lifetime 'a is required to outlive progressively more regions. If it ends up living for too long, we can look at the 'end' of this chain to determine the 'most recent' usage that caused the lifetime to grow too large. However, this logic does not work correctly when higher-ranked trait bounds (HRTBs) come into play. This is because HRTBs have *contravariance* with respect to their bound regions. For example, this code snippet compiles: ```rust let a: for<'a> fn(&'a ()) = |_| {}; let b: fn(&'static ()) = a; ``` Here, we require that 'a' is a subtype of 'b'. Because of contravariance, we end up with the region constraint 'static: 'a, *not* 'a: 'static This means that our 'constraint chains' grow in the opposite direction of 'normal lifetime' constraint chains. As we introduce subtypes, our lifetime ends up being outlived by other lifetimes, rather than outliving other lifetimes. Therefore, starting at the end of the 'constraint chain' will cause us to 'blame' a lifetime close to the original definition of a variable, instead of close to where the bad lifetime constraint is introduced. This PR improves how we select the region to blame for 'too large' universal lifetimes, when bound lifetimes are involved. If the region we're checking is a 'placeholder' region (e.g. the region 'a' in for<'a>, or the implicit region in fn(&())), we start traversing the constraint chain from the beginning, rather than the end. There are two (maybe more) different ways we generate region constraints for NLL: requirements generated from trait queries, and requirements generated from MIR subtype constraints. While the former always use explicit placeholder regions, the latter is more tricky. In order to implement contravariance for HRTBs, TypeRelating replaces placeholder regions with existential regions. This requires us to keep track of whether or not an existential region was originally a placeholder region. When we look for a region to blame, we check if our starting region is either a placeholder region or is an existential region created from a placeholder region. If so, we start iterating from the beginning of the constraint chain, rather than the end.
2019-10-01Rollup merge of #64950 - nnethercote:simplify-interners, r=varkor,spastorinoMazdak Farrokhzad-47/+22
Simplify interners Some code readability improvements.
2019-10-01Update src/librustc/ty/mod.rsSantiago Pastorino-1/+1
Co-Authored-By: Oliver Scherer <github35764891676564198441@oli-obk.de>
2019-10-01Make comment about dummy type a bit more clearSantiago Pastorino-1/+2
2019-10-01address review commentsAlex Zatelepin-15/+13
2019-10-01fix spurious unreachable_code lints for try{} block ok-wrappingAlex Zatelepin-13/+32
2019-10-01Rollup merge of #64937 - estebank:dedup-closure-err, r=CentrilMazdak Farrokhzad-1/+12
Deduplicate closure type errors Closure typing obligations flow in both direcitons to properly infer types. Because of this, we will get 2 type errors whenever there's an unfulfilled obligation. To avoid this, we deduplicate them in the `InferCtxt`.
2019-10-01Rollup merge of #64895 - davidtwco:issue-64130-async-error-definition, ↵Mazdak Farrokhzad-13/+201
r=nikomatsakis async/await: improve not-send errors cc #64130. ``` note: future does not implement `std::marker::Send` because this value is used across an await --> $DIR/issue-64130-non-send-future-diags.rs:15:5 | LL | let g = x.lock().unwrap(); | - has type `std::sync::MutexGuard<'_, u32>` LL | baz().await; | ^^^^^^^^^^^ await occurs here, with `g` maybe used later LL | } | - `g` is later dropped here ``` r? @nikomatsakis
2019-10-01Remove the `$lt_tcx` parameter from `direct_interners!`.Nicholas Nethercote-7/+7
It's not necessary.
2019-10-01Inline and remove `intern_method!`.Nicholas Nethercote-26/+14
It's only used in two places, and the code is shorter and more readable with it gone.
2019-10-01Remove special treatment for `_intern_canonical_var_infos`.Nicholas Nethercote-14/+1
This is a leftover from when there were global and thread-local arenas.
2019-10-01Reorder the slice interners.Nicholas Nethercote-2/+2
So the order matches the order in `CtxtInterners`.
2019-10-01Avoid `SmallVec::collect()` in `List<Predicate>::super_fold_with()`.Nicholas Nethercote-2/+15
Also avoid interning when it's not necessary. This commit reduces instruction counts for a couple of benchmarks by up to 1%.
2019-10-01Avoid `SmallVec::collect()` in `Result::intern_with()`.Nicholas Nethercote-2/+23
This commit reduces instruction counts for several benchmarks by up to 5%.
2019-09-30Deduplicate closure type errorsEsteban Küber-1/+12
Closure typing obligations flow in both direcitons to properly infer types. Because of this, we will get 2 type errors whenever there's an unfulfilled obligation. To avoid this, we deduplicate them in the `InferCtxt`.
2019-10-01Avoid `SmallVec::collect()` in `SubstsRef::super_fold_with()`.Nicholas Nethercote-8/+35
This commit reduces instruction counts for several benchmarks by up to 5%.
2019-09-30async/await: improve obligation errorsDavid Wood-13/+201
This commit improves obligation errors for async/await: ``` note: future does not implement `std::marker::Send` because this value is used across an await --> $DIR/issue-64130-non-send-future-diags.rs:15:5 | LL | let g = x.lock().unwrap(); | - has type `std::sync::MutexGuard<'_, u32>` LL | baz().await; | ^^^^^^^^^^^ await occurs here, with `g` maybe used later LL | } | - `g` is later dropped here ``` Signed-off-by: David Wood <david@davidtw.co>
2019-09-30Make the default parallelism 1Mark Rousskov-10/+17
This changes the default parallelism for parallel compilers to one, instead of the previous default, which was "num cpus". This is likely not an optimal default long-term, but it is a good default for testing whether parallel compilers are not a significant regression over a sequential compiler. Notably, this in theory makes a parallel-enabled compiler behave exactly like a sequential compiler with respect to the jobserver.
2019-09-30syntax: Split `ast::Attribute` into container and inner partsVadim Petrochenkov-8/+11
2019-09-30Remove unused parts of ExprUseVisitorMatthew Jasper-380/+78
2019-09-30Remove HIR based const qualificationMatthew Jasper-83/+14
2019-09-30Auto merge of #64778 - csmoe:index, r=eddybbors-52/+53
Introduce librustc_index crate Closes #50592
2019-09-30Self-Profiling: Make names of existing events more consistent and use new API.Michael Woerister-15/+11
2019-09-30Self-Profiling: Refactor SelfProfiler API to be RAII based where possible.Michael Woerister-110/+244
2019-09-29Auto merge of #64673 - Mark-Simulacrum:opt-match-ck, r=oli-obkbors-2/+16
Optimize try_eval_bits to avoid layout queries This specifically targets match checking, but is possibly more widely useful as well. In code with large, single-value match statements, we were previously spending a lot of time running layout_of for the primitive types (integers, chars) -- which is essentially useless. This optimizes the code to avoid those query calls by directly obtaining the size for these types, when possible. It may be worth considering adding a `size_of` query in the future which might be far faster, especially if specialized for "const" cases -- match arms being the most obvious example. It's possibly such a function would benefit from *not* being a query as well, since it's trivially evaluatable from the sty for many cases whereas a query needs to hash the input and such.
2019-09-29Optimize try_eval_bits to avoid layout queriesMark Rousskov-2/+16
This specifically targets match checking, but is possibly more widely useful as well. In code with large, single-value match statements, we were previously spending a lot of time running layout_of for the primitive types (integers, chars) -- which is essentially useless. This optimizes the code to avoid those query calls by directly obtaining the size for these types, when possible. It may be worth considering adding a `size_of` query in the future which might be far faster, especially if specialized for "const" cases -- match arms being the most obvious example. It's possibly such a function would benefit from *not* being a query as well, since it's trivially evaluatable from the sty for many cases whereas a query needs to hash the input and such.
2019-09-29Rollup merge of #64858 - skinny121:str-const-generics, r=varkorMazdak Farrokhzad-3/+31
Add support for relating slices in `super_relate_consts` This allows passing strings as generic arguments. Fixes #63773 Fixes #60813 r? @varkor
2019-09-29Rollup merge of #64825 - estebank:match-unit, r=CentrilMazdak Farrokhzad-12/+37
Point at enclosing match when expecting `()` in arm When encountering code like the following: ```rust fn main() { match 3 { 4 => 1, 3 => { println!("Yep it maches."); 2 } _ => 2 } println!("Bye!") } ``` point at the enclosing `match` expression and suggest ignoring the returned value: ``` error[E0308]: mismatched types --> $DIR/match-needing-semi.rs:8:13 | LL | / match 3 { LL | | 4 => 1, LL | | 3 => { LL | | 2 | | ^ expected (), found integer LL | | } LL | | _ => 2 LL | | } | | -- help: consider using a semicolon here | |_____| | expected this to be `()` | = note: expected type `()` found type `{integer} ``` Fix #40799.
2019-09-29remove indexed_vec re-export from rustc_data_structurescsmoe-45/+45
2019-09-29remove ClosureSubsts with SubstsRefcsmoe-7/+11
2019-09-29clean ClosureSubsts in rustc::tycsmoe-21/+26
2019-09-29introduce from_ref helper for replacementcsmoe-13/+86
2019-09-29remove bit_set re-export from rustc_data_structurescsmoe-7/+8
2019-09-29Auto merge of #64158 - tmandry:libtest-panic-abort, r=alexcrichtonbors-0/+2
panic=abort support in libtest Add experimental support for tests compiled with panic=abort. Enabled with `-Z panic_abort_tests`. r? @alexcrichton cc @cramertj
2019-09-29Auto merge of #64546 - weiznich:bugfix/rfc-2451-rerebalance-tests, ↵bors-1/+9
r=nikomatsakis Bugfix/rfc 2451 rerebalance tests r? @nikomatsakis Fixes #64412 Depends/Contains on #64414 cc #55437 and #63599
2019-09-29Auto merge of #64886 - Centril:rollup-30dqh8j, r=Centrilbors-373/+143
Rollup of 5 pull requests Successful merges: - #63492 (Remove redundancy from the implementation of C variadics.) - #64589 (Differentiate AArch64 bare-metal targets between hf and non-hf.) - #64799 (Fix double panic when printing query stack during an ICE) - #64824 (No StableHasherResult everywhere) - #64884 (Add pkg-config to dependency list if building for Linux on Linux) Failed merges: r? @ghost
2019-09-29Rollup merge of #64824 - Mark-Simulacrum:no-stable-hasher-result-everywhere, ↵Mazdak Farrokhzad-309/+114
r=michaelwoerister No StableHasherResult everywhere This removes the generic parameter on `StableHasher`, instead moving it to the call to `finish`. This has the side-effect of making all `HashStable` impls nicer, since we no longer need the verbose `<W: StableHasherResult>` that previously existed -- often forcing line wrapping. This is done for two reasons: * we should avoid false "generic" dependency on the result of StableHasher * we don't need to codegen two/three copies of all the HashStable impls when they're transitively used to produce a fingerprint, u64, or u128. I haven't measured, but this might actually make our artifacts somewhat smaller too. * Easier to understand/read/write code -- the result of the stable hasher is irrelevant when writing a hash impl.
2019-09-29Rollup merge of #64799 - Aaron1011:fix/double-panic, r=Mark-SimulacrumMazdak Farrokhzad-2/+6
Fix double panic when printing query stack during an ICE On the latest nightly, any call to `bug` or `span_bug` will result in two panics - the first one as a normal result of calling `bug` / `span_bug`, and the second as a result of trying to print the query stack from the panic handler. This is caused by the query-printing code attempting to acquire a lock on `HandlerInnder`, which is still being held by `bug`. This PR moves the actual panic out of `HandlerInner`, into `Handler`. This allows us to release the lock on `HandlerInner` before triggering the panic, ensuring that the panic handler will be able to acquire the lock if necessary.
2019-09-29Rollup merge of #63492 - eddyb:cvarargs, r=nagisa,matthewjasperMazdak Farrokhzad-62/+23
Remove redundancy from the implementation of C variadics. This cleanup was first described in https://github.com/rust-lang/rust/issues/44930#issuecomment-497163539: * AST doesn't track `c_variadic: bool` anymore, relying solely on a trailing `CVarArgs` type in fn signatures * HIR doesn't have a `CVarArgs` anymore, relying solely on `c_variadic: bool` * same for `ty::FnSig` (see tests for diagnostics improvements from that) * `{hir,mir}::Body` have one extra argument than the signature when `c_variadic == true` * `rustc_typeck` and `rustc_mir::{build,borrowck}` need to give that argument the right type (which no longer uses a lifetime parameter, but a function-internal scope) * `rustc_target::abi::call` doesn't need special hacks anymore (since it never sees the `VaListImpl` now, it's all inside the body) r? @nagisa / @rkruppe cc @dlrobertson @oli-obk
2019-09-29Auto merge of #64470 - ecstatic-morse:split-promotion-and-validation, ↵bors-0/+2
r=eddyb,oli-obk Implement dataflow-based const validation This PR adds a separate, dataflow-enabled pass that checks the bodies of `const`s, `static`s and `const fn`s for [const safety](https://github.com/rust-rfcs/const-eval/blob/master/const.md). This is based on my work in #63860, which tried to integrate into the existing pass in [`qualify_consts.rs`](https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/qualify_consts.rs). However, the resulting pass was even more unwieldy than the original. Unlike its predecessor, this PR is designed to be combined with #63812 to replace the existing pass completely. The new checker lives in [`librustc_mir/transform/check_consts`](https://github.com/ecstatic-morse/rust/tree/split-promotion-and-validation/src/librustc_mir/transform/check_consts). [`qualifs.rs`](https://github.com/ecstatic-morse/rust/blob/split-promotion-and-validation/src/librustc_mir/transform/check_consts/qualifs.rs) contains small modifications to the existing `Qualif` trait and its implementors, but is mostly unchanged except for the removal of `IsNotPromotable` and `IsNotImplicitlyPromotable`, which are only necessary for promotion. [`resolver.rs`](https://github.com/ecstatic-morse/rust/blob/split-promotion-and-validation/src/librustc_mir/transform/check_consts/resolver.rs) contains the dataflow analysis used to propagate qualifs between locals. Finally, [`validation.rs`](https://github.com/ecstatic-morse/rust/blob/split-promotion-and-validation/src/librustc_mir/transform/check_consts/validation.rs) contains a refactored version of the existing [`Visitor`](https://github.com/rust-lang/rust/blob/ca3766e2e58f462a20922e42c821a37eaf0e13db/src/librustc_mir/transform/qualify_consts.rs#L1024) in `qualfy_consts.rs`. All errors have been associated with a `struct` to make [comparison with the existing pass](https://github.com/ecstatic-morse/rust/blob/1c19f2d540ca0a964900449d79a5d5181b43146d/src/librustc_mir/transform/qualify_consts.rs#L1006) simple. The existing validation logic in [`qualify_consts`](https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/qualify_consts.rs) has been modified to allow it to run in parallel with the new validator. If [`use_new_validator`](https://github.com/rust-lang/rust/pull/64470/files#diff-c2552a106550d05b69d5e07612f0f812R950) is not set, the old validation will be responsible for actually generating the errors, but those errors can be compared with the ones from the new validator.
2019-09-28Put panic=abort test support behind -Z panic_abort_testsTyler Mandry-0/+2
2019-09-28Rollup merge of #64763 - GuillaumeGomez:long-err-explanation-E0734, r=estebankMazdak Farrokhzad-2/+23
Add E0734 and its long explanation Part of https://github.com/rust-lang/rust/issues/61137
2019-09-28Rollup merge of #64678 - tomtau:fix/no-std-error, r=matthewjasperMazdak Farrokhzad-7/+38
added more context for duplicate lang item errors (fixes #60561) Some more information about #60561 -- these errors are pretty common when one works in restrictive environments with `no_std` or customized `std`, but they don't provide much context for debugging, as any transitive dependency could have brought in `std` crate. With that, currently, one needs to use something like `cargo tree` and investigate transitive dependencies one by one. It'll be more helpful to know at least the crate that uses `std` (which `cargo tree` doesn't show) to pin down this investigation when debugging. I'm not sure what the best way to get this context is inside rustc internals (I'm new to them). I found that `all_crate_nums` query returns the crates in some dependency order, so printing out the name of the preceding crate seems to do the trick. But I welcome suggestions if this can be done in a better way.
2019-09-28clean upEsteban Küber-2/+2
2019-09-28review commentsEsteban Küber-0/+5