New deprecated_suggestion
feature, use in tests
This commit is contained in:
parent
6efc8e34d8
commit
5636655d0f
@ -741,7 +741,19 @@ fn find_deprecation_generic<'a, I>(sess: &Session, attrs_iter: I) -> Option<(Dep
|
||||
continue 'outer;
|
||||
}
|
||||
}
|
||||
sym::suggestion if attr.has_name(sym::rustc_deprecated) => {
|
||||
sym::suggestion => {
|
||||
if !sess.features_untracked().deprecated_suggestion {
|
||||
let mut diag = sess.struct_span_err(
|
||||
mi.span,
|
||||
"suggestions on deprecated items are unstable",
|
||||
);
|
||||
if sess.is_nightly_build() {
|
||||
diag.help("add `#![feature(deprecated_suggestion)]` to the crate root");
|
||||
}
|
||||
// FIXME(jhpratt) change this to an actual tracking issue
|
||||
diag.note("see #XXX for more details").emit();
|
||||
}
|
||||
|
||||
if !get(mi, &mut suggestion) {
|
||||
continue 'outer;
|
||||
}
|
||||
@ -778,10 +790,6 @@ fn find_deprecation_generic<'a, I>(sess: &Session, attrs_iter: I) -> Option<(Dep
|
||||
}
|
||||
}
|
||||
|
||||
if suggestion.is_some() && attr.has_name(sym::deprecated) {
|
||||
unreachable!("only allowed on rustc_deprecated")
|
||||
}
|
||||
|
||||
if attr.has_name(sym::rustc_deprecated) {
|
||||
if since.is_none() {
|
||||
handle_errors(&sess.parse_sess, attr.span, AttrError::MissingSince);
|
||||
|
@ -368,6 +368,8 @@ pub fn set(&self, features: &mut Features, span: Span) {
|
||||
(active, default_alloc_error_handler, "1.48.0", Some(66741), None),
|
||||
/// Allows default type parameters to influence type inference.
|
||||
(active, default_type_parameter_fallback, "1.3.0", Some(27336), None),
|
||||
/// Allows having using `suggestion` in the `#[deprecated]` attribute.
|
||||
(active, deprecated_suggestion, "1.61.0", Some(94785), None),
|
||||
/// Allows `#[derive(Default)]` and `#[default]` on enums.
|
||||
(active, derive_default_enum, "1.56.0", Some(86985), None),
|
||||
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.
|
||||
|
@ -562,6 +562,7 @@
|
||||
delay_span_bug_from_inside_query,
|
||||
deny,
|
||||
deprecated,
|
||||
deprecated_suggestion,
|
||||
deref,
|
||||
deref_method,
|
||||
deref_mut,
|
||||
|
@ -166,6 +166,7 @@
|
||||
#![feature(const_refs_to_cell)]
|
||||
#![feature(decl_macro)]
|
||||
#![feature(derive_default_enum)]
|
||||
#![cfg_attr(not(bootstrap), feature(deprecated_suggestion))]
|
||||
#![feature(doc_cfg)]
|
||||
#![feature(doc_notable_trait)]
|
||||
#![feature(rustdoc_internals)]
|
||||
|
@ -270,6 +270,7 @@
|
||||
#![feature(doc_cfg)]
|
||||
#![feature(doc_cfg_hide)]
|
||||
#![feature(rustdoc_internals)]
|
||||
#![cfg_attr(not(bootstrap), feature(deprecated_suggestion))]
|
||||
#![feature(doc_masked)]
|
||||
#![feature(doc_notable_trait)]
|
||||
#![feature(dropck_eyepatch)]
|
||||
|
@ -0,0 +1,6 @@
|
||||
// compile-flags: --crate-type=lib
|
||||
|
||||
#![no_implicit_prelude]
|
||||
|
||||
#[deprecated(suggestion = "foo")] //~ ERROR suggestions on deprecated items are unstable
|
||||
struct Foo {}
|
@ -0,0 +1,11 @@
|
||||
error: suggestions on deprecated items are unstable
|
||||
--> $DIR/feature-gate-deprecated_suggestion.rs:5:14
|
||||
|
|
||||
LL | #[deprecated(suggestion = "foo")]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(deprecated_suggestion)]` to the crate root
|
||||
= note: see #XXX for more details
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -1,6 +1,7 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(staged_api)]
|
||||
#![feature(deprecated_suggestion)]
|
||||
|
||||
#![stable(since = "1.0.0", feature = "test")]
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(staged_api)]
|
||||
#![feature(deprecated_suggestion)]
|
||||
|
||||
#![stable(since = "1.0.0", feature = "test")]
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
error: use of deprecated function `bar::deprecated`: replaced by `replacement`
|
||||
--> $DIR/suggestion.rs:41:10
|
||||
--> $DIR/suggestion.rs:42:10
|
||||
|
|
||||
LL | bar::deprecated();
|
||||
| ^^^^^^^^^^ help: replace the use of the deprecated function: `replacement`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/suggestion.rs:7:9
|
||||
--> $DIR/suggestion.rs:8:9
|
||||
|
|
||||
LL | #![deny(deprecated)]
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: use of deprecated associated function `Foo::deprecated`: replaced by `replacement`
|
||||
--> $DIR/suggestion.rs:39:9
|
||||
--> $DIR/suggestion.rs:40:9
|
||||
|
|
||||
LL | foo.deprecated();
|
||||
| ^^^^^^^^^^ help: replace the use of the deprecated associated function: `replacement`
|
||||
|
Loading…
Reference in New Issue
Block a user