-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate Error::description for real #66919
Conversation
@rfcbot fcp merge |
Team member @dtolnay has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
@nox Any thoughts on this? If I remember correctly you recently argued for defining |
I don't care enough to argue about that stuff, but I certainly hope this won't land without a crater run, and without an adequate amount of certainty that this won't trigger an important amount of deprecation warnings. All things said, I don't think this hard-deprecation is useful. |
@bors try for a crater run |
Deprecate Error::description for real `description` has been documented as soft-deprecated since 1.27.0 (17 months ago). There is no longer any reason to call it or implement it. This PR: - adds `#[rustc_deprecated(since = "1.41.0")]` to `Error::description`; - moves `description` (and `cause`, which is also deprecated) below the `source` and `backtrace` methods in the Error trait; - reduces documentation of `description` and `cause` to take up much less vertical real estate in rustdocs, while preserving the example that shows how to render errors without needing to call `description`; - removes the description function of all *currently unstable* Error impls in the standard library; - marks `#[allow(deprecated)]` the description function of all *stable* Error impls in the standard library; - replaces miscellaneous uses of `description` in example code and the compiler. --- ![description](https://user-images.githubusercontent.com/1940490/69910369-3bbaca80-13bf-11ea-94f7-2fe27a7ea333.png)
☀️ Try build successful - checks-azure |
@craterbot check |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
I am still seeing description functions pop up in my work codebase. New developers see it in the trait, and obviously errors need a description so they write one. The error idioms in Rust are confusing enough and we don't need to keep around this part of the confusion. As such, I'm set on either real-deprecating it or hiding it from rustdoc (#66859). |
🎉 Experiment
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
All regressions look genuine and the breakage scale is very low; it looks like we are in FCP already as well. I don't know if we want to wait for FCP to expire or not. |
Rebased and amended with the fix that @goodmanjonathan suggested. I think we can go ahead and get this reviewed and landed ahead of the full FCP window, though of course anyone is welcome to voice objections. This isn't a new API being stabilized so in the worst case we end up reverting the deprecation. |
@bors r+ |
@@ -286,7 +286,7 @@ fn main() { | |||
let (format, dst) = parse_args(); | |||
let result = syntax::with_default_globals(move || main_with_result(format, &dst)); | |||
if let Err(e) = result { | |||
panic!("{}", e.description()); | |||
panic!("{}", e.to_string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just looking at this from TWIR, but couldn't this leave out the .to_string()
to avoid double-allocation of the message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If e impl Display, does it turn to
panic!("{}", e.to_string()); | |
panic!("{}", e); |
1175: Remove deprecated Error::description r=asomers a=AnderEnder `Error::description` has been documented as soft-deprecated since 1.27.0 (17 months ago). It is going to be hard-deprecated soon. This PR: - Removes all implementations of `description` in all error types Related PR: rust-lang/rust#66919 Co-authored-by: Radyk Andrii <ander.ender@gmail.com>
If you want to maintain backward compatibility with anybody that relied on the output of |
Error descriptions are soft-deprecated since 1.27.0, and hard-deprecated since 1.42.0. Our MSRV is 1.36.0 so well above the 1.27.0 bound. See also rust-lang/rust#66919
Error descriptions are soft-deprecated since 1.27.0, and hard-deprecated since 1.42.0. See rust-lang/rust#66919
Version 1.42.0 (2020-03-12) ========================== Language -------- - [You can now use the slice pattern syntax with subslices.][67712] e.g. ```rust fn foo(words: &[&str]) { match words { ["Hello", "World", "!", ..] => println!("Hello World!"), ["Foo", "Bar", ..] => println!("Baz"), rest => println!("{:?}", rest), } } ``` - [You can now use `#[repr(transparent)]` on univariant `enum`s.][68122] Meaning that you can create an enum that has the exact layout and ABI of the type it contains. - [There are some *syntax-only* changes:][67131] - `default` is syntactically allowed before items in `trait` definitions. - Items in `impl`s (i.e. `const`s, `type`s, and `fn`s) may syntactically leave out their bodies in favor of `;`. - Bounds on associated types in `impl`s are now syntactically allowed (e.g. `type Foo: Ord;`). - `...` (the C-variadic type) may occur syntactically directly as the type of any function parameter. These are still rejected *semantically*, so you will likely receive an error but these changes can be seen and parsed by procedural macros and conditional compilation. Compiler -------- - [Added tier 2* support for `armv7a-none-eabi`.][68253] - [Added tier 2 support for `riscv64gc-unknown-linux-gnu`.][68339] - [`Option::{expect,unwrap}` and `Result::{expect, expect_err, unwrap, unwrap_err}` now produce panic messages pointing to the location where they were called, rather than `core`'s internals. ][67887] * Refer to Rust's [platform support page][forge-platform-support] for more information on Rust's tiered platform support. Libraries --------- - [`iter::Empty<T>` now implements `Send` and `Sync` for any `T`.][68348] - [`Pin::{map_unchecked, map_unchecked_mut}` no longer require the return type to implement `Sized`.][67935] - [`io::Cursor` now derives `PartialEq` and `Eq`.][67233] - [`Layout::new` is now `const`.][66254] - [Added Standard Library support for `riscv64gc-unknown-linux-gnu`.][66899] Stabilized APIs --------------- - [`CondVar::wait_while`] - [`CondVar::wait_timeout_while`] - [`DebugMap::key`] - [`DebugMap::value`] - [`ManuallyDrop::take`] - [`matches!`] - [`ptr::slice_from_raw_parts_mut`] - [`ptr::slice_from_raw_parts`] Cargo ----- - [You no longer need to include `extern crate proc_macro;` to be able to `use proc_macro;` in the `2018` edition.][cargo/7700] Compatibility Notes ------------------- - [`Error::description` has been deprecated, and its use will now produce a warning.][66919] It's recommended to use `Display`/`to_string` instead. - [`use $crate;` inside macros is now a hard error.][37390] The compiler emitted forward compatibility warnings since Rust 1.14.0. - [As previously announced, this release reduces the level of support for 32-bit Apple targets to tier 3.][apple-32bit-drop]. This means that the source code is still available to build, but the targets are no longer tested and no release binary is distributed by the Rust project. Please refer to the linked blog post for more information. [37390]: rust-lang/rust#37390 [68253]: rust-lang/rust#68253 [68348]: rust-lang/rust#68348 [67935]: rust-lang/rust#67935 [68339]: rust-lang/rust#68339 [68122]: rust-lang/rust#68122 [67712]: rust-lang/rust#67712 [67887]: rust-lang/rust#67887 [67131]: rust-lang/rust#67131 [67233]: rust-lang/rust#67233 [66899]: rust-lang/rust#66899 [66919]: rust-lang/rust#66919 [66254]: rust-lang/rust#66254 [cargo/7700]: rust-lang/cargo#7700 [`DebugMap::key`]: https://doc.rust-lang.org/stable/std/fmt/struct.DebugMap.html#method.key [`DebugMap::value`]: https://doc.rust-lang.org/stable/std/fmt/struct.DebugMap.html#method.value [`ManuallyDrop::take`]: https://doc.rust-lang.org/stable/std/mem/struct.ManuallyDrop.html#method.take [`matches!`]: https://doc.rust-lang.org/stable/std/macro.matches.html [`ptr::slice_from_raw_parts_mut`]: https://doc.rust-lang.org/stable/std/ptr/fn.slice_from_raw_parts_mut.html [`ptr::slice_from_raw_parts`]: https://doc.rust-lang.org/stable/std/ptr/fn.slice_from_raw_parts.html [`CondVar::wait_while`]: https://doc.rust-lang.org/stable/std/sync/struct.Condvar.html#method.wait_while [`CondVar::wait_timeout_while`]: https://doc.rust-lang.org/stable/std/sync/struct.Condvar.html#method.wait_timeout_while
Error descriptions are soft-deprecated since 1.27.0, and hard-deprecated since 1.42.0. MSRV is 1.36.0 so well above the 1.27.0 bound. See also rust-lang/rust#66919
Error::description is fully deprecated now. See: rust-lang/rust#66919
Error descriptions are soft-deprecated since 1.27.0, and hard-deprecated since 1.42.0. See also rust-lang/rust#66919
* when newer rust is used, iotedge-* fails with: with 1.47.0 and 1.46.0 rust_2018_idioms, triggers unused_attributes warning because rust_2018_idioms is for crate level only since: rust-lang/rust#73300 which is then an error because warnings are denied as well: | ''+v8+v8' is not a recognized feature for this target' is not a recognized feature for this target (ignoring feature) | (ignoring feature) | '+v8' is not a recognized feature for this target' (ignoring feature) | +v8' is not a recognized feature for this target (ignoring feature) | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/authentication.rs:3:9 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | | note: the lint level is defined here | --> edgelet-http/src/authentication.rs:3:27 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^ | = note: `#[deny(unused_attributes)]` implied by `#[deny(warnings)]` | | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/certificate_manager.rs:1:9 | | | 1 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | | note: the lint level is defined here | --> edgelet-http/src/certificate_manager.rs:1:27 | | | 1 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^ | | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/authentication.rs:3:9 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/certificate_manager.rs:1:9 | | | 1 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | ''+v8+v8' is not a recognized feature for this target' is not a recognized feature for this target (ignoring feature) | (ignoring feature) | '+v8' is not a recognized feature for this target (ignoring feature) | '+v8' is not a recognized feature for this target (ignoring feature) with 1.43.0 it still fails due to use of deprecated description (since 1.42.0 with rust-lang/rust#66919) | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:248:54 | | | 248 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ | | | note: the lint level is defined here | --> iotedge/src/lib.rs:3:27 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^ | = note: `#[deny(deprecated)]` implied by `#[deny(warnings)]` | | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:302:54 | | | 302 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ | | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:375:54 | | | 375 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ | | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:457:54 | | | 457 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ you can either work around it by allowing warnings (deprecated and unused_attributes): find ${WORKDIR}/iotedge-${PV} -name "*.rs" -exec sed -i 's/idioms, warnings)/idioms)/g' {} \; or fix it properly in next iotedge release, or just select older rust version which doesn't trigger fatal error for this with: RUST_VERSION = "1.41.0" PREFERRED_VERSION_rust-native ?= "${RUST_VERSION}" PREFERRED_VERSION_rust-cross-${TARGET_ARCH} ?= "${RUST_VERSION}" PREFERRED_VERSION_rust-llvm-native ?= "${RUST_VERSION}" PREFERRED_VERSION_libstd-rs ?= "${RUST_VERSION}" PREFERRED_VERSION_cargo-native ?= "${RUST_VERSION}" Signed-off-by: Martin Jansa <martin.jansa@lge.com>
* when newer rust is used, iotedge-* fails with: with 1.47.0 and 1.46.0 rust_2018_idioms, triggers unused_attributes warning because rust_2018_idioms is for crate level only since: rust-lang/rust#73300 which is then an error because warnings are denied as well: | ''+v8+v8' is not a recognized feature for this target' is not a recognized feature for this target (ignoring feature) | (ignoring feature) | '+v8' is not a recognized feature for this target' (ignoring feature) | +v8' is not a recognized feature for this target (ignoring feature) | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/authentication.rs:3:9 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | | note: the lint level is defined here | --> edgelet-http/src/authentication.rs:3:27 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^ | = note: `#[deny(unused_attributes)]` implied by `#[deny(warnings)]` | | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/certificate_manager.rs:1:9 | | | 1 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | | note: the lint level is defined here | --> edgelet-http/src/certificate_manager.rs:1:27 | | | 1 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^ | | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/authentication.rs:3:9 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/certificate_manager.rs:1:9 | | | 1 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | ''+v8+v8' is not a recognized feature for this target' is not a recognized feature for this target (ignoring feature) | (ignoring feature) | '+v8' is not a recognized feature for this target (ignoring feature) | '+v8' is not a recognized feature for this target (ignoring feature) with 1.43.0 it still fails due to use of deprecated description (since 1.42.0 with rust-lang/rust#66919) | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:248:54 | | | 248 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ | | | note: the lint level is defined here | --> iotedge/src/lib.rs:3:27 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^ | = note: `#[deny(deprecated)]` implied by `#[deny(warnings)]` | | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:302:54 | | | 302 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ | | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:375:54 | | | 375 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ | | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:457:54 | | | 457 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ you can either work around it by allowing warnings (deprecated and unused_attributes): find ${WORKDIR}/iotedge-${PV} -name "*.rs" -exec sed -i 's/idioms, warnings)/idioms)/g' {} \; or fix it properly in next iotedge release, or just select older rust version which doesn't trigger fatal error for this with: RUST_VERSION = "1.41.0" PREFERRED_VERSION_rust-native ?= "${RUST_VERSION}" PREFERRED_VERSION_rust-cross-${TARGET_ARCH} ?= "${RUST_VERSION}" PREFERRED_VERSION_rust-llvm-native ?= "${RUST_VERSION}" PREFERRED_VERSION_libstd-rs ?= "${RUST_VERSION}" PREFERRED_VERSION_cargo-native ?= "${RUST_VERSION}" Signed-off-by: Martin Jansa <martin.jansa@lge.com>
* when newer rust is used, iotedge-* fails with: with 1.47.0 and 1.46.0 rust_2018_idioms, triggers unused_attributes warning because rust_2018_idioms is for crate level only since: rust-lang/rust#73300 which is then an error because warnings are denied as well: | ''+v8+v8' is not a recognized feature for this target' is not a recognized feature for this target (ignoring feature) | (ignoring feature) | '+v8' is not a recognized feature for this target' (ignoring feature) | +v8' is not a recognized feature for this target (ignoring feature) | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/authentication.rs:3:9 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | | note: the lint level is defined here | --> edgelet-http/src/authentication.rs:3:27 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^ | = note: `#[deny(unused_attributes)]` implied by `#[deny(warnings)]` | | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/certificate_manager.rs:1:9 | | | 1 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | | note: the lint level is defined here | --> edgelet-http/src/certificate_manager.rs:1:27 | | | 1 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^ | | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/authentication.rs:3:9 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/certificate_manager.rs:1:9 | | | 1 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | ''+v8+v8' is not a recognized feature for this target' is not a recognized feature for this target (ignoring feature) | (ignoring feature) | '+v8' is not a recognized feature for this target (ignoring feature) | '+v8' is not a recognized feature for this target (ignoring feature) with 1.43.0 it still fails due to use of deprecated description (since 1.42.0 with rust-lang/rust#66919) | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:248:54 | | | 248 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ | | | note: the lint level is defined here | --> iotedge/src/lib.rs:3:27 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^ | = note: `#[deny(deprecated)]` implied by `#[deny(warnings)]` | | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:302:54 | | | 302 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ | | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:375:54 | | | 375 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ | | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:457:54 | | | 457 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ you can either work around it by allowing warnings (deprecated and unused_attributes): find ${WORKDIR}/iotedge-${PV} -name "*.rs" -exec sed -i 's/idioms, warnings)/idioms)/g' {} \; or fix it properly in next iotedge release, or just select older rust version which doesn't trigger fatal error for this with: RUST_VERSION = "1.41.0" PREFERRED_VERSION_rust-native ?= "${RUST_VERSION}" PREFERRED_VERSION_rust-cross-${TARGET_ARCH} ?= "${RUST_VERSION}" PREFERRED_VERSION_rust-llvm-native ?= "${RUST_VERSION}" PREFERRED_VERSION_libstd-rs ?= "${RUST_VERSION}" PREFERRED_VERSION_cargo-native ?= "${RUST_VERSION}" Signed-off-by: Martin Jansa <martin.jansa@lge.com>
description
has been documented as soft-deprecated since 1.27.0 (17 months ago). There is no longer any reason to call it or implement it.This PR:
#[rustc_deprecated(since = "1.41.0")]
toError::description
;description
(andcause
, which is also deprecated) below thesource
andbacktrace
methods in the Error trait;description
andcause
to take up much less vertical real estate in rustdocs, while preserving the example that shows how to render errors without needing to calldescription
;#[allow(deprecated)]
the description function of all stable Error impls in the standard library;description
in example code and the compiler.