diff options
| author | cameron <cameron.studdstreet@gmail.com> | 2022-08-14 23:07:47 +0100 |
|---|---|---|
| committer | cameron <cameron.studdstreet@gmail.com> | 2022-08-14 23:07:47 +0100 |
| commit | 34e0d9a0bb409bb6c7fc45f1c222340b02989b8b (patch) | |
| tree | c86ef095c108db756b59ae6ab2481ab628306fc7 /compiler/rustc_const_eval/src | |
| parent | 75b7e52e92c3b00fc891b47f5b2efdff0a2be55a (diff) | |
| download | rust-34e0d9a0bb409bb6c7fc45f1c222340b02989b8b.tar.gz rust-34e0d9a0bb409bb6c7fc45f1c222340b02989b8b.zip | |
suggest lazy-static for non-const statics
Diffstat (limited to 'compiler/rustc_const_eval/src')
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/check_consts/ops.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs index 33802261644..c9cfc1f3f46 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs @@ -1,6 +1,7 @@ //! Concrete error types for all operations which may be invalid in a certain const context. use hir::def_id::LocalDefId; +use hir::ConstContext; use rustc_errors::{ error_code, struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, }; @@ -331,6 +332,10 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> { ccx.const_kind(), )); + if let ConstContext::Static(_) = ccx.const_kind() { + err.note("consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell"); + } + err } } |
