Auto merge of #77917 - JohnTitor:rollup-e47h2qt, r=JohnTitor
Rollup of 14 pull requests Successful merges: - #77239 (Enable building Cargo for aarch64-apple-darwin) - #77569 (BTreeMap: type-specific variants of node_as_mut and cast_unchecked) - #77719 (Remove unnecessary rustc_const_stable attributes.) - #77722 (Remove unsafety from sys/unsupported and add deny(unsafe_op_in_unsafe_fn).) - #77725 (Add regression issue template) - #77776 ( Give an error when running `x.py test --stage 0 src/test/ui`) - #77786 (Mention rustdoc in `x.py setup`) - #77825 (`min_const_generics` diagnostics improvements) - #77868 (Include `llvm-dis`, `llc` and `opt` in `llvm-tools-preview` component) - #77884 (Use Option::unwrap_or instead of open-coding it) - #77886 (Replace trivial bool matches with the `matches!` macro) - #77892 (Replace absolute paths with relative ones) - #77895 (Include aarch64-apple-darwin in the dist manifests) - #77909 (bootstrap: set correct path for the build-manifest binary) Failed merges: - #77902 (Include aarch64-pc-windows-msvc in the dist manifests) r? `@ghost`
This commit is contained in:
commit
f243a2ad90
107 changed files with 426 additions and 359 deletions
68
.github/ISSUE_TEMPLATE/regression.md
vendored
Normal file
68
.github/ISSUE_TEMPLATE/regression.md
vendored
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
---
|
||||||
|
name: Regression
|
||||||
|
about: Report something that unexpectedly changed between Rust versions.
|
||||||
|
labels: C-bug regression-untriaged
|
||||||
|
---
|
||||||
|
<!--
|
||||||
|
Thank you for filing a regression report! 🐛 A regression is something that changed between versions of Rust but was not supposed to.
|
||||||
|
|
||||||
|
Please provide a short summary of the regression, along with any information you feel is relevant to replicate it.
|
||||||
|
-->
|
||||||
|
|
||||||
|
### Code
|
||||||
|
|
||||||
|
I tried this code:
|
||||||
|
|
||||||
|
```rust
|
||||||
|
<code>
|
||||||
|
```
|
||||||
|
|
||||||
|
I expected to see this happen: *explanation*
|
||||||
|
|
||||||
|
Instead, this happened: *explanation*
|
||||||
|
|
||||||
|
### Version it worked on
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Provide the most recent version this worked on, for example:
|
||||||
|
|
||||||
|
It most recently worked on: Rust 1.47
|
||||||
|
-->
|
||||||
|
|
||||||
|
It most recently worked on: <!-- version -->
|
||||||
|
|
||||||
|
### Version with regression
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Provide the version you are using that has the regression.
|
||||||
|
-->
|
||||||
|
|
||||||
|
`rustc --version --verbose`:
|
||||||
|
```
|
||||||
|
<version>
|
||||||
|
```
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Did the compiler crash? If so, please provide a backtrace.
|
||||||
|
-->
|
||||||
|
|
||||||
|
### Backtrace
|
||||||
|
<!--
|
||||||
|
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
|
||||||
|
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
|
||||||
|
-->
|
||||||
|
<details><summary>Backtrace</summary>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
```
|
||||||
|
<backtrace>
|
||||||
|
```
|
||||||
|
|
||||||
|
</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
If you know when this regression occurred, please add a line like below, replacing `{channel}` with one of stable, beta, or nightly.
|
||||||
|
|
||||||
|
@rustbot modify labels: +regression-from-stable-to-{channel} -regression-untriaged
|
||||||
|
-->
|
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
@ -306,7 +306,7 @@ jobs:
|
||||||
- name: dist-aarch64-apple
|
- name: dist-aarch64-apple
|
||||||
env:
|
env:
|
||||||
SCRIPT: "./x.py dist --stage 2"
|
SCRIPT: "./x.py dist --stage 2"
|
||||||
RUST_CONFIGURE_ARGS: "--build=x86_64-apple-darwin --host=aarch64-apple-darwin --target=aarch64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false --tools=rls,clippy,rustfmt,analysis,src"
|
RUST_CONFIGURE_ARGS: "--build=x86_64-apple-darwin --host=aarch64-apple-darwin --target=aarch64-apple-darwin --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false"
|
||||||
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
|
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
|
||||||
SELECT_XCODE: /Applications/Xcode_12_beta.app
|
SELECT_XCODE: /Applications/Xcode_12_beta.app
|
||||||
USE_XCODE_CLANG: 1
|
USE_XCODE_CLANG: 1
|
||||||
|
@ -314,6 +314,8 @@ jobs:
|
||||||
MACOSX_STD_DEPLOYMENT_TARGET: 11.0
|
MACOSX_STD_DEPLOYMENT_TARGET: 11.0
|
||||||
NO_LLVM_ASSERTIONS: 1
|
NO_LLVM_ASSERTIONS: 1
|
||||||
NO_DEBUG_ASSERTIONS: 1
|
NO_DEBUG_ASSERTIONS: 1
|
||||||
|
DIST_REQUIRE_ALL_TOOLS: 1
|
||||||
|
JEMALLOC_SYS_WITH_LG_PAGE: 14
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
- name: x86_64-msvc-1
|
- name: x86_64-msvc-1
|
||||||
env:
|
env:
|
||||||
|
|
|
@ -2192,9 +2192,9 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl-src"
|
name = "openssl-src"
|
||||||
version = "111.10.2+1.1.1g"
|
version = "111.12.0+1.1.1h"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a287fdb22e32b5b60624d4a5a7a02dbe82777f730ec0dbc42a0554326fef5a70"
|
checksum = "858a4132194f8570a7ee9eb8629e85b23cbc4565f2d4a162e87556e5956abf61"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
]
|
]
|
||||||
|
|
|
@ -170,17 +170,11 @@ pub enum Token {
|
||||||
|
|
||||||
impl Token {
|
impl Token {
|
||||||
crate fn is_eof(&self) -> bool {
|
crate fn is_eof(&self) -> bool {
|
||||||
match *self {
|
matches!(self, Token::Eof)
|
||||||
Token::Eof => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_hardbreak_tok(&self) -> bool {
|
pub fn is_hardbreak_tok(&self) -> bool {
|
||||||
match *self {
|
matches!(self, Token::Break(BreakToken { offset: 0, blank_space: SIZE_INFINITY }))
|
||||||
Token::Break(BreakToken { offset: 0, blank_space: bs }) if bs == SIZE_INFINITY => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,12 +485,9 @@ impl Printer {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_top(&mut self) -> PrintStackElem {
|
fn get_top(&mut self) -> PrintStackElem {
|
||||||
match self.print_stack.last() {
|
*self.print_stack.last().unwrap_or({
|
||||||
Some(el) => *el,
|
&PrintStackElem { offset: 0, pbreak: PrintStackBreak::Broken(Breaks::Inconsistent) }
|
||||||
None => {
|
})
|
||||||
PrintStackElem { offset: 0, pbreak: PrintStackBreak::Broken(Breaks::Inconsistent) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_begin(&mut self, b: BeginToken, l: isize) {
|
fn print_begin(&mut self, b: BeginToken, l: isize) {
|
||||||
|
|
|
@ -122,7 +122,7 @@ unsafe fn configure_llvm(sess: &Session) {
|
||||||
|
|
||||||
llvm::LLVMInitializePasses();
|
llvm::LLVMInitializePasses();
|
||||||
|
|
||||||
::rustc_llvm::initialize_available_targets();
|
rustc_llvm::initialize_available_targets();
|
||||||
|
|
||||||
llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int, llvm_args.as_ptr());
|
llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int, llvm_args.as_ptr());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1175,7 +1175,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
||||||
// necessary. There's already optimizations in place to avoid sending work
|
// necessary. There's already optimizations in place to avoid sending work
|
||||||
// back to the coordinator if LTO isn't requested.
|
// back to the coordinator if LTO isn't requested.
|
||||||
return thread::spawn(move || {
|
return thread::spawn(move || {
|
||||||
let max_workers = ::num_cpus::get();
|
let max_workers = num_cpus::get();
|
||||||
let mut worker_id_counter = 0;
|
let mut worker_id_counter = 0;
|
||||||
let mut free_worker_ids = Vec::new();
|
let mut free_worker_ids = Vec::new();
|
||||||
let mut get_worker_id = |free_worker_ids: &mut Vec<usize>| {
|
let mut get_worker_id = |free_worker_ids: &mut Vec<usize>| {
|
||||||
|
|
|
@ -695,7 +695,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
||||||
total_codegen_time.into_inner(),
|
total_codegen_time.into_inner(),
|
||||||
);
|
);
|
||||||
|
|
||||||
::rustc_incremental::assert_module_sources::assert_module_sources(tcx);
|
rustc_incremental::assert_module_sources::assert_module_sources(tcx);
|
||||||
|
|
||||||
symbol_names_test::report_symbol_names(tcx);
|
symbol_names_test::report_symbol_names(tcx);
|
||||||
|
|
||||||
|
@ -754,8 +754,8 @@ impl<B: ExtraBackendMethods> Drop for AbortCodegenOnDrop<B> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn finalize_tcx(tcx: TyCtxt<'_>) {
|
fn finalize_tcx(tcx: TyCtxt<'_>) {
|
||||||
tcx.sess.time("assert_dep_graph", || ::rustc_incremental::assert_dep_graph(tcx));
|
tcx.sess.time("assert_dep_graph", || rustc_incremental::assert_dep_graph(tcx));
|
||||||
tcx.sess.time("serialize_dep_graph", || ::rustc_incremental::save_dep_graph(tcx));
|
tcx.sess.time("serialize_dep_graph", || rustc_incremental::save_dep_graph(tcx));
|
||||||
|
|
||||||
// We assume that no queries are run past here. If there are new queries
|
// We assume that no queries are run past here. If there are new queries
|
||||||
// after this point, they'll show up as "<unknown>" in self-profiling data.
|
// after this point, they'll show up as "<unknown>" in self-profiling data.
|
||||||
|
|
|
@ -85,7 +85,7 @@ impl<'tcx, T> CodegenMethods<'tcx> for T where
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait HasCodegen<'tcx>:
|
pub trait HasCodegen<'tcx>:
|
||||||
Backend<'tcx> + ::std::ops::Deref<Target = <Self as HasCodegen<'tcx>>::CodegenCx>
|
Backend<'tcx> + std::ops::Deref<Target = <Self as HasCodegen<'tcx>>::CodegenCx>
|
||||||
{
|
{
|
||||||
type CodegenCx: CodegenMethods<'tcx>
|
type CodegenCx: CodegenMethods<'tcx>
|
||||||
+ BackendTypes<
|
+ BackendTypes<
|
||||||
|
|
|
@ -71,8 +71,8 @@ impl Fingerprint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::fmt::Display for Fingerprint {
|
impl std::fmt::Display for Fingerprint {
|
||||||
fn fmt(&self, formatter: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(formatter, "{:x}-{:x}", self.0, self.1)
|
write!(formatter, "{:x}-{:x}", self.0, self.1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ pub enum ProcessResult<O, E> {
|
||||||
struct ObligationTreeId(usize);
|
struct ObligationTreeId(usize);
|
||||||
|
|
||||||
type ObligationTreeIdGenerator =
|
type ObligationTreeIdGenerator =
|
||||||
::std::iter::Map<::std::ops::RangeFrom<usize>, fn(usize) -> ObligationTreeId>;
|
std::iter::Map<std::ops::RangeFrom<usize>, fn(usize) -> ObligationTreeId>;
|
||||||
|
|
||||||
pub struct ObligationForest<O: ForestObligation> {
|
pub struct ObligationForest<O: ForestObligation> {
|
||||||
/// The list of obligations. In between calls to `process_obligations`,
|
/// The list of obligations. In between calls to `process_obligations`,
|
||||||
|
|
|
@ -93,7 +93,7 @@ impl<K: Ord, V> SortedMap<K, V> {
|
||||||
|
|
||||||
/// Iterate over elements, sorted by key
|
/// Iterate over elements, sorted by key
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn iter(&self) -> ::std::slice::Iter<'_, (K, V)> {
|
pub fn iter(&self) -> std::slice::Iter<'_, (K, V)> {
|
||||||
self.data.iter()
|
self.data.iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ impl<K: Ord, V> SortedMap<K, V> {
|
||||||
R: RangeBounds<K>,
|
R: RangeBounds<K>,
|
||||||
{
|
{
|
||||||
let (start, end) = self.range_slice_indices(range);
|
let (start, end) = self.range_slice_indices(range);
|
||||||
self.data.splice(start..end, ::std::iter::empty());
|
self.data.splice(start..end, std::iter::empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mutate all keys with the given function `f`. This mutation must not
|
/// Mutate all keys with the given function `f`. This mutation must not
|
||||||
|
@ -241,7 +241,7 @@ impl<K: Ord, V> SortedMap<K, V> {
|
||||||
|
|
||||||
impl<K: Ord, V> IntoIterator for SortedMap<K, V> {
|
impl<K: Ord, V> IntoIterator for SortedMap<K, V> {
|
||||||
type Item = (K, V);
|
type Item = (K, V);
|
||||||
type IntoIter = ::std::vec::IntoIter<(K, V)>;
|
type IntoIter = std::vec::IntoIter<(K, V)>;
|
||||||
|
|
||||||
fn into_iter(self) -> Self::IntoIter {
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
self.data.into_iter()
|
self.data.into_iter()
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub struct StableHasher {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::fmt::Debug for StableHasher {
|
impl ::std::fmt::Debug for StableHasher {
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "{:?}", self.state)
|
write!(f, "{:?}", self.state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ impl DefKey {
|
||||||
|
|
||||||
let DisambiguatedDefPathData { ref data, disambiguator } = self.disambiguated_data;
|
let DisambiguatedDefPathData { ref data, disambiguator } = self.disambiguated_data;
|
||||||
|
|
||||||
::std::mem::discriminant(data).hash(&mut hasher);
|
std::mem::discriminant(data).hash(&mut hasher);
|
||||||
if let Some(name) = data.get_opt_name() {
|
if let Some(name) = data.get_opt_name() {
|
||||||
// Get a stable hash by considering the symbol chars rather than
|
// Get a stable hash by considering the symbol chars rather than
|
||||||
// the symbol index.
|
// the symbol index.
|
||||||
|
|
|
@ -341,7 +341,7 @@ where
|
||||||
// been fully instantiated and hence the set of scopes we have
|
// been fully instantiated and hence the set of scopes we have
|
||||||
// doesn't matter -- just to be sure, put an empty vector
|
// doesn't matter -- just to be sure, put an empty vector
|
||||||
// in there.
|
// in there.
|
||||||
let old_a_scopes = ::std::mem::take(pair.vid_scopes(self));
|
let old_a_scopes = std::mem::take(pair.vid_scopes(self));
|
||||||
|
|
||||||
// Relate the generalized kind to the original one.
|
// Relate the generalized kind to the original one.
|
||||||
let result = pair.relate_generalized_ty(self, generalized_ty);
|
let result = pair.relate_generalized_ty(self, generalized_ty);
|
||||||
|
@ -680,7 +680,7 @@ where
|
||||||
// itself occurs. Note that `'b` and `'c` must both
|
// itself occurs. Note that `'b` and `'c` must both
|
||||||
// include P. At the point, the call works because of
|
// include P. At the point, the call works because of
|
||||||
// subtyping (i.e., `&'b u32 <: &{P} u32`).
|
// subtyping (i.e., `&'b u32 <: &{P} u32`).
|
||||||
let variance = ::std::mem::replace(&mut self.ambient_variance, ty::Variance::Covariant);
|
let variance = std::mem::replace(&mut self.ambient_variance, ty::Variance::Covariant);
|
||||||
|
|
||||||
self.relate(a.skip_binder(), b.skip_binder())?;
|
self.relate(a.skip_binder(), b.skip_binder())?;
|
||||||
|
|
||||||
|
@ -709,7 +709,7 @@ where
|
||||||
// Reset ambient variance to contravariance. See the
|
// Reset ambient variance to contravariance. See the
|
||||||
// covariant case above for an explanation.
|
// covariant case above for an explanation.
|
||||||
let variance =
|
let variance =
|
||||||
::std::mem::replace(&mut self.ambient_variance, ty::Variance::Contravariant);
|
std::mem::replace(&mut self.ambient_variance, ty::Variance::Contravariant);
|
||||||
|
|
||||||
self.relate(a.skip_binder(), b.skip_binder())?;
|
self.relate(a.skip_binder(), b.skip_binder())?;
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
||||||
|
|
||||||
/// Trait queries just want to pass back type obligations "as is"
|
/// Trait queries just want to pass back type obligations "as is"
|
||||||
pub fn take_registered_region_obligations(&self) -> Vec<(hir::HirId, RegionObligation<'tcx>)> {
|
pub fn take_registered_region_obligations(&self) -> Vec<(hir::HirId, RegionObligation<'tcx>)> {
|
||||||
::std::mem::take(&mut self.inner.borrow_mut().region_obligations)
|
std::mem::take(&mut self.inner.borrow_mut().region_obligations)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Process the region obligations that must be proven (during
|
/// Process the region obligations that must be proven (during
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::ich::StableHashingContext;
|
||||||
|
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||||
use rustc_span::SourceFile;
|
use rustc_span::{BytePos, NormalizedPos, SourceFile};
|
||||||
|
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
|
@ -102,22 +102,19 @@ impl<'a> HashStable<StableHashingContext<'a>> for SourceFile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stable_byte_pos(pos: ::rustc_span::BytePos, source_file_start: ::rustc_span::BytePos) -> u32 {
|
fn stable_byte_pos(pos: BytePos, source_file_start: BytePos) -> u32 {
|
||||||
pos.0 - source_file_start.0
|
pos.0 - source_file_start.0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stable_multibyte_char(
|
fn stable_multibyte_char(mbc: rustc_span::MultiByteChar, source_file_start: BytePos) -> (u32, u32) {
|
||||||
mbc: ::rustc_span::MultiByteChar,
|
let rustc_span::MultiByteChar { pos, bytes } = mbc;
|
||||||
source_file_start: ::rustc_span::BytePos,
|
|
||||||
) -> (u32, u32) {
|
|
||||||
let ::rustc_span::MultiByteChar { pos, bytes } = mbc;
|
|
||||||
|
|
||||||
(pos.0 - source_file_start.0, bytes as u32)
|
(pos.0 - source_file_start.0, bytes as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stable_non_narrow_char(
|
fn stable_non_narrow_char(
|
||||||
swc: ::rustc_span::NonNarrowChar,
|
swc: rustc_span::NonNarrowChar,
|
||||||
source_file_start: ::rustc_span::BytePos,
|
source_file_start: BytePos,
|
||||||
) -> (u32, u32) {
|
) -> (u32, u32) {
|
||||||
let pos = swc.pos();
|
let pos = swc.pos();
|
||||||
let width = swc.width();
|
let width = swc.width();
|
||||||
|
@ -125,11 +122,8 @@ fn stable_non_narrow_char(
|
||||||
(pos.0 - source_file_start.0, width as u32)
|
(pos.0 - source_file_start.0, width as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stable_normalized_pos(
|
fn stable_normalized_pos(np: NormalizedPos, source_file_start: BytePos) -> (u32, u32) {
|
||||||
np: ::rustc_span::NormalizedPos,
|
let NormalizedPos { pos, diff } = np;
|
||||||
source_file_start: ::rustc_span::BytePos,
|
|
||||||
) -> (u32, u32) {
|
|
||||||
let ::rustc_span::NormalizedPos { pos, diff } = np;
|
|
||||||
|
|
||||||
(pos.0 - source_file_start.0, diff)
|
(pos.0 - source_file_start.0, diff)
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ pub struct Allocation<Tag = (), Extra = ()> {
|
||||||
pub extra: Extra,
|
pub extra: Extra,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait AllocationExtra<Tag>: ::std::fmt::Debug + Clone {
|
pub trait AllocationExtra<Tag>: std::fmt::Debug + Clone {
|
||||||
// There is no constructor in here because the constructor's type depends
|
// There is no constructor in here because the constructor's type depends
|
||||||
// on `MemoryKind`, and making things sufficiently generic leads to painful
|
// on `MemoryKind`, and making things sufficiently generic leads to painful
|
||||||
// inference failure.
|
// inference failure.
|
||||||
|
|
|
@ -58,7 +58,7 @@ impl<'tcx> ConstValue<'tcx> {
|
||||||
|
|
||||||
pub fn try_to_str_slice(&self) -> Option<&'tcx str> {
|
pub fn try_to_str_slice(&self) -> Option<&'tcx str> {
|
||||||
if let ConstValue::Slice { data, start, end } = *self {
|
if let ConstValue::Slice { data, start, end } = *self {
|
||||||
::std::str::from_utf8(data.inspect_with_uninit_and_ptr_outside_interpreter(start..end))
|
std::str::from_utf8(data.inspect_with_uninit_and_ptr_outside_interpreter(start..end))
|
||||||
.ok()
|
.ok()
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -465,7 +465,7 @@ impl<'tcx, Tag> Scalar<Tag> {
|
||||||
|
|
||||||
pub fn to_char(self) -> InterpResult<'tcx, char> {
|
pub fn to_char(self) -> InterpResult<'tcx, char> {
|
||||||
let val = self.to_u32()?;
|
let val = self.to_u32()?;
|
||||||
match ::std::char::from_u32(val) {
|
match std::char::from_u32(val) {
|
||||||
Some(c) => Ok(c),
|
Some(c) => Ok(c),
|
||||||
None => throw_ub!(InvalidChar(val)),
|
None => throw_ub!(InvalidChar(val)),
|
||||||
}
|
}
|
||||||
|
|
|
@ -775,7 +775,7 @@ mod binding_form_impl {
|
||||||
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for super::BindingForm<'tcx> {
|
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for super::BindingForm<'tcx> {
|
||||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
||||||
use super::BindingForm::*;
|
use super::BindingForm::*;
|
||||||
::std::mem::discriminant(self).hash_stable(hcx, hasher);
|
std::mem::discriminant(self).hash_stable(hcx, hasher);
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
Var(binding) => binding.hash_stable(hcx, hasher),
|
Var(binding) => binding.hash_stable(hcx, hasher),
|
||||||
|
|
|
@ -1894,7 +1894,7 @@ impl<'tcx, T: HasTyCtxt<'tcx>> HasTyCtxt<'tcx> for LayoutCx<'tcx, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type TyAndLayout<'tcx> = ::rustc_target::abi::TyAndLayout<'tcx, Ty<'tcx>>;
|
pub type TyAndLayout<'tcx> = rustc_target::abi::TyAndLayout<'tcx, Ty<'tcx>>;
|
||||||
|
|
||||||
impl<'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'tcx>> {
|
impl<'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||||
type Ty = Ty<'tcx>;
|
type Ty = Ty<'tcx>;
|
||||||
|
|
|
@ -23,7 +23,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
{
|
{
|
||||||
debug!(
|
debug!(
|
||||||
"normalize_erasing_regions::<{}>(value={:?}, param_env={:?})",
|
"normalize_erasing_regions::<{}>(value={:?}, param_env={:?})",
|
||||||
::std::any::type_name::<T>(),
|
std::any::type_name::<T>(),
|
||||||
value,
|
value,
|
||||||
param_env,
|
param_env,
|
||||||
);
|
);
|
||||||
|
|
|
@ -1142,7 +1142,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
// relocations (we have an active `str` reference here). We don't use this
|
// relocations (we have an active `str` reference here). We don't use this
|
||||||
// result to affect interpreter execution.
|
// result to affect interpreter execution.
|
||||||
let slice = data.inspect_with_uninit_and_ptr_outside_interpreter(start..end);
|
let slice = data.inspect_with_uninit_and_ptr_outside_interpreter(start..end);
|
||||||
let s = ::std::str::from_utf8(slice).expect("non utf8 str from miri");
|
let s = std::str::from_utf8(slice).expect("non utf8 str from miri");
|
||||||
p!(write("{:?}", s));
|
p!(write("{:?}", s));
|
||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
|
|
|
@ -543,7 +543,7 @@ impl<'a, 'tcx> DecoderWithPosition for CacheDecoder<'a, 'tcx> {
|
||||||
// tag matches and the correct amount of bytes was read.
|
// tag matches and the correct amount of bytes was read.
|
||||||
fn decode_tagged<D, T, V>(decoder: &mut D, expected_tag: T) -> Result<V, D::Error>
|
fn decode_tagged<D, T, V>(decoder: &mut D, expected_tag: T) -> Result<V, D::Error>
|
||||||
where
|
where
|
||||||
T: Decodable<D> + Eq + ::std::fmt::Debug,
|
T: Decodable<D> + Eq + std::fmt::Debug,
|
||||||
V: Decodable<D>,
|
V: Decodable<D>,
|
||||||
D: DecoderWithPosition,
|
D: DecoderWithPosition,
|
||||||
{
|
{
|
||||||
|
@ -1023,7 +1023,7 @@ where
|
||||||
let _timer = tcx
|
let _timer = tcx
|
||||||
.sess
|
.sess
|
||||||
.prof
|
.prof
|
||||||
.extra_verbose_generic_activity("encode_query_results_for", ::std::any::type_name::<Q>());
|
.extra_verbose_generic_activity("encode_query_results_for", std::any::type_name::<Q>());
|
||||||
|
|
||||||
let state = Q::query_state(tcx);
|
let state = Q::query_state(tcx);
|
||||||
assert!(state.all_inactive());
|
assert!(state.all_inactive());
|
||||||
|
|
|
@ -646,8 +646,8 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||||
}
|
}
|
||||||
ty::Char => Some(std::char::MAX as u128),
|
ty::Char => Some(std::char::MAX as u128),
|
||||||
ty::Float(fty) => Some(match fty {
|
ty::Float(fty) => Some(match fty {
|
||||||
ast::FloatTy::F32 => ::rustc_apfloat::ieee::Single::INFINITY.to_bits(),
|
ast::FloatTy::F32 => rustc_apfloat::ieee::Single::INFINITY.to_bits(),
|
||||||
ast::FloatTy::F64 => ::rustc_apfloat::ieee::Double::INFINITY.to_bits(),
|
ast::FloatTy::F64 => rustc_apfloat::ieee::Double::INFINITY.to_bits(),
|
||||||
}),
|
}),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
//! interpreting common C functions leak into CTFE.
|
//! interpreting common C functions leak into CTFE.
|
||||||
|
|
||||||
use std::borrow::{Borrow, Cow};
|
use std::borrow::{Borrow, Cow};
|
||||||
|
use std::fmt::Debug;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
use rustc_middle::mir;
|
use rustc_middle::mir;
|
||||||
|
@ -79,19 +80,19 @@ pub trait AllocMap<K: Hash + Eq, V> {
|
||||||
/// and some use case dependent behaviour can instead be applied.
|
/// and some use case dependent behaviour can instead be applied.
|
||||||
pub trait Machine<'mir, 'tcx>: Sized {
|
pub trait Machine<'mir, 'tcx>: Sized {
|
||||||
/// Additional memory kinds a machine wishes to distinguish from the builtin ones
|
/// Additional memory kinds a machine wishes to distinguish from the builtin ones
|
||||||
type MemoryKind: ::std::fmt::Debug + ::std::fmt::Display + MayLeak + Eq + 'static;
|
type MemoryKind: Debug + std::fmt::Display + MayLeak + Eq + 'static;
|
||||||
|
|
||||||
/// Tag tracked alongside every pointer. This is used to implement "Stacked Borrows"
|
/// Tag tracked alongside every pointer. This is used to implement "Stacked Borrows"
|
||||||
/// <https://www.ralfj.de/blog/2018/08/07/stacked-borrows.html>.
|
/// <https://www.ralfj.de/blog/2018/08/07/stacked-borrows.html>.
|
||||||
/// The `default()` is used for pointers to consts, statics, vtables and functions.
|
/// The `default()` is used for pointers to consts, statics, vtables and functions.
|
||||||
/// The `Debug` formatting is used for displaying pointers; we cannot use `Display`
|
/// The `Debug` formatting is used for displaying pointers; we cannot use `Display`
|
||||||
/// as `()` does not implement that, but it should be "nice" output.
|
/// as `()` does not implement that, but it should be "nice" output.
|
||||||
type PointerTag: ::std::fmt::Debug + Copy + Eq + Hash + 'static;
|
type PointerTag: Debug + Copy + Eq + Hash + 'static;
|
||||||
|
|
||||||
/// Machines can define extra (non-instance) things that represent values of function pointers.
|
/// Machines can define extra (non-instance) things that represent values of function pointers.
|
||||||
/// For example, Miri uses this to return a function pointer from `dlsym`
|
/// For example, Miri uses this to return a function pointer from `dlsym`
|
||||||
/// that can later be called to execute the right thing.
|
/// that can later be called to execute the right thing.
|
||||||
type ExtraFnVal: ::std::fmt::Debug + Copy;
|
type ExtraFnVal: Debug + Copy;
|
||||||
|
|
||||||
/// Extra data stored in every call frame.
|
/// Extra data stored in every call frame.
|
||||||
type FrameExtra;
|
type FrameExtra;
|
||||||
|
|
|
@ -133,7 +133,7 @@ impl<Tag: Copy> std::fmt::Display for ImmTy<'tcx, Tag> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, Tag> ::std::ops::Deref for ImmTy<'tcx, Tag> {
|
impl<'tcx, Tag> std::ops::Deref for ImmTy<'tcx, Tag> {
|
||||||
type Target = Immediate<Tag>;
|
type Target = Immediate<Tag>;
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn deref(&self) -> &Immediate<Tag> {
|
fn deref(&self) -> &Immediate<Tag> {
|
||||||
|
@ -156,7 +156,7 @@ pub struct OpTy<'tcx, Tag = ()> {
|
||||||
pub layout: TyAndLayout<'tcx>,
|
pub layout: TyAndLayout<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, Tag> ::std::ops::Deref for OpTy<'tcx, Tag> {
|
impl<'tcx, Tag> std::ops::Deref for OpTy<'tcx, Tag> {
|
||||||
type Target = Operand<Tag>;
|
type Target = Operand<Tag>;
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn deref(&self) -> &Operand<Tag> {
|
fn deref(&self) -> &Operand<Tag> {
|
||||||
|
@ -340,7 +340,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
pub fn read_str(&self, mplace: MPlaceTy<'tcx, M::PointerTag>) -> InterpResult<'tcx, &str> {
|
pub fn read_str(&self, mplace: MPlaceTy<'tcx, M::PointerTag>) -> InterpResult<'tcx, &str> {
|
||||||
let len = mplace.len(self)?;
|
let len = mplace.len(self)?;
|
||||||
let bytes = self.memory.read_bytes(mplace.ptr, Size::from_bytes(len))?;
|
let bytes = self.memory.read_bytes(mplace.ptr, Size::from_bytes(len))?;
|
||||||
let str = ::std::str::from_utf8(bytes).map_err(|err| err_ub!(InvalidStr(err)))?;
|
let str = std::str::from_utf8(bytes).map_err(|err| err_ub!(InvalidStr(err)))?;
|
||||||
Ok(str)
|
Ok(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
//! All high-level functions to write to memory work on places as destinations.
|
//! All high-level functions to write to memory work on places as destinations.
|
||||||
|
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
use std::fmt::Debug;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
use rustc_macros::HashStable;
|
use rustc_macros::HashStable;
|
||||||
|
@ -86,7 +87,7 @@ pub struct PlaceTy<'tcx, Tag = ()> {
|
||||||
pub layout: TyAndLayout<'tcx>,
|
pub layout: TyAndLayout<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, Tag> ::std::ops::Deref for PlaceTy<'tcx, Tag> {
|
impl<'tcx, Tag> std::ops::Deref for PlaceTy<'tcx, Tag> {
|
||||||
type Target = Place<Tag>;
|
type Target = Place<Tag>;
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn deref(&self) -> &Place<Tag> {
|
fn deref(&self) -> &Place<Tag> {
|
||||||
|
@ -101,7 +102,7 @@ pub struct MPlaceTy<'tcx, Tag = ()> {
|
||||||
pub layout: TyAndLayout<'tcx>,
|
pub layout: TyAndLayout<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, Tag> ::std::ops::Deref for MPlaceTy<'tcx, Tag> {
|
impl<'tcx, Tag> std::ops::Deref for MPlaceTy<'tcx, Tag> {
|
||||||
type Target = MemPlace<Tag>;
|
type Target = MemPlace<Tag>;
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn deref(&self) -> &MemPlace<Tag> {
|
fn deref(&self) -> &MemPlace<Tag> {
|
||||||
|
@ -226,7 +227,7 @@ impl<'tcx, Tag> MPlaceTy<'tcx, Tag> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// These are defined here because they produce a place.
|
// These are defined here because they produce a place.
|
||||||
impl<'tcx, Tag: ::std::fmt::Debug + Copy> OpTy<'tcx, Tag> {
|
impl<'tcx, Tag: Debug + Copy> OpTy<'tcx, Tag> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
/// Note: do not call `as_ref` on the resulting place. This function should only be used to
|
/// Note: do not call `as_ref` on the resulting place. This function should only be used to
|
||||||
/// read from the resulting mplace, not to get its address back.
|
/// read from the resulting mplace, not to get its address back.
|
||||||
|
@ -251,7 +252,7 @@ impl<'tcx, Tag: ::std::fmt::Debug + Copy> OpTy<'tcx, Tag> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Tag: ::std::fmt::Debug> Place<Tag> {
|
impl<Tag: Debug> Place<Tag> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn assert_mem_place(self) -> MemPlace<Tag> {
|
pub fn assert_mem_place(self) -> MemPlace<Tag> {
|
||||||
match self {
|
match self {
|
||||||
|
@ -261,7 +262,7 @@ impl<Tag: ::std::fmt::Debug> Place<Tag> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, Tag: ::std::fmt::Debug> PlaceTy<'tcx, Tag> {
|
impl<'tcx, Tag: Debug> PlaceTy<'tcx, Tag> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn assert_mem_place(self) -> MPlaceTy<'tcx, Tag> {
|
pub fn assert_mem_place(self) -> MPlaceTy<'tcx, Tag> {
|
||||||
MPlaceTy { mplace: self.place.assert_mem_place(), layout: self.layout }
|
MPlaceTy { mplace: self.place.assert_mem_place(), layout: self.layout }
|
||||||
|
@ -272,7 +273,7 @@ impl<'tcx, Tag: ::std::fmt::Debug> PlaceTy<'tcx, Tag> {
|
||||||
impl<'mir, 'tcx: 'mir, Tag, M> InterpCx<'mir, 'tcx, M>
|
impl<'mir, 'tcx: 'mir, Tag, M> InterpCx<'mir, 'tcx, M>
|
||||||
where
|
where
|
||||||
// FIXME: Working around https://github.com/rust-lang/rust/issues/54385
|
// FIXME: Working around https://github.com/rust-lang/rust/issues/54385
|
||||||
Tag: ::std::fmt::Debug + Copy + Eq + Hash + 'static,
|
Tag: Debug + Copy + Eq + Hash + 'static,
|
||||||
M: Machine<'mir, 'tcx, PointerTag = Tag>,
|
M: Machine<'mir, 'tcx, PointerTag = Tag>,
|
||||||
// FIXME: Working around https://github.com/rust-lang/rust/issues/24159
|
// FIXME: Working around https://github.com/rust-lang/rust/issues/24159
|
||||||
M::MemoryMap: AllocMap<AllocId, (MemoryKind<M::MemoryKind>, Allocation<Tag, M::AllocExtra>)>,
|
M::MemoryMap: AllocMap<AllocId, (MemoryKind<M::MemoryKind>, Allocation<Tag, M::AllocExtra>)>,
|
||||||
|
|
|
@ -137,7 +137,7 @@ fn mir_keys(tcx: TyCtxt<'_>, krate: CrateNum) -> FxHashSet<LocalDefId> {
|
||||||
/// Generates a default name for the pass based on the name of the
|
/// Generates a default name for the pass based on the name of the
|
||||||
/// type `T`.
|
/// type `T`.
|
||||||
pub fn default_name<T: ?Sized>() -> Cow<'static, str> {
|
pub fn default_name<T: ?Sized>() -> Cow<'static, str> {
|
||||||
let name = ::std::any::type_name::<T>();
|
let name = std::any::type_name::<T>();
|
||||||
if let Some(tail) = name.rfind(':') { Cow::from(&name[tail + 1..]) } else { Cow::from(name) }
|
if let Some(tail) = name.rfind(':') { Cow::from(&name[tail + 1..]) } else { Cow::from(name) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,14 +96,14 @@ impl PatCtxt<'_, '_> {
|
||||||
}
|
}
|
||||||
PatternError::FloatBug => {
|
PatternError::FloatBug => {
|
||||||
// FIXME(#31407) this is only necessary because float parsing is buggy
|
// FIXME(#31407) this is only necessary because float parsing is buggy
|
||||||
::rustc_middle::mir::interpret::struct_error(
|
rustc_middle::mir::interpret::struct_error(
|
||||||
self.tcx.at(pat_span),
|
self.tcx.at(pat_span),
|
||||||
"could not evaluate float literal (see issue #31407)",
|
"could not evaluate float literal (see issue #31407)",
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
PatternError::NonConstPath(span) => {
|
PatternError::NonConstPath(span) => {
|
||||||
::rustc_middle::mir::interpret::struct_error(
|
rustc_middle::mir::interpret::struct_error(
|
||||||
self.tcx.at(span),
|
self.tcx.at(span),
|
||||||
"runtime values cannot be referenced in patterns",
|
"runtime values cannot be referenced in patterns",
|
||||||
)
|
)
|
||||||
|
|
|
@ -1060,13 +1060,13 @@ crate fn compare_const_vals<'tcx>(
|
||||||
use rustc_apfloat::Float;
|
use rustc_apfloat::Float;
|
||||||
return match *ty.kind() {
|
return match *ty.kind() {
|
||||||
ty::Float(ast::FloatTy::F32) => {
|
ty::Float(ast::FloatTy::F32) => {
|
||||||
let l = ::rustc_apfloat::ieee::Single::from_bits(a);
|
let l = rustc_apfloat::ieee::Single::from_bits(a);
|
||||||
let r = ::rustc_apfloat::ieee::Single::from_bits(b);
|
let r = rustc_apfloat::ieee::Single::from_bits(b);
|
||||||
l.partial_cmp(&r)
|
l.partial_cmp(&r)
|
||||||
}
|
}
|
||||||
ty::Float(ast::FloatTy::F64) => {
|
ty::Float(ast::FloatTy::F64) => {
|
||||||
let l = ::rustc_apfloat::ieee::Double::from_bits(a);
|
let l = rustc_apfloat::ieee::Double::from_bits(a);
|
||||||
let r = ::rustc_apfloat::ieee::Double::from_bits(b);
|
let r = rustc_apfloat::ieee::Double::from_bits(b);
|
||||||
l.partial_cmp(&r)
|
l.partial_cmp(&r)
|
||||||
}
|
}
|
||||||
ty::Int(ity) => {
|
ty::Int(ity) => {
|
||||||
|
|
|
@ -469,24 +469,17 @@ impl<'a> Resolver<'a> {
|
||||||
ResolutionError::ParamInNonTrivialAnonConst { name, is_type } => {
|
ResolutionError::ParamInNonTrivialAnonConst { name, is_type } => {
|
||||||
let mut err = self.session.struct_span_err(
|
let mut err = self.session.struct_span_err(
|
||||||
span,
|
span,
|
||||||
"generic parameters must not be used inside of non-trivial constant values",
|
"generic parameters may not be used in const operations",
|
||||||
);
|
|
||||||
err.span_label(
|
|
||||||
span,
|
|
||||||
&format!(
|
|
||||||
"non-trivial anonymous constants must not depend on the parameter `{}`",
|
|
||||||
name
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
err.span_label(span, &format!("cannot perform const operation using `{}`", name));
|
||||||
|
|
||||||
if is_type {
|
if is_type {
|
||||||
err.note("type parameters are currently not permitted in anonymous constants");
|
err.note("type parameters may not be used in const expressions");
|
||||||
} else {
|
} else {
|
||||||
err.help(
|
err.help(&format!(
|
||||||
&format!("it is currently only allowed to use either `{0}` or `{{ {0} }}` as generic constants",
|
"const parameters may only be used as standalone arguments, i.e. `{}`",
|
||||||
name
|
name
|
||||||
)
|
));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err
|
err
|
||||||
|
|
|
@ -218,7 +218,7 @@ enum ResolutionError<'a> {
|
||||||
ParamInTyOfConstParam(Symbol),
|
ParamInTyOfConstParam(Symbol),
|
||||||
/// constant values inside of type parameter defaults must not depend on generic parameters.
|
/// constant values inside of type parameter defaults must not depend on generic parameters.
|
||||||
ParamInAnonConstInTyDefault(Symbol),
|
ParamInAnonConstInTyDefault(Symbol),
|
||||||
/// generic parameters must not be used inside of non-trivial constant values.
|
/// generic parameters must not be used inside const evaluations.
|
||||||
///
|
///
|
||||||
/// This error is only emitted when using `min_const_generics`.
|
/// This error is only emitted when using `min_const_generics`.
|
||||||
ParamInNonTrivialAnonConst { name: Symbol, is_type: bool },
|
ParamInNonTrivialAnonConst { name: Symbol, is_type: bool },
|
||||||
|
|
|
@ -107,7 +107,7 @@ impl serialize::Encoder for Encoder {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn emit_i8(&mut self, v: i8) -> EncodeResult {
|
fn emit_i8(&mut self, v: i8) -> EncodeResult {
|
||||||
let as_u8: u8 = unsafe { ::std::mem::transmute(v) };
|
let as_u8: u8 = unsafe { std::mem::transmute(v) };
|
||||||
self.emit_u8(as_u8)
|
self.emit_u8(as_u8)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,13 +300,13 @@ impl<'a> serialize::Decoder for Decoder<'a> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_char(&mut self) -> Result<char, Self::Error> {
|
fn read_char(&mut self) -> Result<char, Self::Error> {
|
||||||
let bits = self.read_u32()?;
|
let bits = self.read_u32()?;
|
||||||
Ok(::std::char::from_u32(bits).unwrap())
|
Ok(std::char::from_u32(bits).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_str(&mut self) -> Result<Cow<'_, str>, Self::Error> {
|
fn read_str(&mut self) -> Result<Cow<'_, str>, Self::Error> {
|
||||||
let len = self.read_usize()?;
|
let len = self.read_usize()?;
|
||||||
let s = ::std::str::from_utf8(&self.data[self.position..self.position + len]).unwrap();
|
let s = std::str::from_utf8(&self.data[self.position..self.position + len]).unwrap();
|
||||||
self.position += len;
|
self.position += len;
|
||||||
Ok(Cow::Borrowed(s))
|
Ok(Cow::Borrowed(s))
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ impl SymbolMangler<'tcx> {
|
||||||
self.push("u");
|
self.push("u");
|
||||||
|
|
||||||
// FIXME(eddyb) we should probably roll our own punycode implementation.
|
// FIXME(eddyb) we should probably roll our own punycode implementation.
|
||||||
let mut punycode_bytes = match ::punycode::encode(ident) {
|
let mut punycode_bytes = match punycode::encode(ident) {
|
||||||
Ok(s) => s.into_bytes(),
|
Ok(s) => s.into_bytes(),
|
||||||
Err(()) => bug!("symbol_names: punycode encoding failed for ident {:?}", ident),
|
Err(()) => bug!("symbol_names: punycode encoding failed for ident {:?}", ident),
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,6 +22,7 @@ use rustc_middle::ty::{
|
||||||
use rustc_middle::ty::{TypeAndMut, TypeckResults};
|
use rustc_middle::ty::{TypeAndMut, TypeckResults};
|
||||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||||
use rustc_span::{MultiSpan, Span, DUMMY_SP};
|
use rustc_span::{MultiSpan, Span, DUMMY_SP};
|
||||||
|
use rustc_target::spec::abi;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use super::InferCtxtPrivExt;
|
use super::InferCtxtPrivExt;
|
||||||
|
@ -1157,15 +1158,15 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
tcx.mk_ty_infer(ty::TyVar(ty::TyVid { index: 0 })),
|
tcx.mk_ty_infer(ty::TyVar(ty::TyVid { index: 0 })),
|
||||||
false,
|
false,
|
||||||
hir::Unsafety::Normal,
|
hir::Unsafety::Normal,
|
||||||
::rustc_target::spec::abi::Abi::Rust,
|
abi::Abi::Rust,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
tcx.mk_fn_sig(
|
tcx.mk_fn_sig(
|
||||||
::std::iter::once(inputs),
|
std::iter::once(inputs),
|
||||||
tcx.mk_ty_infer(ty::TyVar(ty::TyVid { index: 0 })),
|
tcx.mk_ty_infer(ty::TyVar(ty::TyVid { index: 0 })),
|
||||||
false,
|
false,
|
||||||
hir::Unsafety::Normal,
|
hir::Unsafety::Normal,
|
||||||
::rustc_target::spec::abi::Abi::Rust,
|
abi::Abi::Rust,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
ty::Binder::bind(sig).to_string()
|
ty::Binder::bind(sig).to_string()
|
||||||
|
|
|
@ -44,7 +44,7 @@ impl<'cx, 'tcx> AtExt<'tcx> for At<'cx, 'tcx> {
|
||||||
{
|
{
|
||||||
debug!(
|
debug!(
|
||||||
"normalize::<{}>(value={:?}, param_env={:?})",
|
"normalize::<{}>(value={:?}, param_env={:?})",
|
||||||
::std::any::type_name::<T>(),
|
std::any::type_name::<T>(),
|
||||||
value,
|
value,
|
||||||
self.param_env,
|
self.param_env,
|
||||||
);
|
);
|
||||||
|
@ -65,13 +65,13 @@ impl<'cx, 'tcx> AtExt<'tcx> for At<'cx, 'tcx> {
|
||||||
let result = value.fold_with(&mut normalizer);
|
let result = value.fold_with(&mut normalizer);
|
||||||
debug!(
|
debug!(
|
||||||
"normalize::<{}>: result={:?} with {} obligations",
|
"normalize::<{}>: result={:?} with {} obligations",
|
||||||
::std::any::type_name::<T>(),
|
std::any::type_name::<T>(),
|
||||||
result,
|
result,
|
||||||
normalizer.obligations.len(),
|
normalizer.obligations.len(),
|
||||||
);
|
);
|
||||||
debug!(
|
debug!(
|
||||||
"normalize::<{}>: obligations={:?}",
|
"normalize::<{}>: obligations={:?}",
|
||||||
::std::any::type_name::<T>(),
|
std::any::type_name::<T>(),
|
||||||
normalizer.obligations,
|
normalizer.obligations,
|
||||||
);
|
);
|
||||||
if normalizer.error {
|
if normalizer.error {
|
||||||
|
|
|
@ -170,6 +170,22 @@ impl<K, V> Root<K, V> {
|
||||||
NodeRef { height: self.height, node: self.node.as_ptr(), _marker: PhantomData }
|
NodeRef { height: self.height, node: self.node.as_ptr(), _marker: PhantomData }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Borrows and returns a mutable reference to the leaf node owned by the root.
|
||||||
|
/// # Safety
|
||||||
|
/// The root node is a leaf.
|
||||||
|
unsafe fn leaf_node_as_mut(&mut self) -> NodeRef<marker::Mut<'_>, K, V, marker::Leaf> {
|
||||||
|
debug_assert!(self.height == 0);
|
||||||
|
NodeRef { height: self.height, node: self.node.as_ptr(), _marker: PhantomData }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Borrows and returns a mutable reference to the internal node owned by the root.
|
||||||
|
/// # Safety
|
||||||
|
/// The root node is not a leaf.
|
||||||
|
unsafe fn internal_node_as_mut(&mut self) -> NodeRef<marker::Mut<'_>, K, V, marker::Internal> {
|
||||||
|
debug_assert!(self.height > 0);
|
||||||
|
NodeRef { height: self.height, node: self.node.as_ptr(), _marker: PhantomData }
|
||||||
|
}
|
||||||
|
|
||||||
pub fn node_as_valmut(&mut self) -> NodeRef<marker::ValMut<'_>, K, V, marker::LeafOrInternal> {
|
pub fn node_as_valmut(&mut self) -> NodeRef<marker::ValMut<'_>, K, V, marker::LeafOrInternal> {
|
||||||
NodeRef { height: self.height, node: self.node.as_ptr(), _marker: PhantomData }
|
NodeRef { height: self.height, node: self.node.as_ptr(), _marker: PhantomData }
|
||||||
}
|
}
|
||||||
|
@ -188,14 +204,11 @@ impl<K, V> Root<K, V> {
|
||||||
self.node = BoxedNode::from_internal(new_node);
|
self.node = BoxedNode::from_internal(new_node);
|
||||||
self.height += 1;
|
self.height += 1;
|
||||||
|
|
||||||
let mut ret =
|
|
||||||
NodeRef { height: self.height, node: self.node.as_ptr(), _marker: PhantomData };
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
let mut ret = self.internal_node_as_mut();
|
||||||
ret.reborrow_mut().first_edge().correct_parent_link();
|
ret.reborrow_mut().first_edge().correct_parent_link();
|
||||||
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
ret
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes the internal root node, using its first child as the new root node.
|
/// Removes the internal root node, using its first child as the new root node.
|
||||||
|
@ -212,11 +225,8 @@ impl<K, V> Root<K, V> {
|
||||||
|
|
||||||
let top = self.node.ptr;
|
let top = self.node.ptr;
|
||||||
|
|
||||||
self.node = unsafe {
|
let internal_node = unsafe { self.internal_node_as_mut() };
|
||||||
BoxedNode::from_ptr(
|
self.node = unsafe { BoxedNode::from_ptr(internal_node.first_edge().descend().node) };
|
||||||
self.node_as_mut().cast_unchecked::<marker::Internal>().first_edge().descend().node,
|
|
||||||
)
|
|
||||||
};
|
|
||||||
self.height -= 1;
|
self.height -= 1;
|
||||||
self.node_as_mut().as_leaf_mut().parent = None;
|
self.node_as_mut().as_leaf_mut().parent = None;
|
||||||
|
|
||||||
|
@ -443,9 +453,9 @@ impl<K, V> NodeRef<marker::Owned, K, V, marker::LeafOrInternal> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
|
impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
|
||||||
/// Unsafely asserts to the compiler some static information about whether this
|
/// Unsafely asserts to the compiler the static information that this node is an `Internal`.
|
||||||
/// node is a `Leaf` or an `Internal`.
|
unsafe fn cast_to_internal_unchecked(self) -> NodeRef<marker::Mut<'a>, K, V, marker::Internal> {
|
||||||
unsafe fn cast_unchecked<NewType>(self) -> NodeRef<marker::Mut<'a>, K, V, NewType> {
|
debug_assert!(self.height > 0);
|
||||||
NodeRef { height: self.height, node: self.node, _marker: PhantomData }
|
NodeRef { height: self.height, node: self.node, _marker: PhantomData }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -943,10 +953,7 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, mark
|
||||||
Handle::new_edge(left.reborrow_mut(), insert_idx)
|
Handle::new_edge(left.reborrow_mut(), insert_idx)
|
||||||
},
|
},
|
||||||
InsertionPlace::Right(insert_idx) => unsafe {
|
InsertionPlace::Right(insert_idx) => unsafe {
|
||||||
Handle::new_edge(
|
Handle::new_edge(right.leaf_node_as_mut(), insert_idx)
|
||||||
right.node_as_mut().cast_unchecked::<marker::Leaf>(),
|
|
||||||
insert_idx,
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let val_ptr = insertion_edge.insert_fit(key, val);
|
let val_ptr = insertion_edge.insert_fit(key, val);
|
||||||
|
@ -1006,10 +1013,7 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>,
|
||||||
Handle::new_edge(left.reborrow_mut(), insert_idx)
|
Handle::new_edge(left.reborrow_mut(), insert_idx)
|
||||||
},
|
},
|
||||||
InsertionPlace::Right(insert_idx) => unsafe {
|
InsertionPlace::Right(insert_idx) => unsafe {
|
||||||
Handle::new_edge(
|
Handle::new_edge(right.internal_node_as_mut(), insert_idx)
|
||||||
right.node_as_mut().cast_unchecked::<marker::Internal>(),
|
|
||||||
insert_idx,
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
insertion_edge.insert_fit(key, val, edge);
|
insertion_edge.insert_fit(key, val, edge);
|
||||||
|
@ -1205,7 +1209,7 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>,
|
||||||
|
|
||||||
let mut new_root = Root { node: BoxedNode::from_internal(new_node), height };
|
let mut new_root = Root { node: BoxedNode::from_internal(new_node), height };
|
||||||
|
|
||||||
new_root.node_as_mut().cast_unchecked().correct_childrens_parent_links(0..=new_len);
|
new_root.internal_node_as_mut().correct_childrens_parent_links(0..=new_len);
|
||||||
|
|
||||||
(self.node, k, v, new_root)
|
(self.node, k, v, new_root)
|
||||||
}
|
}
|
||||||
|
@ -1258,8 +1262,8 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>,
|
||||||
if self.node.height > 1 {
|
if self.node.height > 1 {
|
||||||
// SAFETY: the height of the nodes being merged is one below the height
|
// SAFETY: the height of the nodes being merged is one below the height
|
||||||
// of the node of this edge, thus above zero, so they are internal.
|
// of the node of this edge, thus above zero, so they are internal.
|
||||||
let mut left_node = left_node.cast_unchecked::<marker::Internal>();
|
let mut left_node = left_node.cast_to_internal_unchecked();
|
||||||
let right_node = right_node.cast_unchecked::<marker::Internal>();
|
let right_node = right_node.cast_to_internal_unchecked();
|
||||||
ptr::copy_nonoverlapping(
|
ptr::copy_nonoverlapping(
|
||||||
right_node.edge_at(0),
|
right_node.edge_at(0),
|
||||||
left_node.edges_mut().as_mut_ptr().add(left_len + 1),
|
left_node.edges_mut().as_mut_ptr().add(left_len + 1),
|
||||||
|
|
|
@ -204,8 +204,8 @@ macro_rules! int_module {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_from_str() {
|
fn test_from_str() {
|
||||||
fn from_str<T: ::std::str::FromStr>(t: &str) -> Option<T> {
|
fn from_str<T: std::str::FromStr>(t: &str) -> Option<T> {
|
||||||
::std::str::FromStr::from_str(t).ok()
|
std::str::FromStr::from_str(t).ok()
|
||||||
}
|
}
|
||||||
assert_eq!(from_str::<$T>("0"), Some(0 as $T));
|
assert_eq!(from_str::<$T>("0"), Some(0 as $T));
|
||||||
assert_eq!(from_str::<$T>("3"), Some(3 as $T));
|
assert_eq!(from_str::<$T>("3"), Some(3 as $T));
|
||||||
|
|
|
@ -39,10 +39,13 @@ pub fn hashmap_random_keys() -> (u64, u64) {
|
||||||
pub enum Void {}
|
pub enum Void {}
|
||||||
|
|
||||||
pub unsafe fn strlen(mut s: *const c_char) -> usize {
|
pub unsafe fn strlen(mut s: *const c_char) -> usize {
|
||||||
let mut n = 0;
|
// SAFETY: The caller must guarantee `s` points to a valid 0-terminated string.
|
||||||
while *s != 0 {
|
unsafe {
|
||||||
n += 1;
|
let mut n = 0;
|
||||||
s = s.offset(1);
|
while *s != 0 {
|
||||||
|
n += 1;
|
||||||
|
s = s.offset(1);
|
||||||
|
}
|
||||||
|
n
|
||||||
}
|
}
|
||||||
return n;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(unsafe_op_in_unsafe_fn)]
|
||||||
|
|
||||||
pub mod alloc;
|
pub mod alloc;
|
||||||
pub mod args;
|
pub mod args;
|
||||||
pub mod cmath;
|
pub mod cmath;
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
use crate::cell::UnsafeCell;
|
use crate::cell::Cell;
|
||||||
|
|
||||||
pub struct Mutex {
|
pub struct Mutex {
|
||||||
locked: UnsafeCell<bool>,
|
// This platform has no threads, so we can use a Cell here.
|
||||||
|
locked: Cell<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type MovableMutex = Mutex;
|
pub type MovableMutex = Mutex;
|
||||||
|
@ -10,9 +11,8 @@ unsafe impl Send for Mutex {}
|
||||||
unsafe impl Sync for Mutex {} // no threads on this platform
|
unsafe impl Sync for Mutex {} // no threads on this platform
|
||||||
|
|
||||||
impl Mutex {
|
impl Mutex {
|
||||||
#[rustc_const_stable(feature = "const_sys_mutex_new", since = "1.0.0")]
|
|
||||||
pub const fn new() -> Mutex {
|
pub const fn new() -> Mutex {
|
||||||
Mutex { locked: UnsafeCell::new(false) }
|
Mutex { locked: Cell::new(false) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -20,25 +20,17 @@ impl Mutex {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn lock(&self) {
|
pub unsafe fn lock(&self) {
|
||||||
let locked = self.locked.get();
|
assert_eq!(self.locked.replace(true), false, "cannot recursively acquire mutex");
|
||||||
assert!(!*locked, "cannot recursively acquire mutex");
|
|
||||||
*locked = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn unlock(&self) {
|
pub unsafe fn unlock(&self) {
|
||||||
*self.locked.get() = false;
|
self.locked.set(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn try_lock(&self) -> bool {
|
pub unsafe fn try_lock(&self) -> bool {
|
||||||
let locked = self.locked.get();
|
self.locked.replace(true) == false
|
||||||
if *locked {
|
|
||||||
false
|
|
||||||
} else {
|
|
||||||
*locked = true;
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
use crate::cell::UnsafeCell;
|
use crate::cell::Cell;
|
||||||
|
|
||||||
pub struct RWLock {
|
pub struct RWLock {
|
||||||
mode: UnsafeCell<isize>,
|
// This platform has no threads, so we can use a Cell here.
|
||||||
|
mode: Cell<isize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for RWLock {}
|
unsafe impl Send for RWLock {}
|
||||||
|
@ -9,14 +10,14 @@ unsafe impl Sync for RWLock {} // no threads on this platform
|
||||||
|
|
||||||
impl RWLock {
|
impl RWLock {
|
||||||
pub const fn new() -> RWLock {
|
pub const fn new() -> RWLock {
|
||||||
RWLock { mode: UnsafeCell::new(0) }
|
RWLock { mode: Cell::new(0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn read(&self) {
|
pub unsafe fn read(&self) {
|
||||||
let mode = self.mode.get();
|
let m = self.mode.get();
|
||||||
if *mode >= 0 {
|
if m >= 0 {
|
||||||
*mode += 1;
|
self.mode.set(m + 1);
|
||||||
} else {
|
} else {
|
||||||
rtabort!("rwlock locked for writing");
|
rtabort!("rwlock locked for writing");
|
||||||
}
|
}
|
||||||
|
@ -24,9 +25,9 @@ impl RWLock {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn try_read(&self) -> bool {
|
pub unsafe fn try_read(&self) -> bool {
|
||||||
let mode = self.mode.get();
|
let m = self.mode.get();
|
||||||
if *mode >= 0 {
|
if m >= 0 {
|
||||||
*mode += 1;
|
self.mode.set(m + 1);
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
@ -35,19 +36,15 @@ impl RWLock {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn write(&self) {
|
pub unsafe fn write(&self) {
|
||||||
let mode = self.mode.get();
|
if self.mode.replace(-1) != 0 {
|
||||||
if *mode == 0 {
|
|
||||||
*mode = -1;
|
|
||||||
} else {
|
|
||||||
rtabort!("rwlock locked for reading")
|
rtabort!("rwlock locked for reading")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn try_write(&self) -> bool {
|
pub unsafe fn try_write(&self) -> bool {
|
||||||
let mode = self.mode.get();
|
if self.mode.get() == 0 {
|
||||||
if *mode == 0 {
|
self.mode.set(-1);
|
||||||
*mode = -1;
|
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
@ -56,12 +53,12 @@ impl RWLock {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn read_unlock(&self) {
|
pub unsafe fn read_unlock(&self) {
|
||||||
*self.mode.get() -= 1;
|
self.mode.set(self.mode.get() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn write_unlock(&self) {
|
pub unsafe fn write_unlock(&self) {
|
||||||
*self.mode.get() += 1;
|
assert_eq!(self.mode.replace(0), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -53,6 +53,7 @@ pub mod thread_local_key;
|
||||||
pub mod time;
|
pub mod time;
|
||||||
|
|
||||||
#[path = "../unsupported/common.rs"]
|
#[path = "../unsupported/common.rs"]
|
||||||
|
#[deny(unsafe_op_in_unsafe_fn)]
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
mod common;
|
mod common;
|
||||||
pub use common::*;
|
pub use common::*;
|
||||||
|
|
|
@ -66,5 +66,6 @@ cfg_if::cfg_if! {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[path = "../unsupported/common.rs"]
|
#[path = "../unsupported/common.rs"]
|
||||||
|
#[deny(unsafe_op_in_unsafe_fn)]
|
||||||
mod common;
|
mod common;
|
||||||
pub use common::*;
|
pub use common::*;
|
||||||
|
|
|
@ -21,7 +21,6 @@ impl StaticMutex {
|
||||||
/// first used with any of the functions below.
|
/// first used with any of the functions below.
|
||||||
/// Also, the behavior is undefined if this mutex is ever used reentrantly,
|
/// Also, the behavior is undefined if this mutex is ever used reentrantly,
|
||||||
/// i.e., `lock` is called by the thread currently holding the lock.
|
/// i.e., `lock` is called by the thread currently holding the lock.
|
||||||
#[rustc_const_stable(feature = "const_sys_mutex_new", since = "1.0.0")]
|
|
||||||
pub const fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self(imp::Mutex::new())
|
Self(imp::Mutex::new())
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,8 +182,8 @@ impl<T: Write> OutputFormatter for JsonFormatter<T> {
|
||||||
/// Base code taken form `libserialize::json::escape_str`
|
/// Base code taken form `libserialize::json::escape_str`
|
||||||
struct EscapedString<S: AsRef<str>>(S);
|
struct EscapedString<S: AsRef<str>>(S);
|
||||||
|
|
||||||
impl<S: AsRef<str>> ::std::fmt::Display for EscapedString<S> {
|
impl<S: AsRef<str>> std::fmt::Display for EscapedString<S> {
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||||
let mut start = 0;
|
let mut start = 0;
|
||||||
|
|
||||||
for (i, byte) in self.0.as_ref().bytes().enumerate() {
|
for (i, byte) in self.0.as_ref().bytes().enumerate() {
|
||||||
|
|
|
@ -2617,7 +2617,7 @@ impl Step for BuildManifest {
|
||||||
let image_bin = image.join("bin");
|
let image_bin = image.join("bin");
|
||||||
let _ = fs::remove_dir_all(&image);
|
let _ = fs::remove_dir_all(&image);
|
||||||
t!(fs::create_dir_all(&image_bin));
|
t!(fs::create_dir_all(&image_bin));
|
||||||
builder.install(&build_manifest, &image_bin.join("build-manifest"), 0o755);
|
builder.install(&build_manifest, &image_bin, 0o755);
|
||||||
|
|
||||||
// Prepare the overlay.
|
// Prepare the overlay.
|
||||||
let overlay = tmp.join("build-manifest-overlay");
|
let overlay = tmp.join("build-manifest-overlay");
|
||||||
|
|
|
@ -177,6 +177,9 @@ const LLVM_TOOLS: &[&str] = &[
|
||||||
"llvm-size", // used to prints the size of the linker sections of a program
|
"llvm-size", // used to prints the size of the linker sections of a program
|
||||||
"llvm-strip", // used to discard symbols from binary files to reduce their size
|
"llvm-strip", // used to discard symbols from binary files to reduce their size
|
||||||
"llvm-ar", // used for creating and modifying archive files
|
"llvm-ar", // used for creating and modifying archive files
|
||||||
|
"llvm-dis", // used to disassemble LLVM bitcode
|
||||||
|
"llc", // used to compile LLVM bytecode
|
||||||
|
"opt", // used to optimize LLVM bytecode
|
||||||
];
|
];
|
||||||
|
|
||||||
pub const VERSION: usize = 2;
|
pub const VERSION: usize = 2;
|
||||||
|
|
|
@ -30,7 +30,7 @@ impl FromStr for Profile {
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
match s {
|
match s {
|
||||||
"a" | "lib" | "library" => Ok(Profile::Library),
|
"a" | "lib" | "library" => Ok(Profile::Library),
|
||||||
"b" | "compiler" => Ok(Profile::Compiler),
|
"b" | "compiler" | "rustdoc" => Ok(Profile::Compiler),
|
||||||
"c" | "llvm" | "codegen" => Ok(Profile::Codegen),
|
"c" | "llvm" | "codegen" => Ok(Profile::Codegen),
|
||||||
"d" | "maintainer" | "user" => Ok(Profile::User),
|
"d" | "maintainer" | "user" => Ok(Profile::User),
|
||||||
_ => Err(format!("unknown profile: '{}'", s)),
|
_ => Err(format!("unknown profile: '{}'", s)),
|
||||||
|
@ -108,7 +108,7 @@ pub fn interactive_path() -> io::Result<Profile> {
|
||||||
println!(
|
println!(
|
||||||
"Welcome to the Rust project! What do you want to do with x.py?
|
"Welcome to the Rust project! What do you want to do with x.py?
|
||||||
a) Contribute to the standard library
|
a) Contribute to the standard library
|
||||||
b) Contribute to the compiler
|
b) Contribute to the compiler or rustdoc
|
||||||
c) Contribute to the compiler, and also modify LLVM or codegen
|
c) Contribute to the compiler, and also modify LLVM or codegen
|
||||||
d) Install Rust from source"
|
d) Install Rust from source"
|
||||||
);
|
);
|
||||||
|
|
|
@ -966,6 +966,15 @@ impl Step for Compiletest {
|
||||||
/// compiletest `mode` and `suite` arguments. For example `mode` can be
|
/// compiletest `mode` and `suite` arguments. For example `mode` can be
|
||||||
/// "run-pass" or `suite` can be something like `debuginfo`.
|
/// "run-pass" or `suite` can be something like `debuginfo`.
|
||||||
fn run(self, builder: &Builder<'_>) {
|
fn run(self, builder: &Builder<'_>) {
|
||||||
|
if builder.top_stage == 0 && env::var("COMPILETEST_FORCE_STAGE0").is_err() {
|
||||||
|
eprintln!("\
|
||||||
|
error: `--stage 0` runs compiletest on the beta compiler, not your local changes, and will almost always cause tests to fail
|
||||||
|
help: use `--stage 1` instead
|
||||||
|
note: if you're sure you want to do this, please open an issue as to why. In the meantime, you can override this with `COMPILETEST_FORCE_STAGE0=1`."
|
||||||
|
);
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
let compiler = self.compiler;
|
let compiler = self.compiler;
|
||||||
let target = self.target;
|
let target = self.target;
|
||||||
let mode = self.mode;
|
let mode = self.mode;
|
||||||
|
|
|
@ -469,11 +469,11 @@ jobs:
|
||||||
--build=x86_64-apple-darwin
|
--build=x86_64-apple-darwin
|
||||||
--host=aarch64-apple-darwin
|
--host=aarch64-apple-darwin
|
||||||
--target=aarch64-apple-darwin
|
--target=aarch64-apple-darwin
|
||||||
|
--enable-full-tools
|
||||||
--enable-sanitizers
|
--enable-sanitizers
|
||||||
--enable-profiler
|
--enable-profiler
|
||||||
--set rust.jemalloc
|
--set rust.jemalloc
|
||||||
--set llvm.ninja=false
|
--set llvm.ninja=false
|
||||||
--tools=rls,clippy,rustfmt,analysis,src
|
|
||||||
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
|
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
|
||||||
SELECT_XCODE: /Applications/Xcode_12_beta.app
|
SELECT_XCODE: /Applications/Xcode_12_beta.app
|
||||||
USE_XCODE_CLANG: 1
|
USE_XCODE_CLANG: 1
|
||||||
|
@ -481,12 +481,15 @@ jobs:
|
||||||
MACOSX_STD_DEPLOYMENT_TARGET: 11.0
|
MACOSX_STD_DEPLOYMENT_TARGET: 11.0
|
||||||
NO_LLVM_ASSERTIONS: 1
|
NO_LLVM_ASSERTIONS: 1
|
||||||
NO_DEBUG_ASSERTIONS: 1
|
NO_DEBUG_ASSERTIONS: 1
|
||||||
# TODO: Cargo is disabled until OpenSSL 1.1.1 can be
|
DIST_REQUIRE_ALL_TOOLS: 1
|
||||||
# compiled for aarch64-apple-darwin::
|
# Corresponds to 16K page size
|
||||||
# https://github.com/openssl/openssl/pull/12369. Once
|
#
|
||||||
# fixed, remove `--tools`, add back
|
# Shouldn't be needed if jemalloc-sys is updated to
|
||||||
# `--enable-full-tools`, and enable this again
|
# handle this platform like iOS or if we build on
|
||||||
# DIST_REQUIRE_ALL_TOOLS: 1
|
# aarch64-apple-darwin itself.
|
||||||
|
#
|
||||||
|
# https://github.com/gnzlbg/jemallocator/blob/c27a859e98e3cb790dc269773d9da71a1e918458/jemalloc-sys/build.rs#L237
|
||||||
|
JEMALLOC_SYS_WITH_LG_PAGE: 14
|
||||||
<<: *job-macos-xl
|
<<: *job-macos-xl
|
||||||
|
|
||||||
######################
|
######################
|
||||||
|
|
|
@ -57,7 +57,7 @@ Specifically, these platforms are required to have each of the following:
|
||||||
|
|
||||||
target | std | host | notes
|
target | std | host | notes
|
||||||
-------|-----|------|-------
|
-------|-----|------|-------
|
||||||
`aarch64-apple-darwin` | ✓ | | ARM64 macOS (11.0+, Big Sur+)
|
`aarch64-apple-darwin` | ✓ | ✓ | ARM64 macOS (11.0+, Big Sur+)
|
||||||
`aarch64-apple-ios` | ✓ | | ARM64 iOS
|
`aarch64-apple-ios` | ✓ | | ARM64 iOS
|
||||||
`aarch64-fuchsia` | ✓ | | ARM64 Fuchsia
|
`aarch64-fuchsia` | ✓ | | ARM64 Fuchsia
|
||||||
`aarch64-linux-android` | ✓ | | ARM64 Android
|
`aarch64-linux-android` | ✓ | | ARM64 Android
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/array-size-in-generic-struct-param.rs:9:48
|
--> $DIR/array-size-in-generic-struct-param.rs:9:48
|
||||||
|
|
|
|
||||||
LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
|
LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
| ^ cannot perform const operation using `N`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/array-size-in-generic-struct-param.rs:20:15
|
--> $DIR/array-size-in-generic-struct-param.rs:20:15
|
||||||
|
|
|
|
||||||
LL | arr: [u8; CFG.arr_size],
|
LL | arr: [u8; CFG.arr_size],
|
||||||
| ^^^ non-trivial anonymous constants must not depend on the parameter `CFG`
|
| ^^^ cannot perform const operation using `CFG`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `CFG` or `{ CFG }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `CFG`
|
||||||
|
|
||||||
error: `Config` is forbidden as the type of a const generic parameter
|
error: `Config` is forbidden as the type of a const generic parameter
|
||||||
--> $DIR/array-size-in-generic-struct-param.rs:18:21
|
--> $DIR/array-size-in-generic-struct-param.rs:18:21
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
struct ArithArrayLen<const N: usize>([u32; 0 + N]);
|
struct ArithArrayLen<const N: usize>([u32; 0 + N]);
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^^ ERROR generic parameters may not be used in const operations
|
||||||
|
|
||||||
#[derive(PartialEq, Eq)]
|
#[derive(PartialEq, Eq)]
|
||||||
struct Config {
|
struct Config {
|
||||||
|
@ -19,7 +19,7 @@ struct B<const CFG: Config> {
|
||||||
//[min]~^ ERROR `Config` is forbidden
|
//[min]~^ ERROR `Config` is forbidden
|
||||||
arr: [u8; CFG.arr_size],
|
arr: [u8; CFG.arr_size],
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial
|
//[min]~^^ ERROR generic parameters may not be used in const operations
|
||||||
}
|
}
|
||||||
|
|
||||||
const C: Config = Config { arr_size: 5 };
|
const C: Config = Config { arr_size: 5 };
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/const-argument-if-length.rs:19:24
|
--> $DIR/const-argument-if-length.rs:19:24
|
||||||
|
|
|
|
||||||
LL | pad: [u8; is_zst::<T>()],
|
LL | pad: [u8; is_zst::<T>()],
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `T`
|
| ^ cannot perform const operation using `T`
|
||||||
|
|
|
|
||||||
= note: type parameters are currently not permitted in anonymous constants
|
= note: type parameters may not be used in const expressions
|
||||||
|
|
||||||
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
||||||
--> $DIR/const-argument-if-length.rs:17:12
|
--> $DIR/const-argument-if-length.rs:17:12
|
||||||
|
|
|
@ -17,7 +17,7 @@ pub struct AtLeastByte<T: ?Sized> {
|
||||||
value: T,
|
value: T,
|
||||||
//~^ ERROR the size for values of type `T` cannot be known at compilation time
|
//~^ ERROR the size for values of type `T` cannot be known at compilation time
|
||||||
pad: [u8; is_zst::<T>()],
|
pad: [u8; is_zst::<T>()],
|
||||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^ ERROR generic parameters may not be used in const operations
|
||||||
//[full]~^^ ERROR evaluation of constant value failed
|
//[full]~^^ ERROR evaluation of constant value failed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/feature-gate-const_evaluatable_checked.rs:6:33
|
--> $DIR/feature-gate-const_evaluatable_checked.rs:6:33
|
||||||
|
|
|
|
||||||
LL | type Arr<const N: usize> = [u8; N - 1];
|
LL | type Arr<const N: usize> = [u8; N - 1];
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
| ^ cannot perform const operation using `N`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#![cfg_attr(min, feature(min_const_generics))]
|
#![cfg_attr(min, feature(min_const_generics))]
|
||||||
|
|
||||||
type Arr<const N: usize> = [u8; N - 1];
|
type Arr<const N: usize> = [u8; N - 1];
|
||||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^ ERROR generic parameters may not be used in const operations
|
||||||
|
|
||||||
fn test<const N: usize>() -> Arr<N> where Arr<N>: Default {
|
fn test<const N: usize>() -> Arr<N> where Arr<N>: Default {
|
||||||
//[full]~^ ERROR constant expression depends
|
//[full]~^ ERROR constant expression depends
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/simple.rs:8:53
|
--> $DIR/simple.rs:8:53
|
||||||
|
|
|
|
||||||
LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
|
LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
| ^ cannot perform const operation using `N`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/simple.rs:8:35
|
--> $DIR/simple.rs:8:35
|
||||||
|
|
|
|
||||||
LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
|
LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
| ^ cannot perform const operation using `N`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/simple_fail.rs:7:33
|
--> $DIR/simple_fail.rs:7:33
|
||||||
|
|
|
|
||||||
LL | type Arr<const N: usize> = [u8; N - 1];
|
LL | type Arr<const N: usize> = [u8; N - 1];
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
| ^ cannot perform const operation using `N`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#![allow(incomplete_features)]
|
#![allow(incomplete_features)]
|
||||||
|
|
||||||
type Arr<const N: usize> = [u8; N - 1]; //[full]~ ERROR evaluation of constant
|
type Arr<const N: usize> = [u8; N - 1]; //[full]~ ERROR evaluation of constant
|
||||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^ ERROR generic parameters may not be used in const operations
|
||||||
|
|
||||||
fn test<const N: usize>() -> Arr<N> where Arr<N>: Sized {
|
fn test<const N: usize>() -> Arr<N> where Arr<N>: Sized {
|
||||||
todo!()
|
todo!()
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/generic-function-call-in-array-length.rs:9:39
|
--> $DIR/generic-function-call-in-array-length.rs:9:39
|
||||||
|
|
|
|
||||||
LL | fn bar<const N: usize>() -> [u32; foo(N)] {
|
LL | fn bar<const N: usize>() -> [u32; foo(N)] {
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
| ^ cannot perform const operation using `N`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/generic-function-call-in-array-length.rs:12:13
|
--> $DIR/generic-function-call-in-array-length.rs:12:13
|
||||||
|
|
|
|
||||||
LL | [0; foo(N)]
|
LL | [0; foo(N)]
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
| ^ cannot perform const operation using `N`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
const fn foo(n: usize) -> usize { n * 2 }
|
const fn foo(n: usize) -> usize { n * 2 }
|
||||||
|
|
||||||
fn bar<const N: usize>() -> [u32; foo(N)] {
|
fn bar<const N: usize>() -> [u32; foo(N)] {
|
||||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^ ERROR generic parameters may not be used in const operations
|
||||||
//[full]~^^ ERROR constant expression depends on a generic parameter
|
//[full]~^^ ERROR constant expression depends on a generic parameter
|
||||||
[0; foo(N)]
|
[0; foo(N)]
|
||||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^ ERROR generic parameters may not be used in const operations
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/generic-sum-in-array-length.rs:7:53
|
--> $DIR/generic-sum-in-array-length.rs:7:53
|
||||||
|
|
|
|
||||||
LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
|
LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `A`
|
| ^ cannot perform const operation using `A`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `A` or `{ A }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `A`
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/generic-sum-in-array-length.rs:7:57
|
--> $DIR/generic-sum-in-array-length.rs:7:57
|
||||||
|
|
|
|
||||||
LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
|
LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `B`
|
| ^ cannot perform const operation using `B`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `B` or `{ B }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `B`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
#![cfg_attr(min, feature(min_const_generics))]
|
#![cfg_attr(min, feature(min_const_generics))]
|
||||||
|
|
||||||
fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
|
fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
|
||||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^ ERROR generic parameters may not be used in const operations
|
||||||
//[min]~| ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~| ERROR generic parameters may not be used in const operations
|
||||||
//[full]~^^^ ERROR constant expression depends on a generic parameter
|
//[full]~^^^ ERROR constant expression depends on a generic parameter
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/intrinsics-type_name-as-const-argument.rs:15:44
|
--> $DIR/intrinsics-type_name-as-const-argument.rs:15:44
|
||||||
|
|
|
|
||||||
LL | T: Trait<{std::intrinsics::type_name::<T>()}>
|
LL | T: Trait<{std::intrinsics::type_name::<T>()}>
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `T`
|
| ^ cannot perform const operation using `T`
|
||||||
|
|
|
|
||||||
= note: type parameters are currently not permitted in anonymous constants
|
= note: type parameters may not be used in const expressions
|
||||||
|
|
||||||
error: `&'static str` is forbidden as the type of a const generic parameter
|
error: `&'static str` is forbidden as the type of a const generic parameter
|
||||||
--> $DIR/intrinsics-type_name-as-const-argument.rs:10:22
|
--> $DIR/intrinsics-type_name-as-const-argument.rs:10:22
|
||||||
|
|
|
@ -13,7 +13,7 @@ trait Trait<const S: &'static str> {}
|
||||||
struct Bug<T>
|
struct Bug<T>
|
||||||
where
|
where
|
||||||
T: Trait<{std::intrinsics::type_name::<T>()}>
|
T: Trait<{std::intrinsics::type_name::<T>()}>
|
||||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^ ERROR generic parameters may not be used in const operations
|
||||||
//[full]~^^ ERROR constant expression depends on a generic parameter
|
//[full]~^^ ERROR constant expression depends on a generic parameter
|
||||||
{
|
{
|
||||||
t: T
|
t: T
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-61522-array-len-succ.rs:7:45
|
--> $DIR/issue-61522-array-len-succ.rs:7:45
|
||||||
|
|
|
|
||||||
LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
|
LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
|
||||||
| ^^^^^ non-trivial anonymous constants must not depend on the parameter `COUNT`
|
| ^^^^^ cannot perform const operation using `COUNT`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `COUNT` or `{ COUNT }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `COUNT`
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-61522-array-len-succ.rs:12:30
|
--> $DIR/issue-61522-array-len-succ.rs:12:30
|
||||||
|
|
|
|
||||||
LL | fn inner(&self) -> &[u8; COUNT + 1] {
|
LL | fn inner(&self) -> &[u8; COUNT + 1] {
|
||||||
| ^^^^^ non-trivial anonymous constants must not depend on the parameter `COUNT`
|
| ^^^^^ cannot perform const operation using `COUNT`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `COUNT` or `{ COUNT }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `COUNT`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
|
|
||||||
pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
|
pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used
|
//[min]~^^ ERROR generic parameters may not be used
|
||||||
|
|
||||||
impl<const COUNT: usize> MyArray<COUNT> {
|
impl<const COUNT: usize> MyArray<COUNT> {
|
||||||
fn inner(&self) -> &[u8; COUNT + 1] {
|
fn inner(&self) -> &[u8; COUNT + 1] {
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used
|
//[min]~^^ ERROR generic parameters may not be used
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-67375.rs:9:25
|
--> $DIR/issue-67375.rs:9:25
|
||||||
|
|
|
|
||||||
LL | inner: [(); { [|_: &T| {}; 0].len() }],
|
LL | inner: [(); { [|_: &T| {}; 0].len() }],
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `T`
|
| ^ cannot perform const operation using `T`
|
||||||
|
|
|
|
||||||
= note: type parameters are currently not permitted in anonymous constants
|
= note: type parameters may not be used in const expressions
|
||||||
|
|
||||||
error[E0392]: parameter `T` is never used
|
error[E0392]: parameter `T` is never used
|
||||||
--> $DIR/issue-67375.rs:7:12
|
--> $DIR/issue-67375.rs:7:12
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
struct Bug<T> {
|
struct Bug<T> {
|
||||||
//~^ ERROR parameter `T` is never used
|
//~^ ERROR parameter `T` is never used
|
||||||
inner: [(); { [|_: &T| {}; 0].len() }],
|
inner: [(); { [|_: &T| {}; 0].len() }],
|
||||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^ ERROR generic parameters may not be used in const operations
|
||||||
//[full]~^^ WARN cannot use constants which depend on generic parameters in types
|
//[full]~^^ WARN cannot use constants which depend on generic parameters in types
|
||||||
//[full]~^^^ WARN this was previously accepted by the compiler
|
//[full]~^^^ WARN this was previously accepted by the compiler
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-67945-1.rs:14:16
|
--> $DIR/issue-67945-1.rs:14:16
|
||||||
|
|
|
|
||||||
LL | let x: S = MaybeUninit::uninit();
|
LL | let x: S = MaybeUninit::uninit();
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `S`
|
| ^ cannot perform const operation using `S`
|
||||||
|
|
|
|
||||||
= note: type parameters are currently not permitted in anonymous constants
|
= note: type parameters may not be used in const expressions
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-67945-1.rs:17:45
|
--> $DIR/issue-67945-1.rs:17:45
|
||||||
|
|
|
|
||||||
LL | let b = &*(&x as *const _ as *const S);
|
LL | let b = &*(&x as *const _ as *const S);
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `S`
|
| ^ cannot perform const operation using `S`
|
||||||
|
|
|
|
||||||
= note: type parameters are currently not permitted in anonymous constants
|
= note: type parameters may not be used in const expressions
|
||||||
|
|
||||||
error[E0392]: parameter `S` is never used
|
error[E0392]: parameter `S` is never used
|
||||||
--> $DIR/issue-67945-1.rs:11:12
|
--> $DIR/issue-67945-1.rs:11:12
|
||||||
|
|
|
@ -12,10 +12,10 @@ struct Bug<S> {
|
||||||
//~^ ERROR parameter `S` is never used
|
//~^ ERROR parameter `S` is never used
|
||||||
A: [(); {
|
A: [(); {
|
||||||
let x: S = MaybeUninit::uninit();
|
let x: S = MaybeUninit::uninit();
|
||||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^ ERROR generic parameters may not be used in const operations
|
||||||
//[full]~^^ ERROR mismatched types
|
//[full]~^^ ERROR mismatched types
|
||||||
let b = &*(&x as *const _ as *const S);
|
let b = &*(&x as *const _ as *const S);
|
||||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^ ERROR generic parameters may not be used in const operations
|
||||||
0
|
0
|
||||||
}],
|
}],
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-67945-2.rs:12:16
|
--> $DIR/issue-67945-2.rs:12:16
|
||||||
|
|
|
|
||||||
LL | let x: S = MaybeUninit::uninit();
|
LL | let x: S = MaybeUninit::uninit();
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `S`
|
| ^ cannot perform const operation using `S`
|
||||||
|
|
|
|
||||||
= note: type parameters are currently not permitted in anonymous constants
|
= note: type parameters may not be used in const expressions
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-67945-2.rs:15:45
|
--> $DIR/issue-67945-2.rs:15:45
|
||||||
|
|
|
|
||||||
LL | let b = &*(&x as *const _ as *const S);
|
LL | let b = &*(&x as *const _ as *const S);
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `S`
|
| ^ cannot perform const operation using `S`
|
||||||
|
|
|
|
||||||
= note: type parameters are currently not permitted in anonymous constants
|
= note: type parameters may not be used in const expressions
|
||||||
|
|
||||||
error[E0392]: parameter `S` is never used
|
error[E0392]: parameter `S` is never used
|
||||||
--> $DIR/issue-67945-2.rs:9:12
|
--> $DIR/issue-67945-2.rs:9:12
|
||||||
|
|
|
@ -10,10 +10,10 @@ struct Bug<S> {
|
||||||
//~^ ERROR parameter `S` is never used
|
//~^ ERROR parameter `S` is never used
|
||||||
A: [(); {
|
A: [(); {
|
||||||
let x: S = MaybeUninit::uninit();
|
let x: S = MaybeUninit::uninit();
|
||||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^ ERROR generic parameters may not be used in const operations
|
||||||
//[full]~^^ ERROR mismatched types
|
//[full]~^^ ERROR mismatched types
|
||||||
let b = &*(&x as *const _ as *const S);
|
let b = &*(&x as *const _ as *const S);
|
||||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^ ERROR generic parameters may not be used in const operations
|
||||||
0
|
0
|
||||||
}],
|
}],
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-61747.rs:8:30
|
--> $DIR/issue-61747.rs:8:30
|
||||||
|
|
|
|
||||||
LL | fn successor() -> Const<{C + 1}> {
|
LL | fn successor() -> Const<{C + 1}> {
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `C`
|
| ^ cannot perform const operation using `C`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `C` or `{ C }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `C`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ struct Const<const N: usize>;
|
||||||
impl<const C: usize> Const<{C}> {
|
impl<const C: usize> Const<{C}> {
|
||||||
fn successor() -> Const<{C + 1}> {
|
fn successor() -> Const<{C + 1}> {
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used
|
//[min]~^^ ERROR generic parameters may not be used
|
||||||
Const
|
Const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-61935.rs:10:23
|
--> $DIR/issue-61935.rs:10:23
|
||||||
|
|
|
|
||||||
LL | Self:FooImpl<{N==0}>
|
LL | Self:FooImpl<{N==0}>
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
| ^ cannot perform const operation using `N`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ impl<const N: usize> Foo for [(); N]
|
||||||
where
|
where
|
||||||
Self:FooImpl<{N==0}>
|
Self:FooImpl<{N==0}>
|
||||||
//[full]~^ERROR constant expression depends on a generic parameter
|
//[full]~^ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^^ERROR generic parameters may not be used in const operations
|
||||||
{}
|
{}
|
||||||
|
|
||||||
trait FooImpl<const IS_ZERO: bool>{}
|
trait FooImpl<const IS_ZERO: bool>{}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-62220.rs:8:59
|
--> $DIR/issue-62220.rs:8:59
|
||||||
|
|
|
|
||||||
LL | pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>;
|
LL | pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>;
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
| ^ cannot perform const operation using `N`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
pub struct Vector<T, const N: usize>([T; N]);
|
pub struct Vector<T, const N: usize>([T; N]);
|
||||||
|
|
||||||
pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>;
|
pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>;
|
||||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^ ERROR generic parameters may not be used in const operations
|
||||||
|
|
||||||
impl<T, const N: usize> Vector<T, { N }> {
|
impl<T, const N: usize> Vector<T, { N }> {
|
||||||
/// Drop the last component and return the vector with one fewer dimension.
|
/// Drop the last component and return the vector with one fewer dimension.
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-62456.rs:7:20
|
--> $DIR/issue-62456.rs:7:20
|
||||||
|
|
|
|
||||||
LL | let _ = [0u64; N + 1];
|
LL | let _ = [0u64; N + 1];
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
| ^ cannot perform const operation using `N`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
fn foo<const N: usize>() {
|
fn foo<const N: usize>() {
|
||||||
let _ = [0u64; N + 1];
|
let _ = [0u64; N + 1];
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^^ ERROR generic parameters may not be used in const operations
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-64494.rs:16:38
|
--> $DIR/issue-64494.rs:16:38
|
||||||
|
|
|
|
||||||
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
|
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
|
||||||
| ^^^^^^ non-trivial anonymous constants must not depend on the parameter `T`
|
| ^^^^^^ cannot perform const operation using `T`
|
||||||
|
|
|
|
||||||
= note: type parameters are currently not permitted in anonymous constants
|
= note: type parameters may not be used in const expressions
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-64494.rs:19:38
|
--> $DIR/issue-64494.rs:19:38
|
||||||
|
|
|
|
||||||
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
|
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
|
||||||
| ^^^^^^ non-trivial anonymous constants must not depend on the parameter `T`
|
| ^^^^^^ cannot perform const operation using `T`
|
||||||
|
|
|
|
||||||
= note: type parameters are currently not permitted in anonymous constants
|
= note: type parameters may not be used in const expressions
|
||||||
|
|
||||||
error[E0119]: conflicting implementations of trait `MyTrait`:
|
error[E0119]: conflicting implementations of trait `MyTrait`:
|
||||||
--> $DIR/issue-64494.rs:19:1
|
--> $DIR/issue-64494.rs:19:1
|
||||||
|
|
|
@ -15,10 +15,10 @@ impl True for Is<{true}> {}
|
||||||
|
|
||||||
impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
|
impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^^ ERROR generic parameters may not be used in const operations
|
||||||
impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
|
impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^^ ERROR generic parameters may not be used in const operations
|
||||||
//[min]~| ERROR conflicting implementations of trait `MyTrait`
|
//[min]~| ERROR conflicting implementations of trait `MyTrait`
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-66205.rs:8:14
|
--> $DIR/issue-66205.rs:8:14
|
||||||
|
|
|
|
||||||
LL | fact::<{ N - 1 }>();
|
LL | fact::<{ N - 1 }>();
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
| ^ cannot perform const operation using `N`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
fn fact<const N: usize>() {
|
fn fact<const N: usize>() {
|
||||||
fact::<{ N - 1 }>();
|
fact::<{ N - 1 }>();
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^^ ERROR generic parameters may not be used in const operations
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-67739.rs:12:30
|
--> $DIR/issue-67739.rs:12:30
|
||||||
|
|
|
|
||||||
LL | [0u8; mem::size_of::<Self::Associated>()];
|
LL | [0u8; mem::size_of::<Self::Associated>()];
|
||||||
| ^^^^^^^^^^^^^^^^ non-trivial anonymous constants must not depend on the parameter `Self`
|
| ^^^^^^^^^^^^^^^^ cannot perform const operation using `Self`
|
||||||
|
|
|
|
||||||
= note: type parameters are currently not permitted in anonymous constants
|
= note: type parameters may not be used in const expressions
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub trait Trait {
|
||||||
fn associated_size(&self) -> usize {
|
fn associated_size(&self) -> usize {
|
||||||
[0u8; mem::size_of::<Self::Associated>()];
|
[0u8; mem::size_of::<Self::Associated>()];
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^^ ERROR generic parameters may not be used in const operations
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-68366.rs:12:37
|
--> $DIR/issue-68366.rs:12:37
|
||||||
|
|
|
|
||||||
LL | impl <const N: usize> Collatz<{Some(N)}> {}
|
LL | impl <const N: usize> Collatz<{Some(N)}> {}
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
| ^ cannot perform const operation using `N`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||||
|
|
||||||
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
|
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
|
||||||
--> $DIR/issue-68366.rs:12:13
|
--> $DIR/issue-68366.rs:12:13
|
||||||
|
|
|
@ -11,7 +11,7 @@ struct Collatz<const N: Option<usize>>;
|
||||||
|
|
||||||
impl <const N: usize> Collatz<{Some(N)}> {}
|
impl <const N: usize> Collatz<{Some(N)}> {}
|
||||||
//~^ ERROR the const parameter
|
//~^ ERROR the const parameter
|
||||||
//[min]~^^ generic parameters must not be used inside of non-trivial constant values
|
//[min]~^^ generic parameters may not be used in const operations
|
||||||
|
|
||||||
struct Foo;
|
struct Foo;
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-68977.rs:29:17
|
--> $DIR/issue-68977.rs:29:17
|
||||||
|
|
|
|
||||||
LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
||||||
| ^^^^^^^^ non-trivial anonymous constants must not depend on the parameter `INT_BITS`
|
| ^^^^^^^^ cannot perform const operation using `INT_BITS`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `INT_BITS` or `{ INT_BITS }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `INT_BITS`
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-68977.rs:29:28
|
--> $DIR/issue-68977.rs:29:28
|
||||||
|
|
|
|
||||||
LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
||||||
| ^^^^^^^^^ non-trivial anonymous constants must not depend on the parameter `FRAC_BITS`
|
| ^^^^^^^^^ cannot perform const operation using `FRAC_BITS`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `FRAC_BITS` or `{ FRAC_BITS }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `FRAC_BITS`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,8 @@ fxp_storage_impls! {
|
||||||
|
|
||||||
type FxpStorageHelper<const INT_BITS: u8, const FRAC_BITS: u8> =
|
type FxpStorageHelper<const INT_BITS: u8, const FRAC_BITS: u8> =
|
||||||
PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
||||||
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^ ERROR generic parameters may not be used in const operations
|
||||||
//[min]~| ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~| ERROR generic parameters may not be used in const operations
|
||||||
|
|
||||||
struct Fxp<const INT_BITS: u8, const FRAC_BITS: u8>
|
struct Fxp<const INT_BITS: u8, const FRAC_BITS: u8>
|
||||||
where
|
where
|
||||||
|
|
|
@ -1,34 +1,34 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-72787.rs:11:17
|
--> $DIR/issue-72787.rs:11:17
|
||||||
|
|
|
|
||||||
LL | Condition<{ LHS <= RHS }>: True
|
LL | Condition<{ LHS <= RHS }>: True
|
||||||
| ^^^ non-trivial anonymous constants must not depend on the parameter `LHS`
|
| ^^^ cannot perform const operation using `LHS`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `LHS` or `{ LHS }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `LHS`
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-72787.rs:11:24
|
--> $DIR/issue-72787.rs:11:24
|
||||||
|
|
|
|
||||||
LL | Condition<{ LHS <= RHS }>: True
|
LL | Condition<{ LHS <= RHS }>: True
|
||||||
| ^^^ non-trivial anonymous constants must not depend on the parameter `RHS`
|
| ^^^ cannot perform const operation using `RHS`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `RHS` or `{ RHS }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `RHS`
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-72787.rs:26:25
|
--> $DIR/issue-72787.rs:26:25
|
||||||
|
|
|
|
||||||
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
|
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `I`
|
| ^ cannot perform const operation using `I`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `I` or `{ I }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `I`
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-72787.rs:26:36
|
--> $DIR/issue-72787.rs:26:36
|
||||||
|
|
|
|
||||||
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
|
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `J`
|
| ^ cannot perform const operation using `J`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `J` or `{ J }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `J`
|
||||||
|
|
||||||
error[E0283]: type annotations needed
|
error[E0283]: type annotations needed
|
||||||
--> $DIR/issue-72787.rs:22:26
|
--> $DIR/issue-72787.rs:22:26
|
||||||
|
|
|
@ -10,8 +10,8 @@ pub trait True {}
|
||||||
impl<const LHS: u32, const RHS: u32> True for IsLessOrEqual<LHS, RHS> where
|
impl<const LHS: u32, const RHS: u32> True for IsLessOrEqual<LHS, RHS> where
|
||||||
Condition<{ LHS <= RHS }>: True
|
Condition<{ LHS <= RHS }>: True
|
||||||
//[full]~^ Error constant expression depends on a generic parameter
|
//[full]~^ Error constant expression depends on a generic parameter
|
||||||
//[min]~^^ Error generic parameters must not be used inside of non-trivial constant values
|
//[min]~^^ Error generic parameters may not be used in const operations
|
||||||
//[min]~| Error generic parameters must not be used inside of non-trivial constant values
|
//[min]~| Error generic parameters may not be used in const operations
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
impl True for Condition<true> {}
|
impl True for Condition<true> {}
|
||||||
|
@ -28,8 +28,8 @@ where
|
||||||
//[full]~| constant expression depends on a generic parameter
|
//[full]~| constant expression depends on a generic parameter
|
||||||
//[full]~| constant expression depends on a generic parameter
|
//[full]~| constant expression depends on a generic parameter
|
||||||
//[full]~| constant expression depends on a generic parameter
|
//[full]~| constant expression depends on a generic parameter
|
||||||
//[min]~^^^^^ Error generic parameters must not be used inside of non-trivial constant values
|
//[min]~^^^^^ Error generic parameters may not be used in const operations
|
||||||
//[min]~| Error generic parameters must not be used inside of non-trivial constant values
|
//[min]~| Error generic parameters may not be used in const operations
|
||||||
// Condition<{ 8 - I <= 8 - J }>: True,
|
// Condition<{ 8 - I <= 8 - J }>: True,
|
||||||
{
|
{
|
||||||
fn print() {
|
fn print() {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-72819-generic-in-const-eval.rs:9:17
|
--> $DIR/issue-72819-generic-in-const-eval.rs:9:17
|
||||||
|
|
|
|
||||||
LL | where Assert::<{N < usize::max_value() / 2}>: IsTrue,
|
LL | where Assert::<{N < usize::max_value() / 2}>: IsTrue,
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
| ^ cannot perform const operation using `N`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
struct Arr<const N: usize>
|
struct Arr<const N: usize>
|
||||||
where Assert::<{N < usize::max_value() / 2}>: IsTrue,
|
where Assert::<{N < usize::max_value() / 2}>: IsTrue,
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^^ ERROR generic parameters may not be used in const operations
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-76701-ty-param-in-const.rs:6:46
|
--> $DIR/issue-76701-ty-param-in-const.rs:6:46
|
||||||
|
|
|
|
||||||
LL | fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] {
|
LL | fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] {
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `T`
|
| ^ cannot perform const operation using `T`
|
||||||
|
|
|
|
||||||
= note: type parameters are currently not permitted in anonymous constants
|
= note: type parameters may not be used in const expressions
|
||||||
|
|
||||||
error: generic parameters must not be used inside of non-trivial constant values
|
error: generic parameters may not be used in const operations
|
||||||
--> $DIR/issue-76701-ty-param-in-const.rs:12:42
|
--> $DIR/issue-76701-ty-param-in-const.rs:12:42
|
||||||
|
|
|
|
||||||
LL | fn const_param<const N: usize>() -> [u8; N + 1] {
|
LL | fn const_param<const N: usize>() -> [u8; N + 1] {
|
||||||
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
| ^ cannot perform const operation using `N`
|
||||||
|
|
|
|
||||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
|
|
||||||
fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] {
|
fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] {
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^^ ERROR generic parameters may not be used in const operations
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_param<const N: usize>() -> [u8; N + 1] {
|
fn const_param<const N: usize>() -> [u8; N + 1] {
|
||||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||||
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//[min]~^^ ERROR generic parameters may not be used in const operations
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,19 +7,19 @@ fn ok<const M: usize>() -> [u8; M] {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Break0<const N: usize>([u8; { N + 1 }]);
|
struct Break0<const N: usize>([u8; { N + 1 }]);
|
||||||
//~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//~^ ERROR generic parameters may not be used in const operations
|
||||||
|
|
||||||
struct Break1<const N: usize>([u8; { { N } }]);
|
struct Break1<const N: usize>([u8; { { N } }]);
|
||||||
//~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//~^ ERROR generic parameters may not be used in const operations
|
||||||
|
|
||||||
fn break2<const N: usize>() {
|
fn break2<const N: usize>() {
|
||||||
let _: [u8; N + 1];
|
let _: [u8; N + 1];
|
||||||
//~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//~^ ERROR generic parameters may not be used in const operations
|
||||||
}
|
}
|
||||||
|
|
||||||
fn break3<const N: usize>() {
|
fn break3<const N: usize>() {
|
||||||
let _ = [0; N + 1];
|
let _ = [0; N + 1];
|
||||||
//~^ ERROR generic parameters must not be used inside of non-trivial constant values
|
//~^ ERROR generic parameters may not be used in const operations
|
||||||
}
|
}
|
||||||
|
|
||||||
trait Foo {
|
trait Foo {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue