summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2019-09-13Support "soft" feature-gating using a lintVadim Petrochenkov-2/+4
Use it for feature-gating `#[bench]`
2019-08-12Rollup merge of #63297 - RalfJung:ptr_offset, r=dtolnayMazdak Farrokhzad-34/+128
Improve pointer offset method docs Cc @rkruppe @gnzlbg
2019-08-11Rollup merge of #63442 - lzutao:vec-bin-search-insert, r=Mark-SimulacrumMark Rousskov-0/+11
Add an example to show how to insert item to a sorted vec Closes #61684 cc #61742 r? @Mark-Simulacrum, @jonas-schievink
2019-08-11Rollup merge of #63346 - RalfJung:zeroed-lint, r=eddybMark Rousskov-1/+5
Lint on some incorrect uses of mem::zeroed / mem::uninitialized Cc https://github.com/rust-lang/rust/issues/62825 and https://internals.rust-lang.org/t/make-mem-uninitialized-and-mem-zeroed-panic-for-some-types-where-0-is-a-niche/10605 This does not yet handle `NonNull`/`NonZero*`, but it is a start. I also improved some doc issues I hit on the way, and added a useful helper to `TyS`. EDIT: I added the relnotes label mostly as a proposal -- I think this is worth mentioning, but leave the decision up to the release team.
2019-08-11allow the lint if a few UB-demonstrating doc testsRalf Jung-1/+5
2019-08-11Auto merge of #63343 - ishitatsuyuki:revert-62150, r=RalfJungbors-4/+25
Back out #62150 Ref: #62825 cc @RalfJung
2019-08-10Use Result::unwrap_or_else instead of matchingLzu Tao-4/+1
2019-08-10Add an example to show how to insert item to a sorted vecLzu Tao-0/+14
2019-08-10Revert "Rollup merge of #62150 - alex:mem-uninit-refactor, r=RalfJung"Tatsuyuki Ishi-4/+25
This reverts commit 1d45156866b54c3fc36edfdfcdd8149ad9cb5711, reversing changes made to 0f92eb8a4a7d8715381f5b5d748d22315f6ff9c7.
2019-08-10Rollup merge of #63350 - iluuu1994:use-associated-type-bounds, r=CentrilMazdak Farrokhzad-80/+120
Use associated_type_bounds where applicable - closes #61738
2019-08-10Rollup merge of #63056 - petrochenkov:macstd2, r=alexcrichtonMazdak Farrokhzad-138/+171
Give built-in macros stable addresses in the standard library Continuation of https://github.com/rust-lang/rust/pull/62086. Derive macros corresponding to traits from libcore are now available through the same paths as those traits: - `Clone` - `{core,std}::clone::Clone` - `PartialEq` - `{core,std}::cmp::PartialEq` - `Eq` - `{core,std}::cmp::Eq` - `PartialOrd` - `{core,std}::cmp::PartialOrd` - `Ord` - `{core,std}::cmp::Ord` - `Default` - `{core,std}::default::Default` - `Debug` - `{core,std}::fmt::Debug` - `Hash` - `{core,std}::hash::Hash` - `Copy` - `{core,std}::marker::Copy` Fn-like built-in macros are now available through libcore and libstd's root module, by analogy with non-builtin macros defined by libcore and libstd: ```rust {core,std}::{ __rust_unstable_column, asm, assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args, format_args_nl, global_asm, include, include_bytes, include_str, line, log_syntax, module_path, option_env, stringify, trace_macros, } ``` Derive macros without a corresponding trait in libcore or libstd are still available only through prelude (also see https://github.com/rust-lang/rust/pull/62507). Attribute macros also keep being available only through prelude, mostly because they don't have an existing practice to follow. An advice from the library team on their eventual placement would be appreciated. ```rust RustcDecodable, RustcEncodable, bench, global_allocator, test, test_case, ``` r? @alexcrichton
2019-08-10Auto merge of #62756 - newpavlov:stabilize_dur_float, r=alexcrichtonbors-22/+14
Stabilize duration_float Closes: #54361
2019-08-10Give built-in macros stable addresses in the standard libraryVadim Petrochenkov-138/+171
2019-08-09Rollup merge of #63407 - RalfJung:miri-test-sizes, r=CentrilMazdak Farrokhzad-1/+1
reduce some test sizes in Miri
2019-08-09Rollup merge of #63404 - RalfJung:flt2dec, r=CentrilMazdak Farrokhzad-7/+42
enable flt2dec tests in Miri With ldexp implemented (thanks to @christianpoveda), we can finally enable these tests in Miri. Well, most of them -- some are just too slow.
2019-08-09Rollup merge of #63403 - sntdevco:master, r=CentrilMazdak Farrokhzad-9/+9
Improve test output I'm continuing to improve the test output for liballoc and libcore
2019-08-09Rollup merge of #63114 - matthewjasper:hygienic-format-args, r=petrochenkovMazdak Farrokhzad-22/+20
Remove gensym in format_args This also fixes some things to allow us to export opaque macros from libcore: * Don't consider items that are only reachable through opaque macros as public/exported (so they aren't linted as needing docs) * Mark private items reachable from the root of libcore as unstable - they are now reachable (in principle) in other crates via macros in libcore r? @petrochenkov
2019-08-09Rollup merge of #62672 - lzutao:deprecated-try-macro, r=CentrilMazdak Farrokhzad-0/+1
Deprecate `try!` macro Replaces #62077 Fixes rust-lang/rust-clippy#1361 Fixes #61000
2019-08-09explain Miri disablingRalf Jung-1/+1
2019-08-09Don't use associated type bounds in docs until it is stableIlija Tovilo-3/+2
2019-08-09Add missing #![feature(associated_type_bounds)]Ilija Tovilo-0/+2
2019-08-09Miri is really slowRalf Jung-4/+5
2019-08-09enable flt2dec tests in MiriRalf Jung-7/+41
2019-08-09Merge pull request #1 from rust-lang/masterSayan Nandan-5655/+10841
Merge recent changes into master
2019-08-09Improve tests for libcore/sliceSayan Nandan-8/+8
2019-08-09Improve test output for libcore/timeSayan Nandan-3/+1
2019-08-09Auto merge of #61937 - AaronKutch:master, r=scottmcmbors-69/+216
Improve `ptr_rotate` performance, tests, and benches The corresponding issue is #61784. I am not actually sure if miri can handle the test, but I can change the commit if necessary.
2019-08-09Postpone deprecating try! until 1.39.0Lzu Tao-1/+1
2019-08-09Deprecate `try!` macroBO41-0/+1
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com> Co-Authored-By: Oliver Middleton <olliemail27@gmail.com>
2019-08-09Rollup merge of #63374 - RalfJung:pin-packed, r=cramertjMazdak Farrokhzad-1/+2
move of packed fields might or might not occur when they actually are sufficiently aligned See https://github.com/taiki-e/pin-project/pull/34, where it was pointed out that we actually don't move fields of 1-aligned types when dropping a packed struct -- but e.g. in a `packed(2)` struct, we don't do something similar for 2-aligned types. The code for that is [here](https://github.com/rust-lang/rust/blob/db7c773a6be2f050d1d1504763819ea3916f5428/src/librustc_mir/util/alignment.rs#L7).
2019-08-08Use associated_type_bounds where applicable - closes #61738Ilija Tovilo-80/+119
2019-08-08remove confusing remarkRalf Jung-1/+1
2019-08-08Rollup merge of #63377 - SOF3:issues/63375, r=CentrilMazdak Farrokhzad-1/+1
Improved documentation for compile_error!() Fixes #63375
2019-08-08Rollup merge of #63366 - lzutao:fix-float-to-le-bytes-typo, r=CentrilMazdak Farrokhzad-4/+4
doc: Fix typo in float from bytes methods Thanks @That3Percent for pointing it out. r? @Centril
2019-08-08Rollup merge of #63261 - RalfJung:rand, r=nikomatsakisMazdak Farrokhzad-10/+10
bump rand in libcore/liballoc test suites This pulls in the fix for https://github.com/rust-random/rand/issues/779, which trips Miri when running these test suites. `SmallRng` (formerly used by libcore) is no longer built by default, it needs a feature gate. I opted to switch to `StdRng` instead. Or should I enable the feature gate?
2019-08-08Improved documentation for compile_error!()SOFe-1/+1
Fixes #63375
2019-08-08move of packed fields might or might not occur when they actually are ↵Ralf Jung-1/+2
sufficiently aligned
2019-08-08doc: Fix typo in float from bytes methodsLzu Tao-4/+4
2019-08-07Rollup merge of #63034 - tmandry:reduce-generator-size-regressions, r=cramertjMazdak Farrokhzad-0/+2
Fix generator size regressions due to optimization I tested the generator optimizations in #60187 and #61922 on the Fuchsia build, and noticed that some small generators (about 8% of the async fns in our build) increased in size slightly. This is because in #60187 we split the fields into two groups, a "prefix" non-overlap region and an overlap region, and lay them out separately. This can introduce unnecessary padding bytes between the two groups. In every single case in the Fuchsia build, it was due to there being only a single variant being used in the overlap region. This means that we aren't doing any overlapping, period. So it's better to combine the two regions into one and lay out all the fields at once, which is what this change does. r? @cramertj cc @eddyb @Zoxc
2019-08-06Improve `ptr_rotate` performance, tests, and benchmarksAaron Kutch-69/+216
2019-08-06Rollup merge of #63298 - RalfJung:assume_init, r=Mark-Simulacrum,CentrilMazdak Farrokhzad-1/+10
assume_init: warn about valid != safe We have this warning in the type-level docs, but it seems worth repeating it on the function.
2019-08-06Rollup merge of #62459 - timvermeulen:result_sum_internal_iteration, r=scottmcmMazdak Farrokhzad-119/+67
Use internal iteration in the Sum and Product impls of Result and Option This PR adds internal iteration to the `ResultShunt` iterator type underlying the `Sum` and `Product` impls of `Result`. I had to change `ResultShunt` to hold a mutable reference to an error instead, similar to `itertools::ProcessResults`, in order to be able to pass the `ResultShunt` itself by value (which is necessary for internal iteration). `ResultShunt::process` can unfortunately no longer be an associated function because that would make it generic over the lifetime of the error reference, which wouldn't work, so I turned it into the free function `process_results`. I removed the `OptionShunt` type and forwarded the `Sum` and `Product` impls of `Option` to their respective impls of `Result` instead, to avoid having to repeat the internal iteration logic.
2019-08-06clarifyRalf Jung-2/+2
2019-08-06be clear that 1-init Vec being valid (but not safe) is not a stable guaranteeRalf Jung-2/+4
2019-08-06Rollup merge of #63295 - RalfJung:align_offset, r=dtolnayMazdak Farrokhzad-4/+8
improve align_offset docs Cc @shepmaster
2019-08-06Rollup merge of #63293 - shepmaster:align-to-doc, r=RalfJungMazdak Farrokhzad-6/+8
Clarify align_to's requirements and obligations Based on discussions with @RalfJung around my misunderstandings when using this. r? @RalfJung
2019-08-06Rollup merge of #63260 - RalfJung:ptr-test, r=matkladMazdak Farrokhzad-2/+1
fix UB in a test We used to compare two mutable references that were supposed to point to the same thing. That's no good. Compare them as raw pointers instead.
2019-08-06Rollup merge of #61457 - timvermeulen:double_ended_iters, r=scottmcmMazdak Farrokhzad-13/+296
Implement DoubleEndedIterator for iter::{StepBy, Peekable, Take} Now that `DoubleEndedIterator::nth_back` has landed, `StepBy` and `Take` can have an efficient `DoubleEndedIterator` implementation. I don't know if there was any particular reason for `Peekable` not having a `DoubleEndedIterator` implementation, but it's quite trivial and I don't see any drawbacks to having it. I'm not very happy about the implementation of `Peekable::try_rfold`, but I didn't see another way to only take the value out of `self.peeked` in case `self.iter.try_rfold` didn't exit early. I only added `Peekable::rfold` (in addition to `try_rfold`) because its `Iterator` implementation has both `fold` and `try_fold` (and for similar reasons I added `Take::try_rfold` but not `Take::rfold`). Do we have any guidelines on whether we want both? If we do want both, maybe we should investigate which iterator adaptors override `try_fold` but not `fold` and add the missing implementations. At the moment I think that it's better to always have iterator adaptors implement both, because some iterators have a simpler `fold` implementation than their `try_fold` implementation. The tests that I added may not be sufficient because they're all just existing tests where `next`/`nth`/`fold`/`try_fold` are replaced by their DEI counterparts, but I do think all paths are covered. Is there anything in particular that I should probably also test?
2019-08-05Clarify align_to's requirements and obligationsJake Goulding-6/+8
2019-08-05Remove gensym from format_argsMatthew Jasper-2/+0