about summary refs log tree commit diff
path: root/src
AgeCommit message (Collapse)AuthorLines
2020-03-21Return NonZeroU64 from ThreadId::as_u64.Thomas Bächler-4/+4
As discussed in #67939, this allows turning Option<ThreadId> into Option<NonZeroU64> which can then be stored inside an AtomicU64.
2020-03-21Rollup merge of #70151 - Amanieu:stdarch, r=sfacklerMazdak Farrokhzad-0/+0
Update stdarch submodule This only includes one commit: - https://github.com/rust-lang/stdarch/commit/abe96ca3b87fcca6aa1dfcefd40d8c8d92d2e673 (https://github.com/rust-lang/stdarch/pull/842) Fixes #68905
2020-03-21Rollup merge of #70138 - RalfJung:throw-not-return, r=oli-obkMazdak Farrokhzad-11/+12
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-391/+394
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-76/+51
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 #70054 - rojamd:android-pgo, r=michaelwoeristerMazdak Farrokhzad-1/+1
Build dist-android with --enable-profiler This will make the runtime available to enable PGO for Rust code in Firefox on Android. r? @michaelwoerister
2020-03-21Rollup merge of #69965 - mark-i-m:codegen-utils, r=eddybMazdak Farrokhzad-267/+244
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 #69934 - andjo403:inlinecost, r=wesleywiserMazdak Farrokhzad-2/+17
Update the mir inline costs handle that when mir is lowered to llvm-ir more code is generated. Landingpads generates 10 llvm-ir instructions and resume 9 llvm-ir instructions. r? @wesleywiser
2020-03-21Rollup merge of #67888 - Zoxc:metadata-prefetch, r=matthewjasperMazdak Farrokhzad-33/+136
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-21Rollup merge of #70194 - kornelski:must_split, r=joshtriplettMazdak Farrokhzad-0/+1
#[must_use] on split_off() I've noticed this function used for truncation in the wild. `must_use` will clear that up.
2020-03-21Rollup merge of #70189 - RalfJung:is_signed, r=eddybMazdak Farrokhzad-2/+2
Abi::is_signed: assert that we are a Scalar A bit more sanity checking, suggested by @eddyb. This makes this method actually "safer" than `TyS::is_signed`, so I made sure Miri consistently uses the `Abi` version. Though I am not sure if this would have caught the mistake where the layout of a zero-sized enum was asked for its sign. r? @eddyb
2020-03-21Rollup merge of #70188 - GuillaumeGomez:cleanup-e0439, r=Dylan-DPCMazdak Farrokhzad-2/+3
Clean up E0439 explanation r? @Dylan-DPC
2020-03-21Rollup merge of #70187 - matthiaskrgr:cl2ppy, r=Mark-SimulacrumMazdak Farrokhzad-172/+142
more clippy fixes * remove redundant returns (clippy::needless_return) * remove redundant import (clippy::single_component_path_imports) * remove redundant format!() call (clippy::useless_format) * don't use ok() before calling expect() (clippy::ok_expect)
2020-03-21Rollup merge of #70184 - Centril:include-mod-relativism, r=petrochenkovMazdak Farrokhzad-1/+25
expand_include: set `.directory` to dir of included file. Resolves the regression noted in https://github.com/rust-lang/rust/pull/69838/#discussion_r395217057. r? @petrochenkov cc @eddyb @Mark-Simulacrum
2020-03-21Rollup merge of #70177 - bjorn3:patch-2, r=Dylan-DPCMazdak Farrokhzad-1/+1
Fix oudated comment for NamedRegionMap `ResolveLifetimes` uses a `LocalDefId` since #66131.
2020-03-21Rollup merge of #70176 - rylev:ice-tests, r=CentrilMazdak Farrokhzad-0/+651
Add tests for #58319 and #65131 Fixes #58319 and fixes #65131
2020-03-21Rollup merge of #70166 - CDirkx:range-inclusive-derives, r=cramertjMazdak Farrokhzad-22/+2
Derive PartialEq, Eq and Hash for RangeInclusive The manual implementation of `PartialEq`, `Eq` and `Hash` for `RangeInclusive` was functionally equivalent to a derived implementation. This change removes the manual implementation and adds the respective derives. A side effect of this change is that the derives also add implementations for `StructuralPartialEq` and `StructuralEq`, which enables `RangeInclusive` to be used in const generics, closing #70155. This change is enabled by #68835, which changed the field `is_empty: Option<bool>` to `exhausted: bool` removing the need for *semantic* equality instead of *structural* equality. ## PartialEq original [`PartialEq`](https://github.com/rust-lang/rust/blob/f4c675c476c18b1a11041193f2f59d695b126bc8/src/libcore/ops/range.rs#L353-L359) implementation: ```rust #[stable(feature = "inclusive_range", since = "1.26.0")] impl<Idx: PartialEq> PartialEq for RangeInclusive<Idx> { #[inline] fn eq(&self, other: &Self) -> bool { self.start == other.start && self.end == other.end && self.exhausted == other.exhausted } } ``` expanded derive implementation (using `cargo expand ops::range`): ```rust #[stable(feature = "inclusive_range", since = "1.26.0")] impl<Idx> crate::marker::StructuralPartialEq for RangeInclusive<Idx> {} #[automatically_derived] #[allow(unused_qualifications)] #[stable(feature = "inclusive_range", since = "1.26.0")] impl<Idx: crate::cmp::PartialEq> crate::cmp::PartialEq for RangeInclusive<Idx> { #[inline] fn eq(&self, other: &RangeInclusive<Idx>) -> bool { match *other { RangeInclusive { start: ref __self_1_0,end: ref __self_1_1, exhausted: ref __self_1_2 } => match *self { RangeInclusive { start: ref __self_0_0, end: ref __self_0_1, exhausted: ref __self_0_2 } => { (*__self_0_0) == (*__self_1_0) && (*__self_0_1) == (*__self_1_1) && (*__self_0_2) == (*__self_1_2) } }, } } #[inline] fn ne(&self, other: &RangeInclusive<Idx>) -> bool { match *other { RangeInclusive { start: ref __self_1_0, end: ref __self_1_1, exhausted: ref __self_1_2 } => match *self { RangeInclusive { start: ref __self_0_0, end: ref __self_0_1exhausted: ref __self_0_2 } => { (*__self_0_0) != (*__self_1_0) || (*__self_0_1) != (*__self_1_1) || (*__self_0_2) != (*__self_1_2) } }, } } } ``` These implementations both test for *structural* equality, with the same order of field comparisons, and the bound `Idx: PartialEq` is the same. ## Eq original [`Eq`](https://github.com/rust-lang/rust/blob/f4c675c476c18b1a11041193f2f59d695b126bc8/src/libcore/ops/range.rs#L361-L362) implementation: ```rust #[stable(feature = "inclusive_range", since = "1.26.0")] impl<Idx: Eq> Eq for RangeInclusive<Idx> {} ``` expanded derive implementation (using `cargo expand ops::range`): ```rust #[stable(feature = "inclusive_range", since = "1.26.0")] impl<Idx> crate::marker::StructuralEq for RangeInclusive<Idx> {} #[automatically_derived] #[allow(unused_qualifications)] #[stable(feature = "inclusive_range", since = "1.26.0")] impl<Idx: crate::cmp::Eq> crate::cmp::Eq for RangeInclusive<Idx> { #[inline] #[doc(hidden)] fn assert_receiver_is_total_eq(&self) -> () { { let _: crate::cmp::AssertParamIsEq<Idx>; let _: crate::cmp::AssertParamIsEq<Idx>; let _: crate::cmp::AssertParamIsEq<bool>; } } } ``` These implementations are equivalent since `Eq` is just a marker trait and the bound `Idx: Eq` is the same. ## Hash original [`Hash`](https://github.com/rust-lang/rust/blob/f4c675c476c18b1a11041193f2f59d695b126bc8/src/libcore/ops/range.rs#L364-L371) implementation: ```rust #[stable(feature = "inclusive_range", since = "1.26.0")] impl<Idx: Hash> Hash for RangeInclusive<Idx> { fn hash<H: Hasher>(&self, state: &mut H) { self.start.hash(state); self.end.hash(state); self.exhausted.hash(state); } } ``` expanded derive implementation (using `cargo expand ops::range`): ```rust #[automatically_derived] #[allow(unused_qualifications)] #[stable(feature = "inclusive_range", since = "1.26.0")] impl<Idx: crate::hash::Hash> crate::hash::Hash for RangeInclusive<Idx> { fn hash<__H: crate::hash::Hasher>(&self, state: &mut __H) -> () { match *self { RangeInclusive { start: ref __self_0_0, end: ref __self_0_1, exhausted: ref __self_0_2 } => { crate::hash::Hash::hash(&(*__self_0_0), state); crate::hash::Hash::hash(&(*__self_0_1), state); crate::hash::Hash::hash(&(*__self_0_2), state) } } } } ``` These implementations are functionally equivalent, with the same order of field hashing, and the bound `Idx: Hash` is the same.
2020-03-21Rollup merge of #70165 - matthewjasper:erase-more, r=nikomatsakisMazdak Farrokhzad-110/+63
Remove the erase regions MIR transform We now ensure that MIR never contains unerased regions in the first place.
2020-03-21Rollup merge of #70139 - RalfJung:delay, r=eddybMazdak Farrokhzad-0/+4
add delay_span_bug to TransmuteSizeDiff, just to be sure See https://github.com/rust-lang/rust/pull/69839#discussion_r394858464. r? @eddyb
2020-03-21Rollup merge of #70111 - Mark-Simulacrum:btree-no-shared, r=cuviperMazdak Farrokhzad-266/+223
BTreeMap: remove shared root This replaces the shared root with `Option`s in the BTreeMap code, and then slightly cleans up the node manipulation code taking advantage of the removal of the shared root. I expect that further simplification is possible, but wanted to get this posted for initial review. Note that `BTreeMap::new()` continues to not allocate. Benchmarks seem within the margin of error/unaffected, as expected for an entirely predictable branch. ``` name alloc-bench-a ns/iter alloc-bench-b ns/iter diff ns/iter diff % speedup btree::map::iter_mut_20 20 21 1 5.00% x 0.95 btree::set::clone_100 1,360 1,439 79 5.81% x 0.95 btree::set::clone_100_and_into_iter 1,319 1,434 115 8.72% x 0.92 btree::set::clone_10k 143,515 150,991 7,476 5.21% x 0.95 btree::set::clone_10k_and_clear 142,792 152,916 10,124 7.09% x 0.93 btree::set::clone_10k_and_into_iter 146,019 154,561 8,542 5.85% x 0.94 ```
2020-03-21Rollup merge of #70058 - Centril:fix-70050, r=petrochenkovMazdak Farrokhzad-9/+55
can_begin_literal_maybe_minus: `true` on `"-"? lit` NTs. Make `can_begin_literal_or_bool` (renamed to `can_begin_literal_maybe_minus`) accept `NtLiteral(e) | NtExpr(e)` where `e` is either a literal or a negated literal. Fixes https://github.com/rust-lang/rust/issues/70050. r? @petrochenkov
2020-03-21Rollup merge of #70038 - DutchGhost:const-forget-tests, r=RalfJungMazdak Farrokhzad-18/+22
Remove the call that makes miri fail Fixes the concern raised in https://github.com/rust-lang/rust/pull/69645/files#r392884274 cc @RalfJung
2020-03-21Rollup merge of #69997 - WaffleLapkin:option_zip, r=LukasKalbertodtMazdak Farrokhzad-0/+58
add `Option::{zip,zip_with}` methods under "option_zip" gate This PR introduces 2 methods - `Option::zip` and `Option::zip_with` with respective signatures: - zip: `(Option<T>, Option<U>) -> Option<(T, U)>` - zip_with: `(Option<T>, Option<U>, (T, U) -> R) -> Option<R>` Both are under the feature gate "option_zip". I'm not sure about the name "zip", maybe we can find a better name for this. (I would prefer `union` for example, but this is a keyword :( ) -------------------------------------------------------------------------------- Recently in a russian rust begginers telegram chat a newbie asked (translated): > Are there any methods for these conversions: > > 1. `(Option<A>, Option<B>) -> Option<(A, B)>` > 2. `Vec<Option<T>> -> Option<Vec<T>>` > > ? While second (2.) is clearly `vec.into_iter().collect::<Option<Vec<_>>()`, the first one isn't that clear. I couldn't find anything similar in the `core` and I've come to this solution: ```rust let tuple: (Option<A>, Option<B>) = ...; let res: Option<(A, B)> = tuple.0.and_then(|a| tuple.1.map(|b| (a, b))); ``` However this solution isn't "nice" (same for just `match`/`if let`), so I thought that this functionality should be in `core`.
2020-03-21Rollup merge of #69033 - jonas-schievink:resume-with-context, r=tmandryMazdak Farrokhzad-36/+204
Use generator resume arguments in the async/await lowering This removes the TLS requirement from async/await and enables it in `#![no_std]` crates. Closes https://github.com/rust-lang/rust/issues/56974 I'm not confident the HIR lowering is completely correct, there seem to be quite a few undocumented invariants in there. The `async-std` and tokio test suites are passing with these changes though.
2020-03-21Rollup merge of #65097 - tmiasko:arc, r=AmanieuMazdak Farrokhzad-4/+22
Make std::sync::Arc compatible with ThreadSanitizer The memory fences used previously in Arc implementation are not properly understood by thread sanitizer as synchronization primitives. This had unfortunate effect where running any non-trivial program compiled with `-Z sanitizer=thread` would result in numerous false positives. Replace acquire fences with acquire loads to address the issue. Fixes #39608.
2020-03-20more type annotations to help inferenceRalf Jung-5/+5
2020-03-20remove redundant returns (clippy::needless_return)Matthias Krüger-170/+142
2020-03-20remove redundant import (clippy::single_component_path_imports)Matthias Krüger-4/+1
remove redundant format!() call (clippy::useless_format) don't use ok() before calling expect() (clippy::ok_expect)
2020-03-20Auto merge of #69509 - RalfJung:debug-assert-write, r=eddybbors-12/+6
debug-assert ptr sanity in ptr::write This is a re-submission of the parts that we removed from https://github.com/rust-lang/rust/pull/69208 due to ["interesting" test failures](https://github.com/rust-lang/rust/pull/69208#issuecomment-591310437). Fixes https://github.com/rust-lang/rust/issues/53871 r? @Mark-Simulacrum @eddyb
2020-03-20expand_include: set `.directory` to dir of included file.Mazdak Farrokhzad-1/+25
2020-03-20Abi::is_signed: assert that we are a ScalarRalf Jung-2/+2
2020-03-20Clean up E0439 explanationGuillaume Gomez-2/+3
2020-03-20Fix debugger pretty printing of BTreesMark Rousskov-20/+38
2020-03-20can_begin_literal_maybe_minus: `true` on `"-"? lit` NTs.Mazdak Farrokhzad-9/+55
2020-03-20must_use on split_offKornel-0/+1
2020-03-20Update test commentary for shared root removalMark Rousskov-9/+2
2020-03-20Simplify ensure_root_is_owned callersMark Rousskov-15/+13
This makes ensure_root_is_owned return a reference to the (now guaranteed to exist) root, allowing callers to operate on it without going through another unwrap. Unfortunately this is only rarely useful as it's frequently the case that both the length and the root need to be accessed and field-level borrows in methods don't yet exist.
2020-03-20Drop NodeHeader type from BTree codeMark Rousskov-41/+5
We no longer have a separate header because the shared root is gone; all code can work solely with leafs now.
2020-03-20Make functions dependent only on shared root avoidance safeMark Rousskov-58/+58
2020-03-20Remove shared root code and assertions from BTree nodesMark Rousskov-59/+8
2020-03-20Replace shared root with optional rootMark Rousskov-77/+112
This simplifies the node manipulation, as we can (in later commits) always know when traversing nodes that we are not in a shared root.
2020-03-20Add tests for #58319 and #65131Ryan Levick-0/+651
2020-03-20Fix oudated comment for NamedRegionMapbjorn3-1/+1
2020-03-20Update const_forget.rsDutchGhost-1/+1
2020-03-20Rollup merge of #70146 - GuillaumeGomez:cleanup-e0438, r=Dylan-DPCYuki Okushi-4/+5
Clean up e0438 explanation r? @Dylan-DPC
2020-03-20Rollup merge of #70145 - lzutao:patch-1, r=Dylan-DPCYuki Okushi-4/+4
doc: Add quote to .init_array The current formatting is not good without quotes: ![without-quote](https://i.imgur.com/RkIm4cr.png)
2020-03-20Rollup merge of #70133 - hermitcore:libpanic_unwind, r=nikomatsakisYuki Okushi-1/+0
remove unused imports patch is required to avoid compiler errors by building src/libpanic_unwind/hermit.rs
2020-03-20Rollup merge of #70131 - Aaron1011:fix/issue-55099-test, r=nikomatsakisYuki Okushi-0/+28
Add regression test for TAIT lifetime inference (issue #55099) Fixes #55099 The minimized reproducer in issue #55099 now compiles successfully. This commit adds a regression test for it.
2020-03-20Rollup merge of #70103 - GuillaumeGomez:cleanup-e0437, r=Dylan-DPCYuki Okushi-4/+5
Clean up E0437 explanation r? @Dylan-DPC
2020-03-20Rollup merge of #69935 - davidtwco:issue-69925, r=eddybYuki Okushi-83/+102
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