You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #94121 - matthiaskrgr:rollup-6ps95da, r=matthiaskrgr
Rollup of 6 pull requests
Successful merges:
- #92683 (Suggest copying trait associated type bounds on lifetime error)
- #92933 (Deny mixing bin crate type with lib crate types)
- #92959 (Add more info and suggestions to use of #[test] on invalid items)
- #93024 (Do not ICE when inlining a function with un-satisfiable bounds)
- #93613 (Move `{core,std}::stream::Stream` to `{core,std}::async_iter::AsyncIterator`)
- #93634 (compiler: clippy::complexity fixes)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
"`#[test]` attribute should not be used on macros. Use `#[cfg(test)]` instead.",
109
-
);
106
+
// Note: non-associated fn items are already handled by `expand_test_or_bench`
107
+
if !matches!(item.kind, ast::ItemKind::Fn(_)){
108
+
cx.sess
109
+
.parse_sess
110
+
.span_diagnostic
111
+
.struct_span_err(
112
+
attr_sp,
113
+
"the `#[test]` attribute may only be used on a non-associated function",
114
+
)
115
+
.note("the `#[test]` macro causes a a function to be run on a test and has no effect on non-functions")
116
+
.span_label(item.span,format!("expected a non-associated function, found {} {}", item.kind.article(), item.kind.descr()))
117
+
.span_suggestion(attr_sp,"replace with conditional compilation to make the item only exist when tests are being run",String::from("#[cfg(test)]"),Applicability::MaybeIncorrect)
0 commit comments