if let Some(list) = attr.meta_item_list() {
for meta in list {
- if meta.has_name(sym::include) || meta.has_name(sym::hidden) {
+ if meta.has_name(sym::hidden) {
return true;
}
}
/// [`..` range expression]: https://doc.rust-lang.org/reference/expressions/range-expr.html
pub ELLIPSIS_INCLUSIVE_RANGE_PATTERNS,
Warn,
- "`...` range patterns are deprecated"
+ "`...` range patterns are deprecated",
+ @future_incompatible = FutureIncompatibleInfo {
+ reference: "issue #80165 <https://github.com/rust-lang/rust/issues/80165>",
+ edition: Some(Edition::Edition2021),
+ };
}
#[derive(Default)]
let suggestion = "use `..=` for an inclusive range";
if parenthesise {
self.node_id = Some(pat.id);
- cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, pat.span, |lint| {
- let end = expr_to_string(&end);
- let replace = match start {
- Some(start) => format!("&({}..={})", expr_to_string(&start), end),
- None => format!("&(..={})", end),
- };
- lint.build(msg)
- .span_suggestion(
- pat.span,
- suggestion,
- replace,
- Applicability::MachineApplicable,
- )
- .emit();
- });
+ let end = expr_to_string(&end);
+ let replace = match start {
+ Some(start) => format!("&({}..={})", expr_to_string(&start), end),
+ None => format!("&(..={})", end),
+ };
+ if join.edition() >= Edition::Edition2021 {
+ let mut err =
+ rustc_errors::struct_span_err!(cx.sess, pat.span, E0783, "{}", msg,);
+ err.span_suggestion(
+ pat.span,
+ suggestion,
+ replace,
+ Applicability::MachineApplicable,
+ )
+ .emit();
+ } else {
+ cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, pat.span, |lint| {
+ lint.build(msg)
+ .span_suggestion(
+ pat.span,
+ suggestion,
+ replace,
+ Applicability::MachineApplicable,
+ )
+ .emit();
+ });
+ }
} else {
- cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, join, |lint| {
- lint.build(msg)
- .span_suggestion_short(
- join,
- suggestion,
- "..=".to_owned(),
- Applicability::MachineApplicable,
- )
- .emit();
- });
+ let replace = "..=".to_owned();
+ if join.edition() >= Edition::Edition2021 {
+ let mut err =
+ rustc_errors::struct_span_err!(cx.sess, pat.span, E0783, "{}", msg,);
+ err.span_suggestion_short(
+ join,
+ suggestion,
+ replace,
+ Applicability::MachineApplicable,
+ )
+ .emit();
+ } else {
+ cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, join, |lint| {
+ lint.build(msg)
+ .span_suggestion_short(
+ join,
+ suggestion,
+ replace,
+ Applicability::MachineApplicable,
+ )
+ .emit();
+ });
+ }
};
}
}
declare_lint! {
/// The `invalid_value` lint detects creating a value that is not valid,
- /// such as a NULL reference.
+ /// such as a null reference.
///
/// ### Example
///
/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
pub INVALID_VALUE,
Warn,
- "an invalid value is being created (such as a NULL reference)"
+ "an invalid value is being created (such as a null reference)"
}
declare_lint_pass!(InvalidValue => [INVALID_VALUE]);