-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ use clippy_utils::msrvs; | |
use clippy_utils::source::{first_line_of_span, is_present_in_source, snippet_opt, without_block_comments}; | ||
use clippy_utils::{extract_msrv_attr, meets_msrv}; | ||
use if_chain::if_chain; | ||
use rustc_ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem}; | ||
use rustc_ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MacArgs, MacArgsEq, MetaItemKind, NestedMetaItem}; | ||
use rustc_errors::Applicability; | ||
use rustc_hir::{ | ||
Block, Expr, ExprKind, ImplItem, ImplItemKind, Item, ItemKind, StmtKind, TraitFn, TraitItem, TraitItemKind, | ||
|
@@ -593,6 +593,10 @@ fn check_empty_line_after_outer_attr(cx: &EarlyContext<'_>, item: &rustc_ast::It | |
}; | ||
|
||
if attr.style == AttrStyle::Outer { | ||
if let MacArgs::Eq(_, MacArgsEq::Ast(expr)) = &attr_item.args | ||
&& !matches!(expr.kind, rustc_ast::ExprKind::Lit(..)) { | ||
return; | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
flip1995
Author
Member
|
||
if attr_item.args.inner_tokens().is_empty() || !is_present_in_source(cx, attr.span) { | ||
return; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
macro_rules! foo { | ||
() => { | ||
"bar.rs" | ||
}; | ||
} | ||
|
||
#[path = foo!()] //~ ERROR malformed `path` attribute | ||
mod abc {} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error: malformed `path` attribute input | ||
--> $DIR/ice-96721.rs:7:1 | ||
| | ||
LL | #[path = foo!()] //~ ERROR malformed `path` attribute | ||
| ^^^^^^^^^^^^^^^^ help: must be of the form: `#[path = "file"]` | ||
|
||
error: aborting due to previous error | ||
|
Thanks for fixing this issue! This change is enough to avoid the crash, but I think this would be better:
It's simpler and avoids an unnecessary early return.