-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #98657 - compiler-errors:rustc-const-eval-session-dia…
…gnostic-1, r=davidtwco Migrate some diagnostics from `rustc_const_eval` to `SessionDiagnostic` I'm still trying to get the hang of this, so it doesn't migrate _all_ of `rustc_const_eval`. Working on that later. r? `@davidtwco`
- Loading branch information
Showing
13 changed files
with
188 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
use rustc_hir::ConstContext; | ||
use rustc_macros::SessionDiagnostic; | ||
use rustc_span::Span; | ||
|
||
#[derive(SessionDiagnostic)] | ||
#[error(const_eval::unstable_in_stable)] | ||
pub(crate) struct UnstableInStable { | ||
pub gate: String, | ||
#[primary_span] | ||
pub span: Span, | ||
#[suggestion( | ||
const_eval::unstable_sugg, | ||
code = "#[rustc_const_unstable(feature = \"...\", issue = \"...\")]\n", | ||
applicability = "has-placeholders" | ||
)] | ||
#[suggestion( | ||
const_eval::bypass_sugg, | ||
code = "#[rustc_allow_const_fn_unstable({gate})]\n", | ||
applicability = "has-placeholders" | ||
)] | ||
pub attr_span: Span, | ||
} | ||
|
||
#[derive(SessionDiagnostic)] | ||
#[error(const_eval::thread_local_access, code = "E0625")] | ||
pub(crate) struct NonConstOpErr { | ||
#[primary_span] | ||
pub span: Span, | ||
} | ||
|
||
#[derive(SessionDiagnostic)] | ||
#[error(const_eval::static_access, code = "E0013")] | ||
#[help] | ||
pub(crate) struct StaticAccessErr { | ||
#[primary_span] | ||
pub span: Span, | ||
pub kind: ConstContext, | ||
#[note(const_eval::teach_note)] | ||
#[help(const_eval::teach_help)] | ||
pub teach: Option<()>, | ||
} | ||
|
||
#[derive(SessionDiagnostic)] | ||
#[error(const_eval::raw_ptr_to_int)] | ||
#[note] | ||
#[note(const_eval::note2)] | ||
pub(crate) struct RawPtrToIntErr { | ||
#[primary_span] | ||
pub span: Span, | ||
} | ||
|
||
#[derive(SessionDiagnostic)] | ||
#[error(const_eval::raw_ptr_comparison)] | ||
#[note] | ||
pub(crate) struct RawPtrComparisonErr { | ||
#[primary_span] | ||
pub span: Span, | ||
} | ||
|
||
#[derive(SessionDiagnostic)] | ||
#[error(const_eval::panic_non_str)] | ||
pub(crate) struct PanicNonStrErr { | ||
#[primary_span] | ||
pub span: Span, | ||
} | ||
|
||
#[derive(SessionDiagnostic)] | ||
#[error(const_eval::mut_deref, code = "E0658")] | ||
pub(crate) struct MutDerefErr { | ||
#[primary_span] | ||
pub span: Span, | ||
pub kind: ConstContext, | ||
} | ||
|
||
#[derive(SessionDiagnostic)] | ||
#[error(const_eval::transient_mut_borrow, code = "E0658")] | ||
pub(crate) struct TransientMutBorrowErr { | ||
#[primary_span] | ||
pub span: Span, | ||
pub kind: ConstContext, | ||
} | ||
|
||
#[derive(SessionDiagnostic)] | ||
#[error(const_eval::transient_mut_borrow_raw, code = "E0658")] | ||
pub(crate) struct TransientMutBorrowErrRaw { | ||
#[primary_span] | ||
pub span: Span, | ||
pub kind: ConstContext, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
compiler/rustc_error_messages/locales/en-US/builtin_macros.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
builtin_macros-requires-cfg-pattern = | ||
builtin-macros-requires-cfg-pattern = | ||
macro requires a cfg-pattern as an argument | ||
.label = cfg-pattern required | ||
builtin_macros-expected-one-cfg-pattern = expected 1 cfg-pattern | ||
builtin-macros-expected-one-cfg-pattern = expected 1 cfg-pattern |
31 changes: 31 additions & 0 deletions
31
compiler/rustc_error_messages/locales/en-US/const_eval.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const-eval-unstable-in-stable = | ||
const-stable function cannot use `#[feature({$gate})]` | ||
.unstable-sugg = if it is not part of the public API, make this function unstably const | ||
.bypass-sugg = otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks | ||
const-eval-thread-local-access = | ||
thread-local statics cannot be accessed at compile-time | ||
const-eval-static-access = | ||
{$kind}s cannot refer to statics | ||
.help = consider extracting the value of the `static` to a `const`, and referring to that | ||
.teach-note = `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. | ||
.teach-help = To fix this, the value can be extracted to a `const` and then used. | ||
const-eval-raw-ptr-to-int = | ||
pointers cannot be cast to integers during const eval | ||
.note = at compile-time, pointers do not have an integer value | ||
.note2 = avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior | ||
const-eval-raw-ptr-comparison = | ||
pointers cannot be reliably compared during const eval | ||
.note = see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information | ||
const-eval-panic-non-str = argument to `panic!()` in a const context must have type `&str` | ||
const-eval-mut-deref = | ||
mutation through a reference is not allowed in {$kind}s | ||
const-eval-transient-mut-borrow = mutable references are not allowed in {$kind}s | ||
const-eval-transient-mut-borrow-raw = raw mutable references are not allowed in {$kind}s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.