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

Migrate to v5 of the Linebender lint set #867

Merged
merged 2 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 4 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,69 +37,52 @@ rust.unsafe_code = "deny"
# Intentional break from the lint set. Intended to be temporary
rust.unexpected_cfgs = { level = "warn", check-cfg = ['cfg(FALSE)'] }

# LINEBENDER LINT SET - Cargo.toml - v2
# LINEBENDER LINT SET - Cargo.toml - v5
# See https://linebender.org/wiki/canonical-lints/
rust.keyword_idents_2024 = "forbid"
rust.non_ascii_idents = "forbid"
rust.non_local_definitions = "forbid"
rust.unsafe_op_in_unsafe_fn = "forbid"

rust.elided_lifetimes_in_paths = "warn"
rust.let_underscore_drop = "warn"
rust.missing_debug_implementations = "warn"
rust.missing_docs = "warn"
rust.single_use_lifetimes = "warn"
rust.trivial_numeric_casts = "warn"
# rust.unexpected_cfgs = "warn"
rust.unit_bindings = "warn"
rust.unnameable_types = "warn"
rust.unreachable_pub = "warn"
rust.unused_import_braces = "warn"
rust.unused_lifetimes = "warn"
rust.unused_macro_rules = "warn"
rust.unused_qualifications = "warn"
rust.variant_size_differences = "warn"

clippy.allow_attributes = "warn"
clippy.too_many_arguments = "allow"

clippy.allow_attributes_without_reason = "warn"
clippy.cast_possible_truncation = "warn"
clippy.collection_is_never_read = "warn"
clippy.dbg_macro = "warn"
clippy.debug_assert_with_mut_call = "warn"
clippy.doc_markdown = "warn"
clippy.exhaustive_enums = "warn"
clippy.fn_to_numeric_cast_any = "forbid"
clippy.fn_to_numeric_cast_any = "warn"
clippy.infinite_loop = "warn"
clippy.large_include_file = "warn"
clippy.large_stack_arrays = "warn"
clippy.match_same_arms = "warn"
clippy.mismatching_type_param_order = "warn"
clippy.missing_assert_message = "warn"
clippy.missing_errors_doc = "warn"
clippy.missing_fields_in_debug = "warn"
clippy.missing_panics_doc = "warn"
clippy.partial_pub_fields = "warn"
clippy.return_self_not_must_use = "warn"
clippy.same_functions_in_if_condition = "warn"
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"

clippy.cargo_common_metadata = "warn"
clippy.negative_feature_names = "warn"
clippy.redundant_feature_names = "warn"
clippy.wildcard_dependencies = "warn"
# END LINEBENDER LINT SET

# "https://github.com/rust-lang/rust-clippy/issues/13355"
# Please remove once 1.83 is stable
clippy.duplicated_attributes = "allow"

[workspace.dependencies]
masonry = { version = "0.2.0", path = "masonry" }
xilem_core = { version = "0.1.0", path = "xilem_core" }
Expand Down
1 change: 0 additions & 1 deletion masonry/src/core/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ pub enum WindowTheme {
/// the event loop.
#[non_exhaustive]
#[derive(Debug, Clone)]
#[allow(variant_size_differences)]
pub enum Update {
/// Sent to a `Widget` when it is added to the widget tree. This should be
/// the first message that each widget receives.
Expand Down
1 change: 0 additions & 1 deletion masonry/src/core/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,6 @@ impl WidgetId {
/// The actual inner representation of the returned `WidgetId` will not
/// be the same as the raw value that is passed in; it will be
/// `u64::max_value() - raw`.
#[allow(clippy::missing_panics_doc)] // Can never panic
pub const fn reserved(raw: u16) -> Self {
let id = u64::MAX - raw as u64;
match NonZeroU64::new(id) {
Expand Down
19 changes: 6 additions & 13 deletions masonry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,45 +100,38 @@
// TODO: Add screenshot. This can't use include_screenshot as that doesn't work with cargo-rdme
// See https://github.com/linebender/xilem/issues/851

// LINEBENDER LINT SET - lib.rs - v1
// LINEBENDER LINT SET - lib.rs - v3
// 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)]
// These lints shouldn't apply to examples or tests.
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
// These lints shouldn't apply to examples.
#![warn(clippy::print_stdout, clippy::print_stderr)]
// Targeting e.g. 32-bit means structs containing usize can give false positives for 64-bit.
#![cfg_attr(target_pointer_width = "64", warn(clippy::trivially_copy_pass_by_ref))]
// END LINEBENDER LINT SET
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(
test,
expect(
unused_crate_dependencies,
reason = "False-positive with dev-dependencies only used in examples"
)
)]
#![expect(clippy::allow_attributes, reason = "Deferred: Noisy")]
#![expect(clippy::allow_attributes_without_reason, reason = "Deferred: Noisy")]
// TODO: Remove any items listed as "Deferred"
#![expect(clippy::needless_doctest_main, reason = "Deferred: Noisy")]
#![expect(clippy::should_implement_trait, reason = "Deferred: Noisy")]
#![cfg_attr(not(debug_assertions), expect(unused, reason = "Deferred: Noisy"))]
#![expect(let_underscore_drop, reason = "Deferred: Noisy")]
#![expect(missing_debug_implementations, reason = "Deferred: Noisy")]
#![expect(unused_qualifications, reason = "Deferred: Noisy")]
#![expect(clippy::exhaustive_enums, reason = "Deferred: Noisy")]
#![expect(clippy::match_same_arms, reason = "Deferred: Noisy")]
#![expect(clippy::cast_possible_truncation, reason = "Deferred: Noisy")]
#![expect(clippy::missing_assert_message, reason = "Deferred: Noisy")]
#![expect(clippy::return_self_not_must_use, reason = "Deferred: Noisy")]
#![expect(elided_lifetimes_in_paths, reason = "Deferred: Noisy")]
#![expect(unreachable_pub, reason = "Potentially controversial code style")]
#![expect(
unnameable_types,
reason = "Requires lint_reasons rustc feature for exceptions"
)]
#![expect(clippy::todo, reason = "We have a lot of 'real' todos")]
#![expect(clippy::missing_errors_doc, reason = "Can be quite noisy?")]
#![expect(clippy::missing_panics_doc, reason = "Can be quite noisy?")]
#![expect(
clippy::shadow_unrelated,
reason = "Potentially controversial code style"
Expand Down
25 changes: 10 additions & 15 deletions tree_arena/src/tree_arena_safe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,23 +226,19 @@ impl<T> TreeNode<T> {

impl<T> ArenaRef<'_, T> {
/// Id of the item this handle is associated with.
#[expect(
clippy::missing_panics_doc,
reason = "ArenaRefList always has a parent_id when it's a member of ArenaRef"
)]
pub fn id(&self) -> NodeId {
self.children.parent_id.unwrap()
self.children
.parent_id
.expect("ArenaRefList always has a parent_id when it's a member of ArenaRef")
}
}

impl<T> ArenaMut<'_, T> {
/// Id of the item this handle is associated with.
#[expect(
clippy::missing_panics_doc,
reason = "ArenaRefList always has a parent_id when it's a member of ArenaRef"
)]
pub fn id(&self) -> NodeId {
self.children.parent_id.unwrap()
self.children
.parent_id
.expect("ArenaRefList always has a parent_id when it's a member of ArenaRef")
}

/// Returns a shared reference equivalent to this one.
Expand Down Expand Up @@ -510,10 +506,6 @@ impl ArenaMapRef<'_> {
/// If `start_id` is Some, the path ends just before that id instead; `start_id` is not included.
///
/// If there is no path from `start_id` to id, returns an empty vector.
#[expect(
clippy::missing_panics_doc,
reason = "All ids in the tree should have a parent in the parent map"
)]
pub fn get_id_path(self, id: NodeId, start_id: Option<NodeId>) -> Vec<NodeId> {
let mut path = Vec::new();

Expand All @@ -524,7 +516,10 @@ impl ArenaMapRef<'_> {
let mut current_id = Some(id);
while let Some(current) = current_id {
path.push(current);
current_id = *self.parents_map.get(&current).unwrap();
current_id = *self
.parents_map
.get(&current)
.expect("All ids in the tree should have a parent in the parent map");
if current_id == start_id {
break;
}
Expand Down
16 changes: 6 additions & 10 deletions tree_arena/src/tree_arena_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,10 @@ impl<T> Default for TreeArena<T> {

impl<T> ArenaRef<'_, T> {
/// Id of the item this handle is associated with.
#[expect(
clippy::missing_panics_doc,
reason = "ArenaRefList always has a parent_id when it's a member of ArenaRef"
)]
pub fn id(&self) -> NodeId {
self.children.parent_id.unwrap()
self.children
.parent_id
.expect("ArenaRefList always has a parent_id when it's a member of ArenaRef")
}
}

Expand Down Expand Up @@ -374,12 +372,10 @@ impl<'arena, T> ArenaRefList<'arena, T> {

impl<T> ArenaMut<'_, T> {
/// Id of the item this handle is associated with
#[expect(
clippy::missing_panics_doc,
reason = "ArenaMutList always has a parent_id when it's a member of ArenaMut"
)]
pub fn id(&self) -> NodeId {
self.children.parent_id.unwrap()
self.children
.parent_id
.expect("ArenaMutList always has a parent_id when it's a member of ArenaMut")
}

/// Returns a shared reference equivalent to this one.
Expand Down
1 change: 0 additions & 1 deletion xilem/examples/calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0

//! A simple calculator example
#![expect(clippy::match_same_arms, reason = "Deferred: Noisy")]
#![expect(clippy::cast_possible_truncation, reason = "Deferred: Noisy")]

use masonry::widgets::{CrossAxisAlignment, GridParams, MainAxisAlignment};
Expand Down
1 change: 0 additions & 1 deletion xilem/examples/http_cats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//! An example demonstrating the use of Async web requests in Xilem to access the <https://http.cat/> API.
//! This also demonstrates image loading.

#![expect(clippy::match_same_arms, reason = "Deferred: Noisy")]
#![expect(clippy::missing_assert_message, reason = "Deferred: Noisy")]

use std::sync::Arc;
Expand Down
15 changes: 6 additions & 9 deletions xilem/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,14 @@
//! [xilem_examples]: https://github.com/linebender/xilem/tree/main/xilem/examples

#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/46134943?s=48&v=4")]
// LINEBENDER LINT SET - lib.rs - v1
// LINEBENDER LINT SET - lib.rs - v3
// 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)]
// These lints shouldn't apply to examples or tests.
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
// These lints shouldn't apply to examples.
#![warn(clippy::print_stdout, clippy::print_stderr)]
// Targeting e.g. 32-bit means structs containing usize can give false positives for 64-bit.
#![cfg_attr(target_pointer_width = "64", warn(clippy::trivially_copy_pass_by_ref))]
// END LINEBENDER LINT SET
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(
Expand All @@ -122,19 +124,14 @@
missing_debug_implementations,
reason = "Deferred: Noisy. Requires same lint to be addressed in Masonry"
)]
#![expect(clippy::exhaustive_enums, reason = "Deferred: Noisy")]
#![expect(clippy::match_same_arms, reason = "Deferred: Noisy")]
#![expect(clippy::missing_assert_message, reason = "Deferred: Noisy")]
#![expect(elided_lifetimes_in_paths, reason = "Deferred: Noisy")]
// https://github.com/rust-lang/rust/pull/130025
#![allow(missing_docs, reason = "We have many as-yet undocumented items")]
#![expect(clippy::missing_errors_doc, reason = "Can be quite noisy?")]
#![expect(clippy::missing_panics_doc, reason = "Can be quite noisy?")]
#![expect(
clippy::shadow_unrelated,
reason = "Potentially controversial code style"
)]
#![expect(clippy::allow_attributes, reason = "Deferred: Noisy")]
#![expect(clippy::allow_attributes_without_reason, reason = "Deferred: Noisy")]

use std::collections::HashMap;
Expand Down
2 changes: 0 additions & 2 deletions xilem_core/examples/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

//! An example using Xilem Core to manipulate a filesystem.

#![expect(let_underscore_drop, reason = "Deferred: Noisy")]

use std::io::stdin;
use std::path::PathBuf;

Expand Down
12 changes: 6 additions & 6 deletions xilem_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
//! .rustdoc-hidden { display: none; }
//! </style>
#![doc = include_str!("../README.md")]
// LINEBENDER LINT SET - lib.rs - v1
// LINEBENDER LINT SET - lib.rs - v3
// 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)]
// These lints shouldn't apply to examples or tests.
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
// These lints shouldn't apply to examples.
#![warn(clippy::print_stdout, clippy::print_stderr)]
// Targeting e.g. 32-bit means structs containing usize can give false positives for 64-bit.
#![cfg_attr(target_pointer_width = "64", warn(clippy::trivially_copy_pass_by_ref))]
// END LINEBENDER LINT SET
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(not(test), no_std)]
#![forbid(unsafe_code)]
// TODO: Remove any items listed as "Deferred"
#![expect(clippy::exhaustive_enums, reason = "Deferred: Noisy")]
#![expect(
clippy::shadow_unrelated,
reason = "Potentially controversial code style"
)]
#![expect(clippy::allow_attributes, reason = "Deferred: Noisy")]
#![expect(clippy::allow_attributes_without_reason, reason = "Deferred: Noisy")]
extern crate alloc;

Expand Down
2 changes: 0 additions & 2 deletions xilem_core/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ impl dyn Message {
/// If the message contained within `self` is not of type `T`, returns `self`
/// (so that e.g. a different type can be used)
pub fn downcast<T: Message>(self: Box<Self>) -> Result<Box<T>, Box<Self>> {
// The panic is unreachable
#![allow(clippy::missing_panics_doc)]
if self.deref().as_any().is::<T>() {
Ok(self
.into_any()
Expand Down
1 change: 1 addition & 0 deletions xilem_core/src/views/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

#![allow(
// TODO: Instead of being conditionally no_std, instead conditionally use `extern crate std`
unused_qualifications,
reason = "We have `std` enabled when testing, which means that some items are conditionally in the prelude"
)]
Expand Down
1 change: 0 additions & 1 deletion xilem_core/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
reason = "This is a utility module, which means that some exposed items aren't used in all instantiations"
)]
#![deny(unreachable_pub)]
#![expect(clippy::allow_attributes, reason = "Deferred: Noisy")]
#![expect(clippy::allow_attributes_without_reason, reason = "Deferred: Noisy")]
#![expect(clippy::missing_assert_message, reason = "Deferred: Noisy")]

Expand Down
1 change: 0 additions & 1 deletion xilem_core/tests/one_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//!
//! This is an integration test so that it can use the infrastructure in [`common`].

#![expect(clippy::match_same_arms, reason = "Deferred: Noisy")]
#![expect(clippy::missing_assert_message, reason = "Deferred: Noisy")]

use xilem_core::one_of::{OneOf, OneOf2, OneOfCtx, PhantomElementCtx};
Expand Down
17 changes: 6 additions & 11 deletions xilem_web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,21 @@
//! .rustdoc-hidden { display: none; }
//! </style>
#![doc = include_str!("../README.md")]
// LINEBENDER LINT SET - lib.rs - v1
// LINEBENDER LINT SET - lib.rs - v3
// 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)]
// These lints shouldn't apply to examples or tests.
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
// These lints shouldn't apply to examples.
#![warn(clippy::print_stdout, clippy::print_stderr)]
// Targeting e.g. 32-bit means structs containing usize can give false positives for 64-bit.
#![cfg_attr(target_pointer_width = "64", warn(clippy::trivially_copy_pass_by_ref))]
// END LINEBENDER LINT SET
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
// TODO: Remove any items listed as "Deferred"
#![cfg_attr(test, expect(clippy::print_stdout, reason = "Deferred: Noisy"))]
#![expect(let_underscore_drop, reason = "Deferred: Noisy")]
#![expect(missing_debug_implementations, reason = "Deferred: Noisy")]
#![expect(unused_qualifications, reason = "Deferred: Noisy")]
#![expect(clippy::exhaustive_enums, reason = "Deferred: Noisy")]
#![expect(clippy::match_same_arms, reason = "Deferred: Noisy")]
#![expect(clippy::cast_possible_truncation, reason = "Deferred: Noisy")]
#![expect(clippy::missing_assert_message, reason = "Deferred: Noisy")]
#![expect(clippy::return_self_not_must_use, reason = "Deferred: Noisy")]
#![expect(elided_lifetimes_in_paths, reason = "Deferred: Noisy")]
// expect doesn't work here: https://github.com/rust-lang/rust/pull/130025
#![allow(missing_docs, reason = "We have many as-yet undocumented items")]
Expand All @@ -38,12 +35,10 @@
reason = "Requires lint_reasons rustc feature for exceptions"
)]
#![expect(clippy::todo, reason = "We have a lot of 'real' todos")]
#![expect(clippy::missing_panics_doc, reason = "Can be quite noisy?")]
#![expect(
clippy::shadow_unrelated,
reason = "Potentially controversial code style"
)]
#![expect(clippy::allow_attributes, reason = "Deferred: Noisy")]
#![expect(clippy::allow_attributes_without_reason, reason = "Deferred: Noisy")]

use std::any::Any;
Expand Down
Loading
Loading