Skip to content

Commit f06f449

Browse files
authored
Merge pull request #1663 from LingkKang/explain_dead_code
Update print.md
2 parents 8888f94 + 5c7f580 commit f06f449

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/hello/print.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn main() {
5959
// Only types that implement fmt::Display can be formatted with `{}`. User-
6060
// defined types do not implement fmt::Display by default.
6161
62-
#[allow(dead_code)]
62+
#[allow(dead_code)] // disable `dead_code` which warn against unused module
6363
struct Structure(i32);
6464
6565
// This will not compile because `Structure` does not implement
@@ -89,6 +89,8 @@ for these types. To print text for custom types, more steps are required.
8989
Implementing the `fmt::Display` trait automatically implements the
9090
[`ToString`] trait which allows us to [convert] the type to [`String`][string].
9191

92+
In *line 46*, `#[allow(dead_code)]` is an [attribute] which only apply to the module after it.
93+
9294
### Activities
9395

9496
* Fix the issue in the above code (see FIXME) so that it runs without
@@ -102,8 +104,7 @@ Implementing the `fmt::Display` trait automatically implements the
102104

103105
### See also:
104106

105-
[`std::fmt`][fmt], [`macros`][macros], [`struct`][structs],
106-
and [`traits`][traits]
107+
[`std::fmt`][fmt], [`macros`][macros], [`struct`][structs], [`traits`][traits], and [`dead_code`][dead_code]
107108

108109
[fmt]: https://doc.rust-lang.org/std/fmt/
109110
[macros]: ../macros.md
@@ -112,3 +113,5 @@ and [`traits`][traits]
112113
[traits]: https://doc.rust-lang.org/std/fmt/#formatting-traits
113114
[`ToString`]: https://doc.rust-lang.org/std/string/trait.ToString.html
114115
[convert]: ../conversion/string.md
116+
[attribute]: ../attribute.md
117+
[dead_code]: ../attribute/unused.md

0 commit comments

Comments
 (0)