File tree 2 files changed +11
-10
lines changed
compiler/rustc_mir_build/src/thir/cx
tests/ui/associated-consts
2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -27,8 +27,8 @@ pub(crate) fn thir_body(
27
27
if let Some ( reported) = cx. typeck_results . tainted_by_errors {
28
28
return Err ( reported) ;
29
29
}
30
- let expr = cx. mirror_expr ( body. value ) ;
31
30
31
+ // Lower the params before the body's expression so errors from params are shown first.
32
32
let owner_id = tcx. local_def_id_to_hir_id ( owner_def) ;
33
33
if let Some ( fn_decl) = tcx. hir_fn_decl_by_hir_id ( owner_id) {
34
34
let closure_env_param = cx. closure_env_param ( owner_def, owner_id) ;
@@ -48,6 +48,7 @@ pub(crate) fn thir_body(
48
48
}
49
49
}
50
50
51
+ let expr = cx. mirror_expr ( body. value ) ;
51
52
Ok ( ( tcx. alloc_steal_thir ( cx. thir ) , expr) )
52
53
}
53
54
Original file line number Diff line number Diff line change @@ -27,31 +27,31 @@ LL | B::X => println!("B::X"),
27
27
| ^^^^ `const` depends on a generic parameter
28
28
29
29
error[E0158]: constant pattern cannot depend on generic parameters
30
- --> $DIR/associated-const-type-parameter-pattern.rs:30:9
30
+ --> $DIR/associated-const-type-parameter-pattern.rs:28:48
31
31
|
32
32
LL | pub trait Foo {
33
33
| -------------
34
34
LL | const X: EFoo;
35
35
| ------------- constant defined here
36
36
...
37
37
LL | pub fn test_let_pat<A: Foo, B: Foo>(arg: EFoo, A::X: EFoo) {
38
- | - constant depends on this generic parameter
39
- LL |
40
- LL | let A::X = arg;
41
- | ^^^^ `const` depends on a generic parameter
38
+ | - ^^^^ `const` depends on a generic parameter
39
+ | |
40
+ | constant depends on this generic parameter
42
41
43
42
error[E0158]: constant pattern cannot depend on generic parameters
44
- --> $DIR/associated-const-type-parameter-pattern.rs:28:48
43
+ --> $DIR/associated-const-type-parameter-pattern.rs:30:9
45
44
|
46
45
LL | pub trait Foo {
47
46
| -------------
48
47
LL | const X: EFoo;
49
48
| ------------- constant defined here
50
49
...
51
50
LL | pub fn test_let_pat<A: Foo, B: Foo>(arg: EFoo, A::X: EFoo) {
52
- | - ^^^^ `const` depends on a generic parameter
53
- | |
54
- | constant depends on this generic parameter
51
+ | - constant depends on this generic parameter
52
+ LL |
53
+ LL | let A::X = arg;
54
+ | ^^^^ `const` depends on a generic parameter
55
55
56
56
error: aborting due to 4 previous errors
57
57
You can’t perform that action at this time.
0 commit comments