Skip to content

Commit eee4133

Browse files
authored
Improve plrustc lint messages (#333)
1 parent 3dbd00d commit eee4133

15 files changed

+77
-74
lines changed

plrustc/plrustc/src/lints/builtin_macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl PlrustBuiltinMacros {
1919
fn lint_fs(&self, cx: &LateContext<'_>, sp: Span) {
2020
cx.lint(
2121
PLRUST_FILESYSTEM_MACROS,
22-
"the `include_str`, `include_bytes`, and `include` macros are forbidden",
22+
"the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust",
2323
|b| b.set_span(sp),
2424
);
2525
}

plrustc/plrustc/src/lints/extern_blocks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ impl<'tcx> LateLintPass<'tcx> for NoExternBlockPass {
1414
// TODO: Do we need to allow ones from macros from pgrx?
1515
cx.lint(
1616
PLRUST_EXTERN_BLOCKS,
17-
"`extern` blocks are not allowed",
17+
"`extern` blocks are not allowed in PL/Rust",
1818
|b| b.set_span(item.span),
1919
)
2020
}

plrustc/plrustc/src/lints/lifetime_param_trait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ impl<'tcx> LateLintPass<'tcx> for LifetimeParamTraitPass {
1515
if let hir::GenericParamKind::Lifetime { .. } = param.kind {
1616
cx.lint(
1717
PLRUST_LIFETIME_PARAMETERIZED_TRAITS,
18-
"Trait is parameterize by lifetime.",
18+
"PL/Rust forbids declaring traits with generic lifetime parameters",
1919
|b| b.set_span(item.span),
2020
)
2121
}

plrustc/plrustc/src/lints/print_macros.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ impl PlrustPrintMacros {
2727
fn fire(&self, cx: &LateContext<'_>, span: Span) {
2828
cx.lint(
2929
PLRUST_PRINT_MACROS,
30-
"the printing macros are forbidden, consider using `log!()` instead",
30+
"the printing macros are forbidden in PL/Rust, \
31+
consider using `pgrx::log!()` instead",
3132
|b| b.set_span(span),
3233
);
3334
}

plrustc/plrustc/src/lints/static_impls.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ impl<'tcx> LateLintPass<'tcx> for PlrustStaticImpls {
1616
if self.has_static(imp.self_ty) {
1717
cx.lint(
1818
PLRUST_STATIC_IMPLS,
19-
"`impl` blocks for types containing `'static` references are not allowed",
19+
"`impl` blocks for types containing `'static` references \
20+
are not allowed in PL/Rust",
2021
|b| b.set_span(imp.self_ty.span),
2122
)
2223
}

plrustc/plrustc/src/lints/stdio.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ impl<'tcx> LateLintPass<'tcx> for PlrustPrintFunctions {
1919
if super::utils::does_expr_call_path(cx, expr, path) {
2020
cx.lint(
2121
PLRUST_STDIO,
22-
"the standard streams are forbidden, consider using `log!()` instead",
22+
"the standard streams are forbidden in PL/Rust, \
23+
consider using `pgrx::log!()` instead",
2324
|b| b.set_span(expr.span),
2425
);
2526
}

plrustc/plrustc/src/lints/sus_trait_object.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl<'tcx> LateLintPass<'tcx> for PlrustSuspiciousTraitObject {
3030
if let hir::TyKind::TraitObject(..) = &ty.kind {
3131
cx.lint(
3232
PLRUST_SUSPICIOUS_TRAIT_OBJECT,
33-
"trait objects in turbofish are forbidden",
33+
"using trait objects in turbofish position is forbidden by PL/Rust",
3434
|b| b.set_span(expr.span),
3535
);
3636
}

plrustc/plrustc/uitests/extern_block.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
error: `extern` blocks are not allowed
1+
error: `extern` blocks are not allowed in PL/Rust
22
--> $DIR/extern_block.rs:2:1
33
|
44
LL | extern "C" {}
55
| ^^^^^^^^^^^^^
66
|
77
= note: `-F plrust-extern-blocks` implied by `-F plrust-lints`
88

9-
error: `extern` blocks are not allowed
9+
error: `extern` blocks are not allowed in PL/Rust
1010
--> $DIR/extern_block.rs:3:1
1111
|
1212
LL | extern "Rust" {}
1313
| ^^^^^^^^^^^^^^^^
1414

15-
error: `extern` blocks are not allowed
15+
error: `extern` blocks are not allowed in PL/Rust
1616
--> $DIR/extern_block.rs:5:1
1717
|
1818
LL | extern {}
1919
| ^^^^^^^^^
2020

21-
error: `extern` blocks are not allowed
21+
error: `extern` blocks are not allowed in PL/Rust
2222
--> $DIR/extern_block.rs:9:9
2323
|
2424
LL | extern "C" {}

plrustc/plrustc/uitests/fs_macros.stderr

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,78 @@
1-
error: the `include_str`, `include_bytes`, and `include` macros are forbidden
1+
error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust
22
--> $DIR/fs_macros.rs:3:18
33
|
44
LL | const _A: &str = include_str!("fs_macros_included_file.txt");
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-F plrust-filesystem-macros` implied by `-F plrust-lints`
88

9-
error: the `include_str`, `include_bytes`, and `include` macros are forbidden
9+
error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust
1010
--> $DIR/fs_macros.rs:5:19
1111
|
1212
LL | const _B: &[u8] = include_bytes!("fs_macros_included_file.txt");
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1414

15-
error: the `include_str`, `include_bytes`, and `include` macros are forbidden
15+
error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust
1616
--> $DIR/fs_macros.rs:7:18
1717
|
1818
LL | const _C: &str = core::include_str!("fs_macros_included_file.txt");
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2020

21-
error: the `include_str`, `include_bytes`, and `include` macros are forbidden
21+
error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust
2222
--> $DIR/fs_macros.rs:8:19
2323
|
2424
LL | const _D: &[u8] = core::include_bytes!("fs_macros_included_file.txt");
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2626

27-
error: the `include_str`, `include_bytes`, and `include` macros are forbidden
27+
error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust
2828
--> $DIR/fs_macros.rs:16:18
2929
|
3030
LL | const _E: &str = indirect!(include_str);
3131
| ^^^^^^^^^^^^^^^^^^^^^^
3232

33-
error: the `include_str`, `include_bytes`, and `include` macros are forbidden
33+
error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust
3434
--> $DIR/fs_macros.rs:17:19
3535
|
3636
LL | const _F: &[u8] = indirect!(include_bytes);
3737
| ^^^^^^^^^^^^^^^^^^^^^^^^
3838

39-
error: the `include_str`, `include_bytes`, and `include` macros are forbidden
39+
error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust
4040
--> $DIR/fs_macros.rs:31:18
4141
|
4242
LL | const _G: &str = in_macro!();
4343
| ^^^^^^^^^^^
4444

45-
error: the `include_str`, `include_bytes`, and `include` macros are forbidden
45+
error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust
4646
--> $DIR/fs_macros.rs:32:28
4747
|
4848
LL | const _H: &str = in_macro!(include_str!("fs_macros_included_file.txt"));
4949
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5050

51-
error: the `include_str`, `include_bytes`, and `include` macros are forbidden
51+
error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust
5252
--> $DIR/fs_macros.rs:33:29
5353
|
5454
LL | const _I: &[u8] = in_macro!(include_bytes!("fs_macros_included_file.txt"));
5555
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5656

57-
error: the `include_str`, `include_bytes`, and `include` macros are forbidden
57+
error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust
5858
--> $DIR/fs_macros.rs:34:19
5959
|
6060
LL | const _J: &[u8] = in_macro!(include_bytes, "fs_macros_included_file.txt");
6161
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6262

63-
error: the `include_str`, `include_bytes`, and `include` macros are forbidden
63+
error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust
6464
--> $DIR/fs_macros.rs:37:18
6565
|
6666
LL | const _L: &str = sneaky!("fs_macros_included_file.txt");
6767
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6868

69-
error: the `include_str`, `include_bytes`, and `include` macros are forbidden
69+
error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust
7070
--> $DIR/fs_macros.rs:38:18
7171
|
7272
LL | const _M: &str = in_macro!(sneaky, "fs_macros_included_file.txt");
7373
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7474

75-
error: the `include_str`, `include_bytes`, and `include` macros are forbidden
75+
error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust
7676
--> $DIR/fs_macros.rs:41:21
7777
|
7878
LL | format!("{:?}", in_macro!())

plrustc/plrustc/uitests/lifetime_trait.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
error: Trait is parameterize by lifetime.
1+
error: PL/Rust forbids declaring traits with generic lifetime parameters
22
--> $DIR/lifetime_trait.rs:3:1
33
|
44
LL | trait Foo<'a> {}
55
| ^^^^^^^^^^^^^^^^
66
|
77
= note: `-F plrust-lifetime-parameterized-traits` implied by `-F plrust-lints`
88

9-
error: Trait is parameterize by lifetime.
9+
error: PL/Rust forbids declaring traits with generic lifetime parameters
1010
--> $DIR/lifetime_trait.rs:9:9
1111
|
1212
LL | trait Foobar<'a> {}

0 commit comments

Comments
 (0)