about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2020-07-06Expand abbreviation in core::ffi descriptionpierwill-1/+1
2020-07-05Rollup merge of #74064 - RalfJung:variant-count-bootstrap, r=kennytmManish Goregaokar-7/+2
variant_count: avoid incorrect dummy implementation This also avoids a stage 0 doctest failure.
2020-07-05variant_count: avoid incorrect dummy implementationRalf Jung-7/+2
2020-07-05Fix spacing in Iterator fold docIvan Tham-2/+2
2020-07-03fix typoBastian Kauschke-1/+1
2020-07-02Rollup merge of #73938 - nbdd0121:checked_opt, r=nagisaManish Goregaokar-27/+43
Optimise fast path of checked_ops with `unlikely` This PR marks paths returning `None` in checked_ops as unlikely to improvde codegen. Fixes #73731
2020-07-02Rollup merge of #73684 - richkadel:llvm-coverage-map-gen-2, r=wesleywiserManish Goregaokar-1/+34
add spans to injected coverage counters, extract with CoverageData query This is the next iteration on the Rust Coverage implementation, and follows PR #73488 @tmandry @wesleywiser I came up with an approach for coverage spans, pushing them through the Call terminator as additional args so they can be extracted by the CoverageData query. I'm using an IndexVec to store them in CoverageData such that there can be only one per index (even if parts of the MIR get duplicated during optimization). If this approach works for you, I can quickly expand on this to build a separate IndexVec for counter expressions, using a separate call that will be ignored during code generation, but from which I can extract the counter expression values. Let me know your thoughts. Thanks! r? @tmandry Rust compiler MCP rust-lang/compiler-team#278 Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation
2020-07-02Rollup merge of #73622 - LeSeulArtichaut:unsafe-libcore, r=nikomatsakisManish Goregaokar-337/+772
Deny unsafe ops in unsafe fns in libcore After `liballoc`, It's time for `libcore` :D I planned to do this bit by bit to avoid having a big chunk of diffs, so to make reviews easier, and to make the unsafe blocks narrower and take the time to document them properly. r? @nikomatsakis cc @RalfJung
2020-07-02Rollup merge of #73414 - lzutao:slice_strip, r=dtolnayManish Goregaokar-0/+62
Implement `slice_strip` feature Tracking issue: #73413
2020-07-01Optimise fast path of checked_ops with `unlikely`Gary Guo-27/+43
2020-07-01Rollup merge of #73846 - pierwill:pierwill-patch-2, r=joshtriplettManish Goregaokar-1/+1
Fix comma in debug_assert! docs
2020-07-01Rollup merge of #73778 - nbdd0121:const_likely, r=oli-obkManish Goregaokar-0/+3
Make `likely` and `unlikely` const, gated by feature `const_unlikely` This PR also contains a fix to allow `#[allow_internal_unstable]` to work properly with `#[rustc_const_unstable]`. cc @RalfJung @nagisa r? @oli-obk
2020-07-01Implement slice_strip featureLzu Tao-0/+62
2020-06-30Stabilize `#[track_caller]`.Adam Perry-12/+6
Does not yet make its constness stable, though. Use of `Location::caller` in const contexts is still gated by `#![feature(const_caller_location)]`.
2020-06-30Deny unsafe ops in unsafe fns, part 6LeSeulArtichaut-93/+185
And final part!!!
2020-06-30Deny unsafe ops in unsafe fns, part 5LeSeulArtichaut-47/+108
2020-06-30Deny unsafe ops in unsafe fns, part 4LeSeulArtichaut-40/+108
2020-06-30Deny unsafe ops in unsafe fns, part 3LeSeulArtichaut-113/+181
2020-06-30Deny unsafe ops in unsafe fns, part 2LeSeulArtichaut-37/+103
2020-06-30Deny unsafe ops in unsafe fns, part 1LeSeulArtichaut-31/+111
2020-06-29add spans to injected coverage countersRich Kadel-1/+34
added regions with counter expressions and counters. Added codegen_llvm/coverageinfo mod for upcoming coverage map Move coverage region collection to CodegenCx finalization Moved from `query coverageinfo` (renamed from `query coverage_data`), as discussed in the PR at: https://github.com/rust-lang/rust/pull/73684#issuecomment-649882503 Address merge conflict in MIR instrument_coverage test The MIR test output format changed for int types. moved debug messages out of block.rs This makes the block.rs calls to add coverage mapping data to the CodegenCx much more concise and readable. move coverage intrinsic handling into llvm impl I realized that having half of the coverage intrinsic handling in `rustc_codegen_ssa` and half in `rustc_codegen_llvm` meant that any non-llvm backend would be bound to the same decisions about how the coverage-related MIR terminators should be handled. To fix this, I moved the non-codegen portion of coverage intrinsic handling into its own trait, and implemented it in `rustc_codegen_llvm` alongside `codegen_intrinsic_call`. I also added the (required?) stubs for the new intrinsics to `IntrepretCx::emulate_intrinsic()`, to ensure calls to this function do not fail if called with these new but known intrinsics. address PR Feedback on 28 June 2020 2:48pm PDT
2020-06-29Auto merge of #73032 - yoshuawuyts:stabilize-leading_trailing_ones, r=Amanieubors-13/+12
stabilize leading_trailing_ones This PR stabilizes the `leading_trailing_ones` feature. It's been available on nightly since the start of the year, and hasn't had any issues since. It seems unlikely we'll want to change this, so following up on @djc's suggestion in https://github.com/rust-lang/rust/issues/57969#issuecomment-638405264 I'd like to put forward this PR to stabilize the feature and make it part of `1.46.0`. Thanks! cc/ @djc @rust-lang/libs
2020-06-28Auto merge of #72437 - ecstatic-morse:stabilize-const-if-match, r=oli-obkbors-5/+5
Stabilize `#![feature(const_if_match)]` Quoting from the [stabilization report](https://github.com/rust-lang/rust/issues/49146#issuecomment-616301045): > `if` and `match` expressions as well as the short-circuiting logic operators `&&` and `||` will become legal in all [const contexts](https://doc.rust-lang.org/reference/const_eval.html#const-context). A const context is any of the following: > > - The initializer of a `const`, `static`, `static mut` or enum discriminant. > - The body of a `const fn`. > - The value of a const generic (nightly only). > - The length of an array type (`[u8; 3]`) or an array repeat expression (`[0u8; 3]`). > > Furthermore, the short-circuiting logic operators will no longer be lowered to their bitwise equivalents (`&` and `|` respectively) in `const` and `static` initializers (see #57175). As a result, `let` bindings can be used alongside short-circuiting logic in those initializers. Resolves #49146. Ideally, we would resolve :whale: #66753 before this lands on stable, so it might be worth pushing this back a release. Also, this means we should get the process started for #52000, otherwise people will have no recourse except recursion for iterative `const fn`. r? @oli-obk
2020-06-28Remove uses of `const_loop` in `rustc`Dylan MacKenzie-1/+1
2020-06-28Remove `const_if_match` feature gate from librariesDylan MacKenzie-4/+4
2020-06-28Rollup merge of #73817 - jumbatm:rename-to-clashing-extern-declarations, ↵Manish Goregaokar-2/+2
r=petrochenkov Rename clashing_extern_decl to clashing_extern_declarations. Rename clashing_extern_decl to clashing_extern_declarations to bring in-line with lint naming conventions. Fixes #73802. r? @petrochenkov
2020-06-28Rollup merge of #73800 - nikic:hash_i, r=kennytmManish Goregaokar-5/+5
Forward Hash::write_iN to Hash::write_uN The `Hasher::write_iN()` methods should forward to `Hasher::write_uN()`, because some Hasher implementations implement only the `write_uN()` variants, with the expectation that `write_iN()` will use the same implementation. Most notably, this is the case for the [FxHasher](https://github.com/rust-lang/rustc-hash/blob/5e09ea0a1c7ab7e4f9e27771f5a0e5a36c58d1bb/src/lib.rs#L111) used by rustc itself. This used to be the case previously, but was broken in #59982. As the PR description makes no mention of this particular change, I assume it was unintentional. In a local test, this mitigates the regression from #73526 on at least one test-case (cc @cuviper), because we're no longer at the mercy of `FxHasher::write()` getting inlined to get reasonable performance.
2020-06-28Rollup merge of #73577 - VillSnow:master, r=AmanieuManish Goregaokar-0/+95
Add partition_point Add partition_point in C++. Although existing binary_search in rust does not suitable when the slice has multiple hits, this function returns exact point of partition. The definition of this function is very clear and able to accept general matter, therefore you can easily get index which you want like lower/upper_bound. https://github.com/rust-lang/rfcs/issues/2184
2020-06-28Update src/libcore/slice/mod.rsVillSnow-1/+1
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2020-06-28Update tracking issue numberVillSnow-1/+1
2020-06-28Update doc commentVillSnow-6/+10
2020-06-28Merge branch 'master' of https://github.com/VillSnow/rustVillSnow-1/+2
2020-06-28Update src/libcore/slice/mod.rsVillSnow-1/+2
Co-authored-by: Lukas Kalbertodt <lukas.kalbertodt@gmail.com>
2020-06-28Add comment on use of unsafeVillSnow-0/+9
2020-06-28Fix comma in debug_assert! docspierwill-1/+1
2020-06-27Rollup merge of #73672 - nellshamrell:async-fix, r=estebankManish Goregaokar-0/+1
Adds a clearer message for when the async keyword is missing from a f… …unction This is a somewhat simple fix for #66731. Under the current version of Rust, if a user has a rust file that looks like this: ```rust fn boo (){} async fn foo() { boo().await; } fn main() { } ``` And they attempt to run it, they will receive an error message that looks like this: ```bash error: incorrect use of `await` --> test.rs:4:14 | 4 | boo.await(); | ^^ help: `await` is not a method call, remove the parentheses error[E0277]: the trait bound `fn() {boo}: std::future::Future` is not satisfied --> test.rs:4:5 | 4 | boo.await(); | ^^^^^^^^^ the trait `std::future::Future` is not implemented for `fn() {boo}` error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. ``` This is not very clear. With the changes made in this PR, when a user compiles and runs that same rust code, they will receive an error message that looks like this: ```bash error[E0277]: `()` is not a future. --> test.rs:4:5 | 4 | boo().await; | ^^^^^^^^^^^ `()` is not a future | = help: the trait `std::future::Future` is not implemented for `()` = note: required by `std::future::Future::poll` ``` In the future, I think we should make this error message even clearer, perhaps through a solution like the one described in [this comment](https://github.com/rust-lang/rust/issues/66731#issuecomment-644394287). However, as that potentially involves a major change proposal, I would rather get this change in now and make the error message a little clearer while an MCP is drafted and discussed. Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
2020-06-28Rename the lint to clashing_extern_declarations.jumbatm-2/+2
Also, run RustFmt on the clashing_extern_fn test case and update stderrs.
2020-06-27Forward Hash::write_iN to Hash::write_uNNikita Popov-5/+5
2020-06-26Rollup merge of #73738 - nbdd0121:comment, r=nikomatsakisManish Goregaokar-5/+0
Remove irrelevant comment Iterator is no longer a lang item since 216e72f8d9499d012e23bc4563215e693fcb4f35.
2020-06-26Rollup merge of #73579 - RalfJung:doc-missing-links, r=shepmasterManish Goregaokar-2/+4
add missing doc links The doc comments contain ``[`size_of_val`]`` but the link target was missing.
2020-06-26Make `likely` and `unlikely` constGary Guo-0/+3
They are gated by internal feature gate const_likely
2020-06-26Rollup merge of #73707 - LeSeulArtichaut:patch-3, r=kennytmManish Goregaokar-0/+2
Fix links in `SliceIndex` documentation See [this doc](https://doc.rust-lang.org/nightly/std/slice/trait.SliceIndex.html#tymethod.get_unchecked) whose links aren't active because of this missing newline.
2020-06-25Rollup merge of #73673 - ehuss:fix-ptr-docs, r=oli-obkManish Goregaokar-4/+0
Fix ptr doc warnings. #73398 added some stray backtick lines which cause warnings when the docs are built.
2020-06-25Rollup merge of #73418 - doctorn:variants-intrinsic, r=kennytmManish Goregaokar-0/+46
Add unstable `core::mem::variant_count` intrinsic Adds a new `const fn` intrinsic which can be used to determine the number of variants in an `enum`. I've shown this to a couple of people and they invariably ask 'why on earth?', but there's actually a very neat use case: At the moment, if you want to create an opaque array type that's indexed by an `enum` with one element for each variant, you either have to hard-code the number of variants, add a `LENGTH` variant or use a `Vec`, none of which are suitable in general (number of variants could change; pattern matching `LENGTH` becomes frustrating; might not have `alloc`). By including this intrinsic, it becomes possible to write the following: ```rust #[derive(Copy, Clone)] enum OpaqueIndex { A = 0, B, C, } struct OpaqueVec<T>(Box<[T; std::mem::num_variants::<OpaqueIndex>()]>); impl<T> std::ops::Index<OpaqueIndex> for OpaqueVec<T> { type Output = T; fn index(&self, idx: OpaqueIndex) -> &Self::Output { &self.0[idx as usize] } } ``` (We even have a use cases for this in `rustc` and I plan to use it to re-implement the lang-items table.)
2020-06-25Adds a clearer message for when the async keyword is missing from a functionNell Shamrell-0/+1
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
2020-06-25Remove irrelevant commentGary Guo-5/+0
2020-06-25Auto merge of #72717 - poliorcetics:try-from-int-to-nzint, r=dtolnaybors-0/+58
Add TryFrom<{int}> for NonZero{int} Adds `TryFrom<{int}> for NonZero{int}`. It uses the existing `NonZero{int}::new()` and `Option::ok_or()` functions, meaning the checks are not repeated. I also added tests, I tried to follow the convention I saw in the test file. I also used `#[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")]`, but I have no idea if the feature/version are correctly named or even correct.
2020-06-24Implement associated lang itemsAaron Hill-0/+1
Fixes #70718 This commit allows making associated items (e.g. associated functions and types) into lang items via the `#[lang]` attribute. This allows such items to be accessed directly, rather than by iterating over the parent item's associated items. I've added `FnOnce::Output` as a lang item, and updated one old usage to use the new lang item. The remaining uses can be updated separately.
2020-06-24Fix links in `SliceIndex` documentationLeSeulArtichaut-0/+2
2020-06-24Fix testsNathan Corbyn-0/+1