Skip to content

Commit 1168931

Browse files
minor
1 parent 64dc4a6 commit 1168931

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

src/linted.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const _VERIFY_MODULE_PATH: () = {
1919
[b'p', b'r', b'u', b'd', b'e', b'n', b't', b':', b':', ..]
2020
) {
2121
panic!(
22-
"Use ONLY linted.rs with ::prudent::load in your crate. Do not use linted_internal.rs."
22+
"Use ONLY linted.rs in your crate(s). Do not use linted_internal.rs, as that is internal."
2323
);
2424
}
2525
};
@@ -33,7 +33,7 @@ const _VERIFY_MODULE_PATH: () = {
3333
/// any). If there was such a pair, it could be confused for a tuple. It would also be less readable
3434
/// when some parameters were tuples/complex expressions.
3535
///
36-
/// This does NOT accept closures, since, closures cannot be `unsafe`.
36+
/// This does NOT accept closures, since closures cannot be `unsafe`.
3737
///
3838
/// # Possible violations
3939
/// - Zero arguments. The given expression (which evaluates to the function to be called) is
@@ -65,22 +65,23 @@ macro_rules! internal_prudent_unsafe_fn {
6565
//
6666
// (That minimizes the number of differences between those two files.)
6767
//
68-
// Here we can't refer to
69-
// - $crate::internal_prudent_unsafe_fn_internal_build_tuple_tree, nor
70-
// - crate::internal_prudent_unsafe_fn_internal_build_tuple_tree
68+
// If this file is linted.rs (which then is passed to ::prudent::load!(...)), then
69+
// here we can *not* refer to
70+
// - $crate::unsafe_method, nor
71+
// - crate::unsafe_method
7172
//
7273
// because of error "macro-expanded `macro_export` macros from the current crate
7374
// cannot be referred to by absolute paths"
7475
// https://github.com/rust-lang/rust/issues/52234
75-
// macro_expanded_macro_exports_accessed_by_absolute_paths which also can't be fully
76-
// suppressed. So we refer to
77-
// `internal_prudent_unsafe_fn_internal_build_tuple_tree`.
76+
// "macro_expanded_macro_exports_accessed_by_absolute_paths", which can't be fully
77+
// suppressed! (See also
78+
// https://stackoverflow.com/questions/26731243/how-do-i-use-a-macro-across-module-files).
7879
//
79-
// If we are in linted.rs was "loaded" by the user "dynamically" from its file, then
80-
// by forwarding to ::prudent::XXXX macros here we do use two sets of the same
81-
// macros. But that hardly affects the compile time.
80+
// Also, we want to avoid name conflicts due to short names (for example
81+
// `unsafe_method`). So we add prefix `internal_prudent_`, and we refer to
82+
// `internal_prudent_unsafe_method` instead.
8283
//
83-
// This applies to all other linted-to-linted macros calls in this file.
84+
// This applies to all other linted-to-linted macros calls in linted.rs.
8485
let (tuple_tree, fun) = (internal_prudent_unsafe_fn_internal_build_tuple_tree!{ $($arg),+ }, $fn);
8586

8687
if false {

src/linted_internal.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const _VERIFY_MODULE_PATH: () = {
3131
/// any). If there was such a pair, it could be confused for a tuple. It would also be less readable
3232
/// when some parameters were tuples/complex expressions.
3333
///
34-
/// This does NOT accept closures, since, closures cannot be `unsafe`.
34+
/// This does NOT accept closures, since closures cannot be `unsafe`.
3535
///
3636
/// # Possible violations
3737
/// - Zero arguments. The given expression (which evaluates to the function to be called) is
@@ -63,22 +63,23 @@ macro_rules! internal_prudent_unsafe_fn {
6363
//
6464
// (That minimizes the number of differences between those two files.)
6565
//
66-
// Here we can't refer to
67-
// - $crate::internal_prudent_unsafe_fn_internal_build_tuple_tree, nor
68-
// - crate::internal_prudent_unsafe_fn_internal_build_tuple_tree
66+
// If this file is linted.rs (which then is passed to ::prudent::load!(...)), then
67+
// here we can *not* refer to
68+
// - $crate::unsafe_method, nor
69+
// - crate::unsafe_method
6970
//
7071
// because of error "macro-expanded `macro_export` macros from the current crate
7172
// cannot be referred to by absolute paths"
7273
// https://github.com/rust-lang/rust/issues/52234
73-
// macro_expanded_macro_exports_accessed_by_absolute_paths which also can't be fully
74-
// suppressed. So we refer to
75-
// `::prudent::internal_prudent_unsafe_fn_internal_build_tuple_tree`.
74+
// "macro_expanded_macro_exports_accessed_by_absolute_paths", which can't be fully
75+
// suppressed! (See also
76+
// https://stackoverflow.com/questions/26731243/how-do-i-use-a-macro-across-module-files).
7677
//
77-
// If we are in linted.rs was "loaded" by the user "dynamically" from its file, then
78-
// by forwarding to ::prudent::XXXX macros here we do use two sets of the same
79-
// macros. But that hardly affects the compile time.
78+
// Also, we want to avoid name conflicts due to short names (for example
79+
// `unsafe_method`). So we add prefix `internal_prudent_`, and we refer to
80+
// `internal_prudent_unsafe_method` instead.
8081
//
81-
// This applies to all other linted-to-linted macros calls in this file.
82+
// This applies to all other linted-to-linted macros calls in linted.rs.
8283
let (tuple_tree, fun) = (::prudent::internal_prudent_unsafe_fn_internal_build_tuple_tree!{ $($arg),+ }, $fn);
8384

8485
if false {

0 commit comments

Comments
 (0)