1
Fork 0

Stabilize const_refs_to_static

update tests

fix bitwidth-sensitive stderr output

use build-fail for asm tests
This commit is contained in:
Ding Xiang Fei 2024-08-30 04:48:05 +08:00 committed by Xiang Fei Ding
parent 76ed7a1fa4
commit 1576a6d618
No known key found for this signature in database
GPG key ID: 3CD748647EEF6359
45 changed files with 157 additions and 442 deletions

View file

@ -317,7 +317,6 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
{
self.error_emitted = Some(guar);
}
self.check_op_spanned(ops::StaticAccess, span)
}
/// Returns whether this place can possibly escape the evaluation of the current const/static

View file

@ -16,7 +16,6 @@ use rustc_middle::ty::{
suggest_constraining_type_param,
};
use rustc_middle::util::{CallDesugaringKind, CallKind, call_kind};
use rustc_session::parse::feature_err;
use rustc_span::symbol::sym;
use rustc_span::{BytePos, Pos, Span, Symbol};
use rustc_trait_selection::traits::SelectionContext;
@ -477,33 +476,6 @@ impl<'tcx> NonConstOp<'tcx> for RawPtrToIntCast {
}
}
/// An access to a (non-thread-local) `static`.
#[derive(Debug)]
pub(crate) struct StaticAccess;
impl<'tcx> NonConstOp<'tcx> for StaticAccess {
fn status_in_item(&self, ccx: &ConstCx<'_, 'tcx>) -> Status {
if let hir::ConstContext::Static(_) = ccx.const_kind() {
Status::Allowed
} else {
Status::Unstable(sym::const_refs_to_static)
}
}
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
let mut err = feature_err(
&ccx.tcx.sess,
sym::const_refs_to_static,
span,
format!("referencing statics in {}s is unstable", ccx.const_kind(),),
);
err
.note("`static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.")
.help("to fix this, the value can be extracted to a `const` and then used.");
err
}
}
/// An access to a thread-local `static`.
#[derive(Debug)]
pub(crate) struct ThreadLocalAccess;