Auto merge of #74245 - Manishearth:rollup-r0xq9dn, r=Manishearth
Rollup of 10 pull requests Successful merges: - #72920 (Stabilize `transmute` in constants and statics but not const fn) - #73715 (debuginfo: Mangle tuples to be natvis friendly, typedef basic types) - #74066 (Optimize is_ascii for str and [u8].) - #74116 (Fix cross compilation of LLVM to aarch64 Windows targets) - #74167 (linker: illumos ld does not support --eh-frame-hdr) - #74168 (Add a help to use `in_band_lifetimes` in nightly) - #74197 (Reword incorrect `self` token suggestion) - #74213 (Minor refactor for rustc_resolve diagnostics match) - #74240 (Fix #74081 and add the test case from #74236) - #74241 (update miri) Failed merges: r? @ghost
This commit is contained in:
@@ -404,9 +404,9 @@ version = "0.1.0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.54"
|
version = "1.0.57"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311"
|
checksum = "0fde55d2a2bfaa4c9668bbc63f531fbdeee3ffe188f4662511ce2c22b3eedebe"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jobserver",
|
"jobserver",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
//! ensure that they're always in place if needed.
|
//! ensure that they're always in place if needed.
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::env::consts::EXE_EXTENSION;
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io;
|
use std::io;
|
||||||
@@ -252,8 +253,14 @@ impl Step for Llvm {
|
|||||||
// FIXME: if the llvm root for the build triple is overridden then we
|
// FIXME: if the llvm root for the build triple is overridden then we
|
||||||
// should use llvm-tblgen from there, also should verify that it
|
// should use llvm-tblgen from there, also should verify that it
|
||||||
// actually exists most of the time in normal installs of LLVM.
|
// actually exists most of the time in normal installs of LLVM.
|
||||||
let host = builder.llvm_out(builder.config.build).join("bin/llvm-tblgen");
|
let host_bin = builder.llvm_out(builder.config.build).join("bin");
|
||||||
cfg.define("CMAKE_CROSSCOMPILING", "True").define("LLVM_TABLEGEN", &host);
|
cfg.define("CMAKE_CROSSCOMPILING", "True");
|
||||||
|
cfg.define("LLVM_TABLEGEN", host_bin.join("llvm-tblgen").with_extension(EXE_EXTENSION));
|
||||||
|
cfg.define("LLVM_NM", host_bin.join("llvm-nm").with_extension(EXE_EXTENSION));
|
||||||
|
cfg.define(
|
||||||
|
"LLVM_CONFIG_PATH",
|
||||||
|
host_bin.join("llvm-config").with_extension(EXE_EXTENSION),
|
||||||
|
);
|
||||||
|
|
||||||
if target.contains("netbsd") {
|
if target.contains("netbsd") {
|
||||||
cfg.define("CMAKE_SYSTEM_NAME", "NetBSD");
|
cfg.define("CMAKE_SYSTEM_NAME", "NetBSD");
|
||||||
@@ -262,8 +269,6 @@ impl Step for Llvm {
|
|||||||
} else if target.contains("windows") {
|
} else if target.contains("windows") {
|
||||||
cfg.define("CMAKE_SYSTEM_NAME", "Windows");
|
cfg.define("CMAKE_SYSTEM_NAME", "Windows");
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.define("LLVM_NATIVE_BUILD", builder.llvm_out(builder.config.build).join("build"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref suffix) = builder.config.llvm_version_suffix {
|
if let Some(ref suffix) = builder.config.llvm_version_suffix {
|
||||||
@@ -431,6 +436,9 @@ fn configure_cmake(
|
|||||||
cflags.push_str(" -miphoneos-version-min=10.0");
|
cflags.push_str(" -miphoneos-version-min=10.0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if builder.config.llvm_clang_cl.is_some() {
|
||||||
|
cflags.push_str(&format!(" --target={}", target))
|
||||||
|
}
|
||||||
cfg.define("CMAKE_C_FLAGS", cflags);
|
cfg.define("CMAKE_C_FLAGS", cflags);
|
||||||
let mut cxxflags = builder.cflags(target, GitRepo::Llvm).join(" ");
|
let mut cxxflags = builder.cflags(target, GitRepo::Llvm).join(" ");
|
||||||
if builder.config.llvm_static_stdcpp && !target.contains("msvc") && !target.contains("netbsd") {
|
if builder.config.llvm_static_stdcpp && !target.contains("msvc") && !target.contains("netbsd") {
|
||||||
@@ -439,6 +447,9 @@ fn configure_cmake(
|
|||||||
if let Some(ref s) = builder.config.llvm_cxxflags {
|
if let Some(ref s) = builder.config.llvm_cxxflags {
|
||||||
cxxflags.push_str(&format!(" {}", s));
|
cxxflags.push_str(&format!(" {}", s));
|
||||||
}
|
}
|
||||||
|
if builder.config.llvm_clang_cl.is_some() {
|
||||||
|
cxxflags.push_str(&format!(" --target={}", target))
|
||||||
|
}
|
||||||
cfg.define("CMAKE_CXX_FLAGS", cxxflags);
|
cfg.define("CMAKE_CXX_FLAGS", cxxflags);
|
||||||
if let Some(ar) = builder.ar(target) {
|
if let Some(ar) = builder.ar(target) {
|
||||||
if ar.is_absolute() {
|
if ar.is_absolute() {
|
||||||
@@ -484,7 +495,7 @@ impl Step for Lld {
|
|||||||
run.builder.ensure(Lld { target: run.target });
|
run.builder.ensure(Lld { target: run.target });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compile LLVM for `target`.
|
/// Compile LLD for `target`.
|
||||||
fn run(self, builder: &Builder<'_>) -> PathBuf {
|
fn run(self, builder: &Builder<'_>) -> PathBuf {
|
||||||
if builder.config.dry_run {
|
if builder.config.dry_run {
|
||||||
return PathBuf::from("lld-out-dir-test-gen");
|
return PathBuf::from("lld-out-dir-test-gen");
|
||||||
@@ -521,6 +532,7 @@ impl Step for Lld {
|
|||||||
// can't build on a system where your paths require `\` on Windows, but
|
// can't build on a system where your paths require `\` on Windows, but
|
||||||
// there's probably a lot of reasons you can't do that other than this.
|
// there's probably a lot of reasons you can't do that other than this.
|
||||||
let llvm_config_shim = env::current_exe().unwrap().with_file_name("llvm-config-wrapper");
|
let llvm_config_shim = env::current_exe().unwrap().with_file_name("llvm-config-wrapper");
|
||||||
|
|
||||||
cfg.out_dir(&out_dir)
|
cfg.out_dir(&out_dir)
|
||||||
.profile("Release")
|
.profile("Release")
|
||||||
.env("LLVM_CONFIG_REAL", &llvm_config)
|
.env("LLVM_CONFIG_REAL", &llvm_config)
|
||||||
@@ -543,7 +555,10 @@ impl Step for Lld {
|
|||||||
if target != builder.config.build {
|
if target != builder.config.build {
|
||||||
cfg.env("LLVM_CONFIG_SHIM_REPLACE", &builder.config.build)
|
cfg.env("LLVM_CONFIG_SHIM_REPLACE", &builder.config.build)
|
||||||
.env("LLVM_CONFIG_SHIM_REPLACE_WITH", &target)
|
.env("LLVM_CONFIG_SHIM_REPLACE_WITH", &target)
|
||||||
.define("LLVM_TABLEGEN_EXE", llvm_config.with_file_name("llvm-tblgen"));
|
.define(
|
||||||
|
"LLVM_TABLEGEN_EXE",
|
||||||
|
llvm_config.with_file_name("llvm-tblgen").with_extension(EXE_EXTENSION),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Explicitly set C++ standard, because upstream doesn't do so
|
// Explicitly set C++ standard, because upstream doesn't do so
|
||||||
@@ -595,8 +610,8 @@ impl Step for TestHelpers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We may have found various cross-compilers a little differently due to our
|
// We may have found various cross-compilers a little differently due to our
|
||||||
// extra configuration, so inform gcc of these compilers. Note, though, that
|
// extra configuration, so inform cc of these compilers. Note, though, that
|
||||||
// on MSVC we still need gcc's detection of env vars (ugh).
|
// on MSVC we still need cc's detection of env vars (ugh).
|
||||||
if !target.contains("msvc") {
|
if !target.contains("msvc") {
|
||||||
if let Some(ar) = builder.ar(target) {
|
if let Some(ar) = builder.ar(target) {
|
||||||
cfg.archiver(ar);
|
cfg.archiver(ar);
|
||||||
|
|||||||
@@ -21,4 +21,128 @@
|
|||||||
</ArrayItems>
|
</ArrayItems>
|
||||||
</Expand>
|
</Expand>
|
||||||
</Type>
|
</Type>
|
||||||
|
<Type Name="tuple<>">
|
||||||
|
<DisplayString>()</DisplayString>
|
||||||
|
</Type>
|
||||||
|
<Type Name="tuple<*>">
|
||||||
|
<DisplayString>({__0})</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<Item Name="[0]">__0</Item>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
<Type Name="tuple<*,*>">
|
||||||
|
<DisplayString>({__0}, {__1})</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<Item Name="[0]">__0</Item>
|
||||||
|
<Item Name="[1]">__1</Item>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
<Type Name="tuple<*,*,*>">
|
||||||
|
<DisplayString>({__0}, {__1}, {__2})</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<Item Name="[0]">__0</Item>
|
||||||
|
<Item Name="[1]">__1</Item>
|
||||||
|
<Item Name="[2]">__2</Item>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
<Type Name="tuple<*,*,*,*>">
|
||||||
|
<DisplayString>({__0}, {__1}, {__2}, {__3})</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<Item Name="[0]">__0</Item>
|
||||||
|
<Item Name="[1]">__1</Item>
|
||||||
|
<Item Name="[2]">__2</Item>
|
||||||
|
<Item Name="[3]">__3</Item>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
<Type Name="tuple<*,*,*,*,*>">
|
||||||
|
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4})</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<Item Name="[0]">__0</Item>
|
||||||
|
<Item Name="[1]">__1</Item>
|
||||||
|
<Item Name="[2]">__2</Item>
|
||||||
|
<Item Name="[3]">__3</Item>
|
||||||
|
<Item Name="[4]">__4</Item>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
<Type Name="tuple<*,*,*,*,*,*>">
|
||||||
|
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5})</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<Item Name="[0]">__0</Item>
|
||||||
|
<Item Name="[1]">__1</Item>
|
||||||
|
<Item Name="[2]">__2</Item>
|
||||||
|
<Item Name="[3]">__3</Item>
|
||||||
|
<Item Name="[4]">__4</Item>
|
||||||
|
<Item Name="[5]">__5</Item>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
<Type Name="tuple<*,*,*,*,*,*,*>">
|
||||||
|
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6})</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<Item Name="[0]">__0</Item>
|
||||||
|
<Item Name="[1]">__1</Item>
|
||||||
|
<Item Name="[2]">__2</Item>
|
||||||
|
<Item Name="[3]">__3</Item>
|
||||||
|
<Item Name="[4]">__4</Item>
|
||||||
|
<Item Name="[5]">__5</Item>
|
||||||
|
<Item Name="[6]">__6</Item>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
<Type Name="tuple<*,*,*,*,*,*,*,*>">
|
||||||
|
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6}, {__7})</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<Item Name="[0]">__0</Item>
|
||||||
|
<Item Name="[1]">__1</Item>
|
||||||
|
<Item Name="[2]">__2</Item>
|
||||||
|
<Item Name="[3]">__3</Item>
|
||||||
|
<Item Name="[4]">__4</Item>
|
||||||
|
<Item Name="[5]">__5</Item>
|
||||||
|
<Item Name="[6]">__6</Item>
|
||||||
|
<Item Name="[7]">__7</Item>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
<Type Name="tuple<*,*,*,*,*,*,*,*,*>">
|
||||||
|
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6}, {__7}, {__8})</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<Item Name="[0]">__0</Item>
|
||||||
|
<Item Name="[1]">__1</Item>
|
||||||
|
<Item Name="[2]">__2</Item>
|
||||||
|
<Item Name="[3]">__3</Item>
|
||||||
|
<Item Name="[4]">__4</Item>
|
||||||
|
<Item Name="[5]">__5</Item>
|
||||||
|
<Item Name="[6]">__6</Item>
|
||||||
|
<Item Name="[7]">__7</Item>
|
||||||
|
<Item Name="[8]">__8</Item>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
<Type Name="tuple<*,*,*,*,*,*,*,*,*,*>">
|
||||||
|
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6}, {__7}, {__8}, {__9})</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<Item Name="[0]">__0</Item>
|
||||||
|
<Item Name="[1]">__1</Item>
|
||||||
|
<Item Name="[2]">__2</Item>
|
||||||
|
<Item Name="[3]">__3</Item>
|
||||||
|
<Item Name="[4]">__4</Item>
|
||||||
|
<Item Name="[5]">__5</Item>
|
||||||
|
<Item Name="[6]">__6</Item>
|
||||||
|
<Item Name="[7]">__7</Item>
|
||||||
|
<Item Name="[8]">__8</Item>
|
||||||
|
<Item Name="[9]">__9</Item>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
<Type Name="tuple<*,*,*,*,*,*,*,*,*,*,*>">
|
||||||
|
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6}, {__7}, {__8}, {__9}, ...)</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<Item Name="[0]">__0</Item>
|
||||||
|
<Item Name="[1]">__1</Item>
|
||||||
|
<Item Name="[2]">__2</Item>
|
||||||
|
<Item Name="[3]">__3</Item>
|
||||||
|
<Item Name="[4]">__4</Item>
|
||||||
|
<Item Name="[5]">__5</Item>
|
||||||
|
<Item Name="[6]">__6</Item>
|
||||||
|
<Item Name="[7]">__7</Item>
|
||||||
|
<Item Name="[8]">__8</Item>
|
||||||
|
<Item Name="[9]">__9</Item>
|
||||||
|
<Synthetic Name="[...]"><DisplayString>...</DisplayString></Synthetic>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
</AutoVisualizer>
|
</AutoVisualizer>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
mod is_ascii;
|
||||||
|
|
||||||
// Lower-case ASCII 'a' is the first byte that has its highest bit set
|
// Lower-case ASCII 'a' is the first byte that has its highest bit set
|
||||||
// after wrap-adding 0x1F:
|
// after wrap-adding 0x1F:
|
||||||
//
|
//
|
||||||
|
|||||||
82
src/libcore/benches/ascii/is_ascii.rs
Normal file
82
src/libcore/benches/ascii/is_ascii.rs
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
use super::{LONG, MEDIUM, SHORT};
|
||||||
|
use test::black_box;
|
||||||
|
use test::Bencher;
|
||||||
|
|
||||||
|
macro_rules! benches {
|
||||||
|
($( fn $name: ident($arg: ident: &[u8]) $body: block )+) => {
|
||||||
|
benches!(mod short SHORT[..] $($name $arg $body)+);
|
||||||
|
benches!(mod medium MEDIUM[..] $($name $arg $body)+);
|
||||||
|
benches!(mod long LONG[..] $($name $arg $body)+);
|
||||||
|
// Ensure we benchmark cases where the functions are called with strings
|
||||||
|
// that are not perfectly aligned or have a length which is not a
|
||||||
|
// multiple of size_of::<usize>() (or both)
|
||||||
|
benches!(mod unaligned_head MEDIUM[1..] $($name $arg $body)+);
|
||||||
|
benches!(mod unaligned_tail MEDIUM[..(MEDIUM.len() - 1)] $($name $arg $body)+);
|
||||||
|
benches!(mod unaligned_both MEDIUM[1..(MEDIUM.len() - 1)] $($name $arg $body)+);
|
||||||
|
};
|
||||||
|
|
||||||
|
(mod $mod_name: ident $input: ident [$range: expr] $($name: ident $arg: ident $body: block)+) => {
|
||||||
|
mod $mod_name {
|
||||||
|
use super::*;
|
||||||
|
$(
|
||||||
|
#[bench]
|
||||||
|
fn $name(bencher: &mut Bencher) {
|
||||||
|
bencher.bytes = $input[$range].len() as u64;
|
||||||
|
let mut vec = $input.as_bytes().to_vec();
|
||||||
|
bencher.iter(|| {
|
||||||
|
let $arg: &[u8] = &black_box(&mut vec)[$range];
|
||||||
|
black_box($body)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)+
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
benches! {
|
||||||
|
fn case00_libcore(bytes: &[u8]) {
|
||||||
|
bytes.is_ascii()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn case01_iter_all(bytes: &[u8]) {
|
||||||
|
bytes.iter().all(|b| b.is_ascii())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn case02_align_to(bytes: &[u8]) {
|
||||||
|
is_ascii_align_to(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn case03_align_to_unrolled(bytes: &[u8]) {
|
||||||
|
is_ascii_align_to_unrolled(bytes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// These are separate since it's easier to debug errors if they don't go through
|
||||||
|
// macro expansion first.
|
||||||
|
fn is_ascii_align_to(bytes: &[u8]) -> bool {
|
||||||
|
if bytes.len() < core::mem::size_of::<usize>() {
|
||||||
|
return bytes.iter().all(|b| b.is_ascii());
|
||||||
|
}
|
||||||
|
// SAFETY: transmuting a sequence of `u8` to `usize` is always fine
|
||||||
|
let (head, body, tail) = unsafe { bytes.align_to::<usize>() };
|
||||||
|
head.iter().all(|b| b.is_ascii())
|
||||||
|
&& body.iter().all(|w| !contains_nonascii(*w))
|
||||||
|
&& tail.iter().all(|b| b.is_ascii())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_ascii_align_to_unrolled(bytes: &[u8]) -> bool {
|
||||||
|
if bytes.len() < core::mem::size_of::<usize>() {
|
||||||
|
return bytes.iter().all(|b| b.is_ascii());
|
||||||
|
}
|
||||||
|
// SAFETY: transmuting a sequence of `u8` to `[usize; 2]` is always fine
|
||||||
|
let (head, body, tail) = unsafe { bytes.align_to::<[usize; 2]>() };
|
||||||
|
head.iter().all(|b| b.is_ascii())
|
||||||
|
&& body.iter().all(|w| !contains_nonascii(w[0] | w[1]))
|
||||||
|
&& tail.iter().all(|b| b.is_ascii())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn contains_nonascii(v: usize) -> bool {
|
||||||
|
const NONASCII_MASK: usize = 0x80808080_80808080u64 as usize;
|
||||||
|
(NONASCII_MASK & v) != 0
|
||||||
|
}
|
||||||
@@ -1285,7 +1285,9 @@ extern "rust-intrinsic" {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_const_unstable(feature = "const_transmute", issue = "53605")]
|
// NOTE: While this makes the intrinsic const stable, we have some custom code in const fn
|
||||||
|
// checks that prevent its use within `const fn`.
|
||||||
|
#[rustc_const_stable(feature = "const_transmute", since = "1.46.0")]
|
||||||
pub fn transmute<T, U>(e: T) -> U;
|
pub fn transmute<T, U>(e: T) -> U;
|
||||||
|
|
||||||
/// Returns `true` if the actual type given as `T` requires drop
|
/// Returns `true` if the actual type given as `T` requires drop
|
||||||
|
|||||||
@@ -140,7 +140,7 @@
|
|||||||
#![feature(rtm_target_feature)]
|
#![feature(rtm_target_feature)]
|
||||||
#![feature(f16c_target_feature)]
|
#![feature(f16c_target_feature)]
|
||||||
#![feature(hexagon_target_feature)]
|
#![feature(hexagon_target_feature)]
|
||||||
#![feature(const_transmute)]
|
#![cfg_attr(not(bootstrap), feature(const_fn_transmute))]
|
||||||
#![feature(abi_unadjusted)]
|
#![feature(abi_unadjusted)]
|
||||||
#![feature(adx_target_feature)]
|
#![feature(adx_target_feature)]
|
||||||
#![feature(maybe_uninit_slice)]
|
#![feature(maybe_uninit_slice)]
|
||||||
|
|||||||
@@ -2795,7 +2795,7 @@ impl [u8] {
|
|||||||
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
|
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_ascii(&self) -> bool {
|
pub fn is_ascii(&self) -> bool {
|
||||||
self.iter().all(|b| b.is_ascii())
|
is_ascii(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks that two slices are an ASCII case-insensitive match.
|
/// Checks that two slices are an ASCII case-insensitive match.
|
||||||
@@ -2843,6 +2843,106 @@ impl [u8] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns `true` if any byte in the word `v` is nonascii (>= 128). Snarfed
|
||||||
|
/// from `../str/mod.rs`, which does something similar for utf8 validation.
|
||||||
|
#[inline]
|
||||||
|
fn contains_nonascii(v: usize) -> bool {
|
||||||
|
const NONASCII_MASK: usize = 0x80808080_80808080u64 as usize;
|
||||||
|
(NONASCII_MASK & v) != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Optimized ASCII test that will use usize-at-a-time operations instead of
|
||||||
|
/// byte-at-a-time operations (when possible).
|
||||||
|
///
|
||||||
|
/// The algorithm we use here is pretty simple. If `s` is too short, we just
|
||||||
|
/// check each byte and be done with it. Otherwise:
|
||||||
|
///
|
||||||
|
/// - Read the first word with an unaligned load.
|
||||||
|
/// - Align the pointer, read subsequent words until end with aligned loads.
|
||||||
|
/// - If there's a tail, the last `usize` from `s` with an unaligned load.
|
||||||
|
///
|
||||||
|
/// If any of these loads produces something for which `contains_nonascii`
|
||||||
|
/// (above) returns true, then we know the answer is false.
|
||||||
|
#[inline]
|
||||||
|
fn is_ascii(s: &[u8]) -> bool {
|
||||||
|
const USIZE_SIZE: usize = mem::size_of::<usize>();
|
||||||
|
|
||||||
|
let len = s.len();
|
||||||
|
let align_offset = s.as_ptr().align_offset(USIZE_SIZE);
|
||||||
|
|
||||||
|
// If we wouldn't gain anything from the word-at-a-time implementation, fall
|
||||||
|
// back to a scalar loop.
|
||||||
|
//
|
||||||
|
// We also do this for architectures where `size_of::<usize>()` isn't
|
||||||
|
// sufficient alignment for `usize`, because it's a weird edge case.
|
||||||
|
if len < USIZE_SIZE || len < align_offset || USIZE_SIZE < mem::align_of::<usize>() {
|
||||||
|
return s.iter().all(|b| b.is_ascii());
|
||||||
|
}
|
||||||
|
|
||||||
|
// We always read the first word unaligned, which means `align_offset` is
|
||||||
|
// 0, we'd read the same value again for the aligned read.
|
||||||
|
let offset_to_aligned = if align_offset == 0 { USIZE_SIZE } else { align_offset };
|
||||||
|
|
||||||
|
let start = s.as_ptr();
|
||||||
|
// SAFETY: We verify `len < USIZE_SIZE` above.
|
||||||
|
let first_word = unsafe { (start as *const usize).read_unaligned() };
|
||||||
|
|
||||||
|
if contains_nonascii(first_word) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// We checked this above, somewhat implicitly. Note that `offset_to_aligned`
|
||||||
|
// is either `align_offset` or `USIZE_SIZE`, both of are explicitly checked
|
||||||
|
// above.
|
||||||
|
debug_assert!(offset_to_aligned <= len);
|
||||||
|
|
||||||
|
// word_ptr is the (properly aligned) usize ptr we use to read the middle chunk of the slice.
|
||||||
|
let mut word_ptr = unsafe { start.add(offset_to_aligned) as *const usize };
|
||||||
|
|
||||||
|
// `byte_pos` is the byte index of `word_ptr`, used for loop end checks.
|
||||||
|
let mut byte_pos = offset_to_aligned;
|
||||||
|
|
||||||
|
// Paranoia check about alignment, since we're about to do a bunch of
|
||||||
|
// unaligned loads. In practice this should be impossible barring a bug in
|
||||||
|
// `align_offset` though.
|
||||||
|
debug_assert_eq!((word_ptr as usize) % mem::align_of::<usize>(), 0);
|
||||||
|
|
||||||
|
while byte_pos <= len - USIZE_SIZE {
|
||||||
|
debug_assert!(
|
||||||
|
// Sanity check that the read is in bounds
|
||||||
|
(word_ptr as usize + USIZE_SIZE) <= (start.wrapping_add(len) as usize) &&
|
||||||
|
// And that our assumptions about `byte_pos` hold.
|
||||||
|
(word_ptr as usize) - (start as usize) == byte_pos
|
||||||
|
);
|
||||||
|
|
||||||
|
// Safety: We know `word_ptr` is properly aligned (because of
|
||||||
|
// `align_offset`), and we know that we have enough bytes between `word_ptr` and the end
|
||||||
|
let word = unsafe { word_ptr.read() };
|
||||||
|
if contains_nonascii(word) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte_pos += USIZE_SIZE;
|
||||||
|
// SAFETY: We know that `byte_pos <= len - USIZE_SIZE`, which means that
|
||||||
|
// after this `add`, `word_ptr` will be at most one-past-the-end.
|
||||||
|
word_ptr = unsafe { word_ptr.add(1) };
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we have anything left over, it should be at-most 1 usize worth of bytes,
|
||||||
|
// which we check with a read_unaligned.
|
||||||
|
if byte_pos == len {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sanity check to ensure there really is only one `usize` left. This should
|
||||||
|
// be guaranteed by our loop condition.
|
||||||
|
debug_assert!(byte_pos < len && len - byte_pos < USIZE_SIZE);
|
||||||
|
|
||||||
|
// SAFETY: This relies on `len >= USIZE_SIZE`, which we check at the start.
|
||||||
|
let last_word = unsafe { (start.add(len - USIZE_SIZE) as *const usize).read_unaligned() };
|
||||||
|
|
||||||
|
!contains_nonascii(last_word)
|
||||||
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<T, I> ops::Index<I> for [T]
|
impl<T, I> ops::Index<I> for [T]
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -4348,7 +4348,7 @@ impl str {
|
|||||||
// We can treat each byte as character here: all multibyte characters
|
// We can treat each byte as character here: all multibyte characters
|
||||||
// start with a byte that is not in the ascii range, so we will stop
|
// start with a byte that is not in the ascii range, so we will stop
|
||||||
// there already.
|
// there already.
|
||||||
self.bytes().all(|b| b.is_ascii())
|
self.as_bytes().is_ascii()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks that two strings are an ASCII case-insensitive match.
|
/// Checks that two strings are an ASCII case-insensitive match.
|
||||||
|
|||||||
@@ -343,3 +343,59 @@ fn test_is_ascii_control() {
|
|||||||
" ",
|
" ",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// `is_ascii` does a good amount of pointer manipulation and has
|
||||||
|
// alignment-dependent computation. This is all sanity-checked via
|
||||||
|
// `debug_assert!`s, so we test various sizes/alignments thoroughly versus an
|
||||||
|
// "obviously correct" baseline function.
|
||||||
|
#[test]
|
||||||
|
fn test_is_ascii_align_size_thoroughly() {
|
||||||
|
// The "obviously-correct" baseline mentioned above.
|
||||||
|
fn is_ascii_baseline(s: &[u8]) -> bool {
|
||||||
|
s.iter().all(|b| b.is_ascii())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper to repeat `l` copies of `b0` followed by `l` copies of `b1`.
|
||||||
|
fn repeat_concat(b0: u8, b1: u8, l: usize) -> Vec<u8> {
|
||||||
|
use core::iter::repeat;
|
||||||
|
repeat(b0).take(l).chain(repeat(b1).take(l)).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Miri is too slow for much of this, and in miri `align_offset` always
|
||||||
|
// returns `usize::max_value()` anyway (at the moment), so we just test
|
||||||
|
// lightly.
|
||||||
|
let iter = if cfg!(miri) { 0..5 } else { 0..100 };
|
||||||
|
|
||||||
|
for i in iter {
|
||||||
|
#[cfg(not(miri))]
|
||||||
|
let cases = &[
|
||||||
|
b"a".repeat(i),
|
||||||
|
b"\0".repeat(i),
|
||||||
|
b"\x7f".repeat(i),
|
||||||
|
b"\x80".repeat(i),
|
||||||
|
b"\xff".repeat(i),
|
||||||
|
repeat_concat(b'a', 0x80u8, i),
|
||||||
|
repeat_concat(0x80u8, b'a', i),
|
||||||
|
];
|
||||||
|
|
||||||
|
#[cfg(miri)]
|
||||||
|
let cases = &[repeat_concat(b'a', 0x80u8, i)];
|
||||||
|
|
||||||
|
for case in cases {
|
||||||
|
for pos in 0..=case.len() {
|
||||||
|
// Potentially misaligned head
|
||||||
|
let prefix = &case[pos..];
|
||||||
|
assert_eq!(is_ascii_baseline(prefix), prefix.is_ascii(),);
|
||||||
|
|
||||||
|
// Potentially misaligned tail
|
||||||
|
let suffix = &case[..case.len() - pos];
|
||||||
|
|
||||||
|
assert_eq!(is_ascii_baseline(suffix), suffix.is_ascii(),);
|
||||||
|
|
||||||
|
// Both head and tail are potentially misaligned
|
||||||
|
let mid = &case[(pos / 2)..(case.len() - (pos / 2))];
|
||||||
|
assert_eq!(is_ascii_baseline(mid), mid.is_ascii(),);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#![cfg_attr(bootstrap, feature(const_if_match))]
|
#![cfg_attr(bootstrap, feature(const_if_match))]
|
||||||
#![feature(const_fn)] // For the `transmute` in `P::new`
|
#![feature(const_fn)] // For the `transmute` in `P::new`
|
||||||
#![feature(const_panic)]
|
#![feature(const_panic)]
|
||||||
#![feature(const_transmute)]
|
#![cfg_attr(not(bootstrap), feature(const_fn_transmute))]
|
||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
#![feature(label_break_value)]
|
#![feature(label_break_value)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ use crate::llvm::debuginfo::{
|
|||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
|
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
use rustc_ast::ast;
|
||||||
use rustc_codegen_ssa::traits::*;
|
use rustc_codegen_ssa::traits::*;
|
||||||
use rustc_data_structures::const_cstr;
|
use rustc_data_structures::const_cstr;
|
||||||
use rustc_data_structures::fingerprint::Fingerprint;
|
use rustc_data_structures::fingerprint::Fingerprint;
|
||||||
@@ -827,14 +828,60 @@ fn file_metadata_raw(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trait MsvcBasicName {
|
||||||
|
fn msvc_basic_name(self) -> &'static str;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MsvcBasicName for ast::IntTy {
|
||||||
|
fn msvc_basic_name(self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
ast::IntTy::Isize => "ptrdiff_t",
|
||||||
|
ast::IntTy::I8 => "__int8",
|
||||||
|
ast::IntTy::I16 => "__int16",
|
||||||
|
ast::IntTy::I32 => "__int32",
|
||||||
|
ast::IntTy::I64 => "__int64",
|
||||||
|
ast::IntTy::I128 => "__int128",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MsvcBasicName for ast::UintTy {
|
||||||
|
fn msvc_basic_name(self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
ast::UintTy::Usize => "size_t",
|
||||||
|
ast::UintTy::U8 => "unsigned __int8",
|
||||||
|
ast::UintTy::U16 => "unsigned __int16",
|
||||||
|
ast::UintTy::U32 => "unsigned __int32",
|
||||||
|
ast::UintTy::U64 => "unsigned __int64",
|
||||||
|
ast::UintTy::U128 => "unsigned __int128",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MsvcBasicName for ast::FloatTy {
|
||||||
|
fn msvc_basic_name(self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
ast::FloatTy::F32 => "float",
|
||||||
|
ast::FloatTy::F64 => "double",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
|
fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
|
||||||
debug!("basic_type_metadata: {:?}", t);
|
debug!("basic_type_metadata: {:?}", t);
|
||||||
|
|
||||||
|
// When targeting MSVC, emit MSVC style type names for compatibility with
|
||||||
|
// .natvis visualizers (and perhaps other existing native debuggers?)
|
||||||
|
let msvc_like_names = cx.tcx.sess.target.target.options.is_like_msvc;
|
||||||
|
|
||||||
let (name, encoding) = match t.kind {
|
let (name, encoding) = match t.kind {
|
||||||
ty::Never => ("!", DW_ATE_unsigned),
|
ty::Never => ("!", DW_ATE_unsigned),
|
||||||
ty::Tuple(ref elements) if elements.is_empty() => ("()", DW_ATE_unsigned),
|
ty::Tuple(ref elements) if elements.is_empty() => ("()", DW_ATE_unsigned),
|
||||||
ty::Bool => ("bool", DW_ATE_boolean),
|
ty::Bool => ("bool", DW_ATE_boolean),
|
||||||
ty::Char => ("char", DW_ATE_unsigned_char),
|
ty::Char => ("char", DW_ATE_unsigned_char),
|
||||||
|
ty::Int(int_ty) if msvc_like_names => (int_ty.msvc_basic_name(), DW_ATE_signed),
|
||||||
|
ty::Uint(uint_ty) if msvc_like_names => (uint_ty.msvc_basic_name(), DW_ATE_unsigned),
|
||||||
|
ty::Float(float_ty) if msvc_like_names => (float_ty.msvc_basic_name(), DW_ATE_float),
|
||||||
ty::Int(int_ty) => (int_ty.name_str(), DW_ATE_signed),
|
ty::Int(int_ty) => (int_ty.name_str(), DW_ATE_signed),
|
||||||
ty::Uint(uint_ty) => (uint_ty.name_str(), DW_ATE_unsigned),
|
ty::Uint(uint_ty) => (uint_ty.name_str(), DW_ATE_unsigned),
|
||||||
ty::Float(float_ty) => (float_ty.name_str(), DW_ATE_float),
|
ty::Float(float_ty) => (float_ty.name_str(), DW_ATE_float),
|
||||||
@@ -851,7 +898,30 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
ty_metadata
|
if !msvc_like_names {
|
||||||
|
return ty_metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
let typedef_name = match t.kind {
|
||||||
|
ty::Int(int_ty) => int_ty.name_str(),
|
||||||
|
ty::Uint(uint_ty) => uint_ty.name_str(),
|
||||||
|
ty::Float(float_ty) => float_ty.name_str(),
|
||||||
|
_ => return ty_metadata,
|
||||||
|
};
|
||||||
|
|
||||||
|
let typedef_metadata = unsafe {
|
||||||
|
llvm::LLVMRustDIBuilderCreateTypedef(
|
||||||
|
DIB(cx),
|
||||||
|
ty_metadata,
|
||||||
|
typedef_name.as_ptr().cast(),
|
||||||
|
typedef_name.len(),
|
||||||
|
unknown_file_metadata(cx),
|
||||||
|
0,
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef_metadata
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foreign_type_metadata(
|
fn foreign_type_metadata(
|
||||||
|
|||||||
@@ -1703,6 +1703,16 @@ extern "C" {
|
|||||||
Encoding: c_uint,
|
Encoding: c_uint,
|
||||||
) -> &'a DIBasicType;
|
) -> &'a DIBasicType;
|
||||||
|
|
||||||
|
pub fn LLVMRustDIBuilderCreateTypedef(
|
||||||
|
Builder: &DIBuilder<'a>,
|
||||||
|
Type: &'a DIBasicType,
|
||||||
|
Name: *const c_char,
|
||||||
|
NameLen: size_t,
|
||||||
|
File: &'a DIFile,
|
||||||
|
LineNo: c_uint,
|
||||||
|
Scope: Option<&'a DIScope>,
|
||||||
|
) -> &'a DIDerivedType;
|
||||||
|
|
||||||
pub fn LLVMRustDIBuilderCreatePointerType(
|
pub fn LLVMRustDIBuilderCreatePointerType(
|
||||||
Builder: &DIBuilder<'a>,
|
Builder: &DIBuilder<'a>,
|
||||||
PointeeTy: &'a DIType,
|
PointeeTy: &'a DIType,
|
||||||
|
|||||||
@@ -619,9 +619,9 @@ impl<'a> Linker for GccLinker<'a> {
|
|||||||
// Some versions of `gcc` add it implicitly, some (e.g. `musl-gcc`) don't,
|
// Some versions of `gcc` add it implicitly, some (e.g. `musl-gcc`) don't,
|
||||||
// so we just always add it.
|
// so we just always add it.
|
||||||
fn add_eh_frame_header(&mut self) {
|
fn add_eh_frame_header(&mut self) {
|
||||||
// The condition here is "uses ELF" basically.
|
|
||||||
if !self.sess.target.target.options.is_like_osx
|
if !self.sess.target.target.options.is_like_osx
|
||||||
&& !self.sess.target.target.options.is_like_windows
|
&& !self.sess.target.target.options.is_like_windows
|
||||||
|
&& !self.sess.target.target.options.is_like_solaris
|
||||||
&& self.sess.target.target.target_os != "uefi"
|
&& self.sess.target.target.target_os != "uefi"
|
||||||
{
|
{
|
||||||
self.linker_arg("--eh-frame-hdr");
|
self.linker_arg("--eh-frame-hdr");
|
||||||
|
|||||||
@@ -47,7 +47,12 @@ pub fn push_debuginfo_type_name<'tcx>(
|
|||||||
push_type_params(tcx, substs, output, visited);
|
push_type_params(tcx, substs, output, visited);
|
||||||
}
|
}
|
||||||
ty::Tuple(component_types) => {
|
ty::Tuple(component_types) => {
|
||||||
output.push('(');
|
if cpp_like_names {
|
||||||
|
output.push_str("tuple<");
|
||||||
|
} else {
|
||||||
|
output.push('(');
|
||||||
|
}
|
||||||
|
|
||||||
for component_type in component_types {
|
for component_type in component_types {
|
||||||
push_debuginfo_type_name(tcx, component_type.expect_ty(), true, output, visited);
|
push_debuginfo_type_name(tcx, component_type.expect_ty(), true, output, visited);
|
||||||
output.push_str(", ");
|
output.push_str(", ");
|
||||||
@@ -56,7 +61,12 @@ pub fn push_debuginfo_type_name<'tcx>(
|
|||||||
output.pop();
|
output.pop();
|
||||||
output.pop();
|
output.pop();
|
||||||
}
|
}
|
||||||
output.push(')');
|
|
||||||
|
if cpp_like_names {
|
||||||
|
output.push('>');
|
||||||
|
} else {
|
||||||
|
output.push(')');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ty::RawPtr(ty::TypeAndMut { ty: inner_type, mutbl }) => {
|
ty::RawPtr(ty::TypeAndMut { ty: inner_type, mutbl }) => {
|
||||||
if !cpp_like_names {
|
if !cpp_like_names {
|
||||||
|
|||||||
@@ -573,6 +573,9 @@ declare_features! (
|
|||||||
/// Lazily evaluate constants. This allows constants to depend on type parameters.
|
/// Lazily evaluate constants. This allows constants to depend on type parameters.
|
||||||
(active, lazy_normalization_consts, "1.46.0", Some(72219), None),
|
(active, lazy_normalization_consts, "1.46.0", Some(72219), None),
|
||||||
|
|
||||||
|
/// Alloc calling `transmute` in const fn
|
||||||
|
(active, const_fn_transmute, "1.46.0", Some(53605), None),
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// feature-group-end: actual feature gates
|
// feature-group-end: actual feature gates
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
#![cfg_attr(bootstrap, feature(const_if_match))]
|
#![cfg_attr(bootstrap, feature(const_if_match))]
|
||||||
#![feature(const_fn)]
|
#![feature(const_fn)]
|
||||||
#![feature(const_panic)]
|
#![feature(const_panic)]
|
||||||
#![feature(const_transmute)]
|
#![cfg_attr(not(bootstrap), feature(const_fn_transmute))]
|
||||||
#![feature(core_intrinsics)]
|
#![feature(core_intrinsics)]
|
||||||
#![feature(discriminant_kind)]
|
#![feature(discriminant_kind)]
|
||||||
#![feature(drain_filter)]
|
#![feature(drain_filter)]
|
||||||
|
|||||||
@@ -393,7 +393,7 @@ pub trait PrettyPrinter<'tcx>:
|
|||||||
.tcx()
|
.tcx()
|
||||||
.item_children(visible_parent)
|
.item_children(visible_parent)
|
||||||
.iter()
|
.iter()
|
||||||
.find(|child| child.res.def_id() == def_id)
|
.find(|child| child.res.opt_def_id() == Some(def_id))
|
||||||
.map(|child| child.ident.name);
|
.map(|child| child.ident.name);
|
||||||
if let Some(reexport) = reexport {
|
if let Some(reexport) = reexport {
|
||||||
*name = reexport;
|
*name = reexport;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use rustc_middle::ty::subst::GenericArgKind;
|
|||||||
use rustc_middle::ty::{self, adjustment::PointerCast, Ty, TyCtxt};
|
use rustc_middle::ty::{self, adjustment::PointerCast, Ty, TyCtxt};
|
||||||
use rustc_span::symbol::{sym, Symbol};
|
use rustc_span::symbol::{sym, Symbol};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
use rustc_target::spec::abi::Abi::RustIntrinsic;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
type McfResult = Result<(), (Span, Cow<'static, str>)>;
|
type McfResult = Result<(), (Span, Cow<'static, str>)>;
|
||||||
@@ -418,6 +419,20 @@ fn check_terminator(
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HACK: This is to "unstabilize" the `transmute` intrinsic
|
||||||
|
// within const fns. `transmute` is allowed in all other const contexts.
|
||||||
|
// This won't really scale to more intrinsics or functions. Let's allow const
|
||||||
|
// transmutes in const fn before we add more hacks to this.
|
||||||
|
if tcx.fn_sig(fn_def_id).abi() == RustIntrinsic
|
||||||
|
&& tcx.item_name(fn_def_id) == sym::transmute
|
||||||
|
&& !feature_allowed(tcx, def_id, sym::const_fn_transmute)
|
||||||
|
{
|
||||||
|
return Err((
|
||||||
|
span,
|
||||||
|
"can only call `transmute` from const items, not `const fn`".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
check_operand(tcx, func, span, fn_def_id, body)?;
|
check_operand(tcx, func, span, fn_def_id, body)?;
|
||||||
|
|
||||||
for arg in args {
|
for arg in args {
|
||||||
|
|||||||
@@ -100,9 +100,7 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
|
|||||||
let ident_span = path.last().map_or(span, |ident| ident.ident.span);
|
let ident_span = path.last().map_or(span, |ident| ident.ident.span);
|
||||||
let ns = source.namespace();
|
let ns = source.namespace();
|
||||||
let is_expected = &|res| source.is_expected(res);
|
let is_expected = &|res| source.is_expected(res);
|
||||||
let is_enum_variant = &|res| {
|
let is_enum_variant = &|res| matches!(res, Res::Def(DefKind::Variant, _));
|
||||||
if let Res::Def(DefKind::Variant, _) = res { true } else { false }
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make the base error.
|
// Make the base error.
|
||||||
let expected = source.descr_expected();
|
let expected = source.descr_expected();
|
||||||
@@ -168,9 +166,9 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
|
|||||||
if ["this", "my"].contains(&&*item_str.as_str())
|
if ["this", "my"].contains(&&*item_str.as_str())
|
||||||
&& self.self_value_is_available(path[0].ident.span, span)
|
&& self.self_value_is_available(path[0].ident.span, span)
|
||||||
{
|
{
|
||||||
err.span_suggestion(
|
err.span_suggestion_short(
|
||||||
span,
|
span,
|
||||||
"did you mean",
|
"you might have meant to use `self` here instead",
|
||||||
"self".to_string(),
|
"self".to_string(),
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
@@ -1044,6 +1042,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
|
|||||||
lifetime_ref
|
lifetime_ref
|
||||||
);
|
);
|
||||||
err.span_label(lifetime_ref.span, "undeclared lifetime");
|
err.span_label(lifetime_ref.span, "undeclared lifetime");
|
||||||
|
let mut suggests_in_band = false;
|
||||||
for missing in &self.missing_named_lifetime_spots {
|
for missing in &self.missing_named_lifetime_spots {
|
||||||
match missing {
|
match missing {
|
||||||
MissingLifetimeSpot::Generics(generics) => {
|
MissingLifetimeSpot::Generics(generics) => {
|
||||||
@@ -1057,6 +1056,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
|
|||||||
}) {
|
}) {
|
||||||
(param.span.shrink_to_lo(), format!("{}, ", lifetime_ref))
|
(param.span.shrink_to_lo(), format!("{}, ", lifetime_ref))
|
||||||
} else {
|
} else {
|
||||||
|
suggests_in_band = true;
|
||||||
(generics.span, format!("<{}>", lifetime_ref))
|
(generics.span, format!("<{}>", lifetime_ref))
|
||||||
};
|
};
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
@@ -1084,6 +1084,15 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if nightly_options::is_nightly_build()
|
||||||
|
&& !self.tcx.features().in_band_lifetimes
|
||||||
|
&& suggests_in_band
|
||||||
|
{
|
||||||
|
err.help(
|
||||||
|
"if you want to experiment with in-band lifetime bindings, \
|
||||||
|
add `#![feature(in_band_lifetimes)]` to the crate attributes",
|
||||||
|
);
|
||||||
|
}
|
||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -226,6 +226,7 @@ symbols! {
|
|||||||
const_eval_limit,
|
const_eval_limit,
|
||||||
const_extern_fn,
|
const_extern_fn,
|
||||||
const_fn,
|
const_fn,
|
||||||
|
const_fn_transmute,
|
||||||
const_fn_union,
|
const_fn_union,
|
||||||
const_generics,
|
const_generics,
|
||||||
const_if_match,
|
const_if_match,
|
||||||
|
|||||||
Submodule src/llvm-project updated: 6c040dd86e...d134a53927
@@ -762,6 +762,14 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateBasicType(
|
|||||||
return wrap(Builder->createBasicType(StringRef(Name, NameLen), SizeInBits, Encoding));
|
return wrap(Builder->createBasicType(StringRef(Name, NameLen), SizeInBits, Encoding));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateTypedef(
|
||||||
|
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Type, const char *Name, size_t NameLen,
|
||||||
|
LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Scope) {
|
||||||
|
return wrap(Builder->createTypedef(
|
||||||
|
unwrap<DIType>(Type), StringRef(Name, NameLen), unwrap<DIFile>(File),
|
||||||
|
LineNo, unwrap<DIScope>(Scope)));
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreatePointerType(
|
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreatePointerType(
|
||||||
LLVMRustDIBuilderRef Builder, LLVMMetadataRef PointeeTy,
|
LLVMRustDIBuilderRef Builder, LLVMMetadataRef PointeeTy,
|
||||||
uint64_t SizeInBits, uint32_t AlignInBits, unsigned AddressSpace,
|
uint64_t SizeInBits, uint32_t AlignInBits, unsigned AddressSpace,
|
||||||
|
|||||||
@@ -123,6 +123,48 @@
|
|||||||
// lldbg-check:[...]$6 = { 0 = 15 1 = 16 }
|
// lldbg-check:[...]$6 = { 0 = 15 1 = 16 }
|
||||||
// lldbr-check:((i32, i16)) paddingAtEnd = { 0 = 15 1 = 16 }
|
// lldbr-check:((i32, i16)) paddingAtEnd = { 0 = 15 1 = 16 }
|
||||||
|
|
||||||
|
|
||||||
|
// === CDB TESTS ==================================================================================
|
||||||
|
|
||||||
|
// cdb-command: g
|
||||||
|
|
||||||
|
// cdb-command:dx noPadding8,d
|
||||||
|
// cdb-check:noPadding8,d [...]: (-100, 100) [Type: tuple<i8, u8>]
|
||||||
|
// cdb-check:[...][0] : -100 [Type: [...]]
|
||||||
|
// cdb-check:[...][1] : 100 [Type: [...]]
|
||||||
|
// cdb-command:dx noPadding16,d
|
||||||
|
// cdb-check:noPadding16,d [...]: (0, 1, 2) [Type: tuple<i16, i16, u16>]
|
||||||
|
// cdb-check:[...][0] : 0 [Type: [...]]
|
||||||
|
// cdb-check:[...][1] : 1 [Type: [...]]
|
||||||
|
// cdb-check:[...][2] : 2 [Type: [...]]
|
||||||
|
// cdb-command:dx noPadding32,d
|
||||||
|
// cdb-check:noPadding32,d [...]: (3, 4.5[...], 5) [Type: tuple<i32, f32, u32>]
|
||||||
|
// cdb-check:[...][0] : 3 [Type: [...]]
|
||||||
|
// cdb-check:[...][1] : 4.5[...] [Type: [...]]
|
||||||
|
// cdb-check:[...][2] : 5 [Type: [...]]
|
||||||
|
// cdb-command:dx noPadding64,d
|
||||||
|
// cdb-check:noPadding64,d [...]: (6, 7.5[...], 8) [Type: tuple<i64, f64, u64>]
|
||||||
|
// cdb-check:[...][0] : 6 [Type: [...]]
|
||||||
|
// cdb-check:[...][1] : 7.500000 [Type: [...]]
|
||||||
|
// cdb-check:[...][2] : 8 [Type: [...]]
|
||||||
|
|
||||||
|
// cdb-command:dx internalPadding1,d
|
||||||
|
// cdb-check:internalPadding1,d [...]: (9, 10) [Type: tuple<i16, i32>]
|
||||||
|
// cdb-check:[...][0] : 9 [Type: short]
|
||||||
|
// cdb-check:[...][1] : 10 [Type: int]
|
||||||
|
// cdb-command:dx internalPadding2,d
|
||||||
|
// cdb-check:internalPadding2,d [...]: (11, 12, 13, 14) [Type: tuple<i16, i32, u32, u64>]
|
||||||
|
// cdb-check:[...][0] : 11 [Type: [...]]
|
||||||
|
// cdb-check:[...][1] : 12 [Type: [...]]
|
||||||
|
// cdb-check:[...][2] : 13 [Type: [...]]
|
||||||
|
// cdb-check:[...][3] : 14 [Type: [...]]
|
||||||
|
|
||||||
|
// cdb-command:dx paddingAtEnd,d
|
||||||
|
// cdb-check:paddingAtEnd,d [...]: (15, 16) [Type: tuple<i32, i16>]
|
||||||
|
// cdb-check:[...][0] : 15 [Type: [...]]
|
||||||
|
// cdb-check:[...][1] : 16 [Type: [...]]
|
||||||
|
|
||||||
|
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![feature(omit_gdb_pretty_printer_section)]
|
#![feature(omit_gdb_pretty_printer_section)]
|
||||||
|
|||||||
@@ -59,6 +59,73 @@
|
|||||||
// lldbg-check:[...]$6 = { 0 = { 0 = 21 1 = 22 } 1 = 23 }
|
// lldbg-check:[...]$6 = { 0 = { 0 = 21 1 = 22 } 1 = 23 }
|
||||||
// lldbr-check:(((i32, i16), i32)) padding_at_end2 = { 0 = { 0 = 21 1 = 22 } 1 = 23 }
|
// lldbr-check:(((i32, i16), i32)) padding_at_end2 = { 0 = { 0 = 21 1 = 22 } 1 = 23 }
|
||||||
|
|
||||||
|
|
||||||
|
// === CDB TESTS ==================================================================================
|
||||||
|
|
||||||
|
// cdb-command: g
|
||||||
|
|
||||||
|
// cdb-command:dx no_padding1,d
|
||||||
|
// cdb-check:no_padding1,d [...]: ((0, 1), 2, 3) [Type: tuple<tuple<u32, u32>, u32, u32>]
|
||||||
|
// cdb-check:[...][0] : (0, 1) [Type: tuple<u32, u32>]
|
||||||
|
// cdb-check:[...][1] : 2 [Type: [...]]
|
||||||
|
// cdb-check:[...][2] : 3 [Type: [...]]
|
||||||
|
// cdb-command:dx no_padding1.__0,d
|
||||||
|
// cdb-check:no_padding1.__0,d [...]: (0, 1) [Type: tuple<u32, u32>]
|
||||||
|
// cdb-check:[...][0] : 0 [Type: [...]]
|
||||||
|
// cdb-check:[...][1] : 1 [Type: [...]]
|
||||||
|
// cdb-command:dx no_padding2,d
|
||||||
|
// cdb-check:no_padding2,d [...]: (4, (5, 6), 7) [Type: tuple<u32, tuple<u32, u32>, u32>]
|
||||||
|
// cdb-check:[...][0] : 4 [Type: [...]]
|
||||||
|
// cdb-check:[...][1] : (5, 6) [Type: tuple<u32, u32>]
|
||||||
|
// cdb-check:[...][2] : 7 [Type: [...]]
|
||||||
|
// cdb-command:dx no_padding2.__1,d
|
||||||
|
// cdb-check:no_padding2.__1,d [...]: (5, 6) [Type: tuple<u32, u32>]
|
||||||
|
// cdb-check:[...][0] : 5 [Type: [...]]
|
||||||
|
// cdb-check:[...][1] : 6 [Type: [...]]
|
||||||
|
// cdb-command:dx no_padding3,d
|
||||||
|
// cdb-check:no_padding3,d [...]: (8, 9, (10, 11)) [Type: tuple<u32, u32, tuple<u32, u32>>]
|
||||||
|
// cdb-check:[...][0] : 8 [Type: [...]]
|
||||||
|
// cdb-check:[...][1] : 9 [Type: [...]]
|
||||||
|
// cdb-check:[...][2] : (10, 11) [Type: tuple<u32, u32>]
|
||||||
|
// cdb-command:dx no_padding3.__2,d
|
||||||
|
// cdb-check:no_padding3.__2,d [...]: (10, 11) [Type: tuple<u32, u32>]
|
||||||
|
// cdb-check:[...][0] : 10 [Type: [...]]
|
||||||
|
// cdb-check:[...][1] : 11 [Type: [...]]
|
||||||
|
|
||||||
|
// cdb-command:dx internal_padding1,d
|
||||||
|
// cdb-check:internal_padding1,d [...]: (12, (13, 14)) [Type: tuple<i16, tuple<i32, i32>>]
|
||||||
|
// cdb-check:[...][0] : 12 [Type: [...]]
|
||||||
|
// cdb-check:[...][1] : (13, 14) [Type: tuple<i32, i32>]
|
||||||
|
// cdb-command:dx internal_padding1.__1,d
|
||||||
|
// cdb-check:internal_padding1.__1,d [...]: (13, 14) [Type: tuple<i32, i32>]
|
||||||
|
// cdb-check:[...][0] : 13 [Type: [...]]
|
||||||
|
// cdb-check:[...][1] : 14 [Type: [...]]
|
||||||
|
// cdb-command:dx internal_padding2,d
|
||||||
|
// cdb-check:internal_padding2,d [...]: (15, (16, 17)) [Type: tuple<i16, tuple<i16, i32>>]
|
||||||
|
// cdb-check:[...][0] : 15 [Type: [...]]
|
||||||
|
// cdb-check:[...][1] : (16, 17) [Type: tuple<i16, i32>]
|
||||||
|
// cdb-command:dx internal_padding2.__1,d
|
||||||
|
// cdb-check:internal_padding2.__1,d [...]: (16, 17) [Type: tuple<i16, i32>]
|
||||||
|
// cdb-check:[...][0] : 16 [Type: [...]]
|
||||||
|
// cdb-check:[...][1] : 17 [Type: [...]]
|
||||||
|
|
||||||
|
// cdb-command:dx padding_at_end1,d
|
||||||
|
// cdb-check:padding_at_end1,d [...]: (18, (19, 20)) [Type: tuple<i32, tuple<i32, i16>>]
|
||||||
|
// cdb-check:[...][0] : 18 [Type: [...]]
|
||||||
|
// cdb-check:[...][1] : (19, 20) [Type: tuple<i32, i16>]
|
||||||
|
// cdb-command:dx padding_at_end1.__1,d
|
||||||
|
// cdb-check:padding_at_end1.__1,d [...][Type: tuple<i32, i16>]
|
||||||
|
// cdb-check:[...][0] : 19 [Type: [...]]
|
||||||
|
// cdb-check:[...][1] : 20 [Type: [...]]
|
||||||
|
// cdb-command:dx padding_at_end2,d
|
||||||
|
// cdb-check:padding_at_end2,d [...]: ((21, 22), 23) [Type: tuple<tuple<i32, i16>, i32>]
|
||||||
|
// cdb-check:[...][0] : (21, 22) [Type: tuple<i32, i16>]
|
||||||
|
// cdb-check:[...][1] : 23 [Type: [...]]
|
||||||
|
// cdb-command:dx padding_at_end2.__0,d
|
||||||
|
// cdb-check:padding_at_end2.__0,d [...]: (21, 22) [Type: tuple<i32, i16>]
|
||||||
|
// cdb-check:[...][0] : 21 [Type: [...]]
|
||||||
|
// cdb-check:[...][1] : 22 [Type: [...]]
|
||||||
|
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![feature(omit_gdb_pretty_printer_section)]
|
#![feature(omit_gdb_pretty_printer_section)]
|
||||||
#![omit_gdb_pretty_printer_section]
|
#![omit_gdb_pretty_printer_section]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#![feature(const_transmute, const_raw_ptr_deref)]
|
#![feature(const_raw_ptr_deref)]
|
||||||
|
|
||||||
use std::{mem, usize};
|
use std::{mem, usize};
|
||||||
|
|
||||||
|
|||||||
@@ -20,4 +20,6 @@ static FOO: (&Foo, &Bar) = unsafe {(
|
|||||||
Union { u8: &BAR }.bar,
|
Union { u8: &BAR }.bar,
|
||||||
)};
|
)};
|
||||||
|
|
||||||
|
static FOO2: (&Foo, &Bar) = unsafe {(std::mem::transmute(&BAR), std::mem::transmute(&BAR))};
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|||||||
@@ -17,5 +17,7 @@ static FOO: (&Foo, &Bar) = unsafe {( //~ undefined behavior
|
|||||||
Union { u8: &BAR }.foo,
|
Union { u8: &BAR }.foo,
|
||||||
Union { u8: &BAR }.bar,
|
Union { u8: &BAR }.bar,
|
||||||
)};
|
)};
|
||||||
|
static FOO2: (&Foo, &Bar) = unsafe {(std::mem::transmute(&BAR), std::mem::transmute(&BAR))};
|
||||||
|
//~^ undefined behavior
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|||||||
@@ -9,6 +9,14 @@ LL | | )};
|
|||||||
|
|
|
|
||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error: aborting due to previous error
|
error[E0080]: it is undefined behavior to use this value
|
||||||
|
--> $DIR/double_check2.rs:20:1
|
||||||
|
|
|
||||||
|
LL | static FOO2: (&Foo, &Bar) = unsafe {(std::mem::transmute(&BAR), std::mem::transmute(&BAR))};
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x05 at .1.<deref>.<enum-tag>, but expected a valid enum tag
|
||||||
|
|
|
||||||
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
// Test that we can handle newtypes wrapping extern types
|
// Test that we can handle newtypes wrapping extern types
|
||||||
|
|
||||||
#![feature(extern_types, const_transmute)]
|
#![feature(extern_types)]
|
||||||
|
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
#![feature(const_transmute)]
|
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
static FOO: bool = unsafe { mem::transmute(3u8) };
|
static FOO: bool = unsafe { mem::transmute(3u8) };
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/transmute-const.rs:5:1
|
--> $DIR/transmute-const.rs:3:1
|
||||||
|
|
|
|
||||||
LL | static FOO: bool = unsafe { mem::transmute(3u8) };
|
LL | static FOO: bool = unsafe { mem::transmute(3u8) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x03, but expected a boolean
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x03, but expected a boolean
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// normalize-stderr-64bit "0x0000000000" -> "0x00"
|
// normalize-stderr-64bit "0x0000000000" -> "0x00"
|
||||||
#![feature(const_transmute, never_type)]
|
#![feature(never_type)]
|
||||||
#![allow(const_err)] // make sure we cannot allow away the errors tested here
|
#![allow(const_err)] // make sure we cannot allow away the errors tested here
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#![feature(const_transmute)]
|
|
||||||
#![allow(const_err)] // make sure we cannot allow away the errors tested here
|
#![allow(const_err)] // make sure we cannot allow away the errors tested here
|
||||||
|
|
||||||
//! Test the "array of int" fast path in validity checking, and in particular whether it
|
//! Test the "array of int" fast path in validity checking, and in particular whether it
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-int-array.rs:15:1
|
--> $DIR/ub-int-array.rs:14:1
|
||||||
|
|
|
|
||||||
LL | / const UNINIT_INT_0: [u32; 3] = unsafe {
|
LL | / const UNINIT_INT_0: [u32; 3] = unsafe {
|
||||||
LL | |
|
LL | |
|
||||||
@@ -13,7 +13,7 @@ LL | | };
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-int-array.rs:24:1
|
--> $DIR/ub-int-array.rs:23:1
|
||||||
|
|
|
|
||||||
LL | / const UNINIT_INT_1: [u32; 3] = unsafe {
|
LL | / const UNINIT_INT_1: [u32; 3] = unsafe {
|
||||||
LL | |
|
LL | |
|
||||||
@@ -27,7 +27,7 @@ LL | | };
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-int-array.rs:44:1
|
--> $DIR/ub-int-array.rs:43:1
|
||||||
|
|
|
|
||||||
LL | / const UNINIT_INT_2: [u32; 3] = unsafe {
|
LL | / const UNINIT_INT_2: [u32; 3] = unsafe {
|
||||||
LL | |
|
LL | |
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#![feature(rustc_attrs, const_transmute)]
|
#![feature(rustc_attrs)]
|
||||||
#![allow(const_err, invalid_value)] // make sure we cannot allow away the errors tested here
|
#![allow(const_err, invalid_value)] // make sure we cannot allow away the errors tested here
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// ignore-tidy-linelength
|
// ignore-tidy-linelength
|
||||||
#![feature(const_transmute)]
|
|
||||||
#![allow(const_err, invalid_value)] // make sure we cannot allow away the errors tested here
|
#![allow(const_err, invalid_value)] // make sure we cannot allow away the errors tested here
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-ref.rs:7:1
|
--> $DIR/ub-ref.rs:6:1
|
||||||
|
|
|
|
||||||
LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
|
LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered an unaligned reference (required 2 byte alignment but found 1)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered an unaligned reference (required 2 byte alignment but found 1)
|
||||||
@@ -7,7 +7,7 @@ LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-ref.rs:11:1
|
--> $DIR/ub-ref.rs:10:1
|
||||||
|
|
|
|
||||||
LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
|
LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered an unaligned box (required 2 byte alignment but found 1)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered an unaligned box (required 2 byte alignment but found 1)
|
||||||
@@ -15,7 +15,7 @@ LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-ref.rs:15:1
|
--> $DIR/ub-ref.rs:14:1
|
||||||
|
|
|
|
||||||
LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
|
LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a NULL reference
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a NULL reference
|
||||||
@@ -23,7 +23,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-ref.rs:18:1
|
--> $DIR/ub-ref.rs:17:1
|
||||||
|
|
|
|
||||||
LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
|
LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a NULL box
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a NULL box
|
||||||
@@ -31,7 +31,7 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-ref.rs:24:1
|
--> $DIR/ub-ref.rs:23:1
|
||||||
|
|
|
|
||||||
LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
|
LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc16, but expected initialized plain (non-pointer) bytes
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc16, but expected initialized plain (non-pointer) bytes
|
||||||
@@ -39,7 +39,7 @@ LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-ref.rs:27:1
|
--> $DIR/ub-ref.rs:26:1
|
||||||
|
|
|
|
||||||
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
|
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer at .<deref>, but expected plain (non-pointer) bytes
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer at .<deref>, but expected plain (non-pointer) bytes
|
||||||
@@ -47,7 +47,7 @@ LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-ref.rs:30:1
|
--> $DIR/ub-ref.rs:29:1
|
||||||
|
|
|
|
||||||
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
|
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer at .<deref>, but expected plain (non-pointer) bytes
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer at .<deref>, but expected plain (non-pointer) bytes
|
||||||
@@ -55,7 +55,7 @@ LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[us
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-ref.rs:33:1
|
--> $DIR/ub-ref.rs:32:1
|
||||||
|
|
|
|
||||||
LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
|
LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling reference (created from integer)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling reference (created from integer)
|
||||||
@@ -63,7 +63,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-ref.rs:36:1
|
--> $DIR/ub-ref.rs:35:1
|
||||||
|
|
|
|
||||||
LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
|
LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling box (created from integer)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling box (created from integer)
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#![feature(const_transmute)]
|
|
||||||
#![allow(const_err)] // make sure we cannot allow away the errors tested here
|
#![allow(const_err)] // make sure we cannot allow away the errors tested here
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-uninhabit.rs:15:1
|
--> $DIR/ub-uninhabit.rs:14:1
|
||||||
|
|
|
|
||||||
LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init };
|
LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of uninhabited type Bar
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of uninhabited type Bar
|
||||||
@@ -7,7 +7,7 @@ LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init };
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-uninhabit.rs:18:1
|
--> $DIR/ub-uninhabit.rs:17:1
|
||||||
|
|
|
|
||||||
LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
|
LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of uninhabited type Bar at .<deref>
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of uninhabited type Bar at .<deref>
|
||||||
@@ -15,7 +15,7 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-uninhabit.rs:21:1
|
--> $DIR/ub-uninhabit.rs:20:1
|
||||||
|
|
|
|
||||||
LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init };
|
LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of uninhabited type Bar at [0]
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of uninhabited type Bar at [0]
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#![feature(const_transmute)]
|
|
||||||
#![allow(const_err, invalid_value)] // make sure we cannot allow away the errors tested here
|
#![allow(const_err, invalid_value)] // make sure we cannot allow away the errors tested here
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-upvars.rs:6:1
|
--> $DIR/ub-upvars.rs:5:1
|
||||||
|
|
|
|
||||||
LL | / const BAD_UPVAR: &dyn FnOnce() = &{
|
LL | / const BAD_UPVAR: &dyn FnOnce() = &{
|
||||||
LL | | let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) };
|
LL | | let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) };
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// ignore-tidy-linelength
|
// ignore-tidy-linelength
|
||||||
#![feature(const_transmute)]
|
|
||||||
#![allow(unused)]
|
#![allow(unused)]
|
||||||
#![allow(const_err)] // make sure we cannot allow away the errors tested here
|
#![allow(const_err)] // make sure we cannot allow away the errors tested here
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:32:1
|
--> $DIR/ub-wide-ptr.rs:31:1
|
||||||
|
|
|
|
||||||
LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
|
LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling reference (going beyond the bounds of its allocation)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling reference (going beyond the bounds of its allocation)
|
||||||
@@ -7,7 +7,7 @@ LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:34:1
|
--> $DIR/ub-wide-ptr.rs:33:1
|
||||||
|
|
|
|
||||||
LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },);
|
LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid reference metadata: slice is bigger than largest supported object at .0
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid reference metadata: slice is bigger than largest supported object at .0
|
||||||
@@ -15,7 +15,7 @@ LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, us
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:37:1
|
--> $DIR/ub-wide-ptr.rs:36:1
|
||||||
|
|
|
|
||||||
LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) };
|
LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in wide pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in wide pointer
|
||||||
@@ -23,7 +23,7 @@ LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) };
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:40:1
|
--> $DIR/ub-wide-ptr.rs:39:1
|
||||||
|
|
|
|
||||||
LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) };
|
LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in wide pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in wide pointer
|
||||||
@@ -31,7 +31,7 @@ LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) };
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:42:1
|
--> $DIR/ub-wide-ptr.rs:41:1
|
||||||
|
|
|
|
||||||
LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) };
|
LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid reference metadata: slice is bigger than largest supported object
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid reference metadata: slice is bigger than largest supported object
|
||||||
@@ -39,7 +39,7 @@ LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize:
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:46:1
|
--> $DIR/ub-wide-ptr.rs:45:1
|
||||||
|
|
|
|
||||||
LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
|
LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized data in `str` at .<deref>
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized data in `str` at .<deref>
|
||||||
@@ -47,7 +47,7 @@ LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:49:1
|
--> $DIR/ub-wide-ptr.rs:48:1
|
||||||
|
|
|
|
||||||
LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
|
LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized data in `str` at .<deref>.0
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized data in `str` at .<deref>.0
|
||||||
@@ -55,7 +55,7 @@ LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUni
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:56:1
|
--> $DIR/ub-wide-ptr.rs:55:1
|
||||||
|
|
|
|
||||||
LL | / const SLICE_LENGTH_UNINIT: &[u8] = unsafe {
|
LL | / const SLICE_LENGTH_UNINIT: &[u8] = unsafe {
|
||||||
LL | |
|
LL | |
|
||||||
@@ -67,7 +67,7 @@ LL | | };
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:62:1
|
--> $DIR/ub-wide-ptr.rs:61:1
|
||||||
|
|
|
|
||||||
LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
|
LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling reference (going beyond the bounds of its allocation)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling reference (going beyond the bounds of its allocation)
|
||||||
@@ -75,7 +75,7 @@ LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:65:1
|
--> $DIR/ub-wide-ptr.rs:64:1
|
||||||
|
|
|
|
||||||
LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) };
|
LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in wide pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in wide pointer
|
||||||
@@ -83,7 +83,7 @@ LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) };
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:68:1
|
--> $DIR/ub-wide-ptr.rs:67:1
|
||||||
|
|
|
|
||||||
LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) };
|
LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling box (going beyond the bounds of its allocation)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling box (going beyond the bounds of its allocation)
|
||||||
@@ -91,7 +91,7 @@ LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999us
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:71:1
|
--> $DIR/ub-wide-ptr.rs:70:1
|
||||||
|
|
|
|
||||||
LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) };
|
LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in wide pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in wide pointer
|
||||||
@@ -99,7 +99,7 @@ LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:75:1
|
--> $DIR/ub-wide-ptr.rs:74:1
|
||||||
|
|
|
|
||||||
LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x03 at .<deref>[0], but expected a boolean
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x03 at .<deref>[0], but expected a boolean
|
||||||
@@ -107,7 +107,7 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:81:1
|
--> $DIR/ub-wide-ptr.rs:80:1
|
||||||
|
|
|
|
||||||
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
|
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x03 at .<deref>.0, but expected a boolean
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x03 at .<deref>.0, but expected a boolean
|
||||||
@@ -115,7 +115,7 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:84:1
|
--> $DIR/ub-wide-ptr.rs:83:1
|
||||||
|
|
|
|
||||||
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
|
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x03 at .<deref>.1[0], but expected a boolean
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x03 at .<deref>.1[0], but expected a boolean
|
||||||
@@ -123,7 +123,7 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:91:1
|
--> $DIR/ub-wide-ptr.rs:90:1
|
||||||
|
|
|
|
||||||
LL | / const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe {
|
LL | / const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe {
|
||||||
LL | |
|
LL | |
|
||||||
@@ -135,7 +135,7 @@ LL | | };
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:99:1
|
--> $DIR/ub-wide-ptr.rs:98:1
|
||||||
|
|
|
|
||||||
LL | const TRAIT_OBJ_SHORT_VTABLE_1: &dyn Trait = unsafe { mem::transmute((&92u8, &3u8)) };
|
LL | const TRAIT_OBJ_SHORT_VTABLE_1: &dyn Trait = unsafe { mem::transmute((&92u8, &3u8)) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered too small vtable
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered too small vtable
|
||||||
@@ -143,7 +143,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_1: &dyn Trait = unsafe { mem::transmute((&92u8
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:102:1
|
--> $DIR/ub-wide-ptr.rs:101:1
|
||||||
|
|
|
|
||||||
LL | const TRAIT_OBJ_SHORT_VTABLE_2: &dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
|
LL | const TRAIT_OBJ_SHORT_VTABLE_2: &dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered too small vtable
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered too small vtable
|
||||||
@@ -151,7 +151,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_2: &dyn Trait = unsafe { mem::transmute((&92u8
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:105:1
|
--> $DIR/ub-wide-ptr.rs:104:1
|
||||||
|
|
|
|
||||||
LL | const TRAIT_OBJ_INT_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, 4usize)) };
|
LL | const TRAIT_OBJ_INT_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, 4usize)) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling vtable pointer in wide pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling vtable pointer in wide pointer
|
||||||
@@ -159,7 +159,7 @@ LL | const TRAIT_OBJ_INT_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, 4u
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:107:1
|
--> $DIR/ub-wide-ptr.rs:106:1
|
||||||
|
|
|
|
||||||
LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) };
|
LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered unaligned vtable pointer in wide pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered unaligned vtable pointer in wide pointer
|
||||||
@@ -167,7 +167,7 @@ LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:109:1
|
--> $DIR/ub-wide-ptr.rs:108:1
|
||||||
|
|
|
|
||||||
LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) };
|
LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable (not pointing to a function)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable (not pointing to a function)
|
||||||
@@ -175,7 +175,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:111:1
|
--> $DIR/ub-wide-ptr.rs:110:1
|
||||||
|
|
|
|
||||||
LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) };
|
LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable (not pointing to a function)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable (not pointing to a function)
|
||||||
@@ -183,7 +183,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:113:1
|
--> $DIR/ub-wide-ptr.rs:112:1
|
||||||
|
|
|
|
||||||
LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: &dyn Trait = unsafe { mem::transmute((&92u8, &[&42u8; 8])) };
|
LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: &dyn Trait = unsafe { mem::transmute((&92u8, &[&42u8; 8])) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable (not pointing to a function)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable (not pointing to a function)
|
||||||
@@ -191,7 +191,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: &dyn Trait = unsafe { mem::transmut
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:117:1
|
--> $DIR/ub-wide-ptr.rs:116:1
|
||||||
|
|
|
|
||||||
LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) };
|
LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x03 at .<deref>.<dyn-downcast>, but expected a boolean
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x03 at .<deref>.<dyn-downcast>, but expected a boolean
|
||||||
@@ -199,7 +199,7 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_,
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:121:1
|
--> $DIR/ub-wide-ptr.rs:120:1
|
||||||
|
|
|
|
||||||
LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
|
LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling vtable pointer in wide pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling vtable pointer in wide pointer
|
||||||
@@ -207,7 +207,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:123:1
|
--> $DIR/ub-wide-ptr.rs:122:1
|
||||||
|
|
|
|
||||||
LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
|
LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered too small vtable
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered too small vtable
|
||||||
@@ -215,13 +215,13 @@ LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transm
|
|||||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||||
|
|
||||||
error[E0080]: could not evaluate static initializer
|
error[E0080]: could not evaluate static initializer
|
||||||
--> $DIR/ub-wide-ptr.rs:129:5
|
--> $DIR/ub-wide-ptr.rs:128:5
|
||||||
|
|
|
|
||||||
LL | mem::transmute::<_, &dyn Trait>((&92u8, 0usize))
|
LL | mem::transmute::<_, &dyn Trait>((&92u8, 0usize))
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ inbounds test failed: 0x0 is not a valid pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ inbounds test failed: 0x0 is not a valid pointer
|
||||||
|
|
||||||
error[E0080]: could not evaluate static initializer
|
error[E0080]: could not evaluate static initializer
|
||||||
--> $DIR/ub-wide-ptr.rs:133:5
|
--> $DIR/ub-wide-ptr.rs:132:5
|
||||||
|
|
|
|
||||||
LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64))
|
LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64))
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: pointer must be in-bounds at offset N, but is outside bounds of allocN which has size N
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: pointer must be in-bounds at offset N, but is outside bounds of allocN which has size N
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// check-pass
|
// check-pass
|
||||||
|
|
||||||
// Some constants that *are* valid
|
// Some constants that *are* valid
|
||||||
#![feature(const_transmute)]
|
|
||||||
#![deny(const_err)]
|
#![deny(const_err)]
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#![feature(const_fn)]
|
#![feature(const_fn)]
|
||||||
#![feature(const_transmute)]
|
#![feature(const_fn_transmute)]
|
||||||
|
|
||||||
const fn foo() -> ! {
|
const fn foo() -> ! {
|
||||||
unsafe { std::mem::transmute(()) }
|
unsafe { std::mem::transmute(()) }
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// run-pass
|
// run-pass
|
||||||
#![feature(const_transmute)]
|
|
||||||
|
|
||||||
const FOO: isize = 10;
|
const FOO: isize = 10;
|
||||||
const BAR: isize = 3;
|
const BAR: isize = 3;
|
||||||
|
|||||||
@@ -17,11 +17,6 @@ help: skipping check that does not even have a feature gate
|
|||||||
|
|
|
|
||||||
LL | my_fn();
|
LL | my_fn();
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
help: skipping check that does not even have a feature gate
|
|
||||||
--> $DIR/abi-mismatch.rs:16:40
|
|
||||||
|
|
|
||||||
LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) });
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: aborting due to previous error; 1 warning emitted
|
error: aborting due to previous error; 1 warning emitted
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,6 @@ help: skipping check that does not even have a feature gate
|
|||||||
|
|
|
|
||||||
LL | let _v = x == x;
|
LL | let _v = x == x;
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
help: skipping check that does not even have a feature gate
|
|
||||||
--> $DIR/ptr_arith.rs:15:20
|
|
||||||
|
|
|
||||||
LL | let x: usize = std::mem::transmute(&0);
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors; 1 warning emitted
|
error: aborting due to 2 previous errors; 1 warning emitted
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
// run-pass
|
// run-pass
|
||||||
|
|
||||||
#![feature(const_transmute)]
|
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ LL | fn foo(x: &'a str) { }
|
|||||||
| - ^^ undeclared lifetime
|
| - ^^ undeclared lifetime
|
||||||
| |
|
| |
|
||||||
| help: consider introducing lifetime `'a` here: `<'a>`
|
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error[E0261]: use of undeclared lifetime name `'a`
|
error[E0261]: use of undeclared lifetime name `'a`
|
||||||
--> $DIR/E0261.rs:5:9
|
--> $DIR/E0261.rs:5:9
|
||||||
@@ -13,6 +15,8 @@ LL | struct Foo {
|
|||||||
| - help: consider introducing lifetime `'a` here: `<'a>`
|
| - help: consider introducing lifetime `'a` here: `<'a>`
|
||||||
LL | x: &'a str,
|
LL | x: &'a str,
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|||||||
38
src/test/ui/feature-gates/feature-gate-const_fn_transmute.rs
Normal file
38
src/test/ui/feature-gates/feature-gate-const_fn_transmute.rs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
use std::mem;
|
||||||
|
|
||||||
|
#[repr(transparent)]
|
||||||
|
struct Foo(u32);
|
||||||
|
|
||||||
|
const TRANSMUTED_U32: u32 = unsafe { mem::transmute(Foo(3)) };
|
||||||
|
|
||||||
|
const fn transmute_fn() -> u32 { unsafe { mem::transmute(Foo(3)) } }
|
||||||
|
//~^ ERROR can only call `transmute` from const items, not `const fn`
|
||||||
|
|
||||||
|
const fn transmute_fn_intrinsic() -> u32 { unsafe { std::intrinsics::transmute(Foo(3)) } }
|
||||||
|
//~^ ERROR can only call `transmute` from const items, not `const fn`
|
||||||
|
|
||||||
|
const fn transmute_fn_core_intrinsic() -> u32 { unsafe { core::intrinsics::transmute(Foo(3)) } }
|
||||||
|
//~^ ERROR can only call `transmute` from const items, not `const fn`
|
||||||
|
|
||||||
|
const unsafe fn unsafe_transmute_fn() -> u32 { mem::transmute(Foo(3)) }
|
||||||
|
//~^ ERROR can only call `transmute` from const items, not `const fn`
|
||||||
|
|
||||||
|
const unsafe fn unsafe_transmute_fn_intrinsic() -> u32 { std::intrinsics::transmute(Foo(3)) }
|
||||||
|
//~^ ERROR can only call `transmute` from const items, not `const fn`
|
||||||
|
|
||||||
|
const unsafe fn unsafe_transmute_fn_core_intrinsic() -> u32 { core::intrinsics::transmute(Foo(3)) }
|
||||||
|
//~^ ERROR can only call `transmute` from const items, not `const fn`
|
||||||
|
|
||||||
|
const fn safe_transmute_fn() -> u32 { mem::transmute(Foo(3)) }
|
||||||
|
//~^ ERROR can only call `transmute` from const items, not `const fn`
|
||||||
|
//~| ERROR call to unsafe function is unsafe and requires unsafe function or block
|
||||||
|
|
||||||
|
const fn safe_transmute_fn_intrinsic() -> u32 { std::intrinsics::transmute(Foo(3)) }
|
||||||
|
//~^ ERROR can only call `transmute` from const items, not `const fn`
|
||||||
|
//~| ERROR call to unsafe function is unsafe and requires unsafe function or block
|
||||||
|
|
||||||
|
const fn safe_transmute_fn_core_intrinsic() -> u32 { core::intrinsics::transmute(Foo(3)) }
|
||||||
|
//~^ ERROR can only call `transmute` from const items, not `const fn`
|
||||||
|
//~| ERROR call to unsafe function is unsafe and requires unsafe function or block
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
109
src/test/ui/feature-gates/feature-gate-const_fn_transmute.stderr
Normal file
109
src/test/ui/feature-gates/feature-gate-const_fn_transmute.stderr
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||||
|
--> $DIR/feature-gate-const_fn_transmute.rs:8:43
|
||||||
|
|
|
||||||
|
LL | const fn transmute_fn() -> u32 { unsafe { mem::transmute(Foo(3)) } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||||
|
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||||
|
--> $DIR/feature-gate-const_fn_transmute.rs:11:53
|
||||||
|
|
|
||||||
|
LL | const fn transmute_fn_intrinsic() -> u32 { unsafe { std::intrinsics::transmute(Foo(3)) } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||||
|
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||||
|
--> $DIR/feature-gate-const_fn_transmute.rs:14:58
|
||||||
|
|
|
||||||
|
LL | const fn transmute_fn_core_intrinsic() -> u32 { unsafe { core::intrinsics::transmute(Foo(3)) } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||||
|
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||||
|
--> $DIR/feature-gate-const_fn_transmute.rs:17:48
|
||||||
|
|
|
||||||
|
LL | const unsafe fn unsafe_transmute_fn() -> u32 { mem::transmute(Foo(3)) }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||||
|
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||||
|
--> $DIR/feature-gate-const_fn_transmute.rs:20:58
|
||||||
|
|
|
||||||
|
LL | const unsafe fn unsafe_transmute_fn_intrinsic() -> u32 { std::intrinsics::transmute(Foo(3)) }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||||
|
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||||
|
--> $DIR/feature-gate-const_fn_transmute.rs:23:63
|
||||||
|
|
|
||||||
|
LL | const unsafe fn unsafe_transmute_fn_core_intrinsic() -> u32 { core::intrinsics::transmute(Foo(3)) }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||||
|
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||||
|
--> $DIR/feature-gate-const_fn_transmute.rs:26:39
|
||||||
|
|
|
||||||
|
LL | const fn safe_transmute_fn() -> u32 { mem::transmute(Foo(3)) }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||||
|
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||||
|
--> $DIR/feature-gate-const_fn_transmute.rs:30:49
|
||||||
|
|
|
||||||
|
LL | const fn safe_transmute_fn_intrinsic() -> u32 { std::intrinsics::transmute(Foo(3)) }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||||
|
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||||
|
--> $DIR/feature-gate-const_fn_transmute.rs:34:54
|
||||||
|
|
|
||||||
|
LL | const fn safe_transmute_fn_core_intrinsic() -> u32 { core::intrinsics::transmute(Foo(3)) }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||||
|
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
||||||
|
--> $DIR/feature-gate-const_fn_transmute.rs:26:39
|
||||||
|
|
|
||||||
|
LL | const fn safe_transmute_fn() -> u32 { mem::transmute(Foo(3)) }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
||||||
|
|
|
||||||
|
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||||
|
|
||||||
|
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
||||||
|
--> $DIR/feature-gate-const_fn_transmute.rs:30:49
|
||||||
|
|
|
||||||
|
LL | const fn safe_transmute_fn_intrinsic() -> u32 { std::intrinsics::transmute(Foo(3)) }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
||||||
|
|
|
||||||
|
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||||
|
|
||||||
|
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
||||||
|
--> $DIR/feature-gate-const_fn_transmute.rs:34:54
|
||||||
|
|
|
||||||
|
LL | const fn safe_transmute_fn_core_intrinsic() -> u32 { core::intrinsics::transmute(Foo(3)) }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
||||||
|
|
|
||||||
|
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||||
|
|
||||||
|
error: aborting due to 12 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0133, E0723.
|
||||||
|
For more information about an error, try `rustc --explain E0133`.
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
use std::mem;
|
|
||||||
|
|
||||||
#[repr(transparent)]
|
|
||||||
struct Foo(u32);
|
|
||||||
|
|
||||||
const TRANSMUTED_U32: u32 = unsafe { mem::transmute(Foo(3)) };
|
|
||||||
//~^ ERROR `std::intrinsics::transmute` is not yet stable as a const fn
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
error: `std::intrinsics::transmute` is not yet stable as a const fn
|
|
||||||
--> $DIR/feature-gate-const_transmute.rs:6:38
|
|
||||||
|
|
|
||||||
LL | const TRANSMUTED_U32: u32 = unsafe { mem::transmute(Foo(3)) };
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= help: add `#![feature(const_transmute)]` to the crate attributes to enable
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
||||||
@@ -5,6 +5,8 @@ LL | fn foo(x: &'x u8) -> &'x u8 { x }
|
|||||||
| - ^^ undeclared lifetime
|
| - ^^ undeclared lifetime
|
||||||
| |
|
| |
|
||||||
| help: consider introducing lifetime `'x` here: `<'x>`
|
| help: consider introducing lifetime `'x` here: `<'x>`
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error[E0261]: use of undeclared lifetime name `'x`
|
error[E0261]: use of undeclared lifetime name `'x`
|
||||||
--> $DIR/feature-gate-in_band_lifetimes.rs:3:23
|
--> $DIR/feature-gate-in_band_lifetimes.rs:3:23
|
||||||
@@ -13,6 +15,8 @@ LL | fn foo(x: &'x u8) -> &'x u8 { x }
|
|||||||
| - ^^ undeclared lifetime
|
| - ^^ undeclared lifetime
|
||||||
| |
|
| |
|
||||||
| help: consider introducing lifetime `'x` here: `<'x>`
|
| help: consider introducing lifetime `'x` here: `<'x>`
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error[E0261]: use of undeclared lifetime name `'b`
|
error[E0261]: use of undeclared lifetime name `'b`
|
||||||
--> $DIR/feature-gate-in_band_lifetimes.rs:15:12
|
--> $DIR/feature-gate-in_band_lifetimes.rs:15:12
|
||||||
@@ -28,6 +32,7 @@ error[E0261]: use of undeclared lifetime name `'b`
|
|||||||
LL | fn inner_2(&self) -> &'b u8 {
|
LL | fn inner_2(&self) -> &'b u8 {
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
help: consider introducing lifetime `'b` here
|
help: consider introducing lifetime `'b` here
|
||||||
|
|
|
|
||||||
LL | impl<'b, 'a> X<'b> {
|
LL | impl<'b, 'a> X<'b> {
|
||||||
@@ -44,6 +49,8 @@ LL | impl X<'b> {
|
|||||||
| - ^^ undeclared lifetime
|
| - ^^ undeclared lifetime
|
||||||
| |
|
| |
|
||||||
| help: consider introducing lifetime `'b` here: `<'b>`
|
| help: consider introducing lifetime `'b` here: `<'b>`
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error[E0261]: use of undeclared lifetime name `'b`
|
error[E0261]: use of undeclared lifetime name `'b`
|
||||||
--> $DIR/feature-gate-in_band_lifetimes.rs:25:27
|
--> $DIR/feature-gate-in_band_lifetimes.rs:25:27
|
||||||
@@ -51,6 +58,7 @@ error[E0261]: use of undeclared lifetime name `'b`
|
|||||||
LL | fn inner_3(&self) -> &'b u8 {
|
LL | fn inner_3(&self) -> &'b u8 {
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
help: consider introducing lifetime `'b` here
|
help: consider introducing lifetime `'b` here
|
||||||
|
|
|
|
||||||
LL | impl<'b> X<'b> {
|
LL | impl<'b> X<'b> {
|
||||||
@@ -67,6 +75,8 @@ LL | impl Y<&'a u8> {
|
|||||||
| - ^^ undeclared lifetime
|
| - ^^ undeclared lifetime
|
||||||
| |
|
| |
|
||||||
| help: consider introducing lifetime `'a` here: `<'a>`
|
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error[E0261]: use of undeclared lifetime name `'a`
|
error[E0261]: use of undeclared lifetime name `'a`
|
||||||
--> $DIR/feature-gate-in_band_lifetimes.rs:35:25
|
--> $DIR/feature-gate-in_band_lifetimes.rs:35:25
|
||||||
@@ -74,6 +84,7 @@ error[E0261]: use of undeclared lifetime name `'a`
|
|||||||
LL | fn inner(&self) -> &'a u8 {
|
LL | fn inner(&self) -> &'a u8 {
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
help: consider introducing lifetime `'a` here
|
help: consider introducing lifetime `'a` here
|
||||||
|
|
|
|
||||||
LL | impl<'a> Y<&'a u8> {
|
LL | impl<'a> Y<&'a u8> {
|
||||||
@@ -89,6 +100,7 @@ error[E0261]: use of undeclared lifetime name `'b`
|
|||||||
LL | fn any_lifetime() -> &'b u8;
|
LL | fn any_lifetime() -> &'b u8;
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
help: consider introducing lifetime `'b` here
|
help: consider introducing lifetime `'b` here
|
||||||
|
|
|
|
||||||
LL | trait MyTrait<'b, 'a> {
|
LL | trait MyTrait<'b, 'a> {
|
||||||
@@ -104,6 +116,7 @@ error[E0261]: use of undeclared lifetime name `'b`
|
|||||||
LL | fn borrowed_lifetime(&'b self) -> &'b u8;
|
LL | fn borrowed_lifetime(&'b self) -> &'b u8;
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
help: consider introducing lifetime `'b` here
|
help: consider introducing lifetime `'b` here
|
||||||
|
|
|
|
||||||
LL | trait MyTrait<'b, 'a> {
|
LL | trait MyTrait<'b, 'a> {
|
||||||
@@ -119,6 +132,7 @@ error[E0261]: use of undeclared lifetime name `'b`
|
|||||||
LL | fn borrowed_lifetime(&'b self) -> &'b u8;
|
LL | fn borrowed_lifetime(&'b self) -> &'b u8;
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
help: consider introducing lifetime `'b` here
|
help: consider introducing lifetime `'b` here
|
||||||
|
|
|
|
||||||
LL | trait MyTrait<'b, 'a> {
|
LL | trait MyTrait<'b, 'a> {
|
||||||
@@ -135,6 +149,8 @@ LL | impl MyTrait<'a> for Y<&'a u8> {
|
|||||||
| - ^^ undeclared lifetime
|
| - ^^ undeclared lifetime
|
||||||
| |
|
| |
|
||||||
| help: consider introducing lifetime `'a` here: `<'a>`
|
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error[E0261]: use of undeclared lifetime name `'a`
|
error[E0261]: use of undeclared lifetime name `'a`
|
||||||
--> $DIR/feature-gate-in_band_lifetimes.rs:50:25
|
--> $DIR/feature-gate-in_band_lifetimes.rs:50:25
|
||||||
@@ -143,6 +159,8 @@ LL | impl MyTrait<'a> for Y<&'a u8> {
|
|||||||
| - ^^ undeclared lifetime
|
| - ^^ undeclared lifetime
|
||||||
| |
|
| |
|
||||||
| help: consider introducing lifetime `'a` here: `<'a>`
|
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error[E0261]: use of undeclared lifetime name `'a`
|
error[E0261]: use of undeclared lifetime name `'a`
|
||||||
--> $DIR/feature-gate-in_band_lifetimes.rs:53:31
|
--> $DIR/feature-gate-in_band_lifetimes.rs:53:31
|
||||||
@@ -150,6 +168,7 @@ error[E0261]: use of undeclared lifetime name `'a`
|
|||||||
LL | fn my_lifetime(&self) -> &'a u8 { self.0 }
|
LL | fn my_lifetime(&self) -> &'a u8 { self.0 }
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
help: consider introducing lifetime `'a` here
|
help: consider introducing lifetime `'a` here
|
||||||
|
|
|
|
||||||
LL | impl<'a> MyTrait<'a> for Y<&'a u8> {
|
LL | impl<'a> MyTrait<'a> for Y<&'a u8> {
|
||||||
@@ -165,6 +184,7 @@ error[E0261]: use of undeclared lifetime name `'b`
|
|||||||
LL | fn any_lifetime() -> &'b u8 { &0 }
|
LL | fn any_lifetime() -> &'b u8 { &0 }
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
help: consider introducing lifetime `'b` here
|
help: consider introducing lifetime `'b` here
|
||||||
|
|
|
|
||||||
LL | impl<'b> MyTrait<'a> for Y<&'a u8> {
|
LL | impl<'b> MyTrait<'a> for Y<&'a u8> {
|
||||||
@@ -180,6 +200,7 @@ error[E0261]: use of undeclared lifetime name `'b`
|
|||||||
LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 }
|
LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 }
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
help: consider introducing lifetime `'b` here
|
help: consider introducing lifetime `'b` here
|
||||||
|
|
|
|
||||||
LL | impl<'b> MyTrait<'a> for Y<&'a u8> {
|
LL | impl<'b> MyTrait<'a> for Y<&'a u8> {
|
||||||
@@ -195,6 +216,7 @@ error[E0261]: use of undeclared lifetime name `'b`
|
|||||||
LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 }
|
LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 }
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
help: consider introducing lifetime `'b` here
|
help: consider introducing lifetime `'b` here
|
||||||
|
|
|
|
||||||
LL | impl<'b> MyTrait<'a> for Y<&'a u8> {
|
LL | impl<'b> MyTrait<'a> for Y<&'a u8> {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ error[E0261]: use of undeclared lifetime name `'b`
|
|||||||
LL | + Deref<Target = Self::Item<'b>>;
|
LL | + Deref<Target = Self::Item<'b>>;
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
help: consider introducing lifetime `'b` here
|
help: consider introducing lifetime `'b` here
|
||||||
|
|
|
|
||||||
LL | trait Iterable<'b> {
|
LL | trait Iterable<'b> {
|
||||||
@@ -19,6 +20,7 @@ error[E0261]: use of undeclared lifetime name `'undeclared`
|
|||||||
LL | fn iter<'a>(&'a self) -> Self::Iter<'undeclared>;
|
LL | fn iter<'a>(&'a self) -> Self::Iter<'undeclared>;
|
||||||
| ^^^^^^^^^^^ undeclared lifetime
|
| ^^^^^^^^^^^ undeclared lifetime
|
||||||
|
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
help: consider introducing lifetime `'undeclared` here
|
help: consider introducing lifetime `'undeclared` here
|
||||||
|
|
|
|
||||||
LL | trait Iterable<'undeclared> {
|
LL | trait Iterable<'undeclared> {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
|
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub const fn foo() -> i32 {
|
pub const fn foo() -> i32 {
|
||||||
unsafe { std::mem::transmute(4u32) } //~ ERROR is not stable as `const fn`
|
unsafe { std::mem::transmute(4u32) } //~ ERROR can only call `transmute` from const items
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
error[E0723]: can only call other `const fn` within a `const fn`, but `const std::intrinsics::transmute::<u32, i32>` is not stable as `const fn`
|
error[E0723]: can only call `transmute` from const items, not `const fn`
|
||||||
--> $DIR/internal-unstable-const.rs:11:14
|
--> $DIR/internal-unstable-const.rs:11:14
|
||||||
|
|
|
|
||||||
LL | unsafe { std::mem::transmute(4u32) }
|
LL | unsafe { std::mem::transmute(4u32) }
|
||||||
|
|||||||
8
src/test/ui/issues/issue-74236/auxiliary/dep.rs
Normal file
8
src/test/ui/issues/issue-74236/auxiliary/dep.rs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// edition:2018
|
||||||
|
|
||||||
|
mod private { pub struct Pub; }
|
||||||
|
|
||||||
|
// Reexport built-in attribute without a DefId (requires Rust 2018).
|
||||||
|
pub use cfg_attr as attr;
|
||||||
|
// This export needs to be after the built-in attribute to trigger the bug.
|
||||||
|
pub use private::Pub as Renamed;
|
||||||
9
src/test/ui/issues/issue-74236/main.rs
Normal file
9
src/test/ui/issues/issue-74236/main.rs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
// edition:2018
|
||||||
|
// aux-build:dep.rs
|
||||||
|
// compile-flags:--extern dep
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// Trigger an error that will print the path of dep::private::Pub (as "dep::Renamed").
|
||||||
|
let () = dep::Renamed;
|
||||||
|
//~^ ERROR mismatched types
|
||||||
|
}
|
||||||
11
src/test/ui/issues/issue-74236/main.stderr
Normal file
11
src/test/ui/issues/issue-74236/main.stderr
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/main.rs:7:9
|
||||||
|
|
|
||||||
|
LL | let () = dep::Renamed;
|
||||||
|
| ^^ ------------ this expression has type `dep::Renamed`
|
||||||
|
| |
|
||||||
|
| expected struct `dep::Renamed`, found `()`
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0308`.
|
||||||
@@ -5,6 +5,8 @@ LL | fn main() {
|
|||||||
| - help: consider introducing lifetime `'a` here: `<'a>`
|
| - help: consider introducing lifetime `'a` here: `<'a>`
|
||||||
LL | 0.clone::<'a>();
|
LL | 0.clone::<'a>();
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ LL | enum No0 {
|
|||||||
| - help: consider introducing lifetime `'foo` here: `<'foo>`
|
| - help: consider introducing lifetime `'foo` here: `<'foo>`
|
||||||
LL | X5(&'foo usize)
|
LL | X5(&'foo usize)
|
||||||
| ^^^^ undeclared lifetime
|
| ^^^^ undeclared lifetime
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error[E0261]: use of undeclared lifetime name `'a`
|
error[E0261]: use of undeclared lifetime name `'a`
|
||||||
--> $DIR/regions-in-enums.rs:17:9
|
--> $DIR/regions-in-enums.rs:17:9
|
||||||
@@ -13,6 +15,8 @@ LL | enum No1 {
|
|||||||
| - help: consider introducing lifetime `'a` here: `<'a>`
|
| - help: consider introducing lifetime `'a` here: `<'a>`
|
||||||
LL | X6(&'a usize)
|
LL | X6(&'a usize)
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ LL | struct StructDecl {
|
|||||||
| - help: consider introducing lifetime `'a` here: `<'a>`
|
| - help: consider introducing lifetime `'a` here: `<'a>`
|
||||||
LL | a: &'a isize,
|
LL | a: &'a isize,
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error[E0261]: use of undeclared lifetime name `'a`
|
error[E0261]: use of undeclared lifetime name `'a`
|
||||||
--> $DIR/regions-in-structs.rs:11:9
|
--> $DIR/regions-in-structs.rs:11:9
|
||||||
@@ -14,6 +16,8 @@ LL | struct StructDecl {
|
|||||||
LL | a: &'a isize,
|
LL | a: &'a isize,
|
||||||
LL | b: &'a isize,
|
LL | b: &'a isize,
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ error[E0261]: use of undeclared lifetime name `'b`
|
|||||||
LL | fn m4(&self, arg: &'b isize) { }
|
LL | fn m4(&self, arg: &'b isize) { }
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
help: consider introducing lifetime `'b` here
|
help: consider introducing lifetime `'b` here
|
||||||
|
|
|
|
||||||
LL | impl<'b, 'a> Foo<'a> {
|
LL | impl<'b, 'a> Foo<'a> {
|
||||||
@@ -19,6 +20,7 @@ error[E0261]: use of undeclared lifetime name `'b`
|
|||||||
LL | fn m5(&'b self) { }
|
LL | fn m5(&'b self) { }
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
help: consider introducing lifetime `'b` here
|
help: consider introducing lifetime `'b` here
|
||||||
|
|
|
|
||||||
LL | impl<'b, 'a> Foo<'a> {
|
LL | impl<'b, 'a> Foo<'a> {
|
||||||
@@ -34,6 +36,7 @@ error[E0261]: use of undeclared lifetime name `'b`
|
|||||||
LL | fn m6(&self, arg: Foo<'b>) { }
|
LL | fn m6(&self, arg: Foo<'b>) { }
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
help: consider introducing lifetime `'b` here
|
help: consider introducing lifetime `'b` here
|
||||||
|
|
|
|
||||||
LL | impl<'b, 'a> Foo<'a> {
|
LL | impl<'b, 'a> Foo<'a> {
|
||||||
@@ -50,6 +53,8 @@ LL | type X = Option<&'a isize>;
|
|||||||
| - ^^ undeclared lifetime
|
| - ^^ undeclared lifetime
|
||||||
| |
|
| |
|
||||||
| help: consider introducing lifetime `'a` here: `<'a>`
|
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error[E0261]: use of undeclared lifetime name `'a`
|
error[E0261]: use of undeclared lifetime name `'a`
|
||||||
--> $DIR/regions-name-undeclared.rs:27:13
|
--> $DIR/regions-name-undeclared.rs:27:13
|
||||||
@@ -58,6 +63,8 @@ LL | enum E {
|
|||||||
| - help: consider introducing lifetime `'a` here: `<'a>`
|
| - help: consider introducing lifetime `'a` here: `<'a>`
|
||||||
LL | E1(&'a isize)
|
LL | E1(&'a isize)
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error[E0261]: use of undeclared lifetime name `'a`
|
error[E0261]: use of undeclared lifetime name `'a`
|
||||||
--> $DIR/regions-name-undeclared.rs:30:13
|
--> $DIR/regions-name-undeclared.rs:30:13
|
||||||
@@ -66,6 +73,8 @@ LL | struct S {
|
|||||||
| - help: consider introducing lifetime `'a` here: `<'a>`
|
| - help: consider introducing lifetime `'a` here: `<'a>`
|
||||||
LL | f: &'a isize
|
LL | f: &'a isize
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error[E0261]: use of undeclared lifetime name `'a`
|
error[E0261]: use of undeclared lifetime name `'a`
|
||||||
--> $DIR/regions-name-undeclared.rs:32:14
|
--> $DIR/regions-name-undeclared.rs:32:14
|
||||||
@@ -74,6 +83,8 @@ LL | fn f(a: &'a isize) { }
|
|||||||
| - ^^ undeclared lifetime
|
| - ^^ undeclared lifetime
|
||||||
| |
|
| |
|
||||||
| help: consider introducing lifetime `'a` here: `<'a>`
|
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error[E0261]: use of undeclared lifetime name `'a`
|
error[E0261]: use of undeclared lifetime name `'a`
|
||||||
--> $DIR/regions-name-undeclared.rs:40:17
|
--> $DIR/regions-name-undeclared.rs:40:17
|
||||||
@@ -82,6 +93,8 @@ LL | fn fn_types(a: &'a isize,
|
|||||||
| - ^^ undeclared lifetime
|
| - ^^ undeclared lifetime
|
||||||
| |
|
| |
|
||||||
| help: consider introducing lifetime `'a` here: `<'a>`
|
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error[E0261]: use of undeclared lifetime name `'b`
|
error[E0261]: use of undeclared lifetime name `'b`
|
||||||
--> $DIR/regions-name-undeclared.rs:42:36
|
--> $DIR/regions-name-undeclared.rs:42:36
|
||||||
@@ -90,6 +103,7 @@ LL | ... &'b isize,
|
|||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
|
||||||
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
|
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
help: consider introducing lifetime `'b` here
|
help: consider introducing lifetime `'b` here
|
||||||
|
|
|
|
||||||
LL | fn fn_types<'b>(a: &'a isize,
|
LL | fn fn_types<'b>(a: &'a isize,
|
||||||
@@ -106,6 +120,7 @@ LL | ... &'b isize)>,
|
|||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
|
||||||
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
|
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
help: consider introducing lifetime `'b` here
|
help: consider introducing lifetime `'b` here
|
||||||
|
|
|
|
||||||
LL | fn fn_types<'b>(a: &'a isize,
|
LL | fn fn_types<'b>(a: &'a isize,
|
||||||
@@ -123,6 +138,8 @@ LL | fn fn_types(a: &'a isize,
|
|||||||
...
|
...
|
||||||
LL | c: &'a isize)
|
LL | c: &'a isize)
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error: aborting due to 11 previous errors
|
error: aborting due to 11 previous errors
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ LL | enum EnumDecl {
|
|||||||
| - help: consider introducing lifetime `'a` here: `<'a>`
|
| - help: consider introducing lifetime `'a` here: `<'a>`
|
||||||
LL | Foo(&'a isize),
|
LL | Foo(&'a isize),
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error[E0261]: use of undeclared lifetime name `'a`
|
error[E0261]: use of undeclared lifetime name `'a`
|
||||||
--> $DIR/regions-undeclared.rs:5:10
|
--> $DIR/regions-undeclared.rs:5:10
|
||||||
@@ -20,6 +22,8 @@ LL | enum EnumDecl {
|
|||||||
LL | Foo(&'a isize),
|
LL | Foo(&'a isize),
|
||||||
LL | Bar(&'a isize),
|
LL | Bar(&'a isize),
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error[E0261]: use of undeclared lifetime name `'a`
|
error[E0261]: use of undeclared lifetime name `'a`
|
||||||
--> $DIR/regions-undeclared.rs:8:15
|
--> $DIR/regions-undeclared.rs:8:15
|
||||||
@@ -28,6 +32,8 @@ LL | fn fnDecl(x: &'a isize,
|
|||||||
| - ^^ undeclared lifetime
|
| - ^^ undeclared lifetime
|
||||||
| |
|
| |
|
||||||
| help: consider introducing lifetime `'a` here: `<'a>`
|
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error[E0261]: use of undeclared lifetime name `'a`
|
error[E0261]: use of undeclared lifetime name `'a`
|
||||||
--> $DIR/regions-undeclared.rs:9:15
|
--> $DIR/regions-undeclared.rs:9:15
|
||||||
@@ -36,6 +42,8 @@ LL | fn fnDecl(x: &'a isize,
|
|||||||
| - help: consider introducing lifetime `'a` here: `<'a>`
|
| - help: consider introducing lifetime `'a` here: `<'a>`
|
||||||
LL | y: &'a isize)
|
LL | y: &'a isize)
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ LL | this.x
|
|||||||
| ^^^^
|
| ^^^^
|
||||||
| |
|
| |
|
||||||
| not found in this scope
|
| not found in this scope
|
||||||
| help: did you mean: `self`
|
| help: you might have meant to use `self` here instead
|
||||||
|
|
||||||
error[E0425]: cannot find value `this` in this scope
|
error[E0425]: cannot find value `this` in this scope
|
||||||
--> $DIR/suggest-self.rs:26:9
|
--> $DIR/suggest-self.rs:26:9
|
||||||
@@ -14,7 +14,7 @@ LL | this.foo()
|
|||||||
| ^^^^
|
| ^^^^
|
||||||
| |
|
| |
|
||||||
| not found in this scope
|
| not found in this scope
|
||||||
| help: did you mean: `self`
|
| help: you might have meant to use `self` here instead
|
||||||
|
|
||||||
error[E0425]: cannot find value `my` in this scope
|
error[E0425]: cannot find value `my` in this scope
|
||||||
--> $DIR/suggest-self.rs:31:9
|
--> $DIR/suggest-self.rs:31:9
|
||||||
@@ -23,7 +23,7 @@ LL | my.bar()
|
|||||||
| ^^
|
| ^^
|
||||||
| |
|
| |
|
||||||
| not found in this scope
|
| not found in this scope
|
||||||
| help: did you mean: `self`
|
| help: you might have meant to use `self` here instead
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ LL | fn f() where
|
|||||||
LL | for<'a> dyn Trait1<'a>: Trait1<'a>, // OK
|
LL | for<'a> dyn Trait1<'a>: Trait1<'a>, // OK
|
||||||
LL | (dyn for<'a> Trait1<'a>): Trait1<'a>,
|
LL | (dyn for<'a> Trait1<'a>): Trait1<'a>,
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error[E0261]: use of undeclared lifetime name `'b`
|
error[E0261]: use of undeclared lifetime name `'b`
|
||||||
--> $DIR/where-lifetime-resolution.rs:8:52
|
--> $DIR/where-lifetime-resolution.rs:8:52
|
||||||
@@ -15,6 +17,8 @@ LL | fn f() where
|
|||||||
...
|
...
|
||||||
LL | for<'a> dyn for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>,
|
LL | for<'a> dyn for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>,
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
|
||||||
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|||||||
@@ -57,14 +57,6 @@ LL | | t
|
|||||||
LL | | }
|
LL | | }
|
||||||
| |_^
|
| |_^
|
||||||
|
|
||||||
error: this could be a `const fn`
|
|
||||||
--> $DIR/could_be_const.rs:48:1
|
|
||||||
|
|
|
||||||
LL | / fn sub(x: u32) -> usize {
|
|
||||||
LL | | unsafe { transmute(&x) }
|
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
||||||
error: this could be a `const fn`
|
error: this could be a `const fn`
|
||||||
--> $DIR/could_be_const.rs:67:9
|
--> $DIR/could_be_const.rs:67:9
|
||||||
|
|
|
|
||||||
@@ -73,5 +65,5 @@ LL | | B
|
|||||||
LL | | }
|
LL | | }
|
||||||
| |_________^
|
| |_________^
|
||||||
|
|
||||||
error: aborting due to 9 previous errors
|
error: aborting due to 8 previous errors
|
||||||
|
|
||||||
|
|||||||
Submodule src/tools/miri updated: eb5ff1791b...eee22ffdda
Reference in New Issue
Block a user