stop evaluating constants in Relate
This commit is contained in:
parent
060f3e0c65
commit
01adb7e98d
7 changed files with 11 additions and 56 deletions
|
@ -594,10 +594,6 @@ pub fn super_relate_consts<'tcx, R: TypeRelation<'tcx>>(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let eagerly_eval = |x: ty::Const<'tcx>| x.eval(tcx, relation.param_env());
|
|
||||||
let a = eagerly_eval(a);
|
|
||||||
let b = eagerly_eval(b);
|
|
||||||
|
|
||||||
// Currently, the values that can be unified are primitive types,
|
// Currently, the values that can be unified are primitive types,
|
||||||
// and those that derive both `PartialEq` and `Eq`, corresponding
|
// and those that derive both `PartialEq` and `Eq`, corresponding
|
||||||
// to structural-match types.
|
// to structural-match types.
|
||||||
|
|
|
@ -635,7 +635,7 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> {
|
||||||
|
|
||||||
#[instrument(skip(self), level = "debug")]
|
#[instrument(skip(self), level = "debug")]
|
||||||
fn fold_const(&mut self, constant: ty::Const<'tcx>) -> ty::Const<'tcx> {
|
fn fold_const(&mut self, constant: ty::Const<'tcx>) -> ty::Const<'tcx> {
|
||||||
if self.selcx.tcx().lazy_normalization() || !self.eager_inference_replacement {
|
if self.selcx.tcx().lazy_normalization() {
|
||||||
constant
|
constant
|
||||||
} else {
|
} else {
|
||||||
let constant = constant.super_fold_with(self);
|
let constant = constant.super_fold_with(self);
|
||||||
|
|
|
@ -495,13 +495,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
pub fn to_const(&self, ast_c: &hir::AnonConst) -> ty::Const<'tcx> {
|
pub fn to_const(&self, ast_c: &hir::AnonConst) -> ty::Const<'tcx> {
|
||||||
let const_def_id = self.tcx.hir().local_def_id(ast_c.hir_id);
|
let const_def_id = self.tcx.hir().local_def_id(ast_c.hir_id);
|
||||||
|
let span = self.tcx.hir().span(ast_c.hir_id);
|
||||||
let c = ty::Const::from_anon_const(self.tcx, const_def_id);
|
let c = ty::Const::from_anon_const(self.tcx, const_def_id);
|
||||||
self.register_wf_obligation(
|
self.register_wf_obligation(c.into(), span, ObligationCauseCode::WellFormed(None));
|
||||||
c.into(),
|
self.normalize_associated_types_in(span, c)
|
||||||
self.tcx.hir().span(ast_c.hir_id),
|
|
||||||
ObligationCauseCode::WellFormed(None),
|
|
||||||
);
|
|
||||||
c
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn const_arg_to_const(
|
pub fn const_arg_to_const(
|
||||||
|
|
|
@ -2,5 +2,4 @@ fn main() {
|
||||||
[(); &(&'static: loop { |x| {}; }) as *const _ as usize]
|
[(); &(&'static: loop { |x| {}; }) as *const _ as usize]
|
||||||
//~^ ERROR: invalid label name `'static`
|
//~^ ERROR: invalid label name `'static`
|
||||||
//~| ERROR: type annotations needed
|
//~| ERROR: type annotations needed
|
||||||
//~| ERROR mismatched types
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,15 +15,6 @@ help: consider giving this closure parameter an explicit type
|
||||||
LL | [(); &(&'static: loop { |x: _| {}; }) as *const _ as usize]
|
LL | [(); &(&'static: loop { |x: _| {}; }) as *const _ as usize]
|
||||||
| +++
|
| +++
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error: aborting due to 2 previous errors
|
||||||
--> $DIR/issue-52437.rs:2:5
|
|
||||||
|
|
|
||||||
LL | fn main() {
|
|
||||||
| - expected `()` because of default return type
|
|
||||||
LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found array `[(); _]`
|
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
For more information about this error, try `rustc --explain E0282`.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0282, E0308.
|
|
||||||
For more information about an error, try `rustc --explain E0282`.
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ fn a() {
|
||||||
[0; [|_: _ &_| ()].len()]
|
[0; [|_: _ &_| ()].len()]
|
||||||
//~^ ERROR expected `,`, found `&`
|
//~^ ERROR expected `,`, found `&`
|
||||||
//~| ERROR type annotations needed
|
//~| ERROR type annotations needed
|
||||||
//~| ERROR mismatched types
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn b() {
|
fn b() {
|
||||||
|
@ -13,13 +12,11 @@ fn b() {
|
||||||
fn c() {
|
fn c() {
|
||||||
[0; [|&_: _ &_| {}; 0 ].len()]
|
[0; [|&_: _ &_| {}; 0 ].len()]
|
||||||
//~^ ERROR expected `,`, found `&`
|
//~^ ERROR expected `,`, found `&`
|
||||||
//~| ERROR mismatched types
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn d() {
|
fn d() {
|
||||||
[0; match [|f @ &ref _| () ] {} ]
|
[0; match [|f @ &ref _| () ] {} ]
|
||||||
//~^ ERROR expected identifier, found reserved identifier `_`
|
//~^ ERROR expected identifier, found reserved identifier `_`
|
||||||
//~| ERROR mismatched types
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -7,13 +7,13 @@ LL | [0; [|_: _ &_| ()].len()]
|
||||||
| help: missing `,`
|
| help: missing `,`
|
||||||
|
|
||||||
error: expected identifier, found reserved identifier `_`
|
error: expected identifier, found reserved identifier `_`
|
||||||
--> $DIR/issue-66706.rs:9:20
|
--> $DIR/issue-66706.rs:8:20
|
||||||
|
|
|
|
||||||
LL | [0; [|f @ &ref _| {} ; 0 ].len() ];
|
LL | [0; [|f @ &ref _| {} ; 0 ].len() ];
|
||||||
| ^ expected identifier, found reserved identifier
|
| ^ expected identifier, found reserved identifier
|
||||||
|
|
||||||
error: expected `,`, found `&`
|
error: expected `,`, found `&`
|
||||||
--> $DIR/issue-66706.rs:14:17
|
--> $DIR/issue-66706.rs:13:17
|
||||||
|
|
|
|
||||||
LL | [0; [|&_: _ &_| {}; 0 ].len()]
|
LL | [0; [|&_: _ &_| {}; 0 ].len()]
|
||||||
| -^ expected `,`
|
| -^ expected `,`
|
||||||
|
@ -21,7 +21,7 @@ LL | [0; [|&_: _ &_| {}; 0 ].len()]
|
||||||
| help: missing `,`
|
| help: missing `,`
|
||||||
|
|
||||||
error: expected identifier, found reserved identifier `_`
|
error: expected identifier, found reserved identifier `_`
|
||||||
--> $DIR/issue-66706.rs:20:26
|
--> $DIR/issue-66706.rs:18:26
|
||||||
|
|
|
|
||||||
LL | [0; match [|f @ &ref _| () ] {} ]
|
LL | [0; match [|f @ &ref _| () ] {} ]
|
||||||
| ^ expected identifier, found reserved identifier
|
| ^ expected identifier, found reserved identifier
|
||||||
|
@ -32,31 +32,6 @@ error[E0282]: type annotations needed
|
||||||
LL | [0; [|_: _ &_| ()].len()]
|
LL | [0; [|_: _ &_| ()].len()]
|
||||||
| ^ cannot infer type
|
| ^ cannot infer type
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error: aborting due to 5 previous errors
|
||||||
--> $DIR/issue-66706.rs:2:5
|
|
||||||
|
|
|
||||||
LL | fn a() {
|
|
||||||
| - help: try adding a return type: `-> [i32; _]`
|
|
||||||
LL | [0; [|_: _ &_| ()].len()]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found array `[{integer}; _]`
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
For more information about this error, try `rustc --explain E0282`.
|
||||||
--> $DIR/issue-66706.rs:14:5
|
|
||||||
|
|
|
||||||
LL | fn c() {
|
|
||||||
| - help: try adding a return type: `-> [i32; _]`
|
|
||||||
LL | [0; [|&_: _ &_| {}; 0 ].len()]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found array `[{integer}; _]`
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/issue-66706.rs:20:5
|
|
||||||
|
|
|
||||||
LL | fn d() {
|
|
||||||
| - help: try adding a return type: `-> [i32; _]`
|
|
||||||
LL | [0; match [|f @ &ref _| () ] {} ]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found array `[{integer}; _]`
|
|
||||||
|
|
||||||
error: aborting due to 8 previous errors
|
|
||||||
|
|
||||||
Some errors have detailed explanations: E0282, E0308.
|
|
||||||
For more information about an error, try `rustc --explain E0282`.
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue