Skip to content

Commit 15c05fe

Browse files
committed
Auto merge of #3012 - rust-lang:rustup-2023-08-04, r=oli-obk
Automatic sync from rustc
2 parents f8d75a4 + 1a803a0 commit 15c05fe

File tree

226 files changed

+3275
-1694
lines changed

Some content is hidden

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

226 files changed

+3275
-1694
lines changed

.mailmap

+1
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ Ryan Sullivant <[email protected]>
494494
Ryan Wiedemann <[email protected]>
495495
S Pradeep Kumar <[email protected]>
496496
Sam Radhakrishnan <[email protected]>
497+
Samuel Tardieu <[email protected]>
497498
Scott McMurray <[email protected]>
498499
Scott Olson <[email protected]> Scott Olson <[email protected]>
499500
Sean Gillespie <[email protected]> swgillespie <[email protected]>

compiler/rustc_abi/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![cfg_attr(feature = "nightly", feature(step_trait, rustc_attrs, min_specialization))]
2+
#![cfg_attr(all(not(bootstrap), feature = "nightly"), allow(internal_features))]
23

34
use std::fmt;
45
#[cfg(feature = "nightly")]

compiler/rustc_arena/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#![deny(unsafe_op_in_unsafe_fn)]
2424
#![deny(rustc::untranslatable_diagnostic)]
2525
#![deny(rustc::diagnostic_outside_of_impl)]
26+
#![cfg_attr(not(bootstrap), allow(internal_features))]
2627
#![allow(clippy::mut_from_ref)] // Arena allocators are one of the places where this pattern is fine.
2728

2829
use smallvec::SmallVec;

compiler/rustc_ast/src/ast.rs

+3-29
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//! - [`Generics`], [`GenericParam`], [`WhereClause`]: Metadata associated with generic parameters.
1515
//! - [`EnumDef`] and [`Variant`]: Enum declaration.
1616
//! - [`MetaItemLit`] and [`LitKind`]: Literal expressions.
17-
//! - [`MacroDef`], [`MacStmtStyle`], [`MacCall`], [`MacDelimiter`]: Macro definition and invocation.
17+
//! - [`MacroDef`], [`MacStmtStyle`], [`MacCall`]: Macro definition and invocation.
1818
//! - [`Attribute`]: Metadata associated with item.
1919
//! - [`UnOp`], [`BinOp`], and [`BinOpKind`]: Unary and binary operators.
2020
@@ -1693,15 +1693,15 @@ where
16931693
#[derive(Clone, Encodable, Decodable, Debug)]
16941694
pub struct DelimArgs {
16951695
pub dspan: DelimSpan,
1696-
pub delim: MacDelimiter,
1696+
pub delim: Delimiter, // Note: `Delimiter::Invisible` never occurs
16971697
pub tokens: TokenStream,
16981698
}
16991699

17001700
impl DelimArgs {
17011701
/// Whether a macro with these arguments needs a semicolon
17021702
/// when used as a standalone item or statement.
17031703
pub fn need_semicolon(&self) -> bool {
1704-
!matches!(self, DelimArgs { delim: MacDelimiter::Brace, .. })
1704+
!matches!(self, DelimArgs { delim: Delimiter::Brace, .. })
17051705
}
17061706
}
17071707

@@ -1717,32 +1717,6 @@ where
17171717
}
17181718
}
17191719

1720-
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable_Generic)]
1721-
pub enum MacDelimiter {
1722-
Parenthesis,
1723-
Bracket,
1724-
Brace,
1725-
}
1726-
1727-
impl MacDelimiter {
1728-
pub fn to_token(self) -> Delimiter {
1729-
match self {
1730-
MacDelimiter::Parenthesis => Delimiter::Parenthesis,
1731-
MacDelimiter::Bracket => Delimiter::Bracket,
1732-
MacDelimiter::Brace => Delimiter::Brace,
1733-
}
1734-
}
1735-
1736-
pub fn from_token(delim: Delimiter) -> Option<MacDelimiter> {
1737-
match delim {
1738-
Delimiter::Parenthesis => Some(MacDelimiter::Parenthesis),
1739-
Delimiter::Bracket => Some(MacDelimiter::Bracket),
1740-
Delimiter::Brace => Some(MacDelimiter::Brace),
1741-
Delimiter::Invisible => None,
1742-
}
1743-
}
1744-
}
1745-
17461720
/// Represents a macro definition.
17471721
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
17481722
pub struct MacroDef {

compiler/rustc_ast/src/attr/mod.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::ast::{AttrArgs, AttrArgsEq, AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute};
44
use crate::ast::{DelimArgs, Expr, ExprKind, LitKind, MetaItemLit};
5-
use crate::ast::{MacDelimiter, MetaItem, MetaItemKind, NestedMetaItem, NormalAttr};
5+
use crate::ast::{MetaItem, MetaItemKind, NestedMetaItem, NormalAttr};
66
use crate::ast::{Path, PathSegment, DUMMY_NODE_ID};
77
use crate::ptr::P;
88
use crate::token::{self, CommentKind, Delimiter, Token};
@@ -196,7 +196,7 @@ impl AttrItem {
196196

197197
fn meta_item_list(&self) -> Option<ThinVec<NestedMetaItem>> {
198198
match &self.args {
199-
AttrArgs::Delimited(args) if args.delim == MacDelimiter::Parenthesis => {
199+
AttrArgs::Delimited(args) if args.delim == Delimiter::Parenthesis => {
200200
MetaItemKind::list_from_tokens(args.tokens.clone())
201201
}
202202
AttrArgs::Delimited(_) | AttrArgs::Eq(..) | AttrArgs::Empty => None,
@@ -402,11 +402,9 @@ impl MetaItemKind {
402402
fn from_attr_args(args: &AttrArgs) -> Option<MetaItemKind> {
403403
match args {
404404
AttrArgs::Empty => Some(MetaItemKind::Word),
405-
AttrArgs::Delimited(DelimArgs {
406-
dspan: _,
407-
delim: MacDelimiter::Parenthesis,
408-
tokens,
409-
}) => MetaItemKind::list_from_tokens(tokens.clone()).map(MetaItemKind::List),
405+
AttrArgs::Delimited(DelimArgs { dspan: _, delim: Delimiter::Parenthesis, tokens }) => {
406+
MetaItemKind::list_from_tokens(tokens.clone()).map(MetaItemKind::List)
407+
}
410408
AttrArgs::Delimited(..) => None,
411409
AttrArgs::Eq(_, AttrArgsEq::Ast(expr)) => match expr.kind {
412410
ExprKind::Lit(token_lit) => {
@@ -578,7 +576,7 @@ pub fn mk_attr_nested_word(
578576
let path = Path::from_ident(outer_ident);
579577
let attr_args = AttrArgs::Delimited(DelimArgs {
580578
dspan: DelimSpan::from_single(span),
581-
delim: MacDelimiter::Parenthesis,
579+
delim: Delimiter::Parenthesis,
582580
tokens: inner_tokens,
583581
});
584582
mk_attr(g, style, path, attr_args, span)

compiler/rustc_ast/src/token.rs

-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ pub enum BinOpToken {
4141
/// Describes how a sequence of token trees is delimited.
4242
/// Cannot use `proc_macro::Delimiter` directly because this
4343
/// structure should implement some additional traits.
44-
/// The `None` variant is also renamed to `Invisible` to be
45-
/// less confusing and better convey the semantics.
4644
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
4745
#[derive(Encodable, Decodable, Hash, HashStable_Generic)]
4846
pub enum Delimiter {

compiler/rustc_ast_pretty/src/pprust/state.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
476476
Some(MacHeader::Path(&item.path)),
477477
false,
478478
None,
479-
delim.to_token(),
479+
*delim,
480480
tokens,
481481
true,
482482
span,
@@ -640,7 +640,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
640640
Some(MacHeader::Keyword(kw)),
641641
has_bang,
642642
Some(*ident),
643-
macro_def.body.delim.to_token(),
643+
macro_def.body.delim,
644644
&macro_def.body.tokens.clone(),
645645
true,
646646
sp,
@@ -1240,7 +1240,7 @@ impl<'a> State<'a> {
12401240
Some(MacHeader::Path(&m.path)),
12411241
true,
12421242
None,
1243-
m.args.delim.to_token(),
1243+
m.args.delim,
12441244
&m.args.tokens.clone(),
12451245
true,
12461246
m.span(),

compiler/rustc_borrowck/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#![feature(trusted_step)]
1212
#![feature(try_blocks)]
1313
#![recursion_limit = "256"]
14+
#![cfg_attr(not(bootstrap), allow(internal_features))]
1415

1516
#[macro_use]
1617
extern crate rustc_middle;

compiler/rustc_builtin_macros/src/assert.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ use crate::edition_panic::use_panic_2021;
44
use crate::errors;
55
use rustc_ast::ptr::P;
66
use rustc_ast::token;
7+
use rustc_ast::token::Delimiter;
78
use rustc_ast::tokenstream::{DelimSpan, TokenStream};
8-
use rustc_ast::{DelimArgs, Expr, ExprKind, MacCall, MacDelimiter, Path, PathSegment, UnOp};
9+
use rustc_ast::{DelimArgs, Expr, ExprKind, MacCall, Path, PathSegment, UnOp};
910
use rustc_ast_pretty::pprust;
1011
use rustc_errors::PResult;
1112
use rustc_expand::base::{DummyResult, ExtCtxt, MacEager, MacResult};
@@ -58,7 +59,7 @@ pub fn expand_assert<'cx>(
5859
path: panic_path(),
5960
args: P(DelimArgs {
6061
dspan: DelimSpan::from_single(call_site_span),
61-
delim: MacDelimiter::Parenthesis,
62+
delim: Delimiter::Parenthesis,
6263
tokens,
6364
}),
6465
})),

compiler/rustc_builtin_macros/src/assert/context.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use rustc_ast::{
22
ptr::P,
33
token,
4+
token::Delimiter,
45
tokenstream::{DelimSpan, TokenStream, TokenTree},
5-
BinOpKind, BorrowKind, DelimArgs, Expr, ExprKind, ItemKind, MacCall, MacDelimiter, MethodCall,
6-
Mutability, Path, PathSegment, Stmt, StructRest, UnOp, UseTree, UseTreeKind, DUMMY_NODE_ID,
6+
BinOpKind, BorrowKind, DelimArgs, Expr, ExprKind, ItemKind, MacCall, MethodCall, Mutability,
7+
Path, PathSegment, Stmt, StructRest, UnOp, UseTree, UseTreeKind, DUMMY_NODE_ID,
78
};
89
use rustc_ast_pretty::pprust;
910
use rustc_data_structures::fx::FxHashSet;
@@ -179,7 +180,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
179180
path: panic_path,
180181
args: P(DelimArgs {
181182
dspan: DelimSpan::from_single(self.span),
182-
delim: MacDelimiter::Parenthesis,
183+
delim: Delimiter::Parenthesis,
183184
tokens: initial.into_iter().chain(captures).collect::<TokenStream>(),
184185
}),
185186
})),

compiler/rustc_builtin_macros/src/edition_panic.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use rustc_ast::ptr::P;
2+
use rustc_ast::token::Delimiter;
23
use rustc_ast::tokenstream::{DelimSpan, TokenStream};
34
use rustc_ast::*;
45
use rustc_expand::base::*;
@@ -60,7 +61,7 @@ fn expand<'cx>(
6061
},
6162
args: P(DelimArgs {
6263
dspan: DelimSpan::from_single(sp),
63-
delim: MacDelimiter::Parenthesis,
64+
delim: Delimiter::Parenthesis,
6465
tokens: tts,
6566
}),
6667
})),

compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs

+22-32
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
117117
});
118118
}
119119

120-
// simd_shuffle32<T, U>(x: T, y: T, idx: [u32; 32]) -> U
121-
_ if intrinsic.as_str().starts_with("simd_shuffle") => {
120+
// simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U
121+
sym::simd_shuffle => {
122122
let (x, y, idx) = match args {
123123
[x, y, idx] => (x, y, idx),
124124
_ => {
@@ -133,36 +133,26 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
133133
return;
134134
}
135135

136-
// If this intrinsic is the older "simd_shuffleN" form, simply parse the integer.
137-
// If there is no suffix, use the index array length.
138-
let n: u16 = if intrinsic == sym::simd_shuffle {
139-
// Make sure this is actually an array, since typeck only checks the length-suffixed
140-
// version of this intrinsic.
141-
let idx_ty = fx.monomorphize(idx.ty(fx.mir, fx.tcx));
142-
match idx_ty.kind() {
143-
ty::Array(ty, len) if matches!(ty.kind(), ty::Uint(ty::UintTy::U32)) => len
144-
.try_eval_target_usize(fx.tcx, ty::ParamEnv::reveal_all())
145-
.unwrap_or_else(|| {
146-
span_bug!(span, "could not evaluate shuffle index array length")
147-
})
148-
.try_into()
149-
.unwrap(),
150-
_ => {
151-
fx.tcx.sess.span_err(
152-
span,
153-
format!(
154-
"simd_shuffle index must be an array of `u32`, got `{}`",
155-
idx_ty,
156-
),
157-
);
158-
// Prevent verifier error
159-
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
160-
return;
161-
}
136+
// Make sure this is actually an array, since typeck only checks the length-suffixed
137+
// version of this intrinsic.
138+
let idx_ty = fx.monomorphize(idx.ty(fx.mir, fx.tcx));
139+
let n: u16 = match idx_ty.kind() {
140+
ty::Array(ty, len) if matches!(ty.kind(), ty::Uint(ty::UintTy::U32)) => len
141+
.try_eval_target_usize(fx.tcx, ty::ParamEnv::reveal_all())
142+
.unwrap_or_else(|| {
143+
span_bug!(span, "could not evaluate shuffle index array length")
144+
})
145+
.try_into()
146+
.unwrap(),
147+
_ => {
148+
fx.tcx.sess.span_err(
149+
span,
150+
format!("simd_shuffle index must be an array of `u32`, got `{}`", idx_ty),
151+
);
152+
// Prevent verifier error
153+
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
154+
return;
162155
}
163-
} else {
164-
// FIXME remove this case
165-
intrinsic.as_str()["simd_shuffle".len()..].parse().unwrap()
166156
};
167157

168158
assert_eq!(x.layout(), y.layout());
@@ -179,7 +169,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
179169
let indexes = {
180170
use rustc_middle::mir::interpret::*;
181171
let idx_const = crate::constant::mir_operand_get_const_val(fx, idx)
182-
.expect("simd_shuffle* idx not const");
172+
.expect("simd_shuffle idx not const");
183173

184174
let idx_bytes = match idx_const {
185175
ConstValue::ByRef { alloc, offset } => {

0 commit comments

Comments
 (0)