about summary refs log tree commit diff
path: root/library/core/src/convert
AgeCommit message (Collapse)AuthorLines
2025-09-12Constify Eq, Ord, PartialOrdEvgenii Zheltonozhskii-3/+6
2025-09-06clean up some old const trait impl syntaxNathaniel McCallum-12/+6
2025-09-01Constify conversion traitsltdk-29/+30
2025-08-26remove deprecated Error::description in implsMarijn Schouten-5/+1
2025-08-06tidyBoxy-6/+6
2025-07-21Constify Try, From, TryFromEvgenii Zheltonozhskii-21/+43
2025-07-11constify `From` and `Into`Oli Scherer-8/+21
2025-06-16library/compiler: add `PointeeSized` boundsDavid Wood-5/+6
As core uses an extern type (`ptr::VTable`), the default `?Sized` to `MetaSized` migration isn't sufficient, and some code that previously accepted `VTable` needs relaxed to continue to accept extern types. Similarly, the compiler uses many extern types in `rustc_codegen_llvm` and in the `rustc_middle::ty::List` implementation (`OpaqueListContents`) some bounds must be relaxed to continue to accept these types. Unfortunately, due to the current inability to relax `Deref::Target`, some of the bounds in the standard library are forced to be stricter than they ideally would be.
2025-06-02remove f16: From<u16>usamoi-1/+0
2025-05-22Rollup merge of #141130 - mejrs:use_self, r=compiler-errorsMatthias Krüger-1/+1
rustc_on_unimplemented cleanups Addresses some of the fixmes from https://github.com/rust-lang/rust/pull/139091 and https://github.com/rust-lang/rust/pull/140307. - switch from `_Self` to `Self` in library - properly validate that arguments in the `on` filter and the format strings are actually valid See https://github.com/rust-lang/rustc-dev-guide/pull/2357 for the relevant documentation.
2025-05-17Switch library rustc_unimplemented to use `Self` and `This`mejrs-1/+1
2025-05-08std: Explain prefer `TryInto` over `TryFrom` when specifying traits bounds ↵xizheyin-0/+6
on generic function Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-08std: Make consistence between `From` and `Into`xizheyin-2/+2
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-03-17Auto merge of #138363 - beetrees:f16-f128-integer-convert, r=Amanieubors-2/+48
Add `From<{integer}>` for `f16`/`f128` impls This PR adds `impl From<{bool,i8,u8}> for f16` and `impl From<{bool,i8,u8,i16,u16,i32,u32}> for f128`. The `From<{i64,u64}> for f128` impls are left commented out as adding them would allow using `f128` on stable before it is stabilised like in the following example: ```rust fn f<T: From<u64>>(x: T) -> T { x } fn main() { let x = f(1.0); // the type of the literal is inferred to be `f128` } ``` None of the impls added in this PR have this issue as they are all, at minimum, also implemented by `f64`. This PR will need a crater run for the `From<{i32,u32}>` impls, as `f64` is no longer the only float type to implement them (similar to the cause of #125198). cc `@bjoernager` r? `@tgross35` Tracking issue: #116909
2025-03-16Rollup merge of #138082 - thaliaarchi:slice-cfg-not-test, r=thomcc许杰友 Jieyou Xu (Joe)-2/+2
Remove `#[cfg(not(test))]` gates in `core` These gates are unnecessary now that unit tests for `core` are in a separate package, `coretests`, instead of in the same files as the source code. They previously prevented the two `core` versions from conflicting with each other.
2025-03-11Add `From<{integer}>` for `f16`/`f128` implsbeetrees-2/+48
2025-03-06Remove #[cfg(not(test))] gates in coreThalia Archibald-2/+2
These gates are unnecessary now that unit tests for `core` are in a separate package, `coretests`, instead of in the same files as the source code. They previously prevented the two `core` versions from conflicting with each other.
2025-03-04Ensure that negative auto impls are always applicableMichael Goulet-1/+0
2024-12-13rustdoc-search: let From and Into be unboxedMichael Howell-0/+2
2024-07-26Fix doc nitsJohn Arundel-4/+4
Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits. https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-05-04Re-add `From<f16> for f64`beetrees-2/+3
2024-04-11Remove `From` impls for unstable types that break inferenceTrevor Gross-2/+2
Adding additional `From` implementations that fit `f32::from(<unaffixed float>)` broke inference. Remove these for now. Fixes: <https://github.com/rust-lang/rust/issues/123824>
2024-04-10Add basic library support for `f16` and `f128`Trevor Gross-0/+7
Implement basic operation traits that get lowered to intrinsics. This includes codegen tests for implemented operations.
2024-03-25Import the 2021 prelude in the core crateDaniel Paoliello-4/+0
2024-03-20step cfgsMark Rousskov-1/+1
2024-03-04include feedback from workingjubilee Jonas Pleyer-2/+2
- Refer to trait directly - small typo in encapsulate Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2024-03-03Small enhancement to description of From traitJonas Pleyer-2/+2
- fix small typo - avoid repetition of formulations
2024-02-25Auto merge of #120393 - Urgau:rfc3373-non-local-defs, r=WaffleLapkinbors-0/+1
Implement RFC 3373: Avoid non-local definitions in functions This PR implements [RFC 3373: Avoid non-local definitions in functions](https://github.com/rust-lang/rust/issues/120363).
2024-02-19Refactor trait implementations in `core::convert::num`.Markus Reiter-367/+325
2024-02-17Allow newly added non_local_definitions in stdUrgau-0/+1
2024-01-10Add `#[track_caller]` to the "From implies Into" implEmil Gardström-0/+1
2023-12-10remove redundant importssurechen-1/+1
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-11-04Draft fleshed-out deref docsjmaargh-2/+2
Re-draft Deref docs Make general advice more explicit and note the difference between generic and specific implementations. Re-draft DerefMut docs in-line with Deref Fix Deref docs typos Fix broken links Clarify advice for specific-over-generic impls Add comment addressing Issue #73682 x fmt Copy faillibility warning to DerefMut
2023-10-16Make `rustc_onunimplemented` export path agnosticNilstrieb-1/+1
This makes it so that all the matchers that match against paths use the definition path instead of the export path. This removes all duplication around `std`/`alloc`/`core`. This is not necessarily optimal because we now depend on internal implementation details like `core::ops::control_flow::ControlFlow`, which is not very nice and probably not acceptable for a stable `on_unimplemented`. An alternative would be to just string-replace normalize away `alloc`/`core` to `std` as a special case, keeping the export paths but making it so that we're still fully standard library flavor agnostic.
2023-10-10Update mod.rstae-soo-kim-6/+5
2023-10-06Rollup merge of #114564 - scottmcm:when-to-from, r=dtolnayMatthias Krüger-0/+40
Attempt to describe the intent behind the `From` trait further Inspired by the <https://internals.rust-lang.org/t/allow-use-as-and-try-as-for-from-and-tryfrom-traits/19240/26?u=scottmcm> thread. `@rustbot` label +T-libs-api
2023-10-05Elaborate some caveats to losslessScott McMurray-2/+5
2023-10-06Don't mention "recover the original" in `From` docsscottmcm-2/+5
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2023-10-05Attempt to describe the intent behind the `From` trait furtherScott McMurray-0/+34
2023-10-05Add more diagnostic items for clippyJason Newcomb-0/+2
2023-08-25use the correct linkcui fliter-2/+2
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-06-27Make `rustc_on_unimplemented` std-agnosticRageking8-1/+1
2023-05-31remove reference to Into in ? operator core/std docs, fix 111655anna-singleton-2/+1
2023-05-07Add `#[inline]` to functions that are never calledGary Guo-0/+1
2023-04-16rm const traits in libcoreDeadbeef-48/+24
2023-04-07Inline try_from and try_intoTomasz Miąsko-0/+2
To avoid link time dependency between core and compiler-builtins, when using opt-level that implicitly enables -Zshare-generics. While compiler-builtins should be compiled with -Zshare-generics disabled, the -Zbuild-std does not ensure this at the moment.
2023-03-24Add #[inline] to the Into for From implBen Kimock-0/+1
2023-03-09Add examples section which demonstrates the behaviour (specifically the sign ↵bmoxb-0/+20
positive aspect)
2023-03-09Add missing comment for f64bmoxb-1/+2
2023-03-09Indicate that `0.0` refers to positive `0.0`bmoxb-2/+2