rename lint to unnameable-test-functions
This commit is contained in:
parent
6a2003e4e3
commit
51a0425f36
@ -1740,20 +1740,20 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
|
|||||||
}
|
}
|
||||||
|
|
||||||
declare_lint! {
|
declare_lint! {
|
||||||
UNTESTABLE_METHOD,
|
UNNAMEABLE_TEST_FUNCTIONS,
|
||||||
Warn,
|
Warn,
|
||||||
"detects untestable method marked as #[test]"
|
"detects an function that cannot be named being marked as #[test]"
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct UntestableMethod;
|
pub struct UnnameableTestFunctions;
|
||||||
|
|
||||||
impl LintPass for UntestableMethod {
|
impl LintPass for UnnameableTestFunctions {
|
||||||
fn get_lints(&self) -> LintArray {
|
fn get_lints(&self) -> LintArray {
|
||||||
lint_array!(UNTESTABLE_METHOD)
|
lint_array!(UNNAMEABLE_TEST_FUNCTIONS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UntestableMethod {
|
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnameableTestFunctions {
|
||||||
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
|
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
|
||||||
match it.node {
|
match it.node {
|
||||||
hir::ItemFn(..) => {
|
hir::ItemFn(..) => {
|
||||||
@ -1765,7 +1765,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UntestableMethod {
|
|||||||
None => {}
|
None => {}
|
||||||
_ => {
|
_ => {
|
||||||
cx.struct_span_lint(
|
cx.struct_span_lint(
|
||||||
UNTESTABLE_METHOD,
|
UNNAMEABLE_TEST_FUNCTIONS,
|
||||||
attr.span,
|
attr.span,
|
||||||
"cannot test inner function",
|
"cannot test inner function",
|
||||||
).emit();
|
).emit();
|
||||||
|
@ -130,7 +130,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
|
|||||||
MutableTransmutes: MutableTransmutes,
|
MutableTransmutes: MutableTransmutes,
|
||||||
UnionsWithDropFields: UnionsWithDropFields,
|
UnionsWithDropFields: UnionsWithDropFields,
|
||||||
UnreachablePub: UnreachablePub,
|
UnreachablePub: UnreachablePub,
|
||||||
UntestableMethod: UntestableMethod,
|
UnnameableTestFunctions: UnnameableTestFunctions,
|
||||||
TypeAliasBounds: TypeAliasBounds,
|
TypeAliasBounds: TypeAliasBounds,
|
||||||
UnusedBrokenConst: UnusedBrokenConst,
|
UnusedBrokenConst: UnusedBrokenConst,
|
||||||
TrivialConstraints: TrivialConstraints,
|
TrivialConstraints: TrivialConstraints,
|
||||||
|
@ -8,11 +8,11 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// compile-flags: --test -D untestable_method
|
// compile-flags: --test -D unnameable_test_functions
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn foo() {
|
fn foo() {
|
||||||
#[test] //~ ERROR cannot test inner function [untestable_method]
|
#[test] //~ ERROR cannot test inner function [unnameable_test_functions]
|
||||||
fn bar() {}
|
fn bar() {}
|
||||||
bar();
|
bar();
|
||||||
}
|
}
|
||||||
@ -20,7 +20,7 @@ fn foo() {
|
|||||||
mod x {
|
mod x {
|
||||||
#[test]
|
#[test]
|
||||||
fn foo() {
|
fn foo() {
|
||||||
#[test] //~ ERROR cannot test inner function [untestable_method]
|
#[test] //~ ERROR cannot test inner function [unnameable_test_functions]
|
||||||
fn bar() {}
|
fn bar() {}
|
||||||
bar();
|
bar();
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
error: cannot test inner function
|
error: cannot test inner function
|
||||||
--> $DIR/test-inner-fn.rs:15:5
|
--> $DIR/test-inner-fn.rs:15:5
|
||||||
|
|
|
|
||||||
LL | #[test] //~ ERROR cannot test inner function [untestable_method]
|
LL | #[test] //~ ERROR cannot test inner function [unnameable_test_functions]
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
|
|
||||||
= note: requested on the command line with `-D untestable-method`
|
= note: requested on the command line with `-D unnameable-test-functions`
|
||||||
|
|
||||||
error: cannot test inner function
|
error: cannot test inner function
|
||||||
--> $DIR/test-inner-fn.rs:23:9
|
--> $DIR/test-inner-fn.rs:23:9
|
||||||
|
|
|
|
||||||
LL | #[test] //~ ERROR cannot test inner function [untestable_method]
|
LL | #[test] //~ ERROR cannot test inner function [unnameable_test_functions]
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
Loading…
Reference in New Issue
Block a user