diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-07-18 14:21:54 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-18 14:21:54 +0900 |
| commit | 783efd29ae71fccc7dcc220fbca37765423f6e58 (patch) | |
| tree | 2aad8fac8f1dd8b69e4eea0ca434b4c99d37f03b /compiler/rustc_mir/src/transform/coverage/graph.rs | |
| parent | 469935f7a46e1e3f33b2c70919c70570acaeeed7 (diff) | |
| parent | 9b874c400388a2158b6575e139752b3d0a27645b (diff) | |
| download | rust-783efd29ae71fccc7dcc220fbca37765423f6e58.tar.gz rust-783efd29ae71fccc7dcc220fbca37765423f6e58.zip | |
Rollup merge of #86843 - FabianWolff:issue-86820, r=lcnr
Check that const parameters of trait methods have compatible types
This PR fixes #86820. The problem is that this currently passes the type checker:
```rust
trait Tr {
fn foo<const N: u8>(self) -> u8;
}
impl Tr for f32 {
fn foo<const N: bool>(self) -> u8 { 42 }
}
```
i.e. the type checker fails to check whether const parameters in `impl` methods have the same type as the corresponding declaration in the trait. With my changes, I get, for the above code:
```
error[E0053]: method `foo` has an incompatible const parameter type for trait
--> test.rs:6:18
|
6 | fn foo<const N: bool>(self) -> u8 { 42 }
| ^
|
note: the const parameter `N` has type `bool`, but the declaration in trait `Tr::foo` has type `u8`
--> test.rs:2:18
|
2 | fn foo<const N: u8>(self) -> u8;
| ^
error: aborting due to previous error
```
This fixes #86820, where an ICE happens later on because the trait method is declared with a const parameter of type `u8`, but the `impl` uses one of type `usize`:
> `expected int of size 8, but got size 1`
Diffstat (limited to 'compiler/rustc_mir/src/transform/coverage/graph.rs')
0 files changed, 0 insertions, 0 deletions
