Opened 3 years ago

Closed 20 months ago

#9037 closed feature request (duplicate)

Add option to make selected warnings errors

Reported by: nh2 Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.8.2
Keywords: Cc: mail@…, schyler
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #11219 Differential Rev(s):
Wiki Page:


It would be great if GHC offered a -ferror-* flag for every -fwarn-* flag, that turns the given type of warning into an error.

For example, I would like to always error on uninitialized record fields, but don't want to go full -Werror.

Change History (4)

comment:1 Changed 3 years ago by schyler

The rust compiler has a nice system where you don't need tons and tons of flags for warnings/errors/ignores.

For example:

Kyles-iMac:~ kvanb$ rustc -W

Available lint options:
    -W <foo>           Warn about <foo>
    -A <foo>           Allow <foo>
    -D <foo>           Deny <foo>
    -F <foo>           Forbid <foo> (deny, and deny all overrides)

Available lint checks:

                             name  default  meaning
                             ----  -------  -------

             non-camel-case-types  allow    types, variants and traits should have camel case names
              managed-heap-memory  allow    use of managed (@ type) heap memory
                owned-heap-memory  allow    use of owned (~ type) heap memory
                         unstable  allow    detects use of #[unstable] items (incl. items with no stability attribute)
                      heap-memory  allow    use of any (~ type or @ type) heap memory
        unnecessary-qualification  allow    detects unnecessarily qualified names
            non-uppercase-statics  allow    static constants should have uppercase identifiers
                      missing-doc  allow    detects missing documentation for public members
                     unsafe-block  allow    usage of an `unsafe` block
                 unreachable-code  warn     detects unreachable code
                       deprecated  warn     detects use of #[deprecated] items
                   unused-imports  warn     imports that are never used
                         warnings  warn     mass-change the level for lints which produce warnings
                   path-statement  warn     path statements with no effect
                           ctypes  warn     proper use of std::libc types in foreign modules
                  dead-assignment  warn     detect assignments that will never be read
                    unused-unsafe  warn     unnecessary use of an `unsafe` block
                       unused-mut  warn     detect mut variables which don't need to be mutable
    non-uppercase-pattern-statics  warn     static constants in match patterns should be all caps
                unrecognized-lint  warn     unrecognized lint attribute
                  unused-variable  warn     detect variables which are not used in any way
                        dead-code  warn     detect piece of code that will never be used
           unnecessary-allocation  warn     detects unnecessary allocations that can be eliminated
                  attribute-usage  warn     detects bad use of attributes
                    type-overflow  warn     literal out of range for its type
                      type-limits  warn     comparisons made useless by limits of the types involved
                       while-true  warn     suggest using loop { } instead of while(true) { }
                     experimental  warn     detects use of #[experimental] items
                 unknown-features  deny     unknown features found in create-level #[feature] directives

Maybe a long term goal might be to build something similar-ish. Just a thought.

comment:2 Changed 3 years ago by schyler

Cc: schyler added

comment:3 Changed 22 months ago by hvr

Fwiw, this is related to Design/Warnings which proposes to use -Werror=redundant-imports to selectively promote some warnings to errors.

comment:4 Changed 20 months ago by thomie

Resolution: duplicate
Status: newclosed

There is a new ticket for this now: #11219.

Note: See TracTickets for help on using tickets.