rust/compiler/rustc_resolve/src
Dylan DPC 69c78a98ee
Rollup merge of #85478 - FabianWolff:issue-85348, r=petrochenkov
Disallow shadowing const parameters

This pull request fixes #85348. Trying to shadow a `const` parameter as follows:
```rust
fn foo<const N: i32>() {
    let N @ _ = 0;
}
```
currently causes an ICE. With my changes, I get:
```
error[E0530]: let bindings cannot shadow const parameters
 --> test.rs:2:9
  |
1 | fn foo<const N: i32>() {
  |              - the const parameter `N` is defined here
2 |     let N @ _ = 0;
  |         ^ cannot be named the same as a const parameter

error: aborting due to previous error
```
This is the same error you get when trying to shadow a constant:
```rust
const N: i32 = 0;
let N @ _ = 0;
```
```
error[E0530]: let bindings cannot shadow constants
 --> src/lib.rs:3:5
  |
2 | const N: i32 = 0;
  | ----------------- the constant `N` is defined here
3 | let N @ _ = 0;
  |     ^ cannot be named the same as a constant

error: aborting due to previous error
```
The reason for disallowing shadowing in both cases is described [here](https://github.com/rust-lang/rust/issues/33118#issuecomment-233962221) (the comment there only talks about constants, but the same reasoning applies to `const` parameters).
2021-05-26 13:32:05 +02:00
..
late Auto merge of #85041 - mibac138:suggest-generics, r=estebank 2021-05-13 08:08:20 +00:00
build_reduced_graph.rs Fix diagnostic for matching/creating x-crate re-exported tuple structs with private fields. 2021-05-08 00:33:31 -07:00
check_unused.rs Attach TokenStream to ast::Visibility 2020-09-10 17:33:06 -04:00
def_collector.rs ast/hir: Rename field-related structures 2021-03-16 11:41:24 +03:00
diagnostics.rs Disallow shadowing const parameters 2021-05-19 18:51:42 +02:00
imports.rs Fix ICE with use clippy:🅰️:b; 2021-03-21 14:20:28 -07:00
late.rs Disallow shadowing const parameters 2021-05-19 18:51:42 +02:00
lib.rs Rollup merge of #85478 - FabianWolff:issue-85348, r=petrochenkov 2021-05-26 13:32:05 +02:00
macros.rs Implement span quoting for proc-macros 2021-05-12 00:51:31 -04:00