Skip to content

Tracking issue for RFC 2438, "Deny the overflowing_literals lint for the 2018 edition" #54502

Closed

Description

@Centril

This is a tracking issue for the RFC "Deny the overflowing_literals lint for the 2018 edition" (rust-lang/rfcs#2438).

Steps:

  • Implement the RFC (cc @rust-lang/compiler -- can anyone write up mentoring instructions?)
  • Adjust documentation (see instructions on forge)

Unresolved questions:

None

Activity

  1. added
    P-highHigh priority
    T-langRelevant to the language team
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Sep 23, 2018
  2. Centril commented on Sep 23, 2018

    @Centril
    ContributorAuthor

    Marked as P-high for T-compiler due to edition 2018.

  3. added
    B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    on Sep 23, 2018
  4. eddyb commented on Sep 23, 2018

    @eddyb
    Contributor

    @nikomatsakis Do we have a mechanism for per-edition default lint levels?

  5. varkor commented on Sep 23, 2018

    @varkor
    Contributor

    Do we have a mechanism for per-edition default lint levels?

    Yes we do. We should just be able to replace:
    https://github.com/rust-lang/rust/blob/f0bae412e97db7ef26e24546bce5199c6a086152/src/librustc_lint/types.rs#L38-L42
    with:

    declare_lint! {
        OVERFLOWING_LITERALS,
        Warn,
        "literal out of range for its type",
        Edition::Edition2018 => Deny
    }
  6. added
    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
    on Sep 23, 2018
  7. ollie27 commented on Sep 23, 2018

    @ollie27
    Contributor

    Is there any reason it can't be made deny by default in the 2015 edition as well?

  8. added a commit that references this issue on Sep 24, 2018
  9. Centril commented on Sep 24, 2018

    @Centril
    ContributorAuthor

    Documentation is still todo

  10. self-assigned this
    on Sep 27, 2018
  11. 5 remaining items

  12. added
    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools
    and removed
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Sep 28, 2018
  13. removed their assignment
    on Sep 28, 2018
  14. steveklabnik commented on Sep 30, 2018

    @steveklabnik
    Contributor
  15. removed
    T-langRelevant to the language team
    on Oct 4, 2018
  16. ollie27 commented on Nov 2, 2018

    @ollie27
    Contributor

    Well I couldn't find any reason for it to only be deny by default on the 2018 edition so I've submitted #55632 to make it deny by default on all editions.

  17. removed
    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools
    P-highHigh priority
    on Feb 25, 2019
  18. Centril commented on Feb 25, 2019

    @Centril
    ContributorAuthor

    Only rust-lang/edition-guide#146 remains now that #55632 is merged; closing therefore.

  19. TheDan64 commented on Mar 13, 2019

    @TheDan64
    Contributor

    This broke some of my doc test code in inkwell while updating to 2018e which looked like this:
    assert_eq!(0b1110_0000i8 >> 1, 0b1111_0000i8);

    It was used as an example as to how sign extended bitshifting works.

    I don't really understand why this isn't valid. For example, looking at an even simpler example:
    let _x = 0b1110_0000i8; also won't compile:

    error: literal out of range for i8
     --> src/main.rs:2:14
      |
    2 |     let _x = 0b1110_0000i8;
      |              ^^^^^^^^^^^^^ help: consider using `u8` instead: `0b1110_0000u8`
      |
      = note: #[deny(overflowing_literals)] on by default
      = note: the literal `0b1110_0000i8` (decimal `224`) does not fit into an `i8` and will become `-32i8`

    However, it is my intent to specify the bit representation of an -32i8 (and it clearly has the i8 suffix), so how is this an overflow?

  20. oli-obk commented on Mar 13, 2019

    @oli-obk
    Contributor

    Rust's literals are not the bit representation of the final value. If they were, you'd get different result depending on whether you are on a big endian or a little endian machine (ok not for u8 and i8, but everything else).

    Instead the binary literals are the canonical binary representation of a positive integer, just like decimal literals are the canonical decimal representation of a positive integer. If you write 255_i8 that's the same thing as writing 0b1111_1111_i8, and 255 is not a valid i8.

  21. TheDan64 commented on Mar 13, 2019

    @TheDan64
    Contributor

    I guess that makes sense, thanks for explaining. But it's certainly surprising behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions