Skip to content

Commit c63b51d

Browse files
committed
test(lints): Show existing package/workspace mix behavior
1 parent 87a14ed commit c63b51d

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/testsuite/lints.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,47 @@ error: usage of an `unsafe` block
413413
.run();
414414
}
415415

416+
#[cargo_test]
417+
fn workspace_and_package_lints() {
418+
let foo = project()
419+
.file(
420+
"Cargo.toml",
421+
r#"
422+
[package]
423+
name = "foo"
424+
version = "0.0.1"
425+
authors = []
426+
427+
[lints]
428+
workspace = true
429+
[lints.rust]
430+
"unsafe_code" = "allow"
431+
432+
[workspace.lints.rust]
433+
"unsafe_code" = "deny"
434+
"#,
435+
)
436+
.file(
437+
"src/lib.rs",
438+
"
439+
pub fn foo(num: i32) -> u32 {
440+
unsafe { std::mem::transmute(num) }
441+
}
442+
",
443+
)
444+
.build();
445+
446+
foo.cargo("check -Zlints")
447+
.masquerade_as_nightly_cargo(&["lints"])
448+
.with_status(101)
449+
.with_stderr_contains(
450+
"\
451+
error: usage of an `unsafe` block
452+
",
453+
)
454+
.run();
455+
}
456+
416457
#[cargo_test]
417458
fn attribute_has_precedence() {
418459
let foo = project()

0 commit comments

Comments
 (0)