mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Auto merge of #78212 - JohnTitor:rollup-j5r6xuy, r=JohnTitor
Rollup of 10 pull requests Successful merges: - #77420 (Unify const-checking structured errors for `&mut` and `&raw mut`) - #77554 (Support signed integers and `char` in v0 mangling) - #77976 (Mark inout asm! operands as used in liveness pass) - #78009 (Haiku: explicitly set CMAKE_SYSTEM_NAME when cross-compiling) - #78084 (Greatly improve display for small mobile devices screens) - #78155 (Fix two small issues in compiler/rustc_lint/src/types.rs) - #78156 (Fixed build failure of `rustfmt`) - #78172 (Add test case for #77062) - #78188 (Add tracking issue number for pin_static_ref) - #78200 (Add `ControlFlow::is_{break,continue}` methods) Failed merges: r? `@ghost`
This commit is contained in:
commit
ef3e386393
@ -3276,9 +3276,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.16"
|
||||
version = "0.1.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
|
||||
checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232"
|
||||
dependencies = [
|
||||
"compiler_builtins",
|
||||
"rustc-std-workspace-core",
|
||||
|
@ -15,7 +15,7 @@ measureme = "0.7.1"
|
||||
snap = "1"
|
||||
tracing = "0.1"
|
||||
rustc_middle = { path = "../rustc_middle" }
|
||||
rustc-demangle = "0.1"
|
||||
rustc-demangle = "0.1.18"
|
||||
rustc_attr = { path = "../rustc_attr" }
|
||||
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
|
@ -145,9 +145,9 @@ fn lint_overflowing_range_endpoint<'tcx>(
|
||||
// We need to preserve the literal's suffix,
|
||||
// as it may determine typing information.
|
||||
let suffix = match lit.node {
|
||||
LitKind::Int(_, LitIntType::Signed(s)) => s.name_str().to_string(),
|
||||
LitKind::Int(_, LitIntType::Unsigned(s)) => s.name_str().to_string(),
|
||||
LitKind::Int(_, LitIntType::Unsuffixed) => "".to_string(),
|
||||
LitKind::Int(_, LitIntType::Signed(s)) => s.name_str(),
|
||||
LitKind::Int(_, LitIntType::Unsigned(s)) => s.name_str(),
|
||||
LitKind::Int(_, LitIntType::Unsuffixed) => "",
|
||||
_ => bug!(),
|
||||
};
|
||||
let suggestion = format!("{}..={}{}", start, lit_val - 1, suffix);
|
||||
@ -170,24 +170,25 @@ fn lint_overflowing_range_endpoint<'tcx>(
|
||||
// warnings are consistent between 32- and 64-bit platforms.
|
||||
fn int_ty_range(int_ty: ast::IntTy) -> (i128, i128) {
|
||||
match int_ty {
|
||||
ast::IntTy::Isize => (i64::MIN as i128, i64::MAX as i128),
|
||||
ast::IntTy::I8 => (i8::MIN as i64 as i128, i8::MAX as i128),
|
||||
ast::IntTy::I16 => (i16::MIN as i64 as i128, i16::MAX as i128),
|
||||
ast::IntTy::I32 => (i32::MIN as i64 as i128, i32::MAX as i128),
|
||||
ast::IntTy::I64 => (i64::MIN as i128, i64::MAX as i128),
|
||||
ast::IntTy::I128 => (i128::MIN as i128, i128::MAX),
|
||||
ast::IntTy::Isize => (i64::MIN.into(), i64::MAX.into()),
|
||||
ast::IntTy::I8 => (i8::MIN.into(), i8::MAX.into()),
|
||||
ast::IntTy::I16 => (i16::MIN.into(), i16::MAX.into()),
|
||||
ast::IntTy::I32 => (i32::MIN.into(), i32::MAX.into()),
|
||||
ast::IntTy::I64 => (i64::MIN.into(), i64::MAX.into()),
|
||||
ast::IntTy::I128 => (i128::MIN, i128::MAX),
|
||||
}
|
||||
}
|
||||
|
||||
fn uint_ty_range(uint_ty: ast::UintTy) -> (u128, u128) {
|
||||
match uint_ty {
|
||||
ast::UintTy::Usize => (u64::MIN as u128, u64::MAX as u128),
|
||||
ast::UintTy::U8 => (u8::MIN as u128, u8::MAX as u128),
|
||||
ast::UintTy::U16 => (u16::MIN as u128, u16::MAX as u128),
|
||||
ast::UintTy::U32 => (u32::MIN as u128, u32::MAX as u128),
|
||||
ast::UintTy::U64 => (u64::MIN as u128, u64::MAX as u128),
|
||||
ast::UintTy::U128 => (u128::MIN, u128::MAX),
|
||||
}
|
||||
let max = match uint_ty {
|
||||
ast::UintTy::Usize => u64::MAX.into(),
|
||||
ast::UintTy::U8 => u8::MAX.into(),
|
||||
ast::UintTy::U16 => u16::MAX.into(),
|
||||
ast::UintTy::U32 => u32::MAX.into(),
|
||||
ast::UintTy::U64 => u64::MAX.into(),
|
||||
ast::UintTy::U128 => u128::MAX,
|
||||
};
|
||||
(0, max)
|
||||
}
|
||||
|
||||
fn get_bin_hex_repr(cx: &LateContext<'_>, lit: &hir::Lit) -> Option<String> {
|
||||
|
@ -224,7 +224,8 @@ impl NonConstOp for CellBorrow {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct MutBorrow;
|
||||
pub struct MutBorrow(pub hir::BorrowKind);
|
||||
|
||||
impl NonConstOp for MutBorrow {
|
||||
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
|
||||
// Forbid everywhere except in const fn with a feature gate
|
||||
@ -236,22 +237,28 @@ impl NonConstOp for MutBorrow {
|
||||
}
|
||||
|
||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||
let raw = match self.0 {
|
||||
hir::BorrowKind::Raw => "raw ",
|
||||
hir::BorrowKind::Ref => "",
|
||||
};
|
||||
|
||||
let mut err = if ccx.const_kind() == hir::ConstContext::ConstFn {
|
||||
feature_err(
|
||||
&ccx.tcx.sess.parse_sess,
|
||||
sym::const_mut_refs,
|
||||
span,
|
||||
&format!("mutable references are not allowed in {}s", ccx.const_kind()),
|
||||
&format!("{}mutable references are not allowed in {}s", raw, ccx.const_kind()),
|
||||
)
|
||||
} else {
|
||||
let mut err = struct_span_err!(
|
||||
ccx.tcx.sess,
|
||||
span,
|
||||
E0764,
|
||||
"mutable references are not allowed in {}s",
|
||||
"{}mutable references are not allowed in {}s",
|
||||
raw,
|
||||
ccx.const_kind(),
|
||||
);
|
||||
err.span_label(span, format!("`&mut` is only allowed in `const fn`"));
|
||||
err.span_label(span, format!("`&{}mut` is only allowed in `const fn`", raw));
|
||||
err
|
||||
};
|
||||
if ccx.tcx.sess.teach(&err.get_code().unwrap()) {
|
||||
@ -270,29 +277,6 @@ impl NonConstOp for MutBorrow {
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(ecstaticmorse): Unify this with `MutBorrow`. It has basically the same issues.
|
||||
#[derive(Debug)]
|
||||
pub struct MutAddressOf;
|
||||
impl NonConstOp for MutAddressOf {
|
||||
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
|
||||
// Forbid everywhere except in const fn with a feature gate
|
||||
if ccx.const_kind() == hir::ConstContext::ConstFn {
|
||||
Status::Unstable(sym::const_mut_refs)
|
||||
} else {
|
||||
Status::Forbidden
|
||||
}
|
||||
}
|
||||
|
||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||
feature_err(
|
||||
&ccx.tcx.sess.parse_sess,
|
||||
sym::const_mut_refs,
|
||||
span,
|
||||
&format!("`&raw mut` is not allowed in {}s", ccx.const_kind()),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct MutDeref;
|
||||
impl NonConstOp for MutDeref {
|
||||
|
@ -525,14 +525,16 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
|
||||
|
||||
if !is_allowed {
|
||||
if let BorrowKind::Mut { .. } = kind {
|
||||
self.check_op(ops::MutBorrow);
|
||||
self.check_op(ops::MutBorrow(hir::BorrowKind::Ref));
|
||||
} else {
|
||||
self.check_op(ops::CellBorrow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rvalue::AddressOf(Mutability::Mut, _) => self.check_op(ops::MutAddressOf),
|
||||
Rvalue::AddressOf(Mutability::Mut, _) => {
|
||||
self.check_op(ops::MutBorrow(hir::BorrowKind::Raw))
|
||||
}
|
||||
|
||||
Rvalue::Ref(_, BorrowKind::Shared | BorrowKind::Shallow, ref place)
|
||||
| Rvalue::AddressOf(Mutability::Not, ref place) => {
|
||||
|
@ -71,12 +71,14 @@ impl<'mir, 'tcx> Search<'mir, 'tcx> {
|
||||
|
||||
let func_ty = func.ty(body, tcx);
|
||||
if let ty::FnDef(callee, substs) = *func_ty.kind() {
|
||||
let (callee, call_substs) =
|
||||
if let Ok(Some(instance)) = Instance::resolve(tcx, param_env, callee, substs) {
|
||||
(instance.def_id(), instance.substs)
|
||||
} else {
|
||||
(callee, substs)
|
||||
};
|
||||
let normalized_substs = tcx.normalize_erasing_regions(param_env, substs);
|
||||
let (callee, call_substs) = if let Ok(Some(instance)) =
|
||||
Instance::resolve(tcx, param_env, callee, normalized_substs)
|
||||
{
|
||||
(instance.def_id(), instance.substs)
|
||||
} else {
|
||||
(callee, normalized_substs)
|
||||
};
|
||||
|
||||
// FIXME(#57965): Make this work across function boundaries
|
||||
|
||||
|
@ -1174,7 +1174,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
hir::InlineAsmOperand::InOut { expr, .. } => {
|
||||
succ = self.write_place(expr, succ, ACC_READ | ACC_WRITE);
|
||||
succ = self.write_place(expr, succ, ACC_READ | ACC_WRITE | ACC_USE);
|
||||
}
|
||||
hir::InlineAsmOperand::SplitInOut { out_expr, .. } => {
|
||||
if let Some(expr) = out_expr {
|
||||
|
@ -10,7 +10,7 @@ doctest = false
|
||||
[dependencies]
|
||||
tracing = "0.1"
|
||||
punycode = "0.4.0"
|
||||
rustc-demangle = "0.1.16"
|
||||
rustc-demangle = "0.1.18"
|
||||
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_span = { path = "../rustc_span" }
|
||||
|
@ -4,6 +4,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{CrateNum, DefId};
|
||||
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
|
||||
use rustc_middle::mir::interpret::sign_extend;
|
||||
use rustc_middle::ty::print::{Print, Printer};
|
||||
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, Subst};
|
||||
use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable};
|
||||
@ -527,17 +528,31 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
|
||||
}
|
||||
let start = self.out.len();
|
||||
|
||||
match ct.ty.kind() {
|
||||
ty::Uint(_) => {}
|
||||
ty::Bool => {}
|
||||
let mut neg = false;
|
||||
let val = match ct.ty.kind() {
|
||||
ty::Uint(_) | ty::Bool | ty::Char => {
|
||||
ct.try_eval_bits(self.tcx, ty::ParamEnv::reveal_all(), ct.ty)
|
||||
}
|
||||
ty::Int(_) => {
|
||||
let param_env = ty::ParamEnv::reveal_all();
|
||||
ct.try_eval_bits(self.tcx, param_env, ct.ty).and_then(|b| {
|
||||
let sz = self.tcx.layout_of(param_env.and(ct.ty)).ok()?.size;
|
||||
let val = sign_extend(b, sz) as i128;
|
||||
if val < 0 {
|
||||
neg = true;
|
||||
}
|
||||
Some(val.wrapping_abs() as u128)
|
||||
})
|
||||
}
|
||||
_ => {
|
||||
bug!("symbol_names: unsupported constant of type `{}` ({:?})", ct.ty, ct);
|
||||
}
|
||||
}
|
||||
self = ct.ty.print(self)?;
|
||||
};
|
||||
|
||||
if let Some(bits) = ct.try_eval_bits(self.tcx, ty::ParamEnv::reveal_all(), ct.ty) {
|
||||
let _ = write!(self.out, "{:x}_", bits);
|
||||
if let Some(bits) = val {
|
||||
// We only print the type if the const can be evaluated.
|
||||
self = ct.ty.print(self)?;
|
||||
let _ = write!(self.out, "{}{:x}_", if neg { "n" } else { "" }, bits);
|
||||
} else {
|
||||
// NOTE(eddyb) despite having the path, we need to
|
||||
// encode a placeholder, as the path could refer
|
||||
|
@ -32,6 +32,20 @@ impl<C, B> Try for ControlFlow<C, B> {
|
||||
}
|
||||
|
||||
impl<C, B> ControlFlow<C, B> {
|
||||
/// Returns `true` if this is a `Break` variant.
|
||||
#[inline]
|
||||
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
|
||||
pub fn is_break(&self) -> bool {
|
||||
matches!(*self, ControlFlow::Break(_))
|
||||
}
|
||||
|
||||
/// Returns `true` if this is a `Continue` variant.
|
||||
#[inline]
|
||||
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
|
||||
pub fn is_continue(&self) -> bool {
|
||||
matches!(*self, ControlFlow::Continue(_))
|
||||
}
|
||||
|
||||
/// Converts the `ControlFlow` into an `Option` which is `Some` if the
|
||||
/// `ControlFlow` was `Break` and `None` otherwise.
|
||||
#[inline]
|
||||
|
@ -786,7 +786,7 @@ impl<T: ?Sized> Pin<&'static T> {
|
||||
///
|
||||
/// This is safe, because `T` is borrowed for the `'static` lifetime, which
|
||||
/// never ends.
|
||||
#[unstable(feature = "pin_static_ref", issue = "none")]
|
||||
#[unstable(feature = "pin_static_ref", issue = "78186")]
|
||||
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
|
||||
pub const fn static_ref(r: &'static T) -> Pin<&'static T> {
|
||||
// SAFETY: The 'static borrow guarantees the data will not be
|
||||
@ -800,7 +800,7 @@ impl<T: ?Sized> Pin<&'static mut T> {
|
||||
///
|
||||
/// This is safe, because `T` is borrowed for the `'static` lifetime, which
|
||||
/// never ends.
|
||||
#[unstable(feature = "pin_static_ref", issue = "none")]
|
||||
#[unstable(feature = "pin_static_ref", issue = "78186")]
|
||||
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
|
||||
pub const fn static_mut(r: &'static mut T) -> Pin<&'static mut T> {
|
||||
// SAFETY: The 'static borrow guarantees the data will not be
|
||||
|
@ -24,7 +24,7 @@ hashbrown = { version = "0.9.0", default-features = false, features = ['rustc-de
|
||||
|
||||
# Dependencies of the `backtrace` crate
|
||||
addr2line = { version = "0.13.0", optional = true, default-features = false }
|
||||
rustc-demangle = { version = "0.1.4", features = ['rustc-dep-of-std'] }
|
||||
rustc-demangle = { version = "0.1.18", features = ['rustc-dep-of-std'] }
|
||||
miniz_oxide = { version = "0.4.0", optional = true, default-features = false }
|
||||
[dependencies.object]
|
||||
version = "0.20"
|
||||
|
@ -378,6 +378,8 @@ fn configure_cmake(
|
||||
cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD");
|
||||
} else if target.contains("windows") {
|
||||
cfg.define("CMAKE_SYSTEM_NAME", "Windows");
|
||||
} else if target.contains("haiku") {
|
||||
cfg.define("CMAKE_SYSTEM_NAME", "Haiku");
|
||||
}
|
||||
// When cross-compiling we should also set CMAKE_SYSTEM_VERSION, but in
|
||||
// that case like CMake we cannot easily determine system version either.
|
||||
|
@ -1568,6 +1568,41 @@ h4 > .notable-traits {
|
||||
#titles, #titles > div {
|
||||
height: 73px;
|
||||
}
|
||||
|
||||
#main > table:not(.table-display) td {
|
||||
word-break: break-word;
|
||||
min-width: 10%;
|
||||
}
|
||||
|
||||
.search-container > div {
|
||||
display: block;
|
||||
width: calc(100% - 37px);
|
||||
}
|
||||
|
||||
#crate-search {
|
||||
width: 100%;
|
||||
border-radius: 4px;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
#crate-search + .search-input {
|
||||
width: calc(100% + 71px);
|
||||
margin-left: -36px;
|
||||
}
|
||||
|
||||
#theme-picker, #settings-menu {
|
||||
padding: 5px;
|
||||
width: 31px;
|
||||
height: 31px;
|
||||
}
|
||||
|
||||
#theme-picker {
|
||||
margin-top: -2px;
|
||||
}
|
||||
|
||||
#settings-menu {
|
||||
top: 7px;
|
||||
}
|
||||
}
|
||||
|
||||
h3.notable {
|
||||
|
@ -1,14 +1,14 @@
|
||||
#![feature(raw_ref_op)]
|
||||
|
||||
const A: () = { let mut x = 2; &raw mut x; }; //~ ERROR `&raw mut` is not allowed
|
||||
const A: () = { let mut x = 2; &raw mut x; }; //~ mutable reference
|
||||
|
||||
static B: () = { let mut x = 2; &raw mut x; }; //~ ERROR `&raw mut` is not allowed
|
||||
static B: () = { let mut x = 2; &raw mut x; }; //~ mutable reference
|
||||
|
||||
static mut C: () = { let mut x = 2; &raw mut x; }; //~ ERROR `&raw mut` is not allowed
|
||||
static mut C: () = { let mut x = 2; &raw mut x; }; //~ mutable reference
|
||||
|
||||
const fn foo() {
|
||||
let mut x = 0;
|
||||
let y = &raw mut x; //~ ERROR `&raw mut` is not allowed
|
||||
let y = &raw mut x; //~ mutable reference
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,31 +1,22 @@
|
||||
error[E0658]: `&raw mut` is not allowed in constants
|
||||
error[E0764]: raw mutable references are not allowed in constants
|
||||
--> $DIR/const-address-of-mut.rs:3:32
|
||||
|
|
||||
LL | const A: () = { let mut x = 2; &raw mut x; };
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
| ^^^^^^^^^^ `&raw mut` is only allowed in `const fn`
|
||||
|
||||
error[E0658]: `&raw mut` is not allowed in statics
|
||||
error[E0764]: raw mutable references are not allowed in statics
|
||||
--> $DIR/const-address-of-mut.rs:5:33
|
||||
|
|
||||
LL | static B: () = { let mut x = 2; &raw mut x; };
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
| ^^^^^^^^^^ `&raw mut` is only allowed in `const fn`
|
||||
|
||||
error[E0658]: `&raw mut` is not allowed in statics
|
||||
error[E0764]: raw mutable references are not allowed in statics
|
||||
--> $DIR/const-address-of-mut.rs:7:37
|
||||
|
|
||||
LL | static mut C: () = { let mut x = 2; &raw mut x; };
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
| ^^^^^^^^^^ `&raw mut` is only allowed in `const fn`
|
||||
|
||||
error[E0658]: `&raw mut` is not allowed in constant functions
|
||||
error[E0658]: raw mutable references are not allowed in constant functions
|
||||
--> $DIR/const-address-of-mut.rs:11:13
|
||||
|
|
||||
LL | let y = &raw mut x;
|
||||
@ -36,4 +27,5 @@ LL | let y = &raw mut x;
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
Some errors have detailed explanations: E0658, E0764.
|
||||
For more information about an error, try `rustc --explain E0658`.
|
||||
|
5
src/test/ui/consts/issue-77062-large-zst-array.rs
Normal file
5
src/test/ui/consts/issue-77062-large-zst-array.rs
Normal file
@ -0,0 +1,5 @@
|
||||
// build-pass
|
||||
|
||||
fn main() {
|
||||
let _ = &[(); usize::MAX];
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
const fn mutable_address_of_in_const() {
|
||||
let mut a = 0;
|
||||
let b = &raw mut a; //~ ERROR `&raw mut` is not allowed
|
||||
let b = &raw mut a; //~ ERROR mutable reference
|
||||
}
|
||||
|
||||
struct X;
|
||||
@ -10,7 +10,7 @@ struct X;
|
||||
impl X {
|
||||
const fn inherent_mutable_address_of_in_const() {
|
||||
let mut a = 0;
|
||||
let b = &raw mut a; //~ ERROR `&raw mut` is not allowed
|
||||
let b = &raw mut a; //~ ERROR mutable reference
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
error[E0658]: `&raw mut` is not allowed in constant functions
|
||||
error[E0658]: raw mutable references are not allowed in constant functions
|
||||
--> $DIR/address_of.rs:5:13
|
||||
|
|
||||
LL | let b = &raw mut a;
|
||||
@ -7,7 +7,7 @@ LL | let b = &raw mut a;
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: `&raw mut` is not allowed in constant functions
|
||||
error[E0658]: raw mutable references are not allowed in constant functions
|
||||
--> $DIR/address_of.rs:13:17
|
||||
|
|
||||
LL | let b = &raw mut a;
|
||||
|
44
src/test/ui/liveness/liveness-asm.rs
Normal file
44
src/test/ui/liveness/liveness-asm.rs
Normal file
@ -0,0 +1,44 @@
|
||||
// Ensure inout asm! operands are marked as used by the liveness pass
|
||||
|
||||
// only-x86_64
|
||||
// check-pass
|
||||
|
||||
#![feature(asm)]
|
||||
#![allow(dead_code)]
|
||||
#![warn(unused_assignments)]
|
||||
#![warn(unused_variables)]
|
||||
|
||||
// Test the single inout case
|
||||
unsafe fn f1(mut src: *const u8) {
|
||||
asm!("/*{0}*/", inout(reg) src); //~ WARN value assigned to `src` is never read
|
||||
}
|
||||
|
||||
unsafe fn f2(mut src: *const u8) -> *const u8 {
|
||||
asm!("/*{0}*/", inout(reg) src);
|
||||
src
|
||||
}
|
||||
|
||||
// Test the split inout case
|
||||
unsafe fn f3(mut src: *const u8) {
|
||||
asm!("/*{0}*/", inout(reg) src => src); //~ WARN value assigned to `src` is never read
|
||||
}
|
||||
|
||||
unsafe fn f4(mut src: *const u8) -> *const u8 {
|
||||
asm!("/*{0}*/", inout(reg) src => src);
|
||||
src
|
||||
}
|
||||
|
||||
// Tests the use of field projections
|
||||
struct S {
|
||||
field: *mut u8,
|
||||
}
|
||||
|
||||
unsafe fn f5(src: &mut S) {
|
||||
asm!("/*{0}*/", inout(reg) src.field);
|
||||
}
|
||||
|
||||
unsafe fn f6(src: &mut S) {
|
||||
asm!("/*{0}*/", inout(reg) src.field => src.field);
|
||||
}
|
||||
|
||||
fn main() {}
|
23
src/test/ui/liveness/liveness-asm.stderr
Normal file
23
src/test/ui/liveness/liveness-asm.stderr
Normal file
@ -0,0 +1,23 @@
|
||||
warning: value assigned to `src` is never read
|
||||
--> $DIR/liveness-asm.rs:13:32
|
||||
|
|
||||
LL | asm!("/*{0}*/", inout(reg) src);
|
||||
| ^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/liveness-asm.rs:8:9
|
||||
|
|
||||
LL | #![warn(unused_assignments)]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `src` is never read
|
||||
--> $DIR/liveness-asm.rs:23:39
|
||||
|
|
||||
LL | asm!("/*{0}*/", inout(reg) src => src);
|
||||
| ^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: 2 warnings emitted
|
||||
|
38
src/test/ui/symbol-names/const-generics-demangling.rs
Normal file
38
src/test/ui/symbol-names/const-generics-demangling.rs
Normal file
@ -0,0 +1,38 @@
|
||||
// build-fail
|
||||
// compile-flags: -Z symbol-mangling-version=v0
|
||||
|
||||
#![feature(min_const_generics, rustc_attrs)]
|
||||
|
||||
pub struct Unsigned<const F: u8>;
|
||||
|
||||
#[rustc_symbol_name]
|
||||
//~^ ERROR symbol-name(_RMCs4fqI2P2rA04_25const_generics_demanglingINtB0_8UnsignedKhb_E)
|
||||
//~| ERROR demangling(<const_generics_demangling[317d481089b8c8fe]::Unsigned<11: u8>>)
|
||||
//~| ERROR demangling-alt(<const_generics_demangling::Unsigned<11>>)
|
||||
impl Unsigned<11> {}
|
||||
|
||||
pub struct Signed<const F: i16>;
|
||||
|
||||
#[rustc_symbol_name]
|
||||
//~^ ERROR symbol-name(_RMs_Cs4fqI2P2rA04_25const_generics_demanglingINtB2_6SignedKsn98_E)
|
||||
//~| ERROR demangling(<const_generics_demangling[317d481089b8c8fe]::Signed<-152: i16>>)
|
||||
//~| ERROR demangling-alt(<const_generics_demangling::Signed<-152>>)
|
||||
impl Signed<-152> {}
|
||||
|
||||
pub struct Bool<const F: bool>;
|
||||
|
||||
#[rustc_symbol_name]
|
||||
//~^ ERROR symbol-name(_RMs0_Cs4fqI2P2rA04_25const_generics_demanglingINtB3_4BoolKb1_E)
|
||||
//~| ERROR demangling(<const_generics_demangling[317d481089b8c8fe]::Bool<true: bool>>)
|
||||
//~| ERROR demangling-alt(<const_generics_demangling::Bool<true>>)
|
||||
impl Bool<true> {}
|
||||
|
||||
pub struct Char<const F: char>;
|
||||
|
||||
#[rustc_symbol_name]
|
||||
//~^ ERROR symbol-name(_RMs1_Cs4fqI2P2rA04_25const_generics_demanglingINtB3_4CharKc2202_E)
|
||||
//~| ERROR demangling(<const_generics_demangling[317d481089b8c8fe]::Char<'∂': char>>)
|
||||
//~| ERROR demangling-alt(<const_generics_demangling::Char<'∂'>>)
|
||||
impl Char<'∂'> {}
|
||||
|
||||
fn main() {}
|
74
src/test/ui/symbol-names/const-generics-demangling.stderr
Normal file
74
src/test/ui/symbol-names/const-generics-demangling.stderr
Normal file
@ -0,0 +1,74 @@
|
||||
error: symbol-name(_RMCs4fqI2P2rA04_25const_generics_demanglingINtB0_8UnsignedKhb_E)
|
||||
--> $DIR/const-generics-demangling.rs:8:1
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling(<const_generics_demangling[317d481089b8c8fe]::Unsigned<11: u8>>)
|
||||
--> $DIR/const-generics-demangling.rs:8:1
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling-alt(<const_generics_demangling::Unsigned<11>>)
|
||||
--> $DIR/const-generics-demangling.rs:8:1
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: symbol-name(_RMs_Cs4fqI2P2rA04_25const_generics_demanglingINtB2_6SignedKsn98_E)
|
||||
--> $DIR/const-generics-demangling.rs:16:1
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling(<const_generics_demangling[317d481089b8c8fe]::Signed<-152: i16>>)
|
||||
--> $DIR/const-generics-demangling.rs:16:1
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling-alt(<const_generics_demangling::Signed<-152>>)
|
||||
--> $DIR/const-generics-demangling.rs:16:1
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: symbol-name(_RMs0_Cs4fqI2P2rA04_25const_generics_demanglingINtB3_4BoolKb1_E)
|
||||
--> $DIR/const-generics-demangling.rs:24:1
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling(<const_generics_demangling[317d481089b8c8fe]::Bool<true: bool>>)
|
||||
--> $DIR/const-generics-demangling.rs:24:1
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling-alt(<const_generics_demangling::Bool<true>>)
|
||||
--> $DIR/const-generics-demangling.rs:24:1
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: symbol-name(_RMs1_Cs4fqI2P2rA04_25const_generics_demanglingINtB3_4CharKc2202_E)
|
||||
--> $DIR/const-generics-demangling.rs:32:1
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling(<const_generics_demangling[317d481089b8c8fe]::Char<'∂': char>>)
|
||||
--> $DIR/const-generics-demangling.rs:32:1
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling-alt(<const_generics_demangling::Char<'∂'>>)
|
||||
--> $DIR/const-generics-demangling.rs:32:1
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
87
src/test/ui/symbol-names/const-generics.rs
Normal file
87
src/test/ui/symbol-names/const-generics.rs
Normal file
@ -0,0 +1,87 @@
|
||||
// check-pass
|
||||
// revisions: legacy v0
|
||||
//[legacy]compile-flags: -Z symbol-mangling-version=legacy --crate-type=lib
|
||||
//[v0]compile-flags: -Z symbol-mangling-version=v0 --crate-type=lib
|
||||
|
||||
#![feature(min_const_generics)]
|
||||
|
||||
// `char`
|
||||
pub struct Char<const F: char>;
|
||||
|
||||
impl Char<'A'> {
|
||||
pub fn foo() {}
|
||||
}
|
||||
|
||||
impl<const F: char> Char<F> {
|
||||
pub fn bar() {}
|
||||
}
|
||||
|
||||
// `i8`
|
||||
pub struct I8<const F: i8>;
|
||||
|
||||
impl I8<{std::i8::MIN}> {
|
||||
pub fn foo() {}
|
||||
}
|
||||
|
||||
impl I8<{std::i8::MAX}> {
|
||||
pub fn foo() {}
|
||||
}
|
||||
|
||||
impl<const F: i8> I8<F> {
|
||||
pub fn bar() {}
|
||||
}
|
||||
|
||||
// `i16`
|
||||
pub struct I16<const F: i16>;
|
||||
|
||||
impl I16<{std::i16::MIN}> {
|
||||
pub fn foo() {}
|
||||
}
|
||||
|
||||
impl<const F: i16> I16<F> {
|
||||
pub fn bar() {}
|
||||
}
|
||||
|
||||
// `i32`
|
||||
pub struct I32<const F: i32>;
|
||||
|
||||
impl I32<{std::i32::MIN}> {
|
||||
pub fn foo() {}
|
||||
}
|
||||
|
||||
impl<const F: i32> I32<F> {
|
||||
pub fn bar() {}
|
||||
}
|
||||
|
||||
// `i64`
|
||||
pub struct I64<const F: i64>;
|
||||
|
||||
impl I64<{std::i64::MIN}> {
|
||||
pub fn foo() {}
|
||||
}
|
||||
|
||||
impl<const F: i64> I64<F> {
|
||||
pub fn bar() {}
|
||||
}
|
||||
|
||||
// `i128`
|
||||
pub struct I128<const F: i128>;
|
||||
|
||||
impl I128<{std::i128::MIN}> {
|
||||
pub fn foo() {}
|
||||
}
|
||||
|
||||
impl<const F: i128> I128<F> {
|
||||
pub fn bar() {}
|
||||
}
|
||||
|
||||
// `isize`
|
||||
pub struct ISize<const F: isize>;
|
||||
|
||||
impl ISize<3> {
|
||||
pub fn foo() {}
|
||||
}
|
||||
|
||||
impl<const F: isize> ISize<F> {
|
||||
pub fn bar() {}
|
||||
}
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
regex = "1.0"
|
||||
rustc-demangle = "0.1"
|
||||
rustc-demangle = "0.1.17"
|
||||
|
||||
[[bin]]
|
||||
name = "rust-demangler"
|
||||
|
Loading…
Reference in New Issue
Block a user