Skip to content

Commit 1d029c6

Browse files
committed
Auto merge of #57387 - euclio:nonstandard-style-suggestions, r=oli-obk
Use structured suggestions for nonstandard style lints This PR modifies the lints in the nonstandard_style group to use structured suggestions. Note that there's a bit of tricky span calculation going on for the `crate_name` attribute. It also simplifies the code a bit: I don't think the "fallback" suggestions for these lints can actually be triggered. Fixes #48103. Fixes #52414.
2 parents 0bc0015 + 1b28f5a commit 1d029c6

File tree

45 files changed

+372
-373
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+372
-373
lines changed

src/librustc/hir/intravisit.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ use std::cmp;
4242

4343
#[derive(Copy, Clone)]
4444
pub enum FnKind<'a> {
45-
/// #[xxx] pub async/const/extern "Abi" fn foo()
46-
ItemFn(Name, &'a Generics, FnHeader, &'a Visibility, &'a [Attribute]),
45+
/// `#[xxx] pub async/const/extern "Abi" fn foo()`
46+
ItemFn(Ident, &'a Generics, FnHeader, &'a Visibility, &'a [Attribute]),
4747

48-
/// fn foo(&self)
48+
/// `fn foo(&self)`
4949
Method(Ident, &'a MethodSig, Option<&'a Visibility>, &'a [Attribute]),
5050

51-
/// |x, y| {}
51+
/// `|x, y| {}`
5252
Closure(&'a [Attribute]),
5353
}
5454

@@ -472,7 +472,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
472472
visitor.visit_nested_body(body);
473473
}
474474
ItemKind::Fn(ref declaration, header, ref generics, body_id) => {
475-
visitor.visit_fn(FnKind::ItemFn(item.ident.name,
475+
visitor.visit_fn(FnKind::ItemFn(item.ident,
476476
generics,
477477
header,
478478
&item.vis,

src/librustc/hir/map/blocks.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use hir as ast;
1515
use hir::map;
1616
use hir::{Expr, FnDecl, Node};
1717
use hir::intravisit::FnKind;
18-
use syntax::ast::{Attribute, Ident, Name, NodeId};
18+
use syntax::ast::{Attribute, Ident, NodeId};
1919
use syntax_pos::Span;
2020

2121
/// An FnLikeNode is a Node that is like a fn, in that it has a decl
@@ -98,7 +98,7 @@ impl<'a> Code<'a> {
9898
/// These are all the components one can extract from a fn item for
9999
/// use when implementing FnLikeNode operations.
100100
struct ItemFnParts<'a> {
101-
name: Name,
101+
ident: Ident,
102102
decl: &'a ast::FnDecl,
103103
header: ast::FnHeader,
104104
vis: &'a ast::Visibility,
@@ -200,7 +200,7 @@ impl<'a> FnLikeNode<'a> {
200200

201201
pub fn kind(self) -> FnKind<'a> {
202202
let item = |p: ItemFnParts<'a>| -> FnKind<'a> {
203-
FnKind::ItemFn(p.name, p.generics, p.header, p.vis, p.attrs)
203+
FnKind::ItemFn(p.ident, p.generics, p.header, p.vis, p.attrs)
204204
};
205205
let closure = |c: ClosureParts<'a>| {
206206
FnKind::Closure(c.attrs)
@@ -228,7 +228,7 @@ impl<'a> FnLikeNode<'a> {
228228
ast::ItemKind::Fn(ref decl, header, ref generics, block) =>
229229
item_fn(ItemFnParts {
230230
id: i.id,
231-
name: i.ident.name,
231+
ident: i.ident,
232232
decl: &decl,
233233
body: block,
234234
vis: &i.vis,

0 commit comments

Comments
 (0)