Skip to content

Commit d368c40

Browse files
committed
Auto merge of #3197 - RalfJung:rustup, r=RalfJung
Rustup also move some fail tests into suitable subdirectories
2 parents 33e8232 + cd12440 commit d368c40

File tree

434 files changed

+5731
-2628
lines changed

Some content is hidden

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

434 files changed

+5731
-2628
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
- name: mingw-check-tidy
5757
os: ubuntu-20.04-4core-16gb
5858
env: {}
59-
- name: x86_64-gnu-llvm-15
59+
- name: x86_64-gnu-llvm-16
6060
env:
6161
ENABLE_GCC_CODEGEN: "1"
6262
os: ubuntu-20.04-16core-64gb
@@ -302,10 +302,6 @@ jobs:
302302
env:
303303
RUST_BACKTRACE: 1
304304
os: ubuntu-20.04-8core-32gb
305-
- name: x86_64-gnu-llvm-15
306-
env:
307-
RUST_BACKTRACE: 1
308-
os: ubuntu-20.04-8core-32gb
309305
- name: x86_64-gnu-nopt
310306
os: ubuntu-20.04-4core-16gb
311307
env: {}

.mailmap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,8 @@ Val Markovic <val@markovic.io>
575575
Valerii Lashmanov <vflashm@gmail.com>
576576
Vitali Haravy <HumaneProgrammer@gmail.com> Vitali Haravy <humaneprogrammer@gmail.com>
577577
Vitaly Shukela <vi0oss@gmail.com>
578-
Waffle Maybe <waffle.lapkin@gmail.com>
578+
Waffle Lapkin <waffle.lapkin@gmail.com>
579+
Waffle Lapkin <waffle.lapkin@tasking.com>
579580
Wesley Wiser <wwiser@gmail.com> <wesleywiser@microsoft.com>
580581
whitequark <whitequark@whitequark.org>
581582
William Ting <io@williamting.com> <william.h.ting@gmail.com>

compiler/rustc_ast/src/ast.rs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,7 @@ impl Pat {
645645
// These patterns do not contain subpatterns, skip.
646646
PatKind::Wild
647647
| PatKind::Rest
648+
| PatKind::Never
648649
| PatKind::Lit(_)
649650
| PatKind::Range(..)
650651
| PatKind::Ident(..)
@@ -795,6 +796,9 @@ pub enum PatKind {
795796
/// only one rest pattern may occur in the pattern sequences.
796797
Rest,
797798

799+
// A never pattern `!`
800+
Never,
801+
798802
/// Parentheses in patterns used for grouping (i.e., `(PAT)`).
799803
Paren(P<Pat>),
800804

@@ -817,7 +821,7 @@ pub enum BorrowKind {
817821
Raw,
818822
}
819823

820-
#[derive(Clone, PartialEq, Encodable, Decodable, Debug, Copy)]
824+
#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable_Generic)]
821825
pub enum BinOpKind {
822826
/// The `+` operator (addition)
823827
Add,
@@ -858,9 +862,9 @@ pub enum BinOpKind {
858862
}
859863

860864
impl BinOpKind {
861-
pub fn to_string(&self) -> &'static str {
865+
pub fn as_str(&self) -> &'static str {
862866
use BinOpKind::*;
863-
match *self {
867+
match self {
864868
Add => "+",
865869
Sub => "-",
866870
Mul => "*",
@@ -881,27 +885,33 @@ impl BinOpKind {
881885
Gt => ">",
882886
}
883887
}
884-
pub fn lazy(&self) -> bool {
888+
889+
pub fn is_lazy(&self) -> bool {
885890
matches!(self, BinOpKind::And | BinOpKind::Or)
886891
}
887892

888893
pub fn is_comparison(&self) -> bool {
889894
use BinOpKind::*;
890-
// Note for developers: please keep this as is;
895+
// Note for developers: please keep this match exhaustive;
891896
// we want compilation to fail if another variant is added.
892897
match *self {
893898
Eq | Lt | Le | Ne | Gt | Ge => true,
894899
And | Or | Add | Sub | Mul | Div | Rem | BitXor | BitAnd | BitOr | Shl | Shr => false,
895900
}
896901
}
902+
903+
/// Returns `true` if the binary operator takes its arguments by value.
904+
pub fn is_by_value(self) -> bool {
905+
!self.is_comparison()
906+
}
897907
}
898908

899909
pub type BinOp = Spanned<BinOpKind>;
900910

901911
/// Unary operator.
902912
///
903913
/// Note that `&data` is not an operator, it's an `AddrOf` expression.
904-
#[derive(Clone, Encodable, Decodable, Debug, Copy)]
914+
#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable_Generic)]
905915
pub enum UnOp {
906916
/// The `*` operator for dereferencing
907917
Deref,
@@ -912,13 +922,18 @@ pub enum UnOp {
912922
}
913923

914924
impl UnOp {
915-
pub fn to_string(op: UnOp) -> &'static str {
916-
match op {
925+
pub fn as_str(&self) -> &'static str {
926+
match self {
917927
UnOp::Deref => "*",
918928
UnOp::Not => "!",
919929
UnOp::Neg => "-",
920930
}
921931
}
932+
933+
/// Returns `true` if the unary operator takes its argument by value.
934+
pub fn is_by_value(self) -> bool {
935+
matches!(self, Self::Neg | Self::Not)
936+
}
922937
}
923938

924939
/// A statement

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ pub fn noop_visit_pat<T: MutVisitor>(pat: &mut P<Pat>, vis: &mut T) {
12491249
let Pat { id, kind, span, tokens } = pat.deref_mut();
12501250
vis.visit_id(id);
12511251
match kind {
1252-
PatKind::Wild | PatKind::Rest => {}
1252+
PatKind::Wild | PatKind::Rest | PatKind::Never => {}
12531253
PatKind::Ident(_binding_mode, ident, sub) => {
12541254
vis.visit_ident(ident);
12551255
visit_opt(sub, |sub| vis.visit_pat(sub));

compiler/rustc_ast/src/token.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,11 @@ impl Token {
756756
)
757757
}
758758

759+
/// Returns `true` if the token is the integer literal.
760+
pub fn is_integer_lit(&self) -> bool {
761+
matches!(self.kind, Literal(Lit { kind: LitKind::Integer, .. }))
762+
}
763+
759764
/// Returns `true` if the token is a non-raw identifier for which `pred` holds.
760765
pub fn is_non_raw_ident_where(&self, pred: impl FnOnce(Ident) -> bool) -> bool {
761766
match self.ident() {

compiler/rustc_ast/src/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) {
559559
walk_list!(visitor, visit_expr, lower_bound);
560560
walk_list!(visitor, visit_expr, upper_bound);
561561
}
562-
PatKind::Wild | PatKind::Rest => {}
562+
PatKind::Wild | PatKind::Rest | PatKind::Never => {}
563563
PatKind::Tuple(elems) | PatKind::Slice(elems) | PatKind::Or(elems) => {
564564
walk_list!(visitor, visit_pat, elems);
565565
}

compiler/rustc_ast_lowering/src/asm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
228228
parent_def_id.def_id,
229229
node_id,
230230
DefPathData::AnonConst,
231+
DefKind::AnonConst,
231232
*op_sp,
232233
);
233234
let anon_const = AnonConst { id: node_id, value: P(expr) };

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 33 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_ast::ptr::P as AstP;
1212
use rustc_ast::*;
1313
use rustc_data_structures::stack::ensure_sufficient_stack;
1414
use rustc_hir as hir;
15-
use rustc_hir::def::Res;
15+
use rustc_hir::def::{DefKind, Res};
1616
use rustc_hir::definitions::DefPathData;
1717
use rustc_session::errors::report_lit_error;
1818
use rustc_span::source_map::{respan, Spanned};
@@ -72,7 +72,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
7272
let kind = match &e.kind {
7373
ExprKind::Array(exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)),
7474
ExprKind::ConstBlock(c) => {
75-
let c = self.with_new_scopes(|this| hir::ConstBlock {
75+
let c = self.with_new_scopes(c.value.span, |this| hir::ConstBlock {
7676
def_id: this.local_def_id(c.id),
7777
hir_id: this.lower_node_id(c.id),
7878
body: this.lower_const_body(c.value.span, Some(&c.value)),
@@ -189,7 +189,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
189189
None,
190190
e.span,
191191
hir::CoroutineSource::Block,
192-
|this| this.with_new_scopes(|this| this.lower_block_expr(block)),
192+
|this| this.with_new_scopes(e.span, |this| this.lower_block_expr(block)),
193193
),
194194
ExprKind::Await(expr, await_kw_span) => self.lower_expr_await(*await_kw_span, expr),
195195
ExprKind::Closure(box Closure {
@@ -323,7 +323,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
323323
None,
324324
e.span,
325325
hir::CoroutineSource::Block,
326-
|this| this.with_new_scopes(|this| this.lower_block_expr(block)),
326+
|this| this.with_new_scopes(e.span, |this| this.lower_block_expr(block)),
327327
),
328328
ExprKind::Yield(opt_expr) => self.lower_expr_yield(e.span, opt_expr.as_deref()),
329329
ExprKind::Err => hir::ExprKind::Err(
@@ -350,30 +350,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
350350
}
351351
}
352352

353-
fn lower_binop(&mut self, b: BinOp) -> hir::BinOp {
354-
Spanned {
355-
node: match b.node {
356-
BinOpKind::Add => hir::BinOpKind::Add,
357-
BinOpKind::Sub => hir::BinOpKind::Sub,
358-
BinOpKind::Mul => hir::BinOpKind::Mul,
359-
BinOpKind::Div => hir::BinOpKind::Div,
360-
BinOpKind::Rem => hir::BinOpKind::Rem,
361-
BinOpKind::And => hir::BinOpKind::And,
362-
BinOpKind::Or => hir::BinOpKind::Or,
363-
BinOpKind::BitXor => hir::BinOpKind::BitXor,
364-
BinOpKind::BitAnd => hir::BinOpKind::BitAnd,
365-
BinOpKind::BitOr => hir::BinOpKind::BitOr,
366-
BinOpKind::Shl => hir::BinOpKind::Shl,
367-
BinOpKind::Shr => hir::BinOpKind::Shr,
368-
BinOpKind::Eq => hir::BinOpKind::Eq,
369-
BinOpKind::Lt => hir::BinOpKind::Lt,
370-
BinOpKind::Le => hir::BinOpKind::Le,
371-
BinOpKind::Ne => hir::BinOpKind::Ne,
372-
BinOpKind::Ge => hir::BinOpKind::Ge,
373-
BinOpKind::Gt => hir::BinOpKind::Gt,
374-
},
375-
span: self.lower_span(b.span),
376-
}
353+
fn lower_binop(&mut self, b: BinOp) -> BinOp {
354+
Spanned { node: b.node, span: self.lower_span(b.span) }
377355
}
378356

379357
fn lower_legacy_const_generics(
@@ -395,7 +373,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
395373
let node_id = self.next_node_id();
396374

397375
// Add a definition for the in-band const def.
398-
self.create_def(parent_def_id.def_id, node_id, DefPathData::AnonConst, f.span);
376+
self.create_def(
377+
parent_def_id.def_id,
378+
node_id,
379+
DefPathData::AnonConst,
380+
DefKind::AnonConst,
381+
f.span,
382+
);
399383

400384
let anon_const = AnonConst { id: node_id, value: arg };
401385
generic_args.push(AngleBracketedArg::Arg(GenericArg::Const(anon_const)));
@@ -524,15 +508,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
524508
this.mark_span_with_reason(
525509
DesugaringKind::TryBlock,
526510
expr.span,
527-
this.allow_try_trait.clone(),
511+
Some(this.allow_try_trait.clone()),
528512
),
529513
expr,
530514
)
531515
} else {
532516
let try_span = this.mark_span_with_reason(
533517
DesugaringKind::TryBlock,
534518
this.tcx.sess.source_map().end_point(body.span),
535-
this.allow_try_trait.clone(),
519+
Some(this.allow_try_trait.clone()),
536520
);
537521

538522
(try_span, this.expr_unit(try_span))
@@ -612,8 +596,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
612596
let output = ret_ty.unwrap_or_else(|| hir::FnRetTy::DefaultReturn(self.lower_span(span)));
613597

614598
// Resume argument type: `ResumeTy`
615-
let unstable_span =
616-
self.mark_span_with_reason(DesugaringKind::Async, span, self.allow_gen_future.clone());
599+
let unstable_span = self.mark_span_with_reason(
600+
DesugaringKind::Async,
601+
span,
602+
Some(self.allow_gen_future.clone()),
603+
);
617604
let resume_ty = hir::QPath::LangItem(hir::LangItem::ResumeTy, unstable_span);
618605
let input_ty = hir::Ty {
619606
hir_id: self.next_id(),
@@ -735,7 +722,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
735722
let unstable_span = self.mark_span_with_reason(
736723
DesugaringKind::Async,
737724
span,
738-
self.allow_gen_future.clone(),
725+
Some(self.allow_gen_future.clone()),
739726
);
740727
self.lower_attrs(
741728
inner_hir_id,
@@ -772,17 +759,17 @@ impl<'hir> LoweringContext<'_, 'hir> {
772759
match self.coroutine_kind {
773760
Some(hir::CoroutineKind::Async(_)) => {}
774761
Some(hir::CoroutineKind::Coroutine) | Some(hir::CoroutineKind::Gen(_)) | None => {
775-
self.tcx.sess.emit_err(AwaitOnlyInAsyncFnAndBlocks {
762+
return hir::ExprKind::Err(self.tcx.sess.emit_err(AwaitOnlyInAsyncFnAndBlocks {
776763
await_kw_span,
777764
item_span: self.current_item,
778-
});
765+
}));
779766
}
780767
}
781768
let span = self.mark_span_with_reason(DesugaringKind::Await, await_kw_span, None);
782769
let gen_future_span = self.mark_span_with_reason(
783770
DesugaringKind::Await,
784771
full_span,
785-
self.allow_gen_future.clone(),
772+
Some(self.allow_gen_future.clone()),
786773
);
787774
let expr = self.lower_expr_mut(expr);
788775
let expr_hir_id = expr.hir_id;
@@ -935,9 +922,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
935922
) -> hir::ExprKind<'hir> {
936923
let (binder_clause, generic_params) = self.lower_closure_binder(binder);
937924

938-
let (body_id, coroutine_option) = self.with_new_scopes(move |this| {
939-
let prev = this.current_item;
940-
this.current_item = Some(fn_decl_span);
925+
let (body_id, coroutine_option) = self.with_new_scopes(fn_decl_span, move |this| {
941926
let mut coroutine_kind = None;
942927
let body_id = this.lower_fn_body(decl, |this| {
943928
let e = this.lower_expr_mut(body);
@@ -946,7 +931,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
946931
});
947932
let coroutine_option =
948933
this.coroutine_movability_for_fn(decl, fn_decl_span, coroutine_kind, movability);
949-
this.current_item = prev;
950934
(body_id, coroutine_option)
951935
});
952936

@@ -1032,7 +1016,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10321016
let outer_decl =
10331017
FnDecl { inputs: decl.inputs.clone(), output: FnRetTy::Default(fn_decl_span) };
10341018

1035-
let body = self.with_new_scopes(|this| {
1019+
let body = self.with_new_scopes(fn_decl_span, |this| {
10361020
// FIXME(cramertj): allow `async` non-`move` closures with arguments.
10371021
if capture_clause == CaptureBy::Ref && !decl.inputs.is_empty() {
10381022
this.tcx.sess.emit_err(AsyncNonMoveClosureNotSupported { fn_decl_span });
@@ -1054,7 +1038,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10541038
async_ret_ty,
10551039
body.span,
10561040
hir::CoroutineSource::Closure,
1057-
|this| this.with_new_scopes(|this| this.lower_expr_mut(body)),
1041+
|this| this.with_new_scopes(fn_decl_span, |this| this.lower_expr_mut(body)),
10581042
);
10591043
let hir_id = this.lower_node_id(inner_closure_id);
10601044
this.maybe_forward_track_caller(body.span, closure_hir_id, hir_id);
@@ -1494,7 +1478,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
14941478
match self.coroutine_kind {
14951479
Some(hir::CoroutineKind::Gen(_)) => {}
14961480
Some(hir::CoroutineKind::Async(_)) => {
1497-
self.tcx.sess.emit_err(AsyncCoroutinesNotSupported { span });
1481+
return hir::ExprKind::Err(
1482+
self.tcx.sess.emit_err(AsyncCoroutinesNotSupported { span }),
1483+
);
14981484
}
14991485
Some(hir::CoroutineKind::Coroutine) | None => {
15001486
if !self.tcx.features().coroutines {
@@ -1640,13 +1626,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
16401626
let unstable_span = self.mark_span_with_reason(
16411627
DesugaringKind::QuestionMark,
16421628
span,
1643-
self.allow_try_trait.clone(),
1629+
Some(self.allow_try_trait.clone()),
16441630
);
16451631
let try_span = self.tcx.sess.source_map().end_point(span);
16461632
let try_span = self.mark_span_with_reason(
16471633
DesugaringKind::QuestionMark,
16481634
try_span,
1649-
self.allow_try_trait.clone(),
1635+
Some(self.allow_try_trait.clone()),
16501636
);
16511637

16521638
// `Try::branch(<expr>)`
@@ -1739,7 +1725,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
17391725
let unstable_span = self.mark_span_with_reason(
17401726
DesugaringKind::YeetExpr,
17411727
span,
1742-
self.allow_try_trait.clone(),
1728+
Some(self.allow_try_trait.clone()),
17431729
);
17441730

17451731
let from_yeet_expr = self.wrap_in_try_constructor(

compiler/rustc_ast_lowering/src/index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_middle::ty::TyCtxt;
1010
use rustc_span::{Span, DUMMY_SP};
1111

1212
/// A visitor that walks over the HIR and collects `Node`s into a HIR map.
13-
pub(super) struct NodeCollector<'a, 'hir> {
13+
struct NodeCollector<'a, 'hir> {
1414
tcx: TyCtxt<'hir>,
1515

1616
bodies: &'a SortedMap<ItemLocalId, &'hir Body<'hir>>,

0 commit comments

Comments
 (0)