Skip to content

Commit fd17dea

Browse files
committed
Auto merge of rust-lang#137959 - matthiaskrgr:rollup-62vjvwr, r=matthiaskrgr
Rollup of 12 pull requests Successful merges: - rust-lang#135767 (Future incompatibility warning `unsupported_fn_ptr_calling_conventions`: Also warn in dependencies) - rust-lang#137852 (Remove layouting dead code for non-array SIMD types.) - rust-lang#137863 (Fix pretty printing of unsafe binders) - rust-lang#137882 (do not build additional stage on compiler paths) - rust-lang#137894 (Revert "store ScalarPair via memset when one side is undef and the other side can be memset") - rust-lang#137902 (Make `ast::TokenKind` more like `lexer::TokenKind`) - rust-lang#137921 (Subtree update of `rust-analyzer`) - rust-lang#137922 (A few cleanups after the removal of `cfg(not(parallel))`) - rust-lang#137939 (fix order on shl impl) - rust-lang#137946 (Fix docker run-local docs) - rust-lang#137955 (Always allow rustdoc-json tests to contain long lines) - rust-lang#137958 (triagebot.toml: Don't label `test/rustdoc-json` as A-rustdoc-search) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2010bba + 5d093cb commit fd17dea

File tree

316 files changed

+7290
-4967
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

316 files changed

+7290
-4967
lines changed

compiler/rustc_ast/src/token.rs

+170-126
Large diffs are not rendered by default.

compiler/rustc_ast/src/tokenstream.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ impl TokenStream {
651651
if attr_style == AttrStyle::Inner {
652652
vec![
653653
TokenTree::token_joint(token::Pound, span),
654-
TokenTree::token_joint_hidden(token::Not, span),
654+
TokenTree::token_joint_hidden(token::Bang, span),
655655
body,
656656
]
657657
} else {

compiler/rustc_ast/src/util/parser.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_span::kw;
22

33
use crate::ast::{self, BinOpKind, RangeLimits};
4-
use crate::token::{self, BinOpToken, Token};
4+
use crate::token::{self, Token};
55

66
/// Associative operator.
77
#[derive(Copy, Clone, PartialEq, Debug)]
@@ -34,26 +34,26 @@ impl AssocOp {
3434
use AssocOp::*;
3535
match t.kind {
3636
token::Eq => Some(Assign),
37-
token::BinOp(BinOpToken::Plus) => Some(Binary(BinOpKind::Add)),
38-
token::BinOp(BinOpToken::Minus) => Some(Binary(BinOpKind::Sub)),
39-
token::BinOp(BinOpToken::Star) => Some(Binary(BinOpKind::Mul)),
40-
token::BinOp(BinOpToken::Slash) => Some(Binary(BinOpKind::Div)),
41-
token::BinOp(BinOpToken::Percent) => Some(Binary(BinOpKind::Rem)),
42-
token::BinOp(BinOpToken::Caret) => Some(Binary(BinOpKind::BitXor)),
43-
token::BinOp(BinOpToken::And) => Some(Binary(BinOpKind::BitAnd)),
44-
token::BinOp(BinOpToken::Or) => Some(Binary(BinOpKind::BitOr)),
45-
token::BinOp(BinOpToken::Shl) => Some(Binary(BinOpKind::Shl)),
46-
token::BinOp(BinOpToken::Shr) => Some(Binary(BinOpKind::Shr)),
47-
token::BinOpEq(BinOpToken::Plus) => Some(AssignOp(BinOpKind::Add)),
48-
token::BinOpEq(BinOpToken::Minus) => Some(AssignOp(BinOpKind::Sub)),
49-
token::BinOpEq(BinOpToken::Star) => Some(AssignOp(BinOpKind::Mul)),
50-
token::BinOpEq(BinOpToken::Slash) => Some(AssignOp(BinOpKind::Div)),
51-
token::BinOpEq(BinOpToken::Percent) => Some(AssignOp(BinOpKind::Rem)),
52-
token::BinOpEq(BinOpToken::Caret) => Some(AssignOp(BinOpKind::BitXor)),
53-
token::BinOpEq(BinOpToken::And) => Some(AssignOp(BinOpKind::BitAnd)),
54-
token::BinOpEq(BinOpToken::Or) => Some(AssignOp(BinOpKind::BitOr)),
55-
token::BinOpEq(BinOpToken::Shl) => Some(AssignOp(BinOpKind::Shl)),
56-
token::BinOpEq(BinOpToken::Shr) => Some(AssignOp(BinOpKind::Shr)),
37+
token::Plus => Some(Binary(BinOpKind::Add)),
38+
token::Minus => Some(Binary(BinOpKind::Sub)),
39+
token::Star => Some(Binary(BinOpKind::Mul)),
40+
token::Slash => Some(Binary(BinOpKind::Div)),
41+
token::Percent => Some(Binary(BinOpKind::Rem)),
42+
token::Caret => Some(Binary(BinOpKind::BitXor)),
43+
token::And => Some(Binary(BinOpKind::BitAnd)),
44+
token::Or => Some(Binary(BinOpKind::BitOr)),
45+
token::Shl => Some(Binary(BinOpKind::Shl)),
46+
token::Shr => Some(Binary(BinOpKind::Shr)),
47+
token::PlusEq => Some(AssignOp(BinOpKind::Add)),
48+
token::MinusEq => Some(AssignOp(BinOpKind::Sub)),
49+
token::StarEq => Some(AssignOp(BinOpKind::Mul)),
50+
token::SlashEq => Some(AssignOp(BinOpKind::Div)),
51+
token::PercentEq => Some(AssignOp(BinOpKind::Rem)),
52+
token::CaretEq => Some(AssignOp(BinOpKind::BitXor)),
53+
token::AndEq => Some(AssignOp(BinOpKind::BitAnd)),
54+
token::OrEq => Some(AssignOp(BinOpKind::BitOr)),
55+
token::ShlEq => Some(AssignOp(BinOpKind::Shl)),
56+
token::ShrEq => Some(AssignOp(BinOpKind::Shr)),
5757
token::Lt => Some(Binary(BinOpKind::Lt)),
5858
token::Le => Some(Binary(BinOpKind::Le)),
5959
token::Ge => Some(Binary(BinOpKind::Ge)),

compiler/rustc_ast_pretty/src/pprust/state.rs

+23-22
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ use std::sync::Arc;
1111

1212
use rustc_ast::attr::AttrIdGenerator;
1313
use rustc_ast::ptr::P;
14-
use rustc_ast::token::{
15-
self, BinOpToken, CommentKind, Delimiter, IdentIsRaw, Nonterminal, Token, TokenKind,
16-
};
14+
use rustc_ast::token::{self, CommentKind, Delimiter, IdentIsRaw, Nonterminal, Token, TokenKind};
1715
use rustc_ast::tokenstream::{Spacing, TokenStream, TokenTree};
1816
use rustc_ast::util::classify;
1917
use rustc_ast::util::comments::{Comment, CommentStyle};
@@ -319,7 +317,7 @@ fn space_between(tt1: &TokenTree, tt2: &TokenTree) -> bool {
319317
(tt1, Tok(Token { kind: Comma | Semi | Dot, .. }, _)) if !is_punct(tt1) => false,
320318

321319
// IDENT + `!`: `println!()`, but `if !x { ... }` needs a space after the `if`
322-
(Tok(Token { kind: Ident(sym, is_raw), span }, _), Tok(Token { kind: Not, .. }, _))
320+
(Tok(Token { kind: Ident(sym, is_raw), span }, _), Tok(Token { kind: Bang, .. }, _))
323321
if !Ident::new(*sym, *span).is_reserved() || matches!(is_raw, IdentIsRaw::Yes) =>
324322
{
325323
false
@@ -344,21 +342,6 @@ fn space_between(tt1: &TokenTree, tt2: &TokenTree) -> bool {
344342
}
345343
}
346344

347-
fn binop_to_string(op: BinOpToken) -> &'static str {
348-
match op {
349-
token::Plus => "+",
350-
token::Minus => "-",
351-
token::Star => "*",
352-
token::Slash => "/",
353-
token::Percent => "%",
354-
token::Caret => "^",
355-
token::And => "&",
356-
token::Or => "|",
357-
token::Shl => "<<",
358-
token::Shr => ">>",
359-
}
360-
}
361-
362345
pub fn doc_comment_to_string(
363346
comment_kind: CommentKind,
364347
attr_style: ast::AttrStyle,
@@ -913,12 +896,30 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
913896
token::Ne => "!=".into(),
914897
token::Ge => ">=".into(),
915898
token::Gt => ">".into(),
916-
token::Not => "!".into(),
899+
token::Bang => "!".into(),
917900
token::Tilde => "~".into(),
918901
token::OrOr => "||".into(),
919902
token::AndAnd => "&&".into(),
920-
token::BinOp(op) => binop_to_string(op).into(),
921-
token::BinOpEq(op) => format!("{}=", binop_to_string(op)).into(),
903+
token::Plus => "+".into(),
904+
token::Minus => "-".into(),
905+
token::Star => "*".into(),
906+
token::Slash => "/".into(),
907+
token::Percent => "%".into(),
908+
token::Caret => "^".into(),
909+
token::And => "&".into(),
910+
token::Or => "|".into(),
911+
token::Shl => "<<".into(),
912+
token::Shr => ">>".into(),
913+
token::PlusEq => "+=".into(),
914+
token::MinusEq => "-=".into(),
915+
token::StarEq => "*=".into(),
916+
token::SlashEq => "/=".into(),
917+
token::PercentEq => "%=".into(),
918+
token::CaretEq => "^=".into(),
919+
token::AndEq => "&=".into(),
920+
token::OrEq => "|=".into(),
921+
token::ShlEq => "<<=".into(),
922+
token::ShrEq => ">>=".into(),
922923

923924
/* Structural symbols */
924925
token::At => "@".into(),

compiler/rustc_codegen_gcc/src/common.rs

-5
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ impl<'gcc, 'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
6464
if type_is_pointer(typ) { self.context.new_null(typ) } else { self.const_int(typ, 0) }
6565
}
6666

67-
fn is_undef(&self, _val: RValue<'gcc>) -> bool {
68-
// FIXME: actually check for undef
69-
false
70-
}
71-
7267
fn const_undef(&self, typ: Type<'gcc>) -> RValue<'gcc> {
7368
let local = self.current_func.borrow().expect("func").new_local(None, typ, "undefined");
7469
if typ.is_struct().is_some() {

compiler/rustc_codegen_llvm/src/common.rs

-4
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ impl<'ll, 'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
127127
unsafe { llvm::LLVMGetUndef(t) }
128128
}
129129

130-
fn is_undef(&self, v: &'ll Value) -> bool {
131-
unsafe { llvm::LLVMIsUndef(v) == True }
132-
}
133-
134130
fn const_poison(&self, t: &'ll Type) -> &'ll Value {
135131
unsafe { llvm::LLVMGetPoison(t) }
136132
}

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,6 @@ unsafe extern "C" {
10461046
pub(crate) fn LLVMMetadataTypeInContext(C: &Context) -> &Type;
10471047

10481048
// Operations on all values
1049-
pub(crate) fn LLVMIsUndef(Val: &Value) -> Bool;
10501049
pub(crate) fn LLVMTypeOf(Val: &Value) -> &Type;
10511050
pub(crate) fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char;
10521051
pub(crate) fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t);

compiler/rustc_codegen_ssa/src/mir/operand.rs

+22-37
Original file line numberDiff line numberDiff line change
@@ -203,30 +203,14 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
203203
let alloc_align = alloc.inner().align;
204204
assert!(alloc_align >= layout.align.abi);
205205

206-
// Returns `None` when the value is partially undefined or any byte of it has provenance.
207-
// Otherwise returns the value or (if the entire value is undef) returns an undef.
208206
let read_scalar = |start, size, s: abi::Scalar, ty| {
209-
let range = alloc_range(start, size);
210207
match alloc.0.read_scalar(
211208
bx,
212-
range,
209+
alloc_range(start, size),
213210
/*read_provenance*/ matches!(s.primitive(), abi::Primitive::Pointer(_)),
214211
) {
215-
Ok(val) => Some(bx.scalar_to_backend(val, s, ty)),
216-
Err(_) => {
217-
// We may have failed due to partial provenance or unexpected provenance,
218-
// continue down the normal code path if so.
219-
if alloc.0.provenance().range_empty(range, &bx.tcx())
220-
// Since `read_scalar` failed, but there were no relocations involved, the
221-
// bytes must be partially or fully uninitialized. Thus we can now unwrap the
222-
// information about the range of uninit bytes and check if it's the full range.
223-
&& alloc.0.init_mask().is_range_initialized(range).unwrap_err() == range
224-
{
225-
Some(bx.const_undef(ty))
226-
} else {
227-
None
228-
}
229-
}
212+
Ok(val) => bx.scalar_to_backend(val, s, ty),
213+
Err(_) => bx.const_poison(ty),
230214
}
231215
};
232216

@@ -237,14 +221,16 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
237221
// check that walks over the type of `mplace` to make sure it is truly correct to treat this
238222
// like a `Scalar` (or `ScalarPair`).
239223
match layout.backend_repr {
240-
BackendRepr::Scalar(s) => {
224+
BackendRepr::Scalar(s @ abi::Scalar::Initialized { .. }) => {
241225
let size = s.size(bx);
242226
assert_eq!(size, layout.size, "abi::Scalar size does not match layout size");
243-
if let Some(val) = read_scalar(offset, size, s, bx.immediate_backend_type(layout)) {
244-
return OperandRef { val: OperandValue::Immediate(val), layout };
245-
}
227+
let val = read_scalar(offset, size, s, bx.immediate_backend_type(layout));
228+
OperandRef { val: OperandValue::Immediate(val), layout }
246229
}
247-
BackendRepr::ScalarPair(a, b) => {
230+
BackendRepr::ScalarPair(
231+
a @ abi::Scalar::Initialized { .. },
232+
b @ abi::Scalar::Initialized { .. },
233+
) => {
248234
let (a_size, b_size) = (a.size(bx), b.size(bx));
249235
let b_offset = (offset + a_size).align_to(b.align(bx).abi);
250236
assert!(b_offset.bytes() > 0);
@@ -260,21 +246,20 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
260246
b,
261247
bx.scalar_pair_element_backend_type(layout, 1, true),
262248
);
263-
if let (Some(a_val), Some(b_val)) = (a_val, b_val) {
264-
return OperandRef { val: OperandValue::Pair(a_val, b_val), layout };
265-
}
249+
OperandRef { val: OperandValue::Pair(a_val, b_val), layout }
250+
}
251+
_ if layout.is_zst() => OperandRef::zero_sized(layout),
252+
_ => {
253+
// Neither a scalar nor scalar pair. Load from a place
254+
// FIXME: should we cache `const_data_from_alloc` to avoid repeating this for the
255+
// same `ConstAllocation`?
256+
let init = bx.const_data_from_alloc(alloc);
257+
let base_addr = bx.static_addr_of(init, alloc_align, None);
258+
259+
let llval = bx.const_ptr_byte_offset(base_addr, offset);
260+
bx.load_operand(PlaceRef::new_sized(llval, layout))
266261
}
267-
_ if layout.is_zst() => return OperandRef::zero_sized(layout),
268-
_ => {}
269262
}
270-
// Neither a scalar nor scalar pair. Load from a place
271-
// FIXME: should we cache `const_data_from_alloc` to avoid repeating this for the
272-
// same `ConstAllocation`?
273-
let init = bx.const_data_from_alloc(alloc);
274-
let base_addr = bx.static_addr_of(init, alloc_align, None);
275-
276-
let llval = bx.const_ptr_byte_offset(base_addr, offset);
277-
bx.load_operand(PlaceRef::new_sized(llval, layout))
278263
}
279264

280265
/// Asserts that this operand refers to a scalar and returns

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

+2-24
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
88
use rustc_middle::{bug, mir, span_bug};
99
use rustc_session::config::OptLevel;
1010
use rustc_span::{DUMMY_SP, Span};
11-
use tracing::{debug, instrument, trace};
11+
use tracing::{debug, instrument};
1212

1313
use super::operand::{OperandRef, OperandValue};
1414
use super::place::PlaceRef;
@@ -93,8 +93,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
9393
return;
9494
}
9595

96-
// If `v` is an integer constant whose value is just a single byte repeated N times,
97-
// emit a `memset` filling the entire `dest` with that byte.
9896
let try_init_all_same = |bx: &mut Bx, v| {
9997
let start = dest.val.llval;
10098
let size = bx.const_usize(dest.layout.size.bytes());
@@ -119,33 +117,13 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
119117
false
120118
};
121119

122-
trace!(?cg_elem.val);
123120
match cg_elem.val {
124121
OperandValue::Immediate(v) => {
125122
if try_init_all_same(bx, v) {
126123
return;
127124
}
128125
}
129-
OperandValue::Pair(a, b) => {
130-
let a_is_undef = bx.cx().is_undef(a);
131-
match (a_is_undef, bx.cx().is_undef(b)) {
132-
// Can happen for uninit unions
133-
(true, true) => {
134-
// FIXME: can we produce better output here?
135-
}
136-
(false, true) | (true, false) => {
137-
let val = if a_is_undef { b } else { a };
138-
if try_init_all_same(bx, val) {
139-
return;
140-
}
141-
}
142-
(false, false) => {
143-
// FIXME: if both are the same value, use try_init_all_same
144-
}
145-
}
146-
}
147-
OperandValue::ZeroSized => unreachable!("checked above"),
148-
OperandValue::Ref(..) => {}
126+
_ => (),
149127
}
150128

151129
let count = self

compiler/rustc_codegen_ssa/src/traits/consts.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ pub trait ConstCodegenMethods<'tcx>: BackendTypes {
99
/// Generate an uninitialized value (matching uninitialized memory in MIR).
1010
/// Whether memory is initialized or not is tracked byte-for-byte.
1111
fn const_undef(&self, t: Self::Type) -> Self::Value;
12-
fn is_undef(&self, v: Self::Value) -> bool;
1312
/// Generate a fake value. Poison always affects the entire value, even if just a single byte is
1413
/// poison. This can only be used in codepaths that are already UB, i.e., UB-free Rust code
1514
/// (including code that e.g. copies uninit memory with `MaybeUninit`) can never encounter a

compiler/rustc_data_structures/src/sharded.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ impl<T> Sharded<T> {
4343

4444
/// The shard is selected by hashing `val` with `FxHasher`.
4545
#[inline]
46-
pub fn get_shard_by_value<K: Hash + ?Sized>(&self, _val: &K) -> &Lock<T> {
46+
pub fn get_shard_by_value<K: Hash + ?Sized>(&self, val: &K) -> &Lock<T> {
4747
match self {
4848
Self::Single(single) => single,
49-
Self::Shards(..) => self.get_shard_by_hash(make_hash(_val)),
49+
Self::Shards(..) => self.get_shard_by_hash(make_hash(val)),
5050
}
5151
}
5252

@@ -56,20 +56,20 @@ impl<T> Sharded<T> {
5656
}
5757

5858
#[inline]
59-
pub fn get_shard_by_index(&self, _i: usize) -> &Lock<T> {
59+
pub fn get_shard_by_index(&self, i: usize) -> &Lock<T> {
6060
match self {
6161
Self::Single(single) => single,
6262
Self::Shards(shards) => {
6363
// SAFETY: The index gets ANDed with the shard mask, ensuring it is always inbounds.
64-
unsafe { &shards.get_unchecked(_i & (SHARDS - 1)).0 }
64+
unsafe { &shards.get_unchecked(i & (SHARDS - 1)).0 }
6565
}
6666
}
6767
}
6868

6969
/// The shard is selected by hashing `val` with `FxHasher`.
7070
#[inline]
7171
#[track_caller]
72-
pub fn lock_shard_by_value<K: Hash + ?Sized>(&self, _val: &K) -> LockGuard<'_, T> {
72+
pub fn lock_shard_by_value<K: Hash + ?Sized>(&self, val: &K) -> LockGuard<'_, T> {
7373
match self {
7474
Self::Single(single) => {
7575
// Synchronization is disabled so use the `lock_assume_no_sync` method optimized
@@ -79,7 +79,7 @@ impl<T> Sharded<T> {
7979
// `might_be_dyn_thread_safe` was also false.
8080
unsafe { single.lock_assume(Mode::NoSync) }
8181
}
82-
Self::Shards(..) => self.lock_shard_by_hash(make_hash(_val)),
82+
Self::Shards(..) => self.lock_shard_by_hash(make_hash(val)),
8383
}
8484
}
8585

@@ -91,7 +91,7 @@ impl<T> Sharded<T> {
9191

9292
#[inline]
9393
#[track_caller]
94-
pub fn lock_shard_by_index(&self, _i: usize) -> LockGuard<'_, T> {
94+
pub fn lock_shard_by_index(&self, i: usize) -> LockGuard<'_, T> {
9595
match self {
9696
Self::Single(single) => {
9797
// Synchronization is disabled so use the `lock_assume_no_sync` method optimized
@@ -109,7 +109,7 @@ impl<T> Sharded<T> {
109109
// always inbounds.
110110
// SAFETY (lock_assume_sync): We know `is_dyn_thread_safe` was true when creating
111111
// the lock thus `might_be_dyn_thread_safe` was also true.
112-
unsafe { shards.get_unchecked(_i & (SHARDS - 1)).0.lock_assume(Mode::Sync) }
112+
unsafe { shards.get_unchecked(i & (SHARDS - 1)).0.lock_assume(Mode::Sync) }
113113
}
114114
}
115115
}

0 commit comments

Comments
 (0)