]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_attr/src/builtin.rs
Rollup merge of #93847 - solid-rs:fix-kmc-solid-fs-ts, r=yaahc
[rust.git] / compiler / rustc_attr / src / builtin.rs
index bab50df3dd543351cafc2b394791b4454b9f4ef1..dca7f5dd48769f5a7455dc5ee9f16c763e3714c2 100644 (file)
@@ -217,85 +217,81 @@ fn find_stability_generic<'a, I>(
                     let mut issue_num = None;
                     let mut is_soft = false;
                     for meta in metas {
-                        if let Some(mi) = meta.meta_item() {
-                            match mi.name_or_empty() {
-                                sym::feature => {
-                                    if !get(mi, &mut feature) {
-                                        continue 'outer;
-                                    }
+                        let Some(mi) = meta.meta_item() else {
+                            handle_errors(
+                                &sess.parse_sess,
+                                meta.span(),
+                                AttrError::UnsupportedLiteral("unsupported literal", false),
+                            );
+                            continue 'outer;
+                        };
+                        match mi.name_or_empty() {
+                            sym::feature => {
+                                if !get(mi, &mut feature) {
+                                    continue 'outer;
                                 }
-                                sym::reason => {
-                                    if !get(mi, &mut reason) {
-                                        continue 'outer;
-                                    }
+                            }
+                            sym::reason => {
+                                if !get(mi, &mut reason) {
+                                    continue 'outer;
+                                }
+                            }
+                            sym::issue => {
+                                if !get(mi, &mut issue) {
+                                    continue 'outer;
                                 }
-                                sym::issue => {
-                                    if !get(mi, &mut issue) {
-                                        continue 'outer;
-                                    }
 
-                                    // These unwraps are safe because `get` ensures the meta item
-                                    // is a name/value pair string literal.
-                                    issue_num = match issue.unwrap().as_str() {
-                                        "none" => None,
-                                        issue => {
-                                            let emit_diag = |msg: &str| {
-                                                struct_span_err!(
-                                                    diagnostic,
-                                                    mi.span,
-                                                    E0545,
-                                                    "`issue` must be a non-zero numeric string \
-                                                    or \"none\"",
-                                                )
-                                                .span_label(
-                                                    mi.name_value_literal_span().unwrap(),
-                                                    msg,
-                                                )
-                                                .emit();
-                                            };
-                                            match issue.parse() {
-                                                Ok(0) => {
-                                                    emit_diag(
-                                                        "`issue` must not be \"0\", \
-                                                        use \"none\" instead",
-                                                    );
-                                                    continue 'outer;
-                                                }
-                                                Ok(num) => NonZeroU32::new(num),
-                                                Err(err) => {
-                                                    emit_diag(&err.to_string());
-                                                    continue 'outer;
-                                                }
+                                // These unwraps are safe because `get` ensures the meta item
+                                // is a name/value pair string literal.
+                                issue_num = match issue.unwrap().as_str() {
+                                    "none" => None,
+                                    issue => {
+                                        let emit_diag = |msg: &str| {
+                                            struct_span_err!(
+                                                diagnostic,
+                                                mi.span,
+                                                E0545,
+                                                "`issue` must be a non-zero numeric string \
+                                                or \"none\"",
+                                            )
+                                            .span_label(mi.name_value_literal_span().unwrap(), msg)
+                                            .emit();
+                                        };
+                                        match issue.parse() {
+                                            Ok(0) => {
+                                                emit_diag(
+                                                    "`issue` must not be \"0\", \
+                                                    use \"none\" instead",
+                                                );
+                                                continue 'outer;
+                                            }
+                                            Ok(num) => NonZeroU32::new(num),
+                                            Err(err) => {
+                                                emit_diag(&err.to_string());
+                                                continue 'outer;
                                             }
                                         }
-                                    };
-                                }
-                                sym::soft => {
-                                    if !mi.is_word() {
-                                        let msg = "`soft` should not have any arguments";
-                                        sess.parse_sess.span_diagnostic.span_err(mi.span, msg);
                                     }
-                                    is_soft = true;
-                                }
-                                _ => {
-                                    handle_errors(
-                                        &sess.parse_sess,
-                                        meta.span(),
-                                        AttrError::UnknownMetaItem(
-                                            pprust::path_to_string(&mi.path),
-                                            &["feature", "reason", "issue", "soft"],
-                                        ),
-                                    );
-                                    continue 'outer;
+                                };
+                            }
+                            sym::soft => {
+                                if !mi.is_word() {
+                                    let msg = "`soft` should not have any arguments";
+                                    sess.parse_sess.span_diagnostic.span_err(mi.span, msg);
                                 }
+                                is_soft = true;
+                            }
+                            _ => {
+                                handle_errors(
+                                    &sess.parse_sess,
+                                    meta.span(),
+                                    AttrError::UnknownMetaItem(
+                                        pprust::path_to_string(&mi.path),
+                                        &["feature", "reason", "issue", "soft"],
+                                    ),
+                                );
+                                continue 'outer;
                             }
-                        } else {
-                            handle_errors(
-                                &sess.parse_sess,
-                                meta.span(),
-                                AttrError::UnsupportedLiteral("unsupported literal", false),
-                            );
-                            continue 'outer;
                         }
                     }
 
@@ -608,7 +604,7 @@ pub fn eval_condition(
     }
 }
 
-#[derive(Debug, Encodable, Decodable, Clone, HashStable_Generic)]
+#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable_Generic)]
 pub struct Deprecation {
     pub since: Option<Symbol>,
     /// The note to issue a reason.