Auto merge of #142432 - matthiaskrgr:rollup-ziuls9y, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang/rust#138016 (Added `Clone` implementation for `ChunkBy`) - rust-lang/rust#141162 (refactor `AttributeGate` and `rustc_attr!` to emit notes during feature checking) - rust-lang/rust#141474 (Add `ParseMode::Diagnostic` and fix multiline spans in diagnostic attribute lints) - rust-lang/rust#141947 (Specify that "option-like" enums must be `#[repr(Rust)]` to be ABI-compatible with their non-1ZST field.) - rust-lang/rust#142252 (Improve clarity of `core::sync::atomic` docs about "Considerations" in regards to CAS operations) - rust-lang/rust#142337 (miri: add flag to suppress float non-determinism) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
@@ -22,7 +22,7 @@ use rustc_ast::visit::{FnCtxt, FnKind};
|
||||
use rustc_ast::{self as ast, *};
|
||||
use rustc_ast_pretty::pprust::expr_to_string;
|
||||
use rustc_errors::{Applicability, LintDiagnostic};
|
||||
use rustc_feature::{AttributeGate, BuiltinAttribute, GateIssue, Stability, deprecated_attributes};
|
||||
use rustc_feature::GateIssue;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LocalDefId};
|
||||
@@ -48,8 +48,7 @@ use rustc_trait_selection::traits::{self};
|
||||
|
||||
use crate::errors::BuiltinEllipsisInclusiveRangePatterns;
|
||||
use crate::lints::{
|
||||
BuiltinAnonymousParams, BuiltinConstNoMangle, BuiltinDeprecatedAttrLink,
|
||||
BuiltinDeprecatedAttrLinkSuggestion, BuiltinDerefNullptr, BuiltinDoubleNegations,
|
||||
BuiltinAnonymousParams, BuiltinConstNoMangle, BuiltinDerefNullptr, BuiltinDoubleNegations,
|
||||
BuiltinDoubleNegationsAddParens, BuiltinEllipsisInclusiveRangePatternsLint,
|
||||
BuiltinExplicitOutlives, BuiltinExplicitOutlivesSuggestion, BuiltinFeatureIssueNote,
|
||||
BuiltinIncompleteFeatures, BuiltinIncompleteFeaturesHelp, BuiltinInternalFeatures,
|
||||
@@ -799,53 +798,6 @@ impl EarlyLintPass for AnonymousParameters {
|
||||
}
|
||||
}
|
||||
|
||||
/// Check for use of attributes which have been deprecated.
|
||||
#[derive(Clone)]
|
||||
pub struct DeprecatedAttr {
|
||||
// This is not free to compute, so we want to keep it around, rather than
|
||||
// compute it for every attribute.
|
||||
depr_attrs: Vec<&'static BuiltinAttribute>,
|
||||
}
|
||||
|
||||
impl_lint_pass!(DeprecatedAttr => []);
|
||||
|
||||
impl Default for DeprecatedAttr {
|
||||
fn default() -> Self {
|
||||
DeprecatedAttr { depr_attrs: deprecated_attributes() }
|
||||
}
|
||||
}
|
||||
|
||||
impl EarlyLintPass for DeprecatedAttr {
|
||||
fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &ast::Attribute) {
|
||||
for BuiltinAttribute { name, gate, .. } in &self.depr_attrs {
|
||||
if attr.ident().map(|ident| ident.name) == Some(*name) {
|
||||
if let &AttributeGate::Gated(
|
||||
Stability::Deprecated(link, suggestion),
|
||||
name,
|
||||
reason,
|
||||
_,
|
||||
) = gate
|
||||
{
|
||||
let suggestion = match suggestion {
|
||||
Some(msg) => {
|
||||
BuiltinDeprecatedAttrLinkSuggestion::Msg { suggestion: attr.span, msg }
|
||||
}
|
||||
None => {
|
||||
BuiltinDeprecatedAttrLinkSuggestion::Default { suggestion: attr.span }
|
||||
}
|
||||
};
|
||||
cx.emit_span_lint(
|
||||
DEPRECATED,
|
||||
attr.span,
|
||||
BuiltinDeprecatedAttrLink { name, reason, link, suggestion },
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: &[ast::Attribute]) {
|
||||
use rustc_ast::token::CommentKind;
|
||||
|
||||
|
||||
@@ -174,7 +174,6 @@ early_lint_methods!(
|
||||
AnonymousParameters: AnonymousParameters,
|
||||
EllipsisInclusiveRangePatterns: EllipsisInclusiveRangePatterns::default(),
|
||||
NonCamelCaseTypes: NonCamelCaseTypes,
|
||||
DeprecatedAttr: DeprecatedAttr::default(),
|
||||
WhileTrue: WhileTrue,
|
||||
NonAsciiIdents: NonAsciiIdents,
|
||||
IncompleteInternalFeatures: IncompleteInternalFeatures,
|
||||
|
||||
@@ -199,32 +199,6 @@ pub(crate) struct BuiltinAnonymousParams<'a> {
|
||||
pub ty_snip: &'a str,
|
||||
}
|
||||
|
||||
// FIXME(davidtwco) translatable deprecated attr
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_builtin_deprecated_attr_link)]
|
||||
pub(crate) struct BuiltinDeprecatedAttrLink<'a> {
|
||||
pub name: Symbol,
|
||||
pub reason: &'a str,
|
||||
pub link: &'a str,
|
||||
#[subdiagnostic]
|
||||
pub suggestion: BuiltinDeprecatedAttrLinkSuggestion<'a>,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
pub(crate) enum BuiltinDeprecatedAttrLinkSuggestion<'a> {
|
||||
#[suggestion(lint_msg_suggestion, code = "", applicability = "machine-applicable")]
|
||||
Msg {
|
||||
#[primary_span]
|
||||
suggestion: Span,
|
||||
msg: &'a str,
|
||||
},
|
||||
#[suggestion(lint_default_suggestion, code = "", applicability = "machine-applicable")]
|
||||
Default {
|
||||
#[primary_span]
|
||||
suggestion: Span,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_builtin_unused_doc_comment)]
|
||||
pub(crate) struct BuiltinUnusedDocComment<'a> {
|
||||
|
||||
Reference in New Issue
Block a user