Skip to content

Commit 7d9d599

Browse files
committed
don't look into anon consts in FindHirNodeVisitor
1 parent 23939e4 commit 7d9d599

File tree

5 files changed

+22
-14
lines changed

5 files changed

+22
-14
lines changed

compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ impl<'a, 'tcx> Visitor<'tcx> for FindHirNodeVisitor<'a, 'tcx> {
8787
NestedVisitorMap::OnlyBodies(self.infcx.tcx.hir())
8888
}
8989

90+
fn visit_anon_const(&mut self, _ct: &'tcx hir::AnonConst<'tcx>) {
91+
// Do not look into anonymous constants as they are typechecked
92+
// seperately.
93+
}
94+
9095
fn visit_local(&mut self, local: &'tcx Local<'tcx>) {
9196
if let (None, Some(ty)) =
9297
(self.found_local_pattern, self.node_ty_contains_target(local.hir_id))
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
#![feature(min_const_generics)]
2+
// FIXME(const_generics): should be stable soon
3+
14
trait Adapter {
25
const LINKS: usize;
36
}
47

58
struct Foo<A: Adapter> {
69
adapter: A,
7-
links: [u32; A::LINKS], // Shouldn't suggest bounds already there.
8-
//~^ ERROR: no associated item named `LINKS` found
10+
links: [u32; A::LINKS],
11+
//~^ ERROR generic parameters may not be used
912
}
1013

1114
fn main() {}
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
error[E0599]: no associated item named `LINKS` found for type parameter `A` in the current scope
2-
--> $DIR/associated-item-duplicate-bounds.rs:7:21
1+
error: generic parameters may not be used in const operations
2+
--> $DIR/associated-item-duplicate-bounds.rs:10:18
33
|
4-
LL | links: [u32; A::LINKS], // Shouldn't suggest bounds already there.
5-
| ^^^^^ associated item not found in `A`
4+
LL | links: [u32; A::LINKS],
5+
| ^^^^^^^^ cannot perform const operation using `A`
66
|
7-
= help: items from traits can only be used if the type parameter is bounded by the trait
7+
= note: type parameters may not be used in const expressions
88

99
error: aborting due to previous error
1010

11-
For more information about this error, try `rustc --explain E0599`.

src/test/ui/issues/issue-39559.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(min_const_generics)]
2+
// FIXME(const_generics): This should be stabilized soon enough
13
trait Dim {
24
fn dim() -> usize;
35
}
@@ -12,7 +14,7 @@ impl Dim for Dim3 {
1214

1315
pub struct Vector<T, D: Dim> {
1416
entries: [T; D::dim()],
15-
//~^ ERROR no function or associated item named `dim` found
17+
//~^ ERROR generic parameters may not be used
1618
_dummy: D,
1719
}
1820

src/test/ui/issues/issue-39559.stderr

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
error[E0599]: no function or associated item named `dim` found for type parameter `D` in the current scope
2-
--> $DIR/issue-39559.rs:14:21
1+
error: generic parameters may not be used in const operations
2+
--> $DIR/issue-39559.rs:16:18
33
|
44
LL | entries: [T; D::dim()],
5-
| ^^^ function or associated item not found in `D`
5+
| ^^^^^^ cannot perform const operation using `D`
66
|
7-
= help: items from traits can only be used if the type parameter is bounded by the trait
7+
= note: type parameters may not be used in const expressions
88

99
error: aborting due to previous error
1010

11-
For more information about this error, try `rustc --explain E0599`.

0 commit comments

Comments
 (0)