Skip to content

Commit

Permalink
chore: Add .cargo/config.toml for workspace-level lint config
Browse files Browse the repository at this point in the history
Currently it is not directly possible to configure lints for the
entire workspace via TOML, which forced us to repeat `#![allow]`
blocks in each crate.

embark pointed out this workaround to configure lints at the
workspace level via RUSTFLAGS:

EmbarkStudios/rust-ecosystem#22 (comment)

Remove the common `#![allow]` blocks and switch to this method for
global lint config.

Temporarily allow `needless_borrow` lint, buggy pending this fix:
rust-lang/rust-clippy#8355
  • Loading branch information
Herschel committed Jan 29, 2022
1 parent 1fd1a1e commit 55da3cd
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 37 deletions.
19 changes: 19 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[target.'cfg(all())']
rustflags = [
# CLIPPY LINT SETTINGS
# This is a workaround to configure lints for the entire workspace, pending the ability to configure this via TOML.
# See: https://github.com/rust-lang/cargo/issues/5034
# https://github.com/EmbarkStudios/rust-ecosystem/issues/22#issuecomment-947011395

# Clippy nightly often adds new/buggy lints that we want to ignore.
# Don't warn about these new lints on stable.
"-Arenamed_and_removed_lints",
"-Aunknown_lints",

# LONG-TERM: These lints are unhelpful.
"-Aclippy::manual_map", # Less readable: Suggests `opt.map(..)` instsead of `if let Some(opt) { .. }`
"-Aclippy::manual_range_contains", # Less readable: Suggests `(a..b).contains(n)` instead of `n >= a && n < b`

# TEMPORARY: Buggy lints that will hopefully be fixed soon.
"-Aclippy::needless_borrow", # https://github.com/rust-lang/rust-clippy/pull/8355
]
3 changes: 1 addition & 2 deletions core/src/avm1/globals/movie_clip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,6 @@ fn get_rect<'gc>(
get_bounds(movie_clip, activation, args)
}

#[allow(unused_must_use)] //can't use errors yet
pub fn get_url<'gc>(
_movie_clip: MovieClip<'gc>,
activation: &mut Activation<'_, 'gc, '_>,
Expand All @@ -1256,7 +1255,7 @@ pub fn get_url<'gc>(
if let Some(fscommand) = fscommand::parse(&url) {
let fsargs_val = args.get(1).cloned().unwrap_or(Value::Undefined);
let fsargs = fsargs_val.coerce_to_string(activation)?;
fscommand::handle(fscommand, &fsargs, activation);
let _ = fscommand::handle(fscommand, &fsargs, activation);
return Ok(Value::Undefined);
}

Expand Down
5 changes: 1 addition & 4 deletions core/src/avm1/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ impl<'gc> Value<'gc> {
}

#[cfg(test)]
#[allow(clippy::unreadable_literal)] // Large numeric literals in tests
mod test {
use crate::avm1::activation::Activation;
use crate::avm1::error::Error;
Expand Down Expand Up @@ -637,7 +638,6 @@ mod test {
}

#[test]
#[allow(clippy::unreadable_literal)]

fn wrapping_u16() {
use super::f64_to_wrapping_u16;
Expand All @@ -654,7 +654,6 @@ mod test {
}

#[test]
#[allow(clippy::unreadable_literal)]

fn wrapping_i16() {
use super::f64_to_wrapping_i16;
Expand All @@ -672,7 +671,6 @@ mod test {
}

#[test]
#[allow(clippy::unreadable_literal)]
fn wrapping_u32() {
use super::f64_to_wrapping_u32;
assert_eq!(f64_to_wrapping_u32(0.0), 0);
Expand All @@ -688,7 +686,6 @@ mod test {
}

#[test]
#[allow(clippy::unreadable_literal)]
fn wrapping_i32() {
use super::f64_to_wrapping_i32;
assert_eq!(f64_to_wrapping_i32(0.0), 0);
Expand Down
2 changes: 1 addition & 1 deletion core/src/backend/audio/decoders/mp3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub mod minimp3 {
type Item = [i16; 2];

#[inline]
#[allow(unknown_lints, clippy::branches_sharing_code)]
#[allow(clippy::branches_sharing_code)]
fn next(&mut self) -> Option<Self::Item> {
if self.cur_sample >= self.frame.data.len() {
self.next_frame();
Expand Down
2 changes: 0 additions & 2 deletions core/src/display_object/stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,8 +1019,6 @@ impl Display for StageQuality {
impl FromStr for StageQuality {
type Err = ParseEnumError;

// clippy: False positive pending https://github.com/rust-lang/rust-clippy/pull/7865
#[allow(unknown_lints, clippy::match_str_case_mismatch)]
fn from_str(s: &str) -> Result<Self, Self::Err> {
let quality = match s.to_ascii_lowercase().as_str() {
"low" => StageQuality::Low,
Expand Down
11 changes: 0 additions & 11 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
#![allow(
renamed_and_removed_lints,
unknown_lints,
clippy::unknown_clippy_lints,
clippy::inconsistent_struct_constructor,
clippy::manual_map,
clippy::manual_range_contains,
clippy::same_item_push,
clippy::unnecessary_wraps
)]

#[macro_use]
mod display_object;
pub use display_object::StageDisplayState;
Expand Down
6 changes: 1 addition & 5 deletions core/src/matrix.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#![allow(
renamed_and_removed_lints,
clippy::unknown_clippy_lints,
clippy::suspicious_operation_groupings
)]
#![allow(clippy::suspicious_operation_groupings)]

use swf::{Fixed16, Twips};

Expand Down
2 changes: 1 addition & 1 deletion exporter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ fn capture_single_swf(descriptors: Descriptors, opt: &Opt) -> Result<(), Box<dyn
Ok(())
}

#[allow(unknown_lints, clippy::branches_sharing_code)]
#[allow(clippy::branches_sharing_code)]
fn capture_multiple_swfs(mut descriptors: Descriptors, opt: &Opt) -> Result<(), Box<dyn Error>> {
let output = opt.output_path.clone().unwrap();
let files = find_files(&opt.swf, !opt.silent);
Expand Down
6 changes: 1 addition & 5 deletions swf/src/types/matrix.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#![allow(
renamed_and_removed_lints,
clippy::unknown_clippy_lints,
clippy::suspicious_operation_groupings
)]
#![allow(clippy::suspicious_operation_groupings)]

use crate::{Fixed16, Twips};
use std::ops;
Expand Down
6 changes: 0 additions & 6 deletions web/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#![allow(
renamed_and_removed_lints,
clippy::same_item_push,
clippy::unknown_clippy_lints
)]

//! Ruffle web frontend.
mod audio;
mod locale;
Expand Down

0 comments on commit 55da3cd

Please sign in to comment.