Rust: "exceeding_bitshifts" lint does not work in associated consts

Created on 10 Feb 2020  路  6Comments  路  Source: rust-lang/rust

The exceeding_bitshifts lint should fire on the following code, but it does not:

pub trait Foo {
    const N: i32;
}

impl<T: Foo> Foo for Vec<T> {
    const N: i32 = T::N << 42; // no warning here
}

Playground
(This testcase now exists in-tree as a FIXME in ui/lint/lint-exceeding-bitshifts.rs.)

Cc @oli-obk @wesleywiser


This issue has been assigned to @jumbatm via this comment.


A-lint C-bug T-compiler

All 6 comments

I'd like to take this.

@rustbot claim

@jumbatm I have some plans to follow-up on https://github.com/rust-lang/rust/pull/68969 with some cleanup. That might at least partially resolve this issue here. So it's probably best to wait until after that is done.

All right, https://github.com/rust-lang/rust/pull/69185 landed, so what I planned here is done.

The remaining issue is about associated consts. The issue there is that check_binary_op does not even get called (according to trace! output). My guess is that one of the conditionals guarding this line fails, or maybe we are hitting an early return in const_prop, but I have not tried further.

The issue is all yours, @jumbatm :)

Great! I'll start investigating.

Possibly related: https://github.com/rust-lang/rust/issues/70660~~ Never mind, that one is already fixed on beta.

Was this page helpful?
0 / 5 - 0 ratings