Skip to content

Commit b0aa859

Browse files
committed
fix fmt and bless
1 parent f6725c0 commit b0aa859

21 files changed

+46
-10
lines changed

compiler/rustc_const_eval/src/transform/check_consts/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_attr as attr;
88
use rustc_hir as hir;
99
use rustc_hir::def_id::{DefId, LocalDefId};
1010
use rustc_middle::mir;
11-
use rustc_middle::ty::{self, TyCtxt, PolyFnSig};
11+
use rustc_middle::ty::{self, PolyFnSig, TyCtxt};
1212
use rustc_span::Symbol;
1313

1414
pub use self::qualifs::Qualif;

compiler/rustc_middle/src/hir/map/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,9 @@ impl<'hir> Map<'hir> {
485485
BodyOwnerKind::Static(mt) => ConstContext::Static(mt),
486486

487487
BodyOwnerKind::Fn if self.tcx.is_constructor(def_id.to_def_id()) => return None,
488-
BodyOwnerKind::Fn | BodyOwnerKind::Closure if self.tcx.is_const_fn_raw(def_id.to_def_id()) => {
488+
BodyOwnerKind::Fn | BodyOwnerKind::Closure
489+
if self.tcx.is_const_fn_raw(def_id.to_def_id()) =>
490+
{
489491
ConstContext::ConstFn
490492
}
491493
BodyOwnerKind::Fn if self.tcx.is_const_default_method(def_id.to_def_id()) => {

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -261,16 +261,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
261261
Some(closure_kind) => {
262262
debug!(?closure_kind, "assemble_unboxed_candidates");
263263
if closure_kind.extends(kind) {
264-
candidates.vec.push(ClosureCandidate {
265-
is_const,
266-
});
264+
candidates.vec.push(ClosureCandidate { is_const });
267265
}
268266
}
269267
None => {
270268
debug!("assemble_unboxed_candidates: closure_kind not yet known");
271-
candidates.vec.push(ClosureCandidate {
272-
is_const,
273-
});
269+
candidates.vec.push(ClosureCandidate { is_const });
274270
}
275271
}
276272
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0015]: cannot call non-const fn `<() as Foo>::foo` in constant functions
2+
--> $DIR/non-const-op-const-closure-non-const-outer.rs:13:22
3+
|
4+
LL | (const || { (()).foo() })();
5+
| ^^^^^
6+
|
7+
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0015`.

tests/ui/check-static-values-constraints.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ LL | field2: SafeEnum::Variant4("str".to_string())
2222
| ^^^^^^^^^^^
2323
|
2424
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
25+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
2526
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
2627

2728
error[E0010]: allocations are not allowed in statics

tests/ui/const-generics/issue-93647.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ LL | (||1usize)()
66
|
77
= note: closures need an RFC before allowed to be called in constants
88
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
9+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
910

1011
error: aborting due to previous error
1112

tests/ui/consts/const-fn-error.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ LL | for i in 0..x {
2222
note: impl defined here, but it is not `const`
2323
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
2424
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
25+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
2526

2627
error[E0658]: mutable references are not allowed in constant functions
2728
--> $DIR/const-fn-error.rs:5:14
@@ -39,6 +40,7 @@ LL | for i in 0..x {
3940
| ^^^^
4041
|
4142
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
43+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
4244

4345
error: aborting due to 4 previous errors
4446

tests/ui/consts/const-for.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ LL | for _ in 0..5 {}
77
note: impl defined here, but it is not `const`
88
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
99
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
10+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
1011

1112
error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants
1213
--> $DIR/const-for.rs:5:14
@@ -15,6 +16,7 @@ LL | for _ in 0..5 {}
1516
| ^^^^
1617
|
1718
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
19+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
1820

1921
error: aborting due to 2 previous errors
2022

tests/ui/consts/invalid-inline-const-in-match-arm.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ LL | const { (|| {})() } => {}
66
|
77
= note: closures need an RFC before allowed to be called in constants
88
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
9+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
910

1011
error: aborting due to previous error
1112

tests/ui/consts/issue-28113.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ LL | || -> u8 { 5 }()
66
|
77
= note: closures need an RFC before allowed to be called in constants
88
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
9+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
910

1011
error: aborting due to previous error
1112

tests/ui/consts/issue-56164.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ LL | const fn foo() { (||{})() }
66
|
77
= note: closures need an RFC before allowed to be called in constant functions
88
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
9+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
910

1011
error: function pointer calls are not allowed in constant functions
1112
--> $DIR/issue-56164.rs:5:5

tests/ui/consts/issue-68542-closure-in-array-len.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ LL | a: [(); (|| { 0 })()]
66
|
77
= note: closures need an RFC before allowed to be called in constants
88
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
9+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
910

1011
error: aborting due to previous error
1112

tests/ui/consts/issue-90870.fixed

+3
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,22 @@ const fn f(a: &u8, b: &u8) -> bool {
88
*a == *b
99
//~^ ERROR: cannot call non-const operator in constant functions [E0015]
1010
//~| HELP: consider dereferencing here
11+
//~| HELP: add `#![feature(const_trait_impl)]`
1112
}
1213

1314
const fn g(a: &&&&i64, b: &&&&i64) -> bool {
1415
****a == ****b
1516
//~^ ERROR: cannot call non-const operator in constant functions [E0015]
1617
//~| HELP: consider dereferencing here
18+
//~| HELP: add `#![feature(const_trait_impl)]`
1719
}
1820

1921
const fn h(mut a: &[u8], mut b: &[u8]) -> bool {
2022
while let ([l, at @ ..], [r, bt @ ..]) = (a, b) {
2123
if *l == *r {
2224
//~^ ERROR: cannot call non-const operator in constant functions [E0015]
2325
//~| HELP: consider dereferencing here
26+
//~| HELP: add `#![feature(const_trait_impl)]`
2427
a = at;
2528
b = bt;
2629
} else {

tests/ui/consts/issue-90870.rs

+3
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,22 @@ const fn f(a: &u8, b: &u8) -> bool {
88
a == b
99
//~^ ERROR: cannot call non-const operator in constant functions [E0015]
1010
//~| HELP: consider dereferencing here
11+
//~| HELP: add `#![feature(const_trait_impl)]`
1112
}
1213

1314
const fn g(a: &&&&i64, b: &&&&i64) -> bool {
1415
a == b
1516
//~^ ERROR: cannot call non-const operator in constant functions [E0015]
1617
//~| HELP: consider dereferencing here
18+
//~| HELP: add `#![feature(const_trait_impl)]`
1719
}
1820

1921
const fn h(mut a: &[u8], mut b: &[u8]) -> bool {
2022
while let ([l, at @ ..], [r, bt @ ..]) = (a, b) {
2123
if l == r {
2224
//~^ ERROR: cannot call non-const operator in constant functions [E0015]
2325
//~| HELP: consider dereferencing here
26+
//~| HELP: add `#![feature(const_trait_impl)]`
2427
a = at;
2528
b = bt;
2629
} else {

tests/ui/consts/issue-90870.stderr

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,33 @@ LL | a == b
55
| ^^^^^^
66
|
77
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
8+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
89
help: consider dereferencing here
910
|
1011
LL | *a == *b
1112
| + +
1213

1314
error[E0015]: cannot call non-const operator in constant functions
14-
--> $DIR/issue-90870.rs:14:5
15+
--> $DIR/issue-90870.rs:15:5
1516
|
1617
LL | a == b
1718
| ^^^^^^
1819
|
1920
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
21+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
2022
help: consider dereferencing here
2123
|
2224
LL | ****a == ****b
2325
| ++++ ++++
2426

2527
error[E0015]: cannot call non-const operator in constant functions
26-
--> $DIR/issue-90870.rs:21:12
28+
--> $DIR/issue-90870.rs:23:12
2729
|
2830
LL | if l == r {
2931
| ^^^^^^
3032
|
3133
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
34+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
3235
help: consider dereferencing here
3336
|
3437
LL | if *l == *r {

tests/ui/never_type/issue-52443.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ LL | [(); { for _ in 0usize.. {}; 0}];
4747
note: impl defined here, but it is not `const`
4848
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
4949
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
50+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
5051

5152
error[E0658]: mutable references are not allowed in constants
5253
--> $DIR/issue-52443.rs:9:21
@@ -64,6 +65,7 @@ LL | [(); { for _ in 0usize.. {}; 0}];
6465
| ^^^^^^^^
6566
|
6667
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
68+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
6769

6870
error: aborting due to 6 previous errors; 1 warning emitted
6971

tests/ui/resolve/issue-39559-2.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | let array: [usize; Dim3::dim()]
55
| ^^^^^^^^^^^
66
|
77
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
8+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
89

910
error[E0015]: cannot call non-const fn `<Dim3 as Dim>::dim` in constants
1011
--> $DIR/issue-39559-2.rs:16:15
@@ -13,6 +14,7 @@ LL | = [0; Dim3::dim()];
1314
| ^^^^^^^^^^^
1415
|
1516
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
17+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
1618

1719
error: aborting due to 2 previous errors
1820

tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ LL | pub struct S(A);
77
| ^
88
|
99
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
10+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
1011
= note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
1112

1213
error: aborting due to previous error

tests/ui/rfc-2632-const-trait-impl/cross-crate.stock.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | Const.func();
55
| ^^^^^^
66
|
77
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
8+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
89

910
error: aborting due to previous error
1011

tests/ui/rfc-2632-const-trait-impl/staged-api-user-crate.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | Unstable::func();
55
| ^^^^^^^^^^^^^^^^
66
|
77
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
8+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
89

910
error: aborting due to previous error
1011

tests/ui/rfc-2632-const-trait-impl/std-impl-gate.stock.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | Default::default()
55
| ^^^^^^^^^^^^^^^^^^
66
|
77
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
8+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
89

910
error: aborting due to previous error
1011

0 commit comments

Comments
 (0)