diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 053a581..a9fdb38 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -20,7 +20,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: default - toolchain: 1.73.0 + toolchain: 1.76.0 override: true - name: Install packages (Linux) @@ -40,11 +40,6 @@ jobs: command: fmt args: --all -- --check - - name: Install cargo-cranky - uses: baptiste0928/cargo-install@v1 - with: - crate: cargo-cranky - - name: check --all-features uses: actions-rs/cargo@v1 with: @@ -93,10 +88,10 @@ jobs: command: test args: --all-features - - name: Cranky + - name: Clippy uses: actions-rs/cargo@v1 with: - command: cranky + command: clippy args: --all-targets --all-features -- -D warnings # --------------------------------------------------------------------------- @@ -109,28 +104,23 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.73.0 + toolchain: 1.76.0 target: wasm32-unknown-unknown override: true - name: Set up cargo cache uses: Swatinem/rust-cache@v2 - - name: Install cargo-cranky - uses: baptiste0928/cargo-install@v1 - with: - crate: cargo-cranky - - name: Check wasm32 uses: actions-rs/cargo@v1 with: command: check args: --target wasm32-unknown-unknown --lib - - name: Cranky wasm32 + - name: Clippy wasm32 env: CLIPPY_CONF_DIR: "scripts/clippy_wasm" # Use scripts/clippy_wasm/clippy.toml - run: cargo cranky --target wasm32-unknown-unknown --lib -- -D warnings + run: cargo clippy --target wasm32-unknown-unknown --lib -- -D warnings # --------------------------------------------------------------------------- @@ -141,6 +131,6 @@ jobs: - uses: actions/checkout@v3 - uses: EmbarkStudios/cargo-deny-action@v1 with: - rust-version: "1.73.0" + rust-version: "1.76.0" log-level: warn command: check diff --git a/Cargo.lock b/Cargo.lock index 66664e0..bb02468 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2506,9 +2506,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.2" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" dependencies = [ "log", "ring", diff --git a/Cargo.toml b/Cargo.toml index a730cd9..856e7a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,3 +8,165 @@ members = ["ewebsock", "example_app", "echo_server"] # If you want to use a fork: # eframe = { path = "../egui/eframe" } + + +[workspace.lints.rust] +unsafe_code = "deny" + +elided_lifetimes_in_paths = "warn" +future_incompatible = "warn" +nonstandard_style = "warn" +rust_2018_idioms = "warn" +rust_2021_prelude_collisions = "warn" +semicolon_in_expressions_from_macros = "warn" +trivial_numeric_casts = "warn" +unsafe_op_in_unsafe_fn = "warn" # `unsafe_op_in_unsafe_fn` may become the default in future Rust versions: https://github.com/rust-lang/rust/issues/71668 +unused_extern_crates = "warn" +unused_import_braces = "warn" +unused_lifetimes = "warn" + +trivial_casts = "allow" +unused_qualifications = "allow" + +[workspace.lints.rustdoc] +all = "warn" +missing_crate_level_docs = "warn" + +# See also clippy.toml +[workspace.lints.clippy] +as_ptr_cast_mut = "warn" +await_holding_lock = "warn" +bool_to_int_with_if = "warn" +char_lit_as_u8 = "warn" +checked_conversions = "warn" +clear_with_drain = "warn" +cloned_instead_of_copied = "warn" +dbg_macro = "warn" +debug_assert_with_mut_call = "warn" +derive_partial_eq_without_eq = "warn" +disallowed_macros = "warn" # See clippy.toml +disallowed_methods = "warn" # See clippy.toml +disallowed_names = "warn" # See clippy.toml +disallowed_script_idents = "warn" # See clippy.toml +disallowed_types = "warn" # See clippy.toml +doc_link_with_quotes = "warn" +doc_markdown = "warn" +empty_enum = "warn" +enum_glob_use = "warn" +equatable_if_let = "warn" +exit = "warn" +expl_impl_clone_on_copy = "warn" +explicit_deref_methods = "warn" +explicit_into_iter_loop = "warn" +explicit_iter_loop = "warn" +fallible_impl_from = "warn" +filter_map_next = "warn" +flat_map_option = "warn" +float_cmp_const = "warn" +fn_params_excessive_bools = "warn" +fn_to_numeric_cast_any = "warn" +from_iter_instead_of_collect = "warn" +get_unwrap = "warn" +if_let_mutex = "warn" +implicit_clone = "warn" +imprecise_flops = "warn" +index_refutable_slice = "warn" +inefficient_to_string = "warn" +infinite_loop = "warn" +into_iter_without_iter = "warn" +invalid_upcast_comparisons = "warn" +iter_not_returning_iterator = "warn" +iter_on_empty_collections = "warn" +iter_on_single_items = "warn" +iter_over_hash_type = "warn" +iter_without_into_iter = "warn" +large_digit_groups = "warn" +large_include_file = "warn" +large_stack_arrays = "warn" +large_stack_frames = "warn" +large_types_passed_by_value = "warn" +let_underscore_untyped = "warn" +let_unit_value = "warn" +linkedlist = "warn" +lossy_float_literal = "warn" +macro_use_imports = "warn" +manual_assert = "warn" +manual_clamp = "warn" +manual_instant_elapsed = "warn" +manual_let_else = "warn" +manual_ok_or = "warn" +manual_string_new = "warn" +map_err_ignore = "warn" +map_flatten = "warn" +map_unwrap_or = "warn" +match_on_vec_items = "warn" +match_same_arms = "warn" +match_wild_err_arm = "warn" +match_wildcard_for_single_variants = "warn" +mem_forget = "warn" +mismatched_target_os = "warn" +mismatching_type_param_order = "warn" +missing_assert_message = "warn" +missing_enforced_import_renames = "warn" +missing_errors_doc = "warn" +missing_safety_doc = "warn" +mut_mut = "warn" +mutex_integer = "warn" +needless_borrow = "warn" +needless_continue = "warn" +needless_for_each = "warn" +needless_pass_by_ref_mut = "warn" +needless_pass_by_value = "warn" +negative_feature_names = "warn" +nonstandard_macro_braces = "warn" +option_option = "warn" +path_buf_push_overwrite = "warn" +ptr_as_ptr = "warn" +ptr_cast_constness = "warn" +pub_without_shorthand = "warn" +rc_mutex = "warn" +readonly_write_lock = "warn" +redundant_type_annotations = "warn" +ref_option_ref = "warn" +rest_pat_in_fully_bound_structs = "warn" +same_functions_in_if_condition = "warn" +semicolon_if_nothing_returned = "warn" +should_panic_without_expect = "warn" +significant_drop_tightening = "warn" +single_match_else = "warn" +str_to_string = "warn" +string_add = "warn" +string_add_assign = "warn" +string_lit_as_bytes = "warn" +string_lit_chars_any = "warn" +string_to_string = "warn" +suspicious_command_arg_space = "warn" +suspicious_xor_used_as_pow = "warn" +todo = "warn" +too_many_lines = "warn" +trailing_empty_array = "warn" +trait_duplication_in_bounds = "warn" +tuple_array_conversions = "warn" +unchecked_duration_subtraction = "warn" +undocumented_unsafe_blocks = "warn" +unimplemented = "warn" +uninhabited_references = "warn" +uninlined_format_args = "warn" +unnecessary_box_returns = "warn" +unnecessary_safety_doc = "warn" +unnecessary_struct_initialization = "warn" +unnecessary_wraps = "warn" +unnested_or_patterns = "warn" +unused_peekable = "warn" +unused_rounding = "warn" +unused_self = "warn" +unwrap_used = "warn" +use_self = "warn" +useless_transmute = "warn" +verbose_file_reads = "warn" +wildcard_dependencies = "warn" +wildcard_imports = "warn" +zero_sized_map_values = "warn" + +manual_range_contains = "allow" # this one is just worse imho +ref_patterns = "allow" # It's nice to avoid ref pattern, but there are some situations that are hard (impossible?) to express without. diff --git a/Cranky.toml b/Cranky.toml deleted file mode 100644 index 69cc8bd..0000000 --- a/Cranky.toml +++ /dev/null @@ -1,160 +0,0 @@ -# Copied from https://github.com/rerun-io/rerun_template -# -# https://github.com/ericseppanen/cargo-cranky -# cargo install cargo-cranky && cargo cranky -# See also clippy.toml - -deny = [ - "unsafe_code", - #"clippy::self_named_module_files", # Disabled waiting on https://github.com/rust-lang/rust-clippy/issues/9602 -] - -warn = [ - "clippy::all", - "clippy::as_ptr_cast_mut", - "clippy::await_holding_lock", - "clippy::bool_to_int_with_if", - "clippy::char_lit_as_u8", - "clippy::checked_conversions", - "clippy::clear_with_drain", - "clippy::cloned_instead_of_copied", - "clippy::cloned_instead_of_copied", - "clippy::dbg_macro", - "clippy::debug_assert_with_mut_call", - "clippy::derive_partial_eq_without_eq", - "clippy::disallowed_macros", # See clippy.toml - "clippy::disallowed_methods", # See clippy.toml - "clippy::disallowed_names", # See clippy.toml - "clippy::disallowed_script_idents", # See clippy.toml - "clippy::disallowed_types", # See clippy.toml - "clippy::doc_link_with_quotes", - "clippy::doc_markdown", - "clippy::empty_enum", - "clippy::enum_glob_use", - "clippy::equatable_if_let", - "clippy::exit", - "clippy::expl_impl_clone_on_copy", - "clippy::explicit_deref_methods", - "clippy::explicit_into_iter_loop", - "clippy::explicit_iter_loop", - "clippy::fallible_impl_from", - "clippy::filter_map_next", - "clippy::flat_map_option", - "clippy::float_cmp_const", - "clippy::fn_params_excessive_bools", - "clippy::fn_to_numeric_cast_any", - "clippy::from_iter_instead_of_collect", - "clippy::get_unwrap", - "clippy::if_let_mutex", - "clippy::implicit_clone", - "clippy::imprecise_flops", - "clippy::index_refutable_slice", - "clippy::inefficient_to_string", - "clippy::invalid_upcast_comparisons", - "clippy::iter_not_returning_iterator", - "clippy::iter_on_empty_collections", - "clippy::iter_on_single_items", - "clippy::large_digit_groups", - "clippy::large_include_file", - "clippy::large_stack_arrays", - "clippy::large_stack_frames", - "clippy::large_types_passed_by_value", - "clippy::let_underscore_untyped", - "clippy::let_unit_value", - "clippy::linkedlist", - "clippy::lossy_float_literal", - "clippy::macro_use_imports", - "clippy::manual_assert", - "clippy::manual_clamp", - "clippy::manual_instant_elapsed", - "clippy::manual_let_else", - "clippy::manual_ok_or", - "clippy::manual_string_new", - "clippy::map_err_ignore", - "clippy::map_flatten", - "clippy::map_unwrap_or", - "clippy::match_on_vec_items", - "clippy::match_same_arms", - "clippy::match_wild_err_arm", - "clippy::match_wildcard_for_single_variants", - "clippy::mem_forget", - "clippy::mismatched_target_os", - "clippy::mismatching_type_param_order", - "clippy::missing_assert_message", - "clippy::missing_enforced_import_renames", - "clippy::missing_errors_doc", - "clippy::missing_safety_doc", - "clippy::mut_mut", - "clippy::mutex_integer", - "clippy::needless_borrow", - "clippy::needless_continue", - "clippy::needless_for_each", - "clippy::needless_pass_by_ref_mut", - "clippy::needless_pass_by_value", - "clippy::negative_feature_names", - "clippy::nonstandard_macro_braces", - "clippy::option_option", - "clippy::path_buf_push_overwrite", - "clippy::ptr_as_ptr", - "clippy::ptr_cast_constness", - "clippy::pub_without_shorthand", - "clippy::rc_mutex", - "clippy::readonly_write_lock", - "clippy::redundant_type_annotations", - "clippy::ref_option_ref", - "clippy::ref_patterns", - "clippy::rest_pat_in_fully_bound_structs", - "clippy::same_functions_in_if_condition", - "clippy::semicolon_if_nothing_returned", - "clippy::significant_drop_tightening", - "clippy::single_match_else", - "clippy::str_to_string", - "clippy::string_add_assign", - "clippy::string_add", - "clippy::string_lit_as_bytes", - "clippy::string_lit_chars_any", - "clippy::string_to_string", - "clippy::suspicious_command_arg_space", - "clippy::suspicious_xor_used_as_pow", - "clippy::todo", - "clippy::too_many_lines", - "clippy::trailing_empty_array", - "clippy::trait_duplication_in_bounds", - "clippy::tuple_array_conversions", - "clippy::unchecked_duration_subtraction", - "clippy::undocumented_unsafe_blocks", - "clippy::unimplemented", - "clippy::uninlined_format_args", - "clippy::unnecessary_box_returns", - "clippy::unnecessary_safety_doc", - "clippy::unnecessary_struct_initialization", - "clippy::unnecessary_wraps", - "clippy::unnested_or_patterns", - "clippy::unused_peekable", - "clippy::unused_rounding", - "clippy::unused_self", - "clippy::unwrap_used", - "clippy::useless_transmute", - "clippy::verbose_file_reads", - "clippy::wildcard_dependencies", - "clippy::wildcard_imports", - "clippy::zero_sized_map_values", - "elided_lifetimes_in_paths", - "future_incompatible", - "nonstandard_style", - "rust_2018_idioms", - "rust_2021_prelude_collisions", - "rustdoc::missing_crate_level_docs", - "semicolon_in_expressions_from_macros", - "trivial_casts", - "trivial_numeric_casts", - "unsafe_op_in_unsafe_fn", # `unsafe_op_in_unsafe_fn` may become the default in future Rust versions: https://github.com/rust-lang/rust/issues/71668 - "unused_extern_crates", - "unused_import_braces", - "unused_lifetimes", - "unused_qualifications", -] - -allow = [ - "clippy::manual_range_contains", # this one is just worse imho -] diff --git a/bacon.toml b/bacon.toml deleted file mode 100644 index 0476b3e..0000000 --- a/bacon.toml +++ /dev/null @@ -1,70 +0,0 @@ -# This is a configuration file for the bacon tool -# More info at https://github.com/Canop/bacon - -default_job = "cranky" - -[jobs] - -[jobs.cranky] -command = [ - "cargo", - "cranky", - "--all-targets", - "--all-features", - "--color=always", -] -need_stdout = false -watch = ["tests", "benches", "examples"] - -[jobs.check] -command = [ - "cargo", - "check", - "--all-targets", - "--all-features", - "--color=always", -] -need_stdout = false -watch = ["tests", "benches", "examples"] - -[jobs.test] -command = ["cargo", "test", "--color=always"] -need_stdout = true -watch = ["tests"] - -[jobs.doc] -command = ["cargo", "doc", "--color=always", "--all-features", "--no-deps"] -need_stdout = false - -# if the doc compiles, then it opens in your browser and bacon switches -# to the previous job -[jobs.doc-open] -command = [ - "cargo", - "doc", - "--color=always", - "--all-features", - "--no-deps", - "--open", -] -need_stdout = false -on_success = "back" # so that we don't open the browser at each change - -# You can run your application and have the result displayed in bacon, -# *if* it makes sense for this crate. You can run an example the same -# way. Don't forget the `--color always` part or the errors won't be -# properly parsed. -[jobs.run] -command = ["cargo", "run", "--color=always"] -need_stdout = true - -# You may define here keybindings that would be specific to -# a project, for example a shortcut to launch a specific job. -# Shortcuts to internal functions (scrolling, toggling, etc.) -# should go in your personal prefs.toml file instead. -[keybindings] -i = "job:initial" -c = "job:cranky" -d = "job:doc-open" -t = "job:test" -r = "job:run" diff --git a/clippy.toml b/clippy.toml index d2a61d6..7e6ade7 100644 --- a/clippy.toml +++ b/clippy.toml @@ -5,7 +5,7 @@ # ----------------------------------------------------------------------------- # Section identical to scripts/clippy_wasm/clippy.toml: -msrv = "1.73" +msrv = "1.76" allow-unwrap-in-tests = true diff --git a/echo_server/Cargo.toml b/echo_server/Cargo.toml index f99114f..6e905f3 100644 --- a/echo_server/Cargo.toml +++ b/echo_server/Cargo.toml @@ -3,7 +3,7 @@ name = "echo_server" version = "0.1.0" authors = ["Emil Ernerfeldt "] edition = "2021" -rust-version = "1.73" +rust-version = "1.76" license = "MIT OR Apache-2.0" include = ["../LICENSE-APACHE", "../LICENSE-MIT", "**/*.rs", "Cargo.toml"] publish = false diff --git a/ewebsock/Cargo.toml b/ewebsock/Cargo.toml index 5f81ff0..d9c6b07 100644 --- a/ewebsock/Cargo.toml +++ b/ewebsock/Cargo.toml @@ -4,7 +4,7 @@ version = "0.5.0" authors = ["Emil Ernerfeldt "] description = "WebSocket client that works natively and on the web (WASM)" edition = "2021" -rust-version = "1.73" +rust-version = "1.76" license = "MIT OR Apache-2.0" readme = "../README.md" homepage = "https://github.com/rerun-io/ewebsock" @@ -17,6 +17,8 @@ include = ["../LICENSE-APACHE", "../LICENSE-MIT", "**/*.rs", "Cargo.toml"] all-features = true targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"] +[lints] +workspace = true [features] default = [] diff --git a/ewebsock/src/lib.rs b/ewebsock/src/lib.rs index 1e3c0a1..b0ce916 100644 --- a/ewebsock/src/lib.rs +++ b/ewebsock/src/lib.rs @@ -105,7 +105,7 @@ impl WsReceiver { ControlFlow::Break(()) } }); - let ws_receiver = WsReceiver { rx }; + let ws_receiver = Self { rx }; (ws_receiver, on_event) } diff --git a/ewebsock/src/tungstenite_common.rs b/ewebsock/src/tungstenite_common.rs index 465122a..cc579bd 100644 --- a/ewebsock/src/tungstenite_common.rs +++ b/ewebsock/src/tungstenite_common.rs @@ -4,7 +4,7 @@ impl From for tungstenite::protocol::WebSocketConfig { max_incoming_frame_size, } = options; - tungstenite::protocol::WebSocketConfig { + Self { max_frame_size: if max_incoming_frame_size == usize::MAX { None } else { diff --git a/example_app/Cargo.toml b/example_app/Cargo.toml index a3c1aee..bfb864b 100644 --- a/example_app/Cargo.toml +++ b/example_app/Cargo.toml @@ -3,7 +3,7 @@ name = "example_app" version = "0.1.0" authors = ["Emil Ernerfeldt "] edition = "2021" -rust-version = "1.73" +rust-version = "1.76" license = "MIT OR Apache-2.0" include = ["../LICENSE-APACHE", "../LICENSE-MIT", "**/*.rs", "Cargo.toml"] publish = false diff --git a/rust-toolchain b/rust-toolchain index 521e293..871f562 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -5,6 +5,6 @@ # to the user in the error, instead of "error: invalid channel name '[toolchain]'". [toolchain] -channel = "1.73.0" +channel = "1.76.0" components = ["rustfmt", "clippy"] targets = ["wasm32-unknown-unknown"] diff --git a/scripts/clippy_wasm/clippy.toml b/scripts/clippy_wasm/clippy.toml index 4cc1768..8ba794b 100644 --- a/scripts/clippy_wasm/clippy.toml +++ b/scripts/clippy_wasm/clippy.toml @@ -8,7 +8,7 @@ # ----------------------------------------------------------------------------- # Section identical to the main clippy.toml: -msrv = "1.73" +msrv = "1.76" allow-unwrap-in-tests = true diff --git a/scripts/template_update.py b/scripts/template_update.py index 85e3110..163a7d3 100755 --- a/scripts/template_update.py +++ b/scripts/template_update.py @@ -21,49 +21,64 @@ import shutil import tempfile -from git import Repo +from git import Repo # pip install GitPython OWNER = "rerun-io" -# Files requires by C++, but not by both Python or Rust. +# Don't overwrite these when updating existing repository from the template +DO_NOT_OVERWRITE = { + "Cargo.lock", + "CHANGELOG.md", + "main.py", + "pixi.lock", + "README.md", + "requirements.txt", +} + +# Files required by C++, but not by _both_ Python and Rust CPP_FILES = { ".clang-format", ".github/workflows/cpp.yml", "CMakeLists.txt", - "pixi.lock", # Not needed by Rust - "pixi.toml", # Not needed by Rust - "src/main.cpp", + "pixi.lock", # Pixi is only C++ & Python - For Rust we only use cargo + "pixi.toml", # Pixi is only C++ & Python - For Rust we only use cargo "src/", + "src/main.cpp", } -# Files requires by Python, but not by both C++ or Rust +# Files required by Python, but not by _both_ C++ and Rust PYTHON_FILES = { ".github/workflows/python.yml", ".mypy.ini", "main.py", - "pixi.lock", # Not needed by Rust - "pixi.toml", # Not needed by Rust + "pixi.lock", # Pixi is only C++ & Python - For Rust we only use cargo + "pixi.toml", # Pixi is only C++ & Python - For Rust we only use cargo "pyproject.toml", "requirements.txt", } -# Files requires by Rust, but not by both C++ or Python +# Files required by Rust, but not by _both_ C++ and Python RUST_FILES = { ".github/workflows/rust.yml", "bacon.toml", "Cargo.lock", "Cargo.toml", + "CHANGELOG.md", # We only keep a changelog for Rust crates at the moment "clippy.toml", "Cranky.toml", "deny.toml", "rust-toolchain", "scripts/clippy_wasm/", "scripts/clippy_wasm/clippy.toml", + "scripts/generate_changelog.py", # We only keep a changelog for Rust crates at the moment + "src/", "src/lib.rs", "src/main.rs", - "src/", } +# Files we used to have, but have been removed in never version of rerun_template +DEAD_FILES = ["bacon.toml", "Cranky.toml"] + def parse_languages(lang_str: str) -> set[str]: languages = lang_str.split(",") if lang_str else [] @@ -106,10 +121,12 @@ def delete_files_and_folder(paths: set[str], dry_run: bool) -> None: def update(languages: set[str], dry_run: bool) -> None: - # Don't overwrite these - ALWAYS_IGNORE_FILES = {"README.md", "pixi.lock", "Cargo.lock", "main.py", "requirements.txt"} + for file in DEAD_FILES: + print(f"Removing dead file {file}…") + if not dry_run: + os.remove(file) - files_to_ignore = calc_deny_set(languages) | ALWAYS_IGNORE_FILES + files_to_ignore = calc_deny_set(languages) | DO_NOT_OVERWRITE repo_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) with tempfile.TemporaryDirectory() as temp_dir: