Fix formatting

This commit is contained in:
carbotaniuman 2024-05-27 11:45:32 -05:00
parent 8aa2553b50
commit 15f8ffe371
5 changed files with 25 additions and 7 deletions

View File

@ -260,8 +260,13 @@ pub fn print_crate<'a>(
// root, so this is not needed, and actually breaks things. // root, so this is not needed, and actually breaks things.
if edition.is_rust_2015() { if edition.is_rust_2015() {
// `#![no_std]` // `#![no_std]`
let fake_attr = let fake_attr = attr::mk_attr_word(
attr::mk_attr_word(g, ast::AttrStyle::Inner, Safety::Default, sym::no_std, DUMMY_SP); g,
ast::AttrStyle::Inner,
Safety::Default,
sym::no_std,
DUMMY_SP,
);
s.print_attribute(&fake_attr); s.print_attribute(&fake_attr);
} }
} }

View File

@ -2,7 +2,7 @@
use crate::errors; use crate::errors;
use rustc_ast as ast; use rustc_ast as ast;
use rustc_ast::{GenericParamKind, ItemKind, MetaItemKind, NestedMetaItem, StmtKind, Safety}; use rustc_ast::{GenericParamKind, ItemKind, MetaItemKind, NestedMetaItem, Safety, StmtKind};
use rustc_expand::base::{ use rustc_expand::base::{
Annotatable, DeriveResolution, ExpandResult, ExtCtxt, Indeterminate, MultiItemModifier, Annotatable, DeriveResolution, ExpandResult, ExtCtxt, Indeterminate, MultiItemModifier,
}; };

View File

@ -674,12 +674,26 @@ pub fn attr_word(&self, name: Symbol, span: Span) -> ast::Attribute {
// Note: `span` is used for both the identifier and the value. // Note: `span` is used for both the identifier and the value.
pub fn attr_name_value_str(&self, name: Symbol, val: Symbol, span: Span) -> ast::Attribute { pub fn attr_name_value_str(&self, name: Symbol, val: Symbol, span: Span) -> ast::Attribute {
let g = &self.sess.psess.attr_id_generator; let g = &self.sess.psess.attr_id_generator;
attr::mk_attr_name_value_str(g, ast::AttrStyle::Outer, ast::Safety::Default, name, val, span) attr::mk_attr_name_value_str(
g,
ast::AttrStyle::Outer,
ast::Safety::Default,
name,
val,
span,
)
} }
// Builds `#[outer(inner)]`. // Builds `#[outer(inner)]`.
pub fn attr_nested_word(&self, outer: Symbol, inner: Symbol, span: Span) -> ast::Attribute { pub fn attr_nested_word(&self, outer: Symbol, inner: Symbol, span: Span) -> ast::Attribute {
let g = &self.sess.psess.attr_id_generator; let g = &self.sess.psess.attr_id_generator;
attr::mk_attr_nested_word(g, ast::AttrStyle::Outer, ast::Safety::Default, outer, inner, span) attr::mk_attr_nested_word(
g,
ast::AttrStyle::Outer,
ast::Safety::Default,
outer,
inner,
span,
)
} }
} }

View File

@ -312,7 +312,6 @@ fn check_do_not_recommend(&self, attr_span: Span, hir_id: HirId, target: Target)
true true
} }
/// Checks if `unsafe()` is applied to an invalid attribute. /// Checks if `unsafe()` is applied to an invalid attribute.
fn check_unsafe_attr(&self, attr: &Attribute) { fn check_unsafe_attr(&self, attr: &Attribute) {
if !attr.is_doc_comment() { if !attr.is_doc_comment() {

View File

@ -1,6 +1,6 @@
use super::*; use super::*;
use rustc_ast::{MetaItemLit, Path, StrStyle, Safety}; use rustc_ast::{MetaItemLit, Path, Safety, StrStyle};
use rustc_span::create_default_session_globals_then; use rustc_span::create_default_session_globals_then;
use rustc_span::symbol::{kw, Ident}; use rustc_span::symbol::{kw, Ident};
use rustc_span::DUMMY_SP; use rustc_span::DUMMY_SP;