Auto merge of #96108 - Dylan-DPC:rollup-t5f2fc9, r=Dylan-DPC
Rollup of 9 pull requests Successful merges: - #93969 (Only add codegen backend to dep info if -Zbinary-dep-depinfo is used) - #94605 (Add missing links in platform support docs) - #95372 (make unaligned_references lint deny-by-default) - #95859 (Improve diagnostics for unterminated nested block comment) - #95961 (implement SIMD gather/scatter via vector getelementptr) - #96004 (Consider lifetimes when comparing types for equality in MIR validator) - #96050 (Remove some now-dead code that was only relevant before deaggregation.) - #96070 ([test] Add test cases for untested functions for BTreeMap) - #96099 (MaybeUninit array cleanup) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
c8422403f7
37 changed files with 797 additions and 92 deletions
|
@ -1839,6 +1839,27 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
|
||||||
simd_neg: Int => neg, Float => fneg;
|
simd_neg: Int => neg, Float => fneg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if name == sym::simd_arith_offset {
|
||||||
|
// This also checks that the first operand is a ptr type.
|
||||||
|
let pointee = in_elem.builtin_deref(true).unwrap_or_else(|| {
|
||||||
|
span_bug!(span, "must be called with a vector of pointer types as first argument")
|
||||||
|
});
|
||||||
|
let layout = bx.layout_of(pointee.ty);
|
||||||
|
let ptrs = args[0].immediate();
|
||||||
|
// The second argument must be a ptr-sized integer.
|
||||||
|
// (We don't care about the signedness, this is wrapping anyway.)
|
||||||
|
let (_offsets_len, offsets_elem) = arg_tys[1].simd_size_and_type(bx.tcx());
|
||||||
|
if !matches!(offsets_elem.kind(), ty::Int(ty::IntTy::Isize) | ty::Uint(ty::UintTy::Usize)) {
|
||||||
|
span_bug!(
|
||||||
|
span,
|
||||||
|
"must be called with a vector of pointer-sized integers as second argument"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
let offsets = args[1].immediate();
|
||||||
|
|
||||||
|
return Ok(bx.gep(bx.backend_type(layout), ptrs, &[offsets]));
|
||||||
|
}
|
||||||
|
|
||||||
if name == sym::simd_saturating_add || name == sym::simd_saturating_sub {
|
if name == sym::simd_saturating_add || name == sym::simd_saturating_sub {
|
||||||
let lhs = args[0].immediate();
|
let lhs = args[0].immediate();
|
||||||
let rhs = args[1].immediate();
|
let rhs = args[1].immediate();
|
||||||
|
|
|
@ -196,27 +196,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
self.write_immediate(*val, &dest)?;
|
self.write_immediate(*val, &dest)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Aggregate(ref kind, ref operands) => {
|
Aggregate(box ref kind, ref operands) => {
|
||||||
// active_field_index is for union initialization.
|
assert!(matches!(kind, mir::AggregateKind::Array(..)));
|
||||||
let (dest, active_field_index) = match **kind {
|
|
||||||
mir::AggregateKind::Adt(adt_did, variant_index, _, _, active_field_index) => {
|
|
||||||
self.write_discriminant(variant_index, &dest)?;
|
|
||||||
if self.tcx.adt_def(adt_did).is_enum() {
|
|
||||||
assert!(active_field_index.is_none());
|
|
||||||
(self.place_downcast(&dest, variant_index)?, None)
|
|
||||||
} else {
|
|
||||||
if active_field_index.is_some() {
|
|
||||||
assert_eq!(operands.len(), 1);
|
|
||||||
}
|
|
||||||
(dest, active_field_index)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => (dest, None),
|
|
||||||
};
|
|
||||||
|
|
||||||
for (i, operand) in operands.iter().enumerate() {
|
for (field_index, operand) in operands.iter().enumerate() {
|
||||||
let op = self.eval_operand(operand, None)?;
|
let op = self.eval_operand(operand, None)?;
|
||||||
let field_index = active_field_index.unwrap_or(i);
|
|
||||||
let field_dest = self.place_field(&dest, field_index)?;
|
let field_dest = self.place_field(&dest, field_index)?;
|
||||||
self.copy_op(&op, &field_dest)?;
|
self.copy_op(&op, &field_dest)?;
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,9 +315,8 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
|
||||||
| ty::FnPtr(..)
|
| ty::FnPtr(..)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// None of the possible types have lifetimes, so we can just compare
|
// The function pointer types can have lifetimes
|
||||||
// directly
|
if !self.mir_assign_valid_types(a, b) {
|
||||||
if a != b {
|
|
||||||
self.fail(
|
self.fail(
|
||||||
location,
|
location,
|
||||||
format!("Cannot compare unequal types {:?} and {:?}", a, b),
|
format!("Cannot compare unequal types {:?} and {:?}", a, b),
|
||||||
|
@ -464,7 +463,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
|
||||||
};
|
};
|
||||||
// since CopyNonOverlapping is parametrized by 1 type,
|
// since CopyNonOverlapping is parametrized by 1 type,
|
||||||
// we only need to check that they are equal and not keep an extra parameter.
|
// we only need to check that they are equal and not keep an extra parameter.
|
||||||
if op_src_ty != op_dst_ty {
|
if !self.mir_assign_valid_types(op_src_ty, op_dst_ty) {
|
||||||
self.fail(location, format!("bad arg ({:?} != {:?})", op_src_ty, op_dst_ty));
|
self.fail(location, format!("bad arg ({:?} != {:?})", op_src_ty, op_dst_ty));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#![feature(thread_id_value)]
|
#![feature(thread_id_value)]
|
||||||
#![feature(vec_into_raw_parts)]
|
#![feature(vec_into_raw_parts)]
|
||||||
#![allow(rustc::default_hash_types)]
|
#![allow(rustc::default_hash_types)]
|
||||||
#![deny(unaligned_references)]
|
|
||||||
#![allow(rustc::potential_query_instability)]
|
#![allow(rustc::potential_query_instability)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
|
@ -629,11 +629,15 @@ fn write_out_deps(
|
||||||
});
|
});
|
||||||
files.extend(extra_tracked_files);
|
files.extend(extra_tracked_files);
|
||||||
|
|
||||||
if let Some(ref backend) = sess.opts.debugging_opts.codegen_backend {
|
|
||||||
files.push(backend.to_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
if sess.binary_dep_depinfo() {
|
if sess.binary_dep_depinfo() {
|
||||||
|
if let Some(ref backend) = sess.opts.debugging_opts.codegen_backend {
|
||||||
|
if backend.contains('.') {
|
||||||
|
// If the backend name contain a `.`, it is the path to an external dynamic
|
||||||
|
// library. If not, it is not a path.
|
||||||
|
files.push(backend.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boxed_resolver.borrow_mut().access(|resolver| {
|
boxed_resolver.borrow_mut().access(|resolver| {
|
||||||
for cnum in resolver.cstore().crates_untracked() {
|
for cnum in resolver.cstore().crates_untracked() {
|
||||||
let source = resolver.cstore().crate_source_untracked(cnum);
|
let source = resolver.cstore().crate_source_untracked(cnum);
|
||||||
|
|
|
@ -1110,8 +1110,6 @@ declare_lint! {
|
||||||
/// ### Example
|
/// ### Example
|
||||||
///
|
///
|
||||||
/// ```rust,compile_fail
|
/// ```rust,compile_fail
|
||||||
/// #![deny(unaligned_references)]
|
|
||||||
///
|
|
||||||
/// #[repr(packed)]
|
/// #[repr(packed)]
|
||||||
/// pub struct Foo {
|
/// pub struct Foo {
|
||||||
/// field1: u64,
|
/// field1: u64,
|
||||||
|
@ -1139,10 +1137,11 @@ declare_lint! {
|
||||||
/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
|
/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
|
||||||
/// [issue #82523]: https://github.com/rust-lang/rust/issues/82523
|
/// [issue #82523]: https://github.com/rust-lang/rust/issues/82523
|
||||||
pub UNALIGNED_REFERENCES,
|
pub UNALIGNED_REFERENCES,
|
||||||
Warn,
|
Deny,
|
||||||
"detects unaligned references to fields of packed structs",
|
"detects unaligned references to fields of packed structs",
|
||||||
@future_incompatible = FutureIncompatibleInfo {
|
@future_incompatible = FutureIncompatibleInfo {
|
||||||
reference: "issue #82523 <https://github.com/rust-lang/rust/issues/82523>",
|
reference: "issue #82523 <https://github.com/rust-lang/rust/issues/82523>",
|
||||||
|
reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
|
||||||
};
|
};
|
||||||
report_in_external_macro
|
report_in_external_macro
|
||||||
}
|
}
|
||||||
|
|
|
@ -2518,7 +2518,8 @@ pub enum Rvalue<'tcx> {
|
||||||
/// * `Offset` has the same semantics as [`offset`](pointer::offset), except that the second
|
/// * `Offset` has the same semantics as [`offset`](pointer::offset), except that the second
|
||||||
/// parameter may be a `usize` as well.
|
/// parameter may be a `usize` as well.
|
||||||
/// * The comparison operations accept `bool`s, `char`s, signed or unsigned integers, floats,
|
/// * The comparison operations accept `bool`s, `char`s, signed or unsigned integers, floats,
|
||||||
/// raw pointers, or function pointers of matching types and return a `bool`.
|
/// raw pointers, or function pointers and return a `bool`. The types of the operands must be
|
||||||
|
/// matching, up to the usual caveat of the lifetimes in function pointers.
|
||||||
/// * Left and right shift operations accept signed or unsigned integers not necessarily of the
|
/// * Left and right shift operations accept signed or unsigned integers not necessarily of the
|
||||||
/// same type and return a value of the same type as their LHS. Like in Rust, the RHS is
|
/// same type and return a value of the same type as their LHS. Like in Rust, the RHS is
|
||||||
/// truncated as needed.
|
/// truncated as needed.
|
||||||
|
|
|
@ -182,16 +182,7 @@ impl<'a> StringReader<'a> {
|
||||||
}
|
}
|
||||||
rustc_lexer::TokenKind::BlockComment { doc_style, terminated } => {
|
rustc_lexer::TokenKind::BlockComment { doc_style, terminated } => {
|
||||||
if !terminated {
|
if !terminated {
|
||||||
let msg = match doc_style {
|
self.report_unterminated_block_comment(start, doc_style);
|
||||||
Some(_) => "unterminated block doc-comment",
|
|
||||||
None => "unterminated block comment",
|
|
||||||
};
|
|
||||||
let last_bpos = self.pos;
|
|
||||||
self.sess.span_diagnostic.span_fatal_with_code(
|
|
||||||
self.mk_sp(start, last_bpos),
|
|
||||||
msg,
|
|
||||||
error_code!(E0758),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip non-doc comments
|
// Skip non-doc comments
|
||||||
|
@ -553,6 +544,55 @@ impl<'a> StringReader<'a> {
|
||||||
err.emit()
|
err.emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn report_unterminated_block_comment(&self, start: BytePos, doc_style: Option<DocStyle>) {
|
||||||
|
let msg = match doc_style {
|
||||||
|
Some(_) => "unterminated block doc-comment",
|
||||||
|
None => "unterminated block comment",
|
||||||
|
};
|
||||||
|
let last_bpos = self.pos;
|
||||||
|
let mut err = self.sess.span_diagnostic.struct_span_fatal_with_code(
|
||||||
|
self.mk_sp(start, last_bpos),
|
||||||
|
msg,
|
||||||
|
error_code!(E0758),
|
||||||
|
);
|
||||||
|
let mut nested_block_comment_open_idxs = vec![];
|
||||||
|
let mut last_nested_block_comment_idxs = None;
|
||||||
|
let mut content_chars = self.str_from(start).char_indices().peekable();
|
||||||
|
|
||||||
|
while let Some((idx, current_char)) = content_chars.next() {
|
||||||
|
match content_chars.peek() {
|
||||||
|
Some((_, '*')) if current_char == '/' => {
|
||||||
|
nested_block_comment_open_idxs.push(idx);
|
||||||
|
}
|
||||||
|
Some((_, '/')) if current_char == '*' => {
|
||||||
|
last_nested_block_comment_idxs =
|
||||||
|
nested_block_comment_open_idxs.pop().map(|open_idx| (open_idx, idx));
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some((nested_open_idx, nested_close_idx)) = last_nested_block_comment_idxs {
|
||||||
|
err.span_label(self.mk_sp(start, start + BytePos(2)), msg)
|
||||||
|
.span_label(
|
||||||
|
self.mk_sp(
|
||||||
|
start + BytePos(nested_open_idx as u32),
|
||||||
|
start + BytePos(nested_open_idx as u32 + 2),
|
||||||
|
),
|
||||||
|
"...as last nested comment starts here, maybe you want to close this instead?",
|
||||||
|
)
|
||||||
|
.span_label(
|
||||||
|
self.mk_sp(
|
||||||
|
start + BytePos(nested_close_idx as u32),
|
||||||
|
start + BytePos(nested_close_idx as u32 + 2),
|
||||||
|
),
|
||||||
|
"...and last nested comment terminates here.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
err.emit();
|
||||||
|
}
|
||||||
|
|
||||||
// RFC 3101 introduced the idea of (reserved) prefixes. As of Rust 2021,
|
// RFC 3101 introduced the idea of (reserved) prefixes. As of Rust 2021,
|
||||||
// using a (unknown) prefix is an error. In earlier editions, however, they
|
// using a (unknown) prefix is an error. In earlier editions, however, they
|
||||||
// only result in a (allowed by default) lint, and are treated as regular
|
// only result in a (allowed by default) lint, and are treated as regular
|
||||||
|
|
|
@ -1247,6 +1247,7 @@ symbols! {
|
||||||
simd,
|
simd,
|
||||||
simd_add,
|
simd_add,
|
||||||
simd_and,
|
simd_and,
|
||||||
|
simd_arith_offset,
|
||||||
simd_as,
|
simd_as,
|
||||||
simd_bitmask,
|
simd_bitmask,
|
||||||
simd_cast,
|
simd_cast,
|
||||||
|
|
|
@ -437,6 +437,7 @@ pub fn check_platform_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>)
|
||||||
| sym::simd_fpow
|
| sym::simd_fpow
|
||||||
| sym::simd_saturating_add
|
| sym::simd_saturating_add
|
||||||
| sym::simd_saturating_sub => (1, vec![param(0), param(0)], param(0)),
|
| sym::simd_saturating_sub => (1, vec![param(0), param(0)], param(0)),
|
||||||
|
sym::simd_arith_offset => (2, vec![param(0), param(1)], param(0)),
|
||||||
sym::simd_neg
|
sym::simd_neg
|
||||||
| sym::simd_fsqrt
|
| sym::simd_fsqrt
|
||||||
| sym::simd_fsin
|
| sym::simd_fsin
|
||||||
|
|
|
@ -1878,6 +1878,96 @@ fn test_first_last_entry() {
|
||||||
a.check();
|
a.check();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_pop_first_last() {
|
||||||
|
let mut map = BTreeMap::new();
|
||||||
|
assert_eq!(map.pop_first(), None);
|
||||||
|
assert_eq!(map.pop_last(), None);
|
||||||
|
|
||||||
|
map.insert(1, 10);
|
||||||
|
map.insert(2, 20);
|
||||||
|
map.insert(3, 30);
|
||||||
|
map.insert(4, 40);
|
||||||
|
|
||||||
|
assert_eq!(map.len(), 4);
|
||||||
|
|
||||||
|
let (key, val) = map.pop_first().unwrap();
|
||||||
|
assert_eq!(key, 1);
|
||||||
|
assert_eq!(val, 10);
|
||||||
|
assert_eq!(map.len(), 3);
|
||||||
|
|
||||||
|
let (key, val) = map.pop_first().unwrap();
|
||||||
|
assert_eq!(key, 2);
|
||||||
|
assert_eq!(val, 20);
|
||||||
|
assert_eq!(map.len(), 2);
|
||||||
|
let (key, val) = map.pop_last().unwrap();
|
||||||
|
assert_eq!(key, 4);
|
||||||
|
assert_eq!(val, 40);
|
||||||
|
assert_eq!(map.len(), 1);
|
||||||
|
|
||||||
|
map.insert(5, 50);
|
||||||
|
map.insert(6, 60);
|
||||||
|
assert_eq!(map.len(), 3);
|
||||||
|
|
||||||
|
let (key, val) = map.pop_first().unwrap();
|
||||||
|
assert_eq!(key, 3);
|
||||||
|
assert_eq!(val, 30);
|
||||||
|
assert_eq!(map.len(), 2);
|
||||||
|
|
||||||
|
let (key, val) = map.pop_last().unwrap();
|
||||||
|
assert_eq!(key, 6);
|
||||||
|
assert_eq!(val, 60);
|
||||||
|
assert_eq!(map.len(), 1);
|
||||||
|
|
||||||
|
let (key, val) = map.pop_last().unwrap();
|
||||||
|
assert_eq!(key, 5);
|
||||||
|
assert_eq!(val, 50);
|
||||||
|
assert_eq!(map.len(), 0);
|
||||||
|
|
||||||
|
assert_eq!(map.pop_first(), None);
|
||||||
|
assert_eq!(map.pop_last(), None);
|
||||||
|
|
||||||
|
map.insert(7, 70);
|
||||||
|
map.insert(8, 80);
|
||||||
|
|
||||||
|
let (key, val) = map.pop_last().unwrap();
|
||||||
|
assert_eq!(key, 8);
|
||||||
|
assert_eq!(val, 80);
|
||||||
|
assert_eq!(map.len(), 1);
|
||||||
|
|
||||||
|
let (key, val) = map.pop_last().unwrap();
|
||||||
|
assert_eq!(key, 7);
|
||||||
|
assert_eq!(val, 70);
|
||||||
|
assert_eq!(map.len(), 0);
|
||||||
|
|
||||||
|
assert_eq!(map.pop_first(), None);
|
||||||
|
assert_eq!(map.pop_last(), None);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_key_value() {
|
||||||
|
let mut map = BTreeMap::new();
|
||||||
|
|
||||||
|
assert!(map.is_empty());
|
||||||
|
assert_eq!(map.get_key_value(&1), None);
|
||||||
|
assert_eq!(map.get_key_value(&2), None);
|
||||||
|
|
||||||
|
map.insert(1, 10);
|
||||||
|
map.insert(2, 20);
|
||||||
|
map.insert(3, 30);
|
||||||
|
|
||||||
|
assert_eq!(map.len(), 3);
|
||||||
|
assert_eq!(map.get_key_value(&1), Some((&1, &10)));
|
||||||
|
assert_eq!(map.get_key_value(&3), Some((&3, &30)));
|
||||||
|
assert_eq!(map.get_key_value(&4), None);
|
||||||
|
|
||||||
|
map.remove(&3);
|
||||||
|
|
||||||
|
assert_eq!(map.len(), 2);
|
||||||
|
assert_eq!(map.get_key_value(&3), None);
|
||||||
|
assert_eq!(map.get_key_value(&2), Some((&2, &20)));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_insert_into_full_height_0() {
|
fn test_insert_into_full_height_0() {
|
||||||
let size = node::CAPACITY;
|
let size = node::CAPACITY;
|
||||||
|
@ -1904,6 +1994,21 @@ fn test_insert_into_full_height_1() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_try_insert() {
|
||||||
|
let mut map = BTreeMap::new();
|
||||||
|
|
||||||
|
assert!(map.is_empty());
|
||||||
|
|
||||||
|
assert_eq!(map.try_insert(1, 10).unwrap(), &10);
|
||||||
|
assert_eq!(map.try_insert(2, 20).unwrap(), &20);
|
||||||
|
|
||||||
|
let err = map.try_insert(2, 200).unwrap_err();
|
||||||
|
assert_eq!(err.entry.key(), &2);
|
||||||
|
assert_eq!(err.entry.get(), &20);
|
||||||
|
assert_eq!(err.value, 200);
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! create_append_test {
|
macro_rules! create_append_test {
|
||||||
($name:ident, $len:expr) => {
|
($name:ident, $len:expr) => {
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -117,6 +117,7 @@
|
||||||
#![feature(const_intrinsic_copy)]
|
#![feature(const_intrinsic_copy)]
|
||||||
#![feature(const_intrinsic_forget)]
|
#![feature(const_intrinsic_forget)]
|
||||||
#![feature(const_likely)]
|
#![feature(const_likely)]
|
||||||
|
#![feature(const_maybe_uninit_uninit_array)]
|
||||||
#![feature(const_maybe_uninit_as_mut_ptr)]
|
#![feature(const_maybe_uninit_as_mut_ptr)]
|
||||||
#![feature(const_maybe_uninit_assume_init)]
|
#![feature(const_maybe_uninit_assume_init)]
|
||||||
#![feature(const_num_from_num)]
|
#![feature(const_num_from_num)]
|
||||||
|
|
|
@ -350,13 +350,13 @@ impl<T> MaybeUninit<T> {
|
||||||
/// let mut buf: [MaybeUninit<u8>; 32] = MaybeUninit::uninit_array();
|
/// let mut buf: [MaybeUninit<u8>; 32] = MaybeUninit::uninit_array();
|
||||||
/// let data = read(&mut buf);
|
/// let data = read(&mut buf);
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "maybe_uninit_uninit_array", issue = "none")]
|
#[unstable(feature = "maybe_uninit_uninit_array", issue = "96097")]
|
||||||
#[rustc_const_unstable(feature = "maybe_uninit_uninit_array", issue = "none")]
|
#[rustc_const_unstable(feature = "const_maybe_uninit_uninit_array", issue = "96097")]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub const fn uninit_array<const LEN: usize>() -> [Self; LEN] {
|
pub const fn uninit_array<const N: usize>() -> [Self; N] {
|
||||||
// SAFETY: An uninitialized `[MaybeUninit<_>; LEN]` is valid.
|
// SAFETY: An uninitialized `[MaybeUninit<_>; LEN]` is valid.
|
||||||
unsafe { MaybeUninit::<[MaybeUninit<T>; LEN]>::uninit().assume_init() }
|
unsafe { MaybeUninit::<[MaybeUninit<T>; N]>::uninit().assume_init() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new `MaybeUninit<T>` in an uninitialized state, with the memory being
|
/// Creates a new `MaybeUninit<T>` in an uninitialized state, with the memory being
|
||||||
|
@ -942,19 +942,24 @@ impl<T> MaybeUninit<T> {
|
||||||
///
|
///
|
||||||
/// assert_eq!(array, [0, 1, 2]);
|
/// assert_eq!(array, [0, 1, 2]);
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "maybe_uninit_array_assume_init", issue = "80908")]
|
#[unstable(feature = "maybe_uninit_array_assume_init", issue = "96097")]
|
||||||
|
#[rustc_const_unstable(feature = "const_maybe_uninit_array_assume_init", issue = "96097")]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub unsafe fn array_assume_init<const N: usize>(array: [Self; N]) -> [T; N] {
|
pub const unsafe fn array_assume_init<const N: usize>(array: [Self; N]) -> [T; N] {
|
||||||
// SAFETY:
|
// SAFETY:
|
||||||
// * The caller guarantees that all elements of the array are initialized
|
// * The caller guarantees that all elements of the array are initialized
|
||||||
// * `MaybeUninit<T>` and T are guaranteed to have the same layout
|
// * `MaybeUninit<T>` and T are guaranteed to have the same layout
|
||||||
// * `MaybeUninit` does not drop, so there are no double-frees
|
// * `MaybeUninit` does not drop, so there are no double-frees
|
||||||
// And thus the conversion is safe
|
// And thus the conversion is safe
|
||||||
unsafe {
|
let ret = unsafe {
|
||||||
intrinsics::assert_inhabited::<[T; N]>();
|
intrinsics::assert_inhabited::<[T; N]>();
|
||||||
(&array as *const _ as *const [T; N]).read()
|
(&array as *const _ as *const [T; N]).read()
|
||||||
}
|
};
|
||||||
|
|
||||||
|
// FIXME: required to avoid `~const Destruct` bound
|
||||||
|
super::forget(array);
|
||||||
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Assuming all the elements are initialized, get a slice to them.
|
/// Assuming all the elements are initialized, get a slice to them.
|
||||||
|
|
|
@ -61,6 +61,10 @@ extern "platform-intrinsic" {
|
||||||
/// xor
|
/// xor
|
||||||
pub(crate) fn simd_xor<T>(x: T, y: T) -> T;
|
pub(crate) fn simd_xor<T>(x: T, y: T) -> T;
|
||||||
|
|
||||||
|
/// getelementptr (without inbounds)
|
||||||
|
#[cfg(not(bootstrap))]
|
||||||
|
pub(crate) fn simd_arith_offset<T, U>(ptrs: T, offsets: U) -> T;
|
||||||
|
|
||||||
/// fptoui/fptosi/uitofp/sitofp
|
/// fptoui/fptosi/uitofp/sitofp
|
||||||
/// casting floats to integers is truncating, so it is safe to convert values like e.g. 1.5
|
/// casting floats to integers is truncating, so it is safe to convert values like e.g. 1.5
|
||||||
/// but the truncated value must fit in the target type or the result is poison.
|
/// but the truncated value must fit in the target type or the result is poison.
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
//! Private implementation details of public gather/scatter APIs.
|
//! Private implementation details of public gather/scatter APIs.
|
||||||
|
#[cfg(not(bootstrap))]
|
||||||
|
use crate::simd::intrinsics;
|
||||||
use crate::simd::{LaneCount, Simd, SupportedLaneCount};
|
use crate::simd::{LaneCount, Simd, SupportedLaneCount};
|
||||||
|
#[cfg(bootstrap)]
|
||||||
use core::mem;
|
use core::mem;
|
||||||
|
|
||||||
/// A vector of *const T.
|
/// A vector of *const T.
|
||||||
|
@ -21,12 +24,16 @@ where
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn wrapping_add(self, addend: Simd<usize, LANES>) -> Self {
|
pub fn wrapping_add(self, addend: Simd<usize, LANES>) -> Self {
|
||||||
|
#[cfg(bootstrap)]
|
||||||
// Safety: converting pointers to usize and vice-versa is safe
|
// Safety: converting pointers to usize and vice-versa is safe
|
||||||
// (even if using that pointer is not)
|
// (even if using that pointer is not)
|
||||||
unsafe {
|
unsafe {
|
||||||
let x: Simd<usize, LANES> = mem::transmute_copy(&self);
|
let x: Simd<usize, LANES> = mem::transmute_copy(&self);
|
||||||
mem::transmute_copy(&{ x + (addend * Simd::splat(mem::size_of::<T>())) })
|
mem::transmute_copy(&{ x + (addend * Simd::splat(mem::size_of::<T>())) })
|
||||||
}
|
}
|
||||||
|
#[cfg(not(bootstrap))]
|
||||||
|
// Safety: this intrinsic doesn't have a precondition
|
||||||
|
unsafe { intrinsics::simd_arith_offset(self, addend) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,11 +56,15 @@ where
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn wrapping_add(self, addend: Simd<usize, LANES>) -> Self {
|
pub fn wrapping_add(self, addend: Simd<usize, LANES>) -> Self {
|
||||||
|
#[cfg(bootstrap)]
|
||||||
// Safety: converting pointers to usize and vice-versa is safe
|
// Safety: converting pointers to usize and vice-versa is safe
|
||||||
// (even if using that pointer is not)
|
// (even if using that pointer is not)
|
||||||
unsafe {
|
unsafe {
|
||||||
let x: Simd<usize, LANES> = mem::transmute_copy(&self);
|
let x: Simd<usize, LANES> = mem::transmute_copy(&self);
|
||||||
mem::transmute_copy(&{ x + (addend * Simd::splat(mem::size_of::<T>())) })
|
mem::transmute_copy(&{ x + (addend * Simd::splat(mem::size_of::<T>())) })
|
||||||
}
|
}
|
||||||
|
#[cfg(not(bootstrap))]
|
||||||
|
// Safety: this intrinsic doesn't have a precondition
|
||||||
|
unsafe { intrinsics::simd_arith_offset(self, addend) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,15 @@
|
||||||
- [Platform Support](platform-support.md)
|
- [Platform Support](platform-support.md)
|
||||||
- [Template for target-specific documentation](platform-support/TEMPLATE.md)
|
- [Template for target-specific documentation](platform-support/TEMPLATE.md)
|
||||||
- [aarch64-apple-ios-sim](platform-support/aarch64-apple-ios-sim.md)
|
- [aarch64-apple-ios-sim](platform-support/aarch64-apple-ios-sim.md)
|
||||||
|
- [aarch64-unknown-none-hermitkernel](platform-support/aarch64-unknown-none-hermitkernel.md)
|
||||||
- [armv7-unknown-linux-uclibceabi](platform-support/armv7-unknown-linux-uclibceabi.md)
|
- [armv7-unknown-linux-uclibceabi](platform-support/armv7-unknown-linux-uclibceabi.md)
|
||||||
- [armv7-unknown-linux-uclibceabihf](platform-support/armv7-unknown-linux-uclibceabihf.md)
|
- [armv7-unknown-linux-uclibceabihf](platform-support/armv7-unknown-linux-uclibceabihf.md)
|
||||||
- [\*-kmc-solid_\*](platform-support/kmc-solid.md)
|
- [\*-kmc-solid_\*](platform-support/kmc-solid.md)
|
||||||
|
- [m68k-unknown-linux-gnu](platform-support/m68k-unknown-linux-gnu.md)
|
||||||
|
- [mips64-openwrt-linux-musl](platform-support/mips64-openwrt-linux-musl.md)
|
||||||
- [*-unknown-openbsd](platform-support/openbsd.md)
|
- [*-unknown-openbsd](platform-support/openbsd.md)
|
||||||
- [x86_64-unknown-none](platform-support/x86_64-unknown-none.md)
|
|
||||||
- [wasm64-unknown-unknown](platform-support/wasm64-unknown-unknown.md)
|
- [wasm64-unknown-unknown](platform-support/wasm64-unknown-unknown.md)
|
||||||
|
- [x86_64-unknown-none](platform-support/x86_64-unknown-none.md)
|
||||||
- [Target Tier Policy](target-tier-policy.md)
|
- [Target Tier Policy](target-tier-policy.md)
|
||||||
- [Targets](targets/index.md)
|
- [Targets](targets/index.md)
|
||||||
- [Built-in Targets](targets/built-in.md)
|
- [Built-in Targets](targets/built-in.md)
|
||||||
|
|
|
@ -248,9 +248,9 @@ target | std | host | notes
|
||||||
`i686-uwp-windows-gnu` | ? | |
|
`i686-uwp-windows-gnu` | ? | |
|
||||||
`i686-uwp-windows-msvc` | ? | |
|
`i686-uwp-windows-msvc` | ? | |
|
||||||
`i686-wrs-vxworks` | ? | |
|
`i686-wrs-vxworks` | ? | |
|
||||||
`m68k-unknown-linux-gnu` | ? | | Motorola 680x0 Linux
|
[`m68k-unknown-linux-gnu`](platform-support/m68k-unknown-linux-gnu.md) | ? | | Motorola 680x0 Linux
|
||||||
`mips-unknown-linux-uclibc` | ✓ | | MIPS Linux with uClibc
|
`mips-unknown-linux-uclibc` | ✓ | | MIPS Linux with uClibc
|
||||||
`mips64-openwrt-linux-musl` | ? | | MIPS64 for OpenWrt Linux MUSL
|
[`mips64-openwrt-linux-musl`](platform-support/mips64-openwrt-linux-musl.md) | ? | | MIPS64 for OpenWrt Linux MUSL
|
||||||
`mipsel-sony-psp` | * | | MIPS (LE) Sony PlayStation Portable (PSP)
|
`mipsel-sony-psp` | * | | MIPS (LE) Sony PlayStation Portable (PSP)
|
||||||
`mipsel-unknown-linux-uclibc` | ✓ | | MIPS (LE) Linux with uClibc
|
`mipsel-unknown-linux-uclibc` | ✓ | | MIPS (LE) Linux with uClibc
|
||||||
`mipsel-unknown-none` | * | | Bare MIPS (LE) softfloat
|
`mipsel-unknown-none` | * | | Bare MIPS (LE) softfloat
|
||||||
|
|
26
src/test/codegen/simd_arith_offset.rs
Normal file
26
src/test/codegen/simd_arith_offset.rs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
// compile-flags: -C no-prepopulate-passes
|
||||||
|
// only-64bit (because the LLVM type of i64 for usize shows up)
|
||||||
|
//
|
||||||
|
|
||||||
|
#![crate_type = "lib"]
|
||||||
|
#![feature(repr_simd, platform_intrinsics)]
|
||||||
|
|
||||||
|
extern "platform-intrinsic" {
|
||||||
|
pub(crate) fn simd_arith_offset<T, U>(ptrs: T, offsets: U) -> T;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A vector of *const T.
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
#[repr(simd)]
|
||||||
|
pub struct SimdConstPtr<T, const LANES: usize>([*const T; LANES]);
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
#[repr(simd)]
|
||||||
|
pub struct Simd<T, const LANES: usize>([T; LANES]);
|
||||||
|
|
||||||
|
// CHECK-LABEL: smoke
|
||||||
|
#[no_mangle]
|
||||||
|
pub fn smoke(ptrs: SimdConstPtr<u8, 8>, offsets: Simd<usize, 8>) -> SimdConstPtr<u8, 8> {
|
||||||
|
// CHECK: getelementptr i8, <8 x i8*> %_3, <8 x i64> %_4
|
||||||
|
unsafe { simd_arith_offset(ptrs, offsets) }
|
||||||
|
}
|
|
@ -2,10 +2,25 @@ include ../tools.mk
|
||||||
|
|
||||||
# ignore-stage1
|
# ignore-stage1
|
||||||
|
|
||||||
|
# This test both exists as a check that -Zcodegen-backend is capable of loading external codegen
|
||||||
|
# backends and that this external codegen backend is only included in the dep info if
|
||||||
|
# -Zbinary-dep-depinfo is used.
|
||||||
|
|
||||||
all:
|
all:
|
||||||
/bin/echo || exit 0 # This test requires /bin/echo to exist
|
/bin/echo || exit 0 # This test requires /bin/echo to exist
|
||||||
$(RUSTC) the_backend.rs --crate-name the_backend --crate-type dylib \
|
$(RUSTC) the_backend.rs --crate-name the_backend --crate-type dylib \
|
||||||
-o $(TMPDIR)/the_backend.dylib
|
-o $(TMPDIR)/the_backend.dylib
|
||||||
|
|
||||||
$(RUSTC) some_crate.rs --crate-name some_crate --crate-type lib -o $(TMPDIR)/some_crate \
|
$(RUSTC) some_crate.rs --crate-name some_crate --crate-type lib -o $(TMPDIR)/some_crate \
|
||||||
-Z codegen-backend=$(TMPDIR)/the_backend.dylib -Z unstable-options
|
-Z codegen-backend=$(TMPDIR)/the_backend.dylib -Z unstable-options \
|
||||||
grep -x "This has been \"compiled\" successfully." $(TMPDIR)/some_crate
|
--emit link,dep-info
|
||||||
|
grep -x "This has been \"compiled\" successfully." $(TMPDIR)/libsome_crate.rlib
|
||||||
|
# don't declare a dependency on the codegen backend if -Zbinary-dep-depinfo isn't used.
|
||||||
|
grep -v "the_backend.dylib" $(TMPDIR)/some_crate.d
|
||||||
|
|
||||||
|
$(RUSTC) some_crate.rs --crate-name some_crate --crate-type lib -o $(TMPDIR)/some_crate \
|
||||||
|
-Z codegen-backend=$(TMPDIR)/the_backend.dylib -Z unstable-options \
|
||||||
|
--emit link,dep-info -Zbinary-dep-depinfo
|
||||||
|
grep -x "This has been \"compiled\" successfully." $(TMPDIR)/libsome_crate.rlib
|
||||||
|
# but declare a dependency on the codegen backend if -Zbinary-dep-depinfo it used.
|
||||||
|
grep "the_backend.dylib" $(TMPDIR)/some_crate.d
|
||||||
|
|
|
@ -20,13 +20,13 @@ fn let_wild_gets_unsafe_field() {
|
||||||
let u1 = U { a: I(0) };
|
let u1 = U { a: I(0) };
|
||||||
let u2 = U { a: I(1) };
|
let u2 = U { a: I(1) };
|
||||||
let p = P { a: &2, b: &3 };
|
let p = P { a: &2, b: &3 };
|
||||||
let _ = &p.b; //~ WARN reference to packed field
|
let _ = &p.b; //~ ERROR reference to packed field
|
||||||
//~^ WARN will become a hard error
|
//~^ WARN will become a hard error
|
||||||
let _ = u1.a; // #53114: should eventually signal error as well
|
let _ = u1.a; // #53114: should eventually signal error as well
|
||||||
let _ = &u2.a; //~ ERROR [E0133]
|
let _ = &u2.a; //~ ERROR [E0133]
|
||||||
|
|
||||||
// variation on above with `_` in substructure
|
// variation on above with `_` in substructure
|
||||||
let (_,) = (&p.b,); //~ WARN reference to packed field
|
let (_,) = (&p.b,); //~ ERROR reference to packed field
|
||||||
//~^ WARN will become a hard error
|
//~^ WARN will become a hard error
|
||||||
let (_,) = (u1.a,); //~ ERROR [E0133]
|
let (_,) = (u1.a,); //~ ERROR [E0133]
|
||||||
let (_,) = (&u2.a,); //~ ERROR [E0133]
|
let (_,) = (&u2.a,); //~ ERROR [E0133]
|
||||||
|
@ -36,13 +36,13 @@ fn match_unsafe_field_to_wild() {
|
||||||
let u1 = U { a: I(0) };
|
let u1 = U { a: I(0) };
|
||||||
let u2 = U { a: I(1) };
|
let u2 = U { a: I(1) };
|
||||||
let p = P { a: &2, b: &3 };
|
let p = P { a: &2, b: &3 };
|
||||||
match &p.b { _ => { } } //~ WARN reference to packed field
|
match &p.b { _ => { } } //~ ERROR reference to packed field
|
||||||
//~^ WARN will become a hard error
|
//~^ WARN will become a hard error
|
||||||
match u1.a { _ => { } } //~ ERROR [E0133]
|
match u1.a { _ => { } } //~ ERROR [E0133]
|
||||||
match &u2.a { _ => { } } //~ ERROR [E0133]
|
match &u2.a { _ => { } } //~ ERROR [E0133]
|
||||||
|
|
||||||
// variation on above with `_` in substructure
|
// variation on above with `_` in substructure
|
||||||
match (&p.b,) { (_,) => { } } //~ WARN reference to packed field
|
match (&p.b,) { (_,) => { } } //~ ERROR reference to packed field
|
||||||
//~^ WARN will become a hard error
|
//~^ WARN will become a hard error
|
||||||
match (u1.a,) { (_,) => { } } //~ ERROR [E0133]
|
match (u1.a,) { (_,) => { } } //~ ERROR [E0133]
|
||||||
match (&u2.a,) { (_,) => { } } //~ ERROR [E0133]
|
match (&u2.a,) { (_,) => { } } //~ ERROR [E0133]
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
warning: reference to packed field is unaligned
|
error: reference to packed field is unaligned
|
||||||
--> $DIR/issue-53114-safety-checks.rs:23:13
|
--> $DIR/issue-53114-safety-checks.rs:23:13
|
||||||
|
|
|
|
||||||
LL | let _ = &p.b;
|
LL | let _ = &p.b;
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
|
||||||
= note: `#[warn(unaligned_references)]` on by default
|
= note: `#[deny(unaligned_references)]` on by default
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
warning: reference to packed field is unaligned
|
error: reference to packed field is unaligned
|
||||||
--> $DIR/issue-53114-safety-checks.rs:29:17
|
--> $DIR/issue-53114-safety-checks.rs:29:17
|
||||||
|
|
|
|
||||||
LL | let (_,) = (&p.b,);
|
LL | let (_,) = (&p.b,);
|
||||||
|
@ -21,7 +21,7 @@ LL | let (_,) = (&p.b,);
|
||||||
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
warning: reference to packed field is unaligned
|
error: reference to packed field is unaligned
|
||||||
--> $DIR/issue-53114-safety-checks.rs:39:11
|
--> $DIR/issue-53114-safety-checks.rs:39:11
|
||||||
|
|
|
|
||||||
LL | match &p.b { _ => { } }
|
LL | match &p.b { _ => { } }
|
||||||
|
@ -32,7 +32,7 @@ LL | match &p.b { _ => { } }
|
||||||
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
warning: reference to packed field is unaligned
|
error: reference to packed field is unaligned
|
||||||
--> $DIR/issue-53114-safety-checks.rs:45:12
|
--> $DIR/issue-53114-safety-checks.rs:45:12
|
||||||
|
|
|
|
||||||
LL | match (&p.b,) { (_,) => { } }
|
LL | match (&p.b,) { (_,) => { } }
|
||||||
|
@ -99,6 +99,58 @@ LL | match (&u2.a,) { (_,) => { } }
|
||||||
|
|
|
|
||||||
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
|
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
|
||||||
|
|
||||||
error: aborting due to 7 previous errors; 4 warnings emitted
|
error: aborting due to 11 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0133`.
|
For more information about this error, try `rustc --explain E0133`.
|
||||||
|
Future incompatibility report: Future breakage diagnostic:
|
||||||
|
error: reference to packed field is unaligned
|
||||||
|
--> $DIR/issue-53114-safety-checks.rs:23:13
|
||||||
|
|
|
||||||
|
LL | let _ = &p.b;
|
||||||
|
| ^^^^
|
||||||
|
|
|
||||||
|
= note: `#[deny(unaligned_references)]` on by default
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
error: reference to packed field is unaligned
|
||||||
|
--> $DIR/issue-53114-safety-checks.rs:29:17
|
||||||
|
|
|
||||||
|
LL | let (_,) = (&p.b,);
|
||||||
|
| ^^^^
|
||||||
|
|
|
||||||
|
= note: `#[deny(unaligned_references)]` on by default
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
error: reference to packed field is unaligned
|
||||||
|
--> $DIR/issue-53114-safety-checks.rs:39:11
|
||||||
|
|
|
||||||
|
LL | match &p.b { _ => { } }
|
||||||
|
| ^^^^
|
||||||
|
|
|
||||||
|
= note: `#[deny(unaligned_references)]` on by default
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
error: reference to packed field is unaligned
|
||||||
|
--> $DIR/issue-53114-safety-checks.rs:45:12
|
||||||
|
|
|
||||||
|
LL | match (&p.b,) { (_,) => { } }
|
||||||
|
| ^^^^
|
||||||
|
|
|
||||||
|
= note: `#[deny(unaligned_references)]` on by default
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
// edition:2021
|
// edition:2021
|
||||||
|
|
||||||
// check-pass
|
|
||||||
|
|
||||||
// Given how the closure desugaring is implemented (at least at the time of writing this test),
|
// Given how the closure desugaring is implemented (at least at the time of writing this test),
|
||||||
// we don't need to truncate the captured path to a reference into a packed-struct if the field
|
// we don't need to truncate the captured path to a reference into a packed-struct if the field
|
||||||
// being referenced will be moved into the closure, since it's safe to move out a field from a
|
// being referenced will be moved into the closure, since it's safe to move out a field from a
|
||||||
|
@ -11,9 +9,8 @@
|
||||||
// inlined we will truncate the capture to access just the struct regardless of if the field
|
// inlined we will truncate the capture to access just the struct regardless of if the field
|
||||||
// might get moved into the closure.
|
// might get moved into the closure.
|
||||||
//
|
//
|
||||||
// It is possible for someone to try writing the code that relies on the desugaring to access a ref
|
// It is possible for someone to try writing the code that relies on the desugaring to create a ref
|
||||||
// into a packed-struct without explicity using unsafe. Here we test that the compiler warns the
|
// into a packed-struct. Here we test that the compiler still detects that case.
|
||||||
// user that such an access is still unsafe.
|
|
||||||
fn test_missing_unsafe_warning_on_repr_packed() {
|
fn test_missing_unsafe_warning_on_repr_packed() {
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
struct Foo { x: String }
|
struct Foo { x: String }
|
||||||
|
@ -22,7 +19,7 @@ fn test_missing_unsafe_warning_on_repr_packed() {
|
||||||
|
|
||||||
let c = || {
|
let c = || {
|
||||||
println!("{}", foo.x);
|
println!("{}", foo.x);
|
||||||
//~^ WARNING: reference to packed field is unaligned
|
//~^ ERROR: reference to packed field is unaligned
|
||||||
//~| WARNING: this was previously accepted by the compiler but is being phased out
|
//~| WARNING: this was previously accepted by the compiler but is being phased out
|
||||||
let _z = foo.x;
|
let _z = foo.x;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,15 +1,29 @@
|
||||||
warning: reference to packed field is unaligned
|
error: reference to packed field is unaligned
|
||||||
--> $DIR/repr_packed.rs:24:24
|
--> $DIR/repr_packed.rs:21:24
|
||||||
|
|
|
|
||||||
LL | println!("{}", foo.x);
|
LL | println!("{}", foo.x);
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
|
|
|
|
||||||
= note: `#[warn(unaligned_references)]` on by default
|
= note: `#[deny(unaligned_references)]` on by default
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
= note: this warning originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
warning: 1 warning emitted
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
Future incompatibility report: Future breakage diagnostic:
|
||||||
|
error: reference to packed field is unaligned
|
||||||
|
--> $DIR/repr_packed.rs:21:24
|
||||||
|
|
|
||||||
|
LL | println!("{}", foo.x);
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: `#[deny(unaligned_references)]` on by default
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
|
|
@ -45,3 +45,67 @@ LL | #[derive(PartialEq)]
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
Future incompatibility report: Future breakage diagnostic:
|
||||||
|
error: `#[derive]` can't be used on a `#[repr(packed)]` struct with type or const parameters (error E0133)
|
||||||
|
--> $DIR/deriving-with-repr-packed.rs:8:16
|
||||||
|
|
|
||||||
|
LL | #[derive(Copy, Clone, PartialEq, Eq)]
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/deriving-with-repr-packed.rs:1:9
|
||||||
|
|
|
||||||
|
LL | #![deny(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
error: `#[derive]` can't be used on a `#[repr(packed)]` struct with type or const parameters (error E0133)
|
||||||
|
--> $DIR/deriving-with-repr-packed.rs:8:23
|
||||||
|
|
|
||||||
|
LL | #[derive(Copy, Clone, PartialEq, Eq)]
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/deriving-with-repr-packed.rs:1:9
|
||||||
|
|
|
||||||
|
LL | #![deny(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
error: `#[derive]` can't be used on a `#[repr(packed)]` struct that does not derive Copy (error E0133)
|
||||||
|
--> $DIR/deriving-with-repr-packed.rs:16:10
|
||||||
|
|
|
||||||
|
LL | #[derive(PartialEq, Eq)]
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/deriving-with-repr-packed.rs:1:9
|
||||||
|
|
|
||||||
|
LL | #![deny(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
error: `#[derive]` can't be used on a `#[repr(packed)]` struct that does not derive Copy (error E0133)
|
||||||
|
--> $DIR/deriving-with-repr-packed.rs:25:10
|
||||||
|
|
|
||||||
|
LL | #[derive(PartialEq)]
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/deriving-with-repr-packed.rs:1:9
|
||||||
|
|
|
||||||
|
LL | #![deny(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
|
|
@ -82,3 +82,122 @@ LL | let _ = &packed2.x;
|
||||||
|
|
||||||
error: aborting due to 7 previous errors
|
error: aborting due to 7 previous errors
|
||||||
|
|
||||||
|
Future incompatibility report: Future breakage diagnostic:
|
||||||
|
error: reference to packed field is unaligned
|
||||||
|
--> $DIR/unaligned_references.rs:22:17
|
||||||
|
|
|
||||||
|
LL | let _ = &good.ptr;
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/unaligned_references.rs:1:9
|
||||||
|
|
|
||||||
|
LL | #![deny(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
error: reference to packed field is unaligned
|
||||||
|
--> $DIR/unaligned_references.rs:24:17
|
||||||
|
|
|
||||||
|
LL | let _ = &good.data;
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/unaligned_references.rs:1:9
|
||||||
|
|
|
||||||
|
LL | #![deny(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
error: reference to packed field is unaligned
|
||||||
|
--> $DIR/unaligned_references.rs:27:17
|
||||||
|
|
|
||||||
|
LL | let _ = &good.data as *const _;
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/unaligned_references.rs:1:9
|
||||||
|
|
|
||||||
|
LL | #![deny(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
error: reference to packed field is unaligned
|
||||||
|
--> $DIR/unaligned_references.rs:29:27
|
||||||
|
|
|
||||||
|
LL | let _: *const _ = &good.data;
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/unaligned_references.rs:1:9
|
||||||
|
|
|
||||||
|
LL | #![deny(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
error: reference to packed field is unaligned
|
||||||
|
--> $DIR/unaligned_references.rs:32:17
|
||||||
|
|
|
||||||
|
LL | let _ = good.data.clone();
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/unaligned_references.rs:1:9
|
||||||
|
|
|
||||||
|
LL | #![deny(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
error: reference to packed field is unaligned
|
||||||
|
--> $DIR/unaligned_references.rs:35:17
|
||||||
|
|
|
||||||
|
LL | let _ = &good.data2[0];
|
||||||
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/unaligned_references.rs:1:9
|
||||||
|
|
|
||||||
|
LL | #![deny(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
error: reference to packed field is unaligned
|
||||||
|
--> $DIR/unaligned_references.rs:45:17
|
||||||
|
|
|
||||||
|
LL | let _ = &packed2.x;
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/unaligned_references.rs:1:9
|
||||||
|
|
|
||||||
|
LL | #![deny(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
|
|
@ -29,3 +29,33 @@ LL | | }
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
Future incompatibility report: Future breakage diagnostic:
|
||||||
|
error: reference to packed field is unaligned
|
||||||
|
--> $DIR/unaligned_references_external_macro.rs:5:1
|
||||||
|
|
|
||||||
|
LL | / unaligned_references_external_crate::mac! {
|
||||||
|
LL | |
|
||||||
|
LL | | #[repr(packed)]
|
||||||
|
LL | | pub struct X {
|
||||||
|
LL | | pub field: u16
|
||||||
|
LL | | }
|
||||||
|
LL | | }
|
||||||
|
| |_^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/unaligned_references_external_macro.rs:5:1
|
||||||
|
|
|
||||||
|
LL | / unaligned_references_external_crate::mac! {
|
||||||
|
LL | |
|
||||||
|
LL | | #[repr(packed)]
|
||||||
|
LL | | pub struct X {
|
||||||
|
LL | | pub field: u16
|
||||||
|
LL | | }
|
||||||
|
LL | | }
|
||||||
|
| |_^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
= note: this error originates in the macro `unaligned_references_external_crate::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
|
10
src/test/ui/mir/issue-95978-validator-lifetime-comparison.rs
Normal file
10
src/test/ui/mir/issue-95978-validator-lifetime-comparison.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
// check-pass
|
||||||
|
// compile-flags: -Zvalidate-mir
|
||||||
|
|
||||||
|
fn foo(_a: &str) {}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let x = foo as fn(&'static str);
|
||||||
|
|
||||||
|
let _ = x == foo;
|
||||||
|
}
|
68
src/test/ui/packed/issue-27060-rpass.stderr
Normal file
68
src/test/ui/packed/issue-27060-rpass.stderr
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
Future incompatibility report: Future breakage diagnostic:
|
||||||
|
warning: reference to packed field is unaligned
|
||||||
|
--> $DIR/issue-27060-rpass.rs:15:13
|
||||||
|
|
|
||||||
|
LL | let _ = &good.data; // ok
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/issue-27060-rpass.rs:11:9
|
||||||
|
|
|
||||||
|
LL | #[allow(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
warning: reference to packed field is unaligned
|
||||||
|
--> $DIR/issue-27060-rpass.rs:16:13
|
||||||
|
|
|
||||||
|
LL | let _ = &good.data2[0]; // ok
|
||||||
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/issue-27060-rpass.rs:11:9
|
||||||
|
|
|
||||||
|
LL | #[allow(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
warning: reference to packed field is unaligned
|
||||||
|
--> $DIR/issue-27060-rpass.rs:18:13
|
||||||
|
|
|
||||||
|
LL | let _ = &good.data;
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/issue-27060-rpass.rs:11:9
|
||||||
|
|
|
||||||
|
LL | #[allow(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
warning: reference to packed field is unaligned
|
||||||
|
--> $DIR/issue-27060-rpass.rs:19:13
|
||||||
|
|
|
||||||
|
LL | let _ = &good.data2[0];
|
||||||
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/issue-27060-rpass.rs:11:9
|
||||||
|
|
|
||||||
|
LL | #[allow(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
|
@ -5,7 +5,6 @@ pub struct Good {
|
||||||
aligned: [u8; 32],
|
aligned: [u8; 32],
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deny(unaligned_references)]
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let good = Good {
|
let good = Good {
|
||||||
data: &0,
|
data: &0,
|
||||||
|
|
|
@ -1,21 +1,17 @@
|
||||||
error: reference to packed field is unaligned
|
error: reference to packed field is unaligned
|
||||||
--> $DIR/issue-27060.rs:16:13
|
--> $DIR/issue-27060.rs:15:13
|
||||||
|
|
|
|
||||||
LL | let _ = &good.data;
|
LL | let _ = &good.data;
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
= note: `#[deny(unaligned_references)]` on by default
|
||||||
--> $DIR/issue-27060.rs:8:8
|
|
||||||
|
|
|
||||||
LL | #[deny(unaligned_references)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
error: reference to packed field is unaligned
|
error: reference to packed field is unaligned
|
||||||
--> $DIR/issue-27060.rs:18:13
|
--> $DIR/issue-27060.rs:17:13
|
||||||
|
|
|
|
||||||
LL | let _ = &good.data2[0];
|
LL | let _ = &good.data2[0];
|
||||||
| ^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
|
@ -26,7 +22,7 @@ LL | let _ = &good.data2[0];
|
||||||
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
error: reference to packed field is unaligned
|
error: reference to packed field is unaligned
|
||||||
--> $DIR/issue-27060.rs:21:13
|
--> $DIR/issue-27060.rs:20:13
|
||||||
|
|
|
|
||||||
LL | let _ = &good.data;
|
LL | let _ = &good.data;
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^
|
||||||
|
@ -37,7 +33,7 @@ LL | let _ = &good.data;
|
||||||
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
error: reference to packed field is unaligned
|
error: reference to packed field is unaligned
|
||||||
--> $DIR/issue-27060.rs:23:13
|
--> $DIR/issue-27060.rs:22:13
|
||||||
|
|
|
|
||||||
LL | let _ = &good.data2[0];
|
LL | let _ = &good.data2[0];
|
||||||
| ^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
|
@ -49,3 +45,55 @@ LL | let _ = &good.data2[0];
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
Future incompatibility report: Future breakage diagnostic:
|
||||||
|
error: reference to packed field is unaligned
|
||||||
|
--> $DIR/issue-27060.rs:15:13
|
||||||
|
|
|
||||||
|
LL | let _ = &good.data;
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: `#[deny(unaligned_references)]` on by default
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
error: reference to packed field is unaligned
|
||||||
|
--> $DIR/issue-27060.rs:17:13
|
||||||
|
|
|
||||||
|
LL | let _ = &good.data2[0];
|
||||||
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: `#[deny(unaligned_references)]` on by default
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
error: reference to packed field is unaligned
|
||||||
|
--> $DIR/issue-27060.rs:20:13
|
||||||
|
|
|
||||||
|
LL | let _ = &good.data;
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: `#[deny(unaligned_references)]` on by default
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
error: reference to packed field is unaligned
|
||||||
|
--> $DIR/issue-27060.rs:22:13
|
||||||
|
|
|
||||||
|
LL | let _ = &good.data2[0];
|
||||||
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: `#[deny(unaligned_references)]` on by default
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
// run-pass
|
// run-pass
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![deny(unaligned_references)]
|
|
||||||
#![feature(raw_ref_op)]
|
#![feature(raw_ref_op)]
|
||||||
// ignore-emscripten weird assertion?
|
// ignore-emscripten weird assertion?
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ struct Foo4C {
|
||||||
baz: usize
|
baz: usize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[warn(unaligned_references)]
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let foo = Foo4C { bar: 1, baz: 2 };
|
let foo = Foo4C { bar: 1, baz: 2 };
|
||||||
let brw = &foo.baz; //~WARN reference to packed field is unaligned
|
let brw = &foo.baz; //~WARN reference to packed field is unaligned
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
warning: reference to packed field is unaligned
|
warning: reference to packed field is unaligned
|
||||||
--> $DIR/packed-struct-borrow-element-64bit.rs:14:15
|
--> $DIR/packed-struct-borrow-element-64bit.rs:15:15
|
||||||
|
|
|
|
||||||
LL | let brw = &foo.baz;
|
LL | let brw = &foo.baz;
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: `#[warn(unaligned_references)]` on by default
|
note: the lint level is defined here
|
||||||
|
--> $DIR/packed-struct-borrow-element-64bit.rs:12:8
|
||||||
|
|
|
||||||
|
LL | #[warn(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
@ -12,3 +16,20 @@ LL | let brw = &foo.baz;
|
||||||
|
|
||||||
warning: 1 warning emitted
|
warning: 1 warning emitted
|
||||||
|
|
||||||
|
Future incompatibility report: Future breakage diagnostic:
|
||||||
|
warning: reference to packed field is unaligned
|
||||||
|
--> $DIR/packed-struct-borrow-element-64bit.rs:15:15
|
||||||
|
|
|
||||||
|
LL | let brw = &foo.baz;
|
||||||
|
| ^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/packed-struct-borrow-element-64bit.rs:12:8
|
||||||
|
|
|
||||||
|
LL | #[warn(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ struct Foo4C {
|
||||||
baz: usize
|
baz: usize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[warn(unaligned_references)]
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let foo = Foo1 { bar: 1, baz: 2 };
|
let foo = Foo1 { bar: 1, baz: 2 };
|
||||||
let brw = &foo.baz; //~WARN reference to packed field is unaligned
|
let brw = &foo.baz; //~WARN reference to packed field is unaligned
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
warning: reference to packed field is unaligned
|
warning: reference to packed field is unaligned
|
||||||
--> $DIR/packed-struct-borrow-element.rs:25:15
|
--> $DIR/packed-struct-borrow-element.rs:26:15
|
||||||
|
|
|
|
||||||
LL | let brw = &foo.baz;
|
LL | let brw = &foo.baz;
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: `#[warn(unaligned_references)]` on by default
|
note: the lint level is defined here
|
||||||
|
--> $DIR/packed-struct-borrow-element.rs:23:8
|
||||||
|
|
|
||||||
|
LL | #[warn(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
warning: reference to packed field is unaligned
|
warning: reference to packed field is unaligned
|
||||||
--> $DIR/packed-struct-borrow-element.rs:30:15
|
--> $DIR/packed-struct-borrow-element.rs:31:15
|
||||||
|
|
|
|
||||||
LL | let brw = &foo.baz;
|
LL | let brw = &foo.baz;
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
@ -23,3 +27,37 @@ LL | let brw = &foo.baz;
|
||||||
|
|
||||||
warning: 2 warnings emitted
|
warning: 2 warnings emitted
|
||||||
|
|
||||||
|
Future incompatibility report: Future breakage diagnostic:
|
||||||
|
warning: reference to packed field is unaligned
|
||||||
|
--> $DIR/packed-struct-borrow-element.rs:26:15
|
||||||
|
|
|
||||||
|
LL | let brw = &foo.baz;
|
||||||
|
| ^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/packed-struct-borrow-element.rs:23:8
|
||||||
|
|
|
||||||
|
LL | #[warn(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
warning: reference to packed field is unaligned
|
||||||
|
--> $DIR/packed-struct-borrow-element.rs:31:15
|
||||||
|
|
|
||||||
|
LL | let brw = &foo.baz;
|
||||||
|
| ^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/packed-struct-borrow-element.rs:23:8
|
||||||
|
|
|
||||||
|
LL | #[warn(unaligned_references)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
|
||||||
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
|
||||||
|
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
|
||||||
|
|
||||||
|
|
4
src/test/ui/unterminated-nested-comment.rs
Normal file
4
src/test/ui/unterminated-nested-comment.rs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
/* //~ ERROR E0758
|
||||||
|
/* */
|
||||||
|
/*
|
||||||
|
*/
|
21
src/test/ui/unterminated-nested-comment.stderr
Normal file
21
src/test/ui/unterminated-nested-comment.stderr
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
error[E0758]: unterminated block comment
|
||||||
|
--> $DIR/unterminated-nested-comment.rs:1:1
|
||||||
|
|
|
||||||
|
LL | /*
|
||||||
|
| ^-
|
||||||
|
| |
|
||||||
|
| _unterminated block comment
|
||||||
|
| |
|
||||||
|
LL | | /* */
|
||||||
|
LL | | /*
|
||||||
|
| | --
|
||||||
|
| | |
|
||||||
|
| | ...as last nested comment starts here, maybe you want to close this instead?
|
||||||
|
LL | | */
|
||||||
|
| |_--^
|
||||||
|
| |
|
||||||
|
| ...and last nested comment terminates here.
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0758`.
|
Loading…
Add table
Add a link
Reference in a new issue