Skip to content

Commit

Permalink
code suggestion for deprecated-attribute lint
Browse files Browse the repository at this point in the history
Also, fix the deprecation message for the late no-debug feature.
  • Loading branch information
zackmdavis committed Sep 30, 2017
1 parent d663003 commit f2c5acd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,10 +650,11 @@ impl EarlyLintPass for DeprecatedAttr {
ref name,
ref reason,
_) = g {
cx.span_lint(DEPRECATED,
attr.span,
&format!("use of deprecated attribute `{}`: {}. See {}",
name, reason, link));
let msg = format!("use of deprecated attribute `{}`: {}. See {}",
name, reason, link);
let mut err = cx.struct_span_lint(DEPRECATED, attr.span, &msg);
err.span_suggestion_short(attr.span, "remove this attribute", "".to_owned());
err.emit();
}
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,8 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG
("no_debug", Whitelisted, Gated(
Stability::Deprecated("https://github.com/rust-lang/rust/issues/29721"),
"no_debug",
"the `#[no_debug]` attribute is an experimental feature",
"the `#[no_debug]` attribute was an experimental feature that has been \
deprecated due to lack of demand",
cfg_fn!(no_debug))),
("omit_gdb_pretty_printer_section", Whitelisted, Gated(Stability::Unstable,
"omit_gdb_pretty_printer_section",
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/feature-gate-no-debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@

#![allow(deprecated)]

#[no_debug] //~ ERROR the `#[no_debug]` attribute is
#[no_debug] //~ ERROR the `#[no_debug]` attribute was
fn main() {}

0 comments on commit f2c5acd

Please sign in to comment.