Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add trivially_copy_pass_by_ref to the lint set. #73

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions content/wiki/canonical_lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
title = "Canonical lint set for Linebender projects"
+++

All Linebender projects should include the following set of lints in their `Cargo.toml`:
All Linebender projects should include the following set of lints:

## `Cargo.toml`

```toml
[lints]
# This one may vary depending on the project.
rust.unsafe_code = "forbid"

# LINEBENDER LINT SET - v1
# LINEBENDER LINT SET - Cargo.toml - v2
# See https://linebender.org/wiki/canonical-lints/
rust.keyword_idents_2024 = "forbid"
rust.non_ascii_idents = "forbid"
Expand Down Expand Up @@ -57,6 +59,7 @@ clippy.semicolon_if_nothing_returned = "warn"
clippy.shadow_unrelated = "warn"
clippy.should_panic_without_expect = "warn"
clippy.todo = "warn"
clippy.trivially_copy_pass_by_ref = "warn"
clippy.unseparated_literal_suffix = "warn"
clippy.use_self = "warn"
clippy.wildcard_imports = "warn"
Expand All @@ -68,15 +71,31 @@ clippy.wildcard_dependencies = "warn"
# END LINEBENDER LINT SET
```

And in their `lib.rs`:
## `lib.rs`

```rust
// LINEBENDER LINT SET - v1
// LINEBENDER LINT SET - lib.rs - v1
DJMcNab marked this conversation as resolved.
Show resolved Hide resolved
// See https://linebender.org/wiki/canonical-lints/
// These lints aren't included in Cargo.toml because they
// shouldn't apply to examples and tests
#![warn(unused_crate_dependencies)]
#![warn(clippy::print_stdout, clippy::print_stderr)]
// END LINEBENDER LINT SET
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous discussion here #68 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rustfmt problem is valid, but looking at this in the wild it's not immediately obvious where the set ends. I'll need to think about this a bit more.

Copy link
Member

@DJMcNab DJMcNab Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I think the problem comes if there are no other trailing attributes; we want this to come after crate level docs, so it's plausible that there'd be no other attributes.

Maybe the solution is for the pattern to be:

// LINEBENDER LINT SET ...
 ...
// END LINEBENDER LINT SET
#![cfg_attr(docsrs, feature(doc_auto_cfg))]

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, as we want that present everywhere anyway.

```

## `.clippy.toml`

```toml
# LINEBENDER LINT SET - .clippy.toml - v1
# See https://linebender.org/wiki/canonical-lints/

# The default Clippy value is capped at 8 bytes, which was chosen to improve performance on 32-bit.
# Given that we are building for the future and even low-end mobile phones have 64-bit CPUs,
# it makes sense to optimize for 64-bit and accept the performance hits on 32-bit.
# 16 bytes is the number of bytes that fits into two 64-bit CPU registers.
trivial-copy-size-limit = 16

# END LINEBENDER LINT SET
```

This is a curated list: Clippy has a *lot* of lints, and most of them are not included above.
Expand Down
Loading