about summary refs log tree commit diff
path: root/src/libcore/ops
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-3972/+0
2020-07-26Fixed typo in `closure`Alex-1/+1
2020-07-23Add missing backticks in diagnostics noteYuki Okushi-3/+3
2020-07-20Rollup merge of #73197 - c410-f3r:ranges, r=dtolnayManish Goregaokar-2/+2
Impl Default for ranges Couldn't find an issue about it. `Range` and friends probably can implement `Default` if `Idx: Default`. For example, the following would be possible: ```rust #[derive(Default)] struct Foo(core::ops::RangeToInclusive<u64>); let _ = [1, 2, 3].get(core::ops::Range::default()); core::ops::RangeFrom::<u8>::default().take(20).for_each(|x| { dbg!(x); }); fn stuff<T: Default>() { let instance = T::default(); ... more stuff } stuff::<core::ops::RangeTo<f32>>(); ``` Maybe there are some concerns about safety or misunderstandings?
2020-07-16apply bootstrap cfgsMark Rousskov-1/+1
2020-07-10Remove some Default implsCaio-4/+4
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-09Impl Default for rangesCaio-6/+6
2020-06-03Bump to 1.46Mark Rousskov-1/+1
2020-05-31Rephrase term 'non-pointer type'JOE1994-4/+4
If the reader assumes that 'pointer type's include 'smart pointer's, the term 'non-pointer type' could mislead the reader to assume that x should not be a smart pointer type. I tried to rephrase the term 'non-pointer type' to remove ambiguity in the doc comments. closes #72335 Thank you for reviewing this PR! :)
2020-05-30Rollup merge of #72368 - CAD97:rangeto, r=dtolnayRalf Jung-4/+10
Resolve overflow behavior for RangeFrom This specifies a documented unspecified implementation detail of `RangeFrom` and makes it consistently implement the specified behavior. Specifically, `(u8::MAX).next()` is defined to cause an overflow, and resolve that overflow in the same manner as the `Step::forward` implementation. The inconsistency that has existed is `<RangeFrom as Iterator>::nth`. The existing behavior should be plain to see after #69659: the skipping part previously always panicked if it caused an overflow, but the final step (to set up the state for further iteration) has always been debug-checked. The inconsistency, then, is that `RangeFrom::nth` does not implement the same behavior as the naive (and default) implementation of just calling `next` multiple times. This PR aligns `RangeFrom::nth` to have identical behavior to the naive implementation. It also lines up with the standard behavior of primitive math in Rust everywhere else in the language: debug checked overflow. cc @Amanieu --- Followup to #69659. Closes #25708 (by documenting the panic as intended). The documentation wording is preliminary and can probably be improved. This will probably need an FCP, as it changes observable stable behavior.
2020-05-22only try to suggest for try trait_refcsmoe-0/+1
2020-05-19Resolve overflow behavior for RangeFromCAD97-4/+10
2020-05-07rewrite Drop documentationBastian Kauschke-44/+98
2020-04-25Bump bootstrap compilerMark Rousskov-3/+2
2020-04-13Remove the last remnant of unsigned NegJosh Stone-17/+4
It's been gone since #23945, before Rust 1.0. The former wrapping semantics have also been available as inherent methods for a long time now. There's no reason to keep this unused macro around.
2020-04-05Stop importing the float modules. Use assoc constsLinus Färnstrand-12/+0
2020-04-03Replace float module consts with assoc consts in documentationLinus Färnstrand-6/+4
2020-03-26permit negative impls for non-auto traitsNiko Matsakis-0/+4
2020-03-23#[track_caller] on core::ops::{Index, IndexMut}.Adam Perry-0/+2
2020-03-19Removed unused `Hasher` import.CDirkx-1/+1
2020-03-19Derive PartialEq, Eq and Hash for RangeInclusiveCDirkx-21/+1
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.
2020-03-15Bump the bootstrap compilerJonas Schievink-29/+2
2020-03-10Make Point `Copy` in arithmetic documentationFlorian Gilcher-6/+6
Small composite types like `Point { x: i32, y: i32}` are plain old data and we should encourage users to derive `Copy` on them. This changes the semantics of the edited examples slightly: instead of consuming the operands during addition, it will copy them. This is desired behaviour. Co-Authored-By: Jake Goulding <shepmaster@mac.com>
2020-02-08Remove problematic specialization from RangeInclusiveCAD97-31/+14
2020-02-08Auto merge of #68358 - matthewjasper:spec-fix, r=nikomatsakisbors-23/+15
Remove some unsound specializations This removes the unsound and exploitable specializations in the standard library * The `PartialEq` and `Hash` implementations for `RangeInclusive` are changed to avoid specialization. * The `PartialOrd` specialization for slices now specializes on a limited set of concrete types. * Added some tests for the soundness problems.
2020-02-02Add a resume type parameter to `Generator`Jonas Schievink-4/+31
2020-02-01Remove some unsound specializationsMatthew Jasper-23/+15
2019-12-26Convert collapsed to shortcut reference linksMatthew Kraai-4/+4
2019-12-23Document that calling Drop, even after it panics, is UBMark Rousskov-0/+6
2019-12-22Rollup merge of #67480 - rossmacarthur:fix-41260-avoid-issue-0-part-2, r=CentrilMazdak Farrokhzad-10/+10
Require issue = "none" over issue = "0" in unstable attributes These changes make the use of `issue = "none"` required in unstable attributes throughout the compiler. Notes: - #66299 is now in beta so `issue = "none"` is accepted. - The `tidy` tool now fails on `issue = "0"`. - Tests that used `issue = "0"` were changed to use `issue = "none"`, except for _one_ that asserts `issue = "0"` can still be used. - The compiler still allows `issue = "0"` because some submodules require it, this could be disallowed once these are updated. Resolves #41260 r? @varkor
2019-12-21Document privacy of RangeInclusive fieldsMark Rousskov-0/+5
2019-12-21Require issue = "none" over issue = "0" in unstable attributesRoss MacArthur-10/+10
2019-12-18Propagate cfg bootstrapMark Rousskov-28/+19
2019-12-13Require stable/unstable annotations for the constness of all stable ↵Oliver Scherer-0/+9
functions with a `const` modifier
2019-12-06Format libcore with rustfmt (including tests and benches)David Tolnay-14/+22
2019-12-03Rollup merge of #66651 - Areredify:on-unimplemented-scope, r=davidtwcoMazdak Farrokhzad-3/+4
Add `enclosing scope` parameter to `rustc_on_unimplemented` Adds a new parameter to `#[rustc_on_unimplemented]`, `enclosing scope`, which highlights the function or closure scope with a message. The wip part refers to adding this annotation to `Try` trait to improve ergonomics (which I don't know how to do since I change both std and librustc) Closes #61709.
2019-11-26Format libcore with rustfmtDavid Tolnay-136/+180
This commit applies rustfmt with default settings to files in src/libcore *that are not involved in any currently open PR* to minimize merge conflicts. The list of files involved in open PRs was determined by querying GitHub's GraphQL API with this script: https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8 With the list of files from the script in `outstanding_files`, the relevant commands were: $ find src/libcore -name '*.rs' | xargs rustfmt --edition=2018 $ rg libcore outstanding_files | xargs git checkout -- Repeating this process several months apart should get us coverage of most of the rest of libcore.
2019-11-25added enclosing_scope attr to Try trait and fixed ui tests accordinglyMikhail Babenko-3/+4
2019-11-16Suggest borrowing when it would satisfy an unmet trait boundEsteban Küber-4/+0
When there are multiple implementors for the same trait that is present in an unmet binding, modify the E0277 error to refer to the parent obligation and verify whether borrowing the argument being passed in would satisfy the unmet bound. If it would, suggest it.
2019-11-12Snap cfgsMark Rousskov-15/+2
2019-11-01Rollup merge of #65902 - gilescope:issue62570, r=estebankTyler Mandry-2/+15
Make ItemContext available for better diagnositcs Fix #62570
2019-10-30Make ItemContext available for better diagnositcs.Giles Cope-2/+15
2019-10-20Remove leading :: from paths in doc examplesMikko Rantanen-1/+1
2019-08-24Added an extra line to make the formatting conform to the rest of the document.Christian-0/+1
2019-08-24Removed the confusing FnOnce example. closes #47091Christian-9/+0
2019-07-25Add note suggesting to borrow a String argument to findEsteban Küber-0/+4
2019-07-11hygiene: Fix wording of desugaring descriptionsVadim Petrochenkov-2/+2
Use variant names rather than descriptions for identifying desugarings in `#[rustc_on_unimplemented]`. Both are highly unstable, but variant name is at least a single identifier.
2019-07-01Remove needless lifetimesJeremy Stucki-2/+2
2019-06-15Remove the default type of `Rem::Output`Jonas Schievink-1/+1