about summary refs log tree commit diff
path: root/src/libcore/convert.rs
AgeCommit message (Collapse)AuthorLines
2019-02-25Auto merge of #58302 - SimonSapin:tryfrom, r=alexcrichtonbors-5/+123
Stabilize TryFrom and TryInto with a convert::Infallible empty enum This is the plan proposed in https://github.com/rust-lang/rust/issues/33417#issuecomment-423073898
2019-02-17Review commentsSimon Sapin-2/+16
2019-02-14Rollup merge of #57856 - lzutao:fix-old-first-edition, r=steveklabnikMazdak Farrokhzad-4/+1
Convert old first edition links to current edition one r? @steveklabnik
2019-02-13Add `impl From<!> for Infallible`Simon Sapin-0/+7
The reverse conversion unfortunately causes unexpected errors like: ``` error[E0277]: the trait bound `!: std::convert::From<()>` is not satisfied --> src/librustc_metadata/encoder.rs:105:9 | 105 | self.emit_usize(seq.len)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<()>` is not implemented for `!` | = help: the following implementations were found: <! as std::convert::From<std::convert::Infallible>> = note: the trait is implemented for `()`. Possibly this error has been caused by changes to Rust's type-inference algorithm (see: https://github.com/rust-lang/rust/issues/48950 for more info). Consider whether you meant to use the type `()` here instead. = note: required by `std::convert::From::from` ``` I don’t understand why this error happens. If I’m reading the code correctly the return types of `emit_usize` and of the method that contains line 105 are both `Result<(), !>`, so the expansion of the `?` operator should involve `!: From<!>`, not `From<()>`. Is this a type inference bug?
2019-02-13Stabilize TryFrom and TryIntoSimon Sapin-4/+8
2019-02-13Use convert::Infallible instead of never in the blanket TryFrom implSimon Sapin-1/+1
2019-02-13Add a convert::Infallible empty enum, make string::ParseError an aliasSimon Sapin-0/+93
2019-02-13Convert old doc links to current editionLzu Tao-4/+1
Use footnote style to bypass the tidy check
2019-02-12Auto merge of #58341 - alexreg:cosmetic-2-doc-comments, r=steveklabnikbors-1/+1
Cosmetic improvements to doc comments This has been factored out from https://github.com/rust-lang/rust/pull/58036 to only include changes to documentation comments (throughout the rustc codebase). r? @steveklabnik Once you're happy with this, maybe we could get it through with r=1, so it doesn't constantly get invalidated? (I'm not sure this will be an issue, but just in case...) Anyway, thanks for your advice so far!
2019-02-10tests: doc commentsAlexander Regueiro-1/+1
2019-01-26Tiny improvement to docs for `core::convert`.Simon Heath-1/+4
This is not really significant, accept or reject as you wish. I just want to make sure I understand how the PR process works and I'm doing it right before doing a bigger one for #33417.
2019-01-21Rollup merge of #56796 - KrishnaSannasi:try_from_impl_change, r=shepmasterMazdak Farrokhzad-2/+2
Change bounds on `TryFrom` blanket impl to use `Into` instead of `From` This is from this [comment](https://github.com/rust-lang/rust/issues/33417#issuecomment-447111156) I made. This will expand the impls available for `TryFrom` and `TryInto`, without losing anything in the process.
2019-01-04stabilize convert::identityMazdak Farrokhzad-4/+1
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-13Change bounds on `TryFrom` blanket impl to use `Into` instead of `From`Ozaren-2/+2
2018-12-07use top level `fs` functions where appropriateAndy Russell-4/+3
This commit replaces many usages of `File::open` and reading or writing with `fs::read_to_string`, `fs::read` and `fs::write`. This reduces code complexity, and will improve performance for most reads, since the functions allocate the buffer to be the size of the file. I believe that this commit will not impact behavior in any way, so some matches will check the error kind in case the file was not valid UTF-8. Some of these cases may not actually care about the error.
2018-11-10constify parts of libcore.Mazdak Farrokhzad-1/+0
2018-09-29Use impl_header_lifetime_elision in libcoreScott McMurray-3/+3
2018-08-20core::convert::identity: fix issue number to #53500Mazdak Farrokhzad-1/+1
2018-08-19Make core::convert::identity a const fn.Mazdak Farrokhzad-1/+2
2018-08-19Merge branch 'master' into feature/core_convert_idMazdak Farrokhzad-51/+22
2018-07-15AsRef doc wording tweaksCameron McCormack-3/+3
2018-04-20Revert "Stabilize the TryFrom and TryInto traits"Felix S. Klock II-8/+4
This reverts commit e53a2a72743810e05f58c61c9d8a4c89b712ad2e.
2018-03-26Stabilize the TryFrom and TryInto traitsSimon Sapin-4/+8
Tracking issue: https://github.com/rust-lang/rust/issues/33417
2018-03-22Rollup merge of #49038 - canndrew:replace-infallible-with-never, r=SimonSapinkennytm-20/+1
replace `convert::Infallible` with `!`
2018-03-17update FIXME(#23442) to point to issue 45742 (Blanket impl of AsRef for Deref)Niv Kaminer-2/+2
2018-03-15replace `convert::Infallible` with `!`Andrew Cann-20/+1
2018-02-04Fix info about generic impls in AsMut docsMatt Brubeck-3/+3
This text was copy-pasted from the `AsRef` docs to `AsMut`, but needed some additional adjustments for correctness.
2018-01-19fix doctests for convert::idMazdak-2/+4
2018-01-19add fn core::convert::id<T>(x: T) -> T { x }Mazdak-0/+67
2017-09-23Simplify implementation of Display and Error for convert::Infallible.Jimmy Cuadra-2/+3
2017-09-21Impl fmt::Display for convert::Infallible.Jimmy Cuadra-0/+8
2017-09-18Derive additional traits for Infallible.Jimmy Cuadra-9/+1
2017-09-01Reword docs for Infallible to make them easier to understand.Jimmy Cuadra-6/+5
2017-08-29Add blanket TryFrom impl when From is implemented.Jimmy Cuadra-12/+29
Adds `impl<T, U> TryFrom<T> for U where U: From<T>`. Removes `impl<'a, T> TryFrom<&'a str> for T where T: FromStr` due to overlapping impls caused by the new blanket impl. This removal is to be discussed further on the tracking issue for TryFrom. Refs #33417.
2017-06-15Update older URLs pointing to the first edition of the BookWonwoo Choi-2/+2
`compiler-plugins.html` is moved into the Unstable Book. Explanation is slightly modified to match the change.
2017-05-28Clarify docs on implementing Into.Clar Charr-1/+37
2017-05-02Address reviewest31-1/+1
2017-05-02Removal pass for anonymous parametersest31-1/+1
Removes occurences of anonymous parameters from the rustc codebase, as they are to be deprecated. See issue #41686 and RFC 1685.
2017-04-18Address review commentsDylan Maccora-24/+19
2017-04-08Removing broken examplesDylan Maccora-24/+3
2017-04-04AsMut exampleDylan Maccora-7/+15
2017-04-03Wrapped to 80 characters. Fix links.Dylan Maccora-40/+58
2017-04-01Convert docs clean up.Dylan Maccora-31/+114
2017-03-20Auto merge of #40281 - jimmycuadra:try-from-from-str, r=aturonbors-6/+18
Rename TryFrom's associated type and implement str::parse using TryFrom. Per discussion on the tracking issue, naming `TryFrom`'s associated type `Error` is generally more consistent with similar traits in the Rust ecosystem, and what people seem to assume it should be called. It also helps disambiguate from `Result::Err`, the most common "Err". See https://github.com/rust-lang/rust/issues/33417#issuecomment-269108968. `TryFrom<&str>` and `FromStr` are equivalent, so have the latter provide the former to ensure that. Using `TryFrom` in the implementation of `str::parse` means types that implement either trait can use it. When we're ready to stabilize `TryFrom`, we should update `FromStr` to suggest implementing `TryFrom<&str>` instead for new code. See https://github.com/rust-lang/rust/issues/33417#issuecomment-277175994 and https://github.com/rust-lang/rust/issues/33417#issuecomment-277253827. Refs #33417.
2017-03-15Rename TryFrom's associated type and implement str::parse using TryFrom.Jimmy Cuadra-6/+18
Per discussion on the tracking issue, naming `TryFrom`'s associated type `Error` is generally more consistent with similar traits in the Rust ecosystem, and what people seem to assume it should be called. It also helps disambiguate from `Result::Err`, the most common "Err". See https://github.com/rust-lang/rust/issues/33417#issuecomment-269108968. TryFrom<&str> and FromStr are equivalent, so have the latter provide the former to ensure that. Using TryFrom in the implementation of `str::parse` means types that implement either trait can use it. When we're ready to stabilize `TryFrom`, we should update `FromStr` to suggest implementing `TryFrom<&str>` instead for new code. See https://github.com/rust-lang/rust/issues/33417#issuecomment-277175994 and https://github.com/rust-lang/rust/issues/33417#issuecomment-277253827. Refs #33417.
2017-03-13Remove function invokation parens from documentation links.Corey Farwell-4/+4
This was never established as a convention we should follow in the 'More API Documentation Conventions' RFC: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md
2017-02-02Add a name for the parameter to `TryFrom::try_from`.Jimmy Cuadra-1/+1
Although signatures with anonymous parameters may not be deprecated or removed at this point, the team seems to agree that the ability to have an anonymous parameter is unfortunate historical baggage, and that we shouldn't create new code that uses it. Context: https://github.com/rust-lang/rust/issues/33417#issuecomment-276933861
2017-01-29Add missing url in convert moduleGuillaume Gomez-10/+18
2016-10-21Fix a few links in the docsOliver Middleton-3/+3