Skip to content

[DISCUSS] Method of #![deny(current_warnings)] #1

Closed
@CAD97

Description

@CAD97

I find this tower annoying:

example-warn/src/lib.rs

Lines 1 to 36 in 5cbaf77

#![deny(const_err,
dead_code,
illegal_floating_point_literal_pattern,
improper_ctypes,
non_camel_case_types,
non_shorthand_field_patterns,
non_snake_case,
non_upper_case_globals,
no_mangle_generic_items,
overflowing_literals,
path_statements,
patterns_in_fns_without_body,
plugin_as_library,
private_in_public,
private_no_mangle_fns,
private_no_mangle_statics,
renamed_and_removed_lints,
stable_features,
unconditional_recursion,
unions_with_drop_fields,
unknown_lints,
unreachable_code,
unreachable_patterns,
unused_allocation,
unused_assignments,
unused_attributes,
unused_comparisons,
unused_features,
unused_imports,
unused_macros,
unused_must_use,
unused_mut,
unused_parens,
unused_unsafe,
unused_variables,
while_true)]

Reasoning:

  • 36 (and more in the future) lines of code in the root before the interesting part
  • This prevents local compilation from continuing after a warning
    • Depending on the warning, it can be detected before real errors and prevent them from showing
    • Often times when iterating I care more about correctness than eliminating warnings right now
    • It's beneficial to the compiler UI to have a visual separation between warnings and errors

I fully agree that warnings should be treated as errors on CI. So how do we get cargo build to treat warnings as errors? By the RUSTFLAGS environment variable!

With RUSTFLAGS=-D warnings you can deny the warning group warnings. (For the same reason that we don't use !#[deny(warnings)], this is dangerous. Though we're still technically not free from warnings introduced by new versions of the compiler; deprecation of symbols can introduce deprecation warnings. (As such that one should probably be excluded from our exclusion list.)) With RUSTFLAGS=-D const_err -D dead_code ... you can specify warning (groups) individually.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions