Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit abbba77

Browse files
committedJan 29, 2024
Auto merge of rust-lang#120437 - matthiaskrgr:rollup-h1uai71, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#120358 (Bump Fuchsia, build tests, and use 8 core bots) - rust-lang#120402 (Make the coroutine def id of an async closure the child of the closure def id) - rust-lang#120420 (Stop using derivative in rustc_pattern_analysis) - rust-lang#120425 (Remove unnecessary unit returns in query declarations) - rust-lang#120428 (hir: Two preparatory changes for rust-lang#120206) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7e43442 + 4a759f0 commit abbba77

File tree

28 files changed

+293
-91
lines changed

28 files changed

+293
-91
lines changed
 

‎.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ jobs:
294294
- name: x86_64-gnu-integration
295295
env:
296296
CI_ONLY_WHEN_CHANNEL: nightly
297-
os: ubuntu-20.04-16core-64gb
297+
os: ubuntu-20.04-8core-32gb
298298
- name: x86_64-gnu-debug
299299
os: ubuntu-20.04-8core-32gb
300300
env: {}

‎Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4342,7 +4342,6 @@ dependencies = [
43424342
name = "rustc_pattern_analysis"
43434343
version = "0.0.0"
43444344
dependencies = [
4345-
"derivative",
43464345
"rustc-hash",
43474346
"rustc_apfloat",
43484347
"rustc_arena",

‎compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
153153
}
154154
ExprKind::Let(pat, scrutinee, span, is_recovered) => {
155155
hir::ExprKind::Let(self.arena.alloc(hir::Let {
156-
hir_id: self.next_id(),
157156
span: self.lower_span(*span),
158157
pat: self.lower_pat(pat),
159158
ty: None,

‎compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2305,7 +2305,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23052305
match c.value.kind {
23062306
ExprKind::Underscore => {
23072307
if self.tcx.features().generic_arg_infer {
2308-
hir::ArrayLen::Infer(self.lower_node_id(c.id), self.lower_span(c.value.span))
2308+
hir::ArrayLen::Infer(hir::InferArg {
2309+
hir_id: self.lower_node_id(c.id),
2310+
span: self.lower_span(c.value.span),
2311+
})
23092312
} else {
23102313
feature_err(
23112314
&self.tcx.sess,

‎compiler/rustc_hir/src/hir.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,6 @@ pub struct Arm<'hir> {
12731273
/// desugaring to if-let. Only let-else supports the type annotation at present.
12741274
#[derive(Debug, Clone, Copy, HashStable_Generic)]
12751275
pub struct Let<'hir> {
1276-
pub hir_id: HirId,
12771276
pub span: Span,
12781277
pub pat: &'hir Pat<'hir>,
12791278
pub ty: Option<&'hir Ty<'hir>>,
@@ -1532,14 +1531,16 @@ pub type Lit = Spanned<LitKind>;
15321531

15331532
#[derive(Copy, Clone, Debug, HashStable_Generic)]
15341533
pub enum ArrayLen {
1535-
Infer(HirId, Span),
1534+
Infer(InferArg),
15361535
Body(AnonConst),
15371536
}
15381537

15391538
impl ArrayLen {
15401539
pub fn hir_id(&self) -> HirId {
15411540
match self {
1542-
&ArrayLen::Infer(hir_id, _) | &ArrayLen::Body(AnonConst { hir_id, .. }) => hir_id,
1541+
ArrayLen::Infer(InferArg { hir_id, .. }) | ArrayLen::Body(AnonConst { hir_id, .. }) => {
1542+
*hir_id
1543+
}
15431544
}
15441545
}
15451546
}
@@ -2424,7 +2425,7 @@ impl<'hir> Ty<'hir> {
24242425
TyKind::Infer => true,
24252426
TyKind::Slice(ty) => ty.is_suggestable_infer_ty(),
24262427
TyKind::Array(ty, length) => {
2427-
ty.is_suggestable_infer_ty() || matches!(length, ArrayLen::Infer(_, _))
2428+
ty.is_suggestable_infer_ty() || matches!(length, ArrayLen::Infer(..))
24282429
}
24292430
TyKind::Tup(tys) => tys.iter().any(Self::is_suggestable_infer_ty),
24302431
TyKind::Ptr(mut_ty) | TyKind::Ref(_, mut_ty) => mut_ty.ty.is_suggestable_infer_ty(),

‎compiler/rustc_hir/src/intravisit.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,6 @@ pub trait Visitor<'v>: Sized {
341341
fn visit_expr(&mut self, ex: &'v Expr<'v>) {
342342
walk_expr(self, ex)
343343
}
344-
fn visit_let_expr(&mut self, lex: &'v Let<'v>) {
345-
walk_let_expr(self, lex)
346-
}
347344
fn visit_expr_field(&mut self, field: &'v ExprField<'v>) {
348345
walk_expr_field(self, field)
349346
}
@@ -672,7 +669,7 @@ pub fn walk_pat_field<'v, V: Visitor<'v>>(visitor: &mut V, field: &'v PatField<'
672669

673670
pub fn walk_array_len<'v, V: Visitor<'v>>(visitor: &mut V, len: &'v ArrayLen) {
674671
match len {
675-
&ArrayLen::Infer(hir_id, _span) => visitor.visit_id(hir_id),
672+
ArrayLen::Infer(InferArg { hir_id, span: _ }) => visitor.visit_id(*hir_id),
676673
ArrayLen::Body(c) => visitor.visit_anon_const(c),
677674
}
678675
}
@@ -729,7 +726,12 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
729726
ExprKind::DropTemps(ref subexpression) => {
730727
visitor.visit_expr(subexpression);
731728
}
732-
ExprKind::Let(ref let_expr) => visitor.visit_let_expr(let_expr),
729+
ExprKind::Let(Let { span: _, pat, ty, init, is_recovered: _ }) => {
730+
// match the visit order in walk_local
731+
visitor.visit_expr(init);
732+
visitor.visit_pat(pat);
733+
walk_list!(visitor, visit_ty, ty);
734+
}
733735
ExprKind::If(ref cond, ref then, ref else_opt) => {
734736
visitor.visit_expr(cond);
735737
visitor.visit_expr(then);
@@ -806,14 +808,6 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
806808
}
807809
}
808810

809-
pub fn walk_let_expr<'v, V: Visitor<'v>>(visitor: &mut V, let_expr: &'v Let<'v>) {
810-
// match the visit order in walk_local
811-
visitor.visit_expr(let_expr.init);
812-
visitor.visit_id(let_expr.hir_id);
813-
visitor.visit_pat(let_expr.pat);
814-
walk_list!(visitor, visit_ty, let_expr.ty);
815-
}
816-
817811
pub fn walk_expr_field<'v, V: Visitor<'v>>(visitor: &mut V, field: &'v ExprField<'v>) {
818812
visitor.visit_id(field.hir_id);
819813
visitor.visit_ident(field.ident);

‎compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2529,7 +2529,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
25292529
}
25302530
hir::TyKind::Array(ty, length) => {
25312531
let length = match length {
2532-
&hir::ArrayLen::Infer(_, span) => self.ct_infer(tcx.types.usize, None, span),
2532+
hir::ArrayLen::Infer(inf) => self.ct_infer(tcx.types.usize, None, inf.span),
25332533
hir::ArrayLen::Body(constant) => {
25342534
ty::Const::from_anon_const(tcx, constant.def_id)
25352535
}

‎compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ impl<'v> Visitor<'v> for HirPlaceholderCollector {
146146
}
147147
}
148148
fn visit_array_length(&mut self, length: &'v hir::ArrayLen) {
149-
if let &hir::ArrayLen::Infer(_, span) = length {
150-
self.0.push(span);
149+
if let hir::ArrayLen::Infer(inf) = length {
150+
self.0.push(inf.span);
151151
}
152152
intravisit::walk_array_len(self, length)
153153
}

‎compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ impl<'a> State<'a> {
956956

957957
fn print_array_length(&mut self, len: &hir::ArrayLen) {
958958
match len {
959-
hir::ArrayLen::Infer(_, _) => self.word("_"),
959+
hir::ArrayLen::Infer(..) => self.word("_"),
960960
hir::ArrayLen::Body(ct) => self.print_anon_const(ct),
961961
}
962962
}

‎compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
320320
}
321321
ExprKind::Ret(ref expr_opt) => self.check_expr_return(expr_opt.as_deref(), expr),
322322
ExprKind::Become(call) => self.check_expr_become(call, expr),
323-
ExprKind::Let(let_expr) => self.check_expr_let(let_expr),
323+
ExprKind::Let(let_expr) => self.check_expr_let(let_expr, expr.hir_id),
324324
ExprKind::Loop(body, _, source, _) => {
325325
self.check_expr_loop(body, source, expected, expr)
326326
}
@@ -1259,12 +1259,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12591259
}
12601260
}
12611261

1262-
pub(super) fn check_expr_let(&self, let_expr: &'tcx hir::Let<'tcx>) -> Ty<'tcx> {
1262+
pub(super) fn check_expr_let(&self, let_expr: &'tcx hir::Let<'tcx>, hir_id: HirId) -> Ty<'tcx> {
12631263
// for let statements, this is done in check_stmt
12641264
let init = let_expr.init;
12651265
self.warn_if_unreachable(init.hir_id, init.span, "block in `let` expression");
12661266
// otherwise check exactly as a let statement
1267-
self.check_decl(let_expr.into());
1267+
self.check_decl((let_expr, hir_id).into());
12681268
// but return a bool, for this is a boolean expression
12691269
if let Some(error_guaranteed) = let_expr.is_recovered {
12701270
self.set_tainted_by_errors(error_guaranteed);

‎compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
405405

406406
pub fn array_length_to_const(&self, length: &hir::ArrayLen) -> ty::Const<'tcx> {
407407
match length {
408-
&hir::ArrayLen::Infer(_, span) => self.ct_infer(self.tcx.types.usize, None, span),
408+
hir::ArrayLen::Infer(inf) => self.ct_infer(self.tcx.types.usize, None, inf.span),
409409
hir::ArrayLen::Body(anon_const) => {
410410
let span = self.tcx.def_span(anon_const.def_id);
411411
let c = ty::Const::from_anon_const(self.tcx, anon_const.def_id);

‎compiler/rustc_hir_typeck/src/gather_locals.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ impl<'a> From<&'a hir::Local<'a>> for Declaration<'a> {
4848
}
4949
}
5050

51-
impl<'a> From<&'a hir::Let<'a>> for Declaration<'a> {
52-
fn from(let_expr: &'a hir::Let<'a>) -> Self {
53-
let hir::Let { hir_id, pat, ty, span, init, is_recovered: _ } = *let_expr;
51+
impl<'a> From<(&'a hir::Let<'a>, hir::HirId)> for Declaration<'a> {
52+
fn from((let_expr, hir_id): (&'a hir::Let<'a>, hir::HirId)) -> Self {
53+
let hir::Let { pat, ty, span, init, is_recovered: _ } = *let_expr;
5454
Declaration { hir_id, pat, ty, span, init: Some(init), origin: DeclOrigin::LetExpr }
5555
}
5656
}
@@ -125,9 +125,11 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
125125
intravisit::walk_local(self, local)
126126
}
127127

128-
fn visit_let_expr(&mut self, let_expr: &'tcx hir::Let<'tcx>) {
129-
self.declare(let_expr.into());
130-
intravisit::walk_let_expr(self, let_expr);
128+
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
129+
if let hir::ExprKind::Let(let_expr) = expr.kind {
130+
self.declare((let_expr, expr.hir_id).into());
131+
}
132+
intravisit::walk_expr(self, expr)
131133
}
132134

133135
fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) {

‎compiler/rustc_middle/src/query/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub use plumbing::{IntoQueryParam, TyCtxtAt, TyCtxtEnsure, TyCtxtEnsureWithValue
109109
// as they will raise an fatal error on query cycles instead.
110110
rustc_queries! {
111111
/// This exists purely for testing the interactions between span_delayed_bug and incremental.
112-
query trigger_span_delayed_bug(key: DefId) -> () {
112+
query trigger_span_delayed_bug(key: DefId) {
113113
desc { "triggering a span delayed bug for testing incremental" }
114114
}
115115

@@ -119,7 +119,7 @@ rustc_queries! {
119119
desc { "compute registered tools for crate" }
120120
}
121121

122-
query early_lint_checks(_: ()) -> () {
122+
query early_lint_checks(_: ()) {
123123
desc { "perform lints prior to macro expansion" }
124124
}
125125

@@ -299,7 +299,7 @@ rustc_queries! {
299299
/// name. This is useful for cases were not all linting code from rustc
300300
/// was called. With the default `None` all registered lints will also
301301
/// be checked for expectation fulfillment.
302-
query check_expectations(key: Option<Symbol>) -> () {
302+
query check_expectations(key: Option<Symbol>) {
303303
eval_always
304304
desc { "checking lint expectations (RFC 2383)" }
305305
}
@@ -906,39 +906,39 @@ rustc_queries! {
906906
}
907907

908908
/// Performs lint checking for the module.
909-
query lint_mod(key: LocalModDefId) -> () {
909+
query lint_mod(key: LocalModDefId) {
910910
desc { |tcx| "linting {}", describe_as_module(key, tcx) }
911911
}
912912

913-
query check_unused_traits(_: ()) -> () {
913+
query check_unused_traits(_: ()) {
914914
desc { "checking unused trait imports in crate" }
915915
}
916916

917917
/// Checks the attributes in the module.
918-
query check_mod_attrs(key: LocalModDefId) -> () {
918+
query check_mod_attrs(key: LocalModDefId) {
919919
desc { |tcx| "checking attributes in {}", describe_as_module(key, tcx) }
920920
}
921921

922922
/// Checks for uses of unstable APIs in the module.
923-
query check_mod_unstable_api_usage(key: LocalModDefId) -> () {
923+
query check_mod_unstable_api_usage(key: LocalModDefId) {
924924
desc { |tcx| "checking for unstable API usage in {}", describe_as_module(key, tcx) }
925925
}
926926

927927
/// Checks the const bodies in the module for illegal operations (e.g. `if` or `loop`).
928-
query check_mod_const_bodies(key: LocalModDefId) -> () {
928+
query check_mod_const_bodies(key: LocalModDefId) {
929929
desc { |tcx| "checking consts in {}", describe_as_module(key, tcx) }
930930
}
931931

932932
/// Checks the loops in the module.
933-
query check_mod_loops(key: LocalModDefId) -> () {
933+
query check_mod_loops(key: LocalModDefId) {
934934
desc { |tcx| "checking loops in {}", describe_as_module(key, tcx) }
935935
}
936936

937-
query check_mod_naked_functions(key: LocalModDefId) -> () {
937+
query check_mod_naked_functions(key: LocalModDefId) {
938938
desc { |tcx| "checking naked functions in {}", describe_as_module(key, tcx) }
939939
}
940940

941-
query check_mod_privacy(key: LocalModDefId) -> () {
941+
query check_mod_privacy(key: LocalModDefId) {
942942
desc { |tcx| "checking privacy in {}", describe_as_module(key.to_local_def_id(), tcx) }
943943
}
944944

@@ -958,7 +958,7 @@ rustc_queries! {
958958
desc { "finding live symbols in crate" }
959959
}
960960

961-
query check_mod_deathness(key: LocalModDefId) -> () {
961+
query check_mod_deathness(key: LocalModDefId) {
962962
desc { |tcx| "checking deathness of variables in {}", describe_as_module(key, tcx) }
963963
}
964964

@@ -972,7 +972,7 @@ rustc_queries! {
972972
ensure_forwards_result_if_red
973973
}
974974

975-
query collect_mod_item_types(key: LocalModDefId) -> () {
975+
query collect_mod_item_types(key: LocalModDefId) {
976976
desc { |tcx| "collecting item types in {}", describe_as_module(key, tcx) }
977977
}
978978

@@ -1121,7 +1121,7 @@ rustc_queries! {
11211121
eval_always
11221122
desc { "checking effective visibilities" }
11231123
}
1124-
query check_private_in_public(_: ()) -> () {
1124+
query check_private_in_public(_: ()) {
11251125
eval_always
11261126
desc { "checking for private elements in public interfaces" }
11271127
}

‎compiler/rustc_passes/src/hir_stats.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,6 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
328328
hir_visit::walk_expr(self, e)
329329
}
330330

331-
fn visit_let_expr(&mut self, lex: &'v hir::Let<'v>) {
332-
self.record("Let", Id::Node(lex.hir_id), lex);
333-
hir_visit::walk_let_expr(self, lex)
334-
}
335-
336331
fn visit_expr_field(&mut self, f: &'v hir::ExprField<'v>) {
337332
self.record("ExprField", Id::Node(f.hir_id), f);
338333
hir_visit::walk_expr_field(self, f)

‎compiler/rustc_pattern_analysis/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ edition = "2021"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
derivative = "2.2.0"
98
rustc-hash = "1.1.0"
109
rustc_apfloat = "0.2.0"
1110
rustc_arena = { path = "../rustc_arena", optional = true }

‎compiler/rustc_pattern_analysis/src/constructor.rs

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
use std::cmp::{self, max, min, Ordering};
152152
use std::fmt;
153153
use std::iter::once;
154+
use std::mem;
154155

155156
use smallvec::SmallVec;
156157

@@ -648,8 +649,6 @@ impl OpaqueId {
648649
/// `specialize_constructor` returns the list of fields corresponding to a pattern, given a
649650
/// constructor. `Constructor::apply` reconstructs the pattern from a pair of `Constructor` and
650651
/// `Fields`.
651-
#[derive(derivative::Derivative)]
652-
#[derivative(Debug(bound = ""), Clone(bound = ""), PartialEq(bound = ""))]
653652
pub enum Constructor<Cx: TypeCx> {
654653
/// Tuples and structs.
655654
Struct,
@@ -692,6 +691,101 @@ pub enum Constructor<Cx: TypeCx> {
692691
Missing,
693692
}
694693

694+
impl<Cx: TypeCx> Clone for Constructor<Cx> {
695+
fn clone(&self) -> Self {
696+
match self {
697+
Constructor::Struct => Constructor::Struct,
698+
Constructor::Variant(idx) => Constructor::Variant(idx.clone()),
699+
Constructor::Ref => Constructor::Ref,
700+
Constructor::Slice(slice) => Constructor::Slice(slice.clone()),
701+
Constructor::UnionField => Constructor::UnionField,
702+
Constructor::Bool(b) => Constructor::Bool(b.clone()),
703+
Constructor::IntRange(range) => Constructor::IntRange(range.clone()),
704+
Constructor::F32Range(lo, hi, end) => {
705+
Constructor::F32Range(lo.clone(), hi.clone(), end.clone())
706+
}
707+
Constructor::F64Range(lo, hi, end) => {
708+
Constructor::F64Range(lo.clone(), hi.clone(), end.clone())
709+
}
710+
Constructor::Str(value) => Constructor::Str(value.clone()),
711+
Constructor::Opaque(inner) => Constructor::Opaque(inner.clone()),
712+
Constructor::Or => Constructor::Or,
713+
Constructor::Wildcard => Constructor::Wildcard,
714+
Constructor::NonExhaustive => Constructor::NonExhaustive,
715+
Constructor::Hidden => Constructor::Hidden,
716+
Constructor::Missing => Constructor::Missing,
717+
}
718+
}
719+
}
720+
721+
impl<Cx: TypeCx> fmt::Debug for Constructor<Cx> {
722+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
723+
match self {
724+
Constructor::Struct => f.debug_tuple("Struct").finish(),
725+
Constructor::Variant(idx) => f.debug_tuple("Variant").field(idx).finish(),
726+
Constructor::Ref => f.debug_tuple("Ref").finish(),
727+
Constructor::Slice(slice) => f.debug_tuple("Slice").field(slice).finish(),
728+
Constructor::UnionField => f.debug_tuple("UnionField").finish(),
729+
Constructor::Bool(b) => f.debug_tuple("Bool").field(b).finish(),
730+
Constructor::IntRange(range) => f.debug_tuple("IntRange").field(range).finish(),
731+
Constructor::F32Range(lo, hi, end) => {
732+
f.debug_tuple("F32Range").field(lo).field(hi).field(end).finish()
733+
}
734+
Constructor::F64Range(lo, hi, end) => {
735+
f.debug_tuple("F64Range").field(lo).field(hi).field(end).finish()
736+
}
737+
Constructor::Str(value) => f.debug_tuple("Str").field(value).finish(),
738+
Constructor::Opaque(inner) => f.debug_tuple("Opaque").field(inner).finish(),
739+
Constructor::Or => f.debug_tuple("Or").finish(),
740+
Constructor::Wildcard => f.debug_tuple("Wildcard").finish(),
741+
Constructor::NonExhaustive => f.debug_tuple("NonExhaustive").finish(),
742+
Constructor::Hidden => f.debug_tuple("Hidden").finish(),
743+
Constructor::Missing => f.debug_tuple("Missing").finish(),
744+
}
745+
}
746+
}
747+
748+
impl<Cx: TypeCx> PartialEq for Constructor<Cx> {
749+
fn eq(&self, other: &Self) -> bool {
750+
(mem::discriminant(self) == mem::discriminant(other))
751+
&& match (self, other) {
752+
(Constructor::Struct, Constructor::Struct) => true,
753+
(Constructor::Variant(self_variant), Constructor::Variant(other_variant)) => {
754+
self_variant == other_variant
755+
}
756+
(Constructor::Ref, Constructor::Ref) => true,
757+
(Constructor::Slice(self_slice), Constructor::Slice(other_slice)) => {
758+
self_slice == other_slice
759+
}
760+
(Constructor::UnionField, Constructor::UnionField) => true,
761+
(Constructor::Bool(self_b), Constructor::Bool(other_b)) => self_b == other_b,
762+
(Constructor::IntRange(self_range), Constructor::IntRange(other_range)) => {
763+
self_range == other_range
764+
}
765+
(
766+
Constructor::F32Range(self_lo, self_hi, self_end),
767+
Constructor::F32Range(other_lo, other_hi, other_end),
768+
) => self_lo == other_lo && self_hi == other_hi && self_end == other_end,
769+
(
770+
Constructor::F64Range(self_lo, self_hi, self_end),
771+
Constructor::F64Range(other_lo, other_hi, other_end),
772+
) => self_lo == other_lo && self_hi == other_hi && self_end == other_end,
773+
(Constructor::Str(self_value), Constructor::Str(other_value)) => {
774+
self_value == other_value
775+
}
776+
(Constructor::Opaque(self_inner), Constructor::Opaque(other_inner)) => {
777+
self_inner == other_inner
778+
}
779+
(Constructor::Or, Constructor::Or) => true,
780+
(Constructor::Wildcard, Constructor::Wildcard) => true,
781+
(Constructor::NonExhaustive, Constructor::NonExhaustive) => true,
782+
(Constructor::Hidden, Constructor::Hidden) => true,
783+
(Constructor::Missing, Constructor::Missing) => true,
784+
_ => unreachable!(),
785+
}
786+
}
787+
}
788+
695789
impl<Cx: TypeCx> Constructor<Cx> {
696790
pub(crate) fn is_non_exhaustive(&self) -> bool {
697791
matches!(self, NonExhaustive)

‎compiler/rustc_pattern_analysis/src/lib.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,23 +136,35 @@ pub trait TypeCx: Sized + fmt::Debug {
136136
}
137137

138138
/// Context that provides information global to a match.
139-
#[derive(derivative::Derivative)]
140-
#[derivative(Clone(bound = ""), Copy(bound = ""))]
141139
pub struct MatchCtxt<'a, Cx: TypeCx> {
142140
/// The context for type information.
143141
pub tycx: &'a Cx,
144142
}
145143

144+
impl<'a, Cx: TypeCx> Clone for MatchCtxt<'a, Cx> {
145+
fn clone(&self) -> Self {
146+
Self { tycx: self.tycx }
147+
}
148+
}
149+
150+
impl<'a, Cx: TypeCx> Copy for MatchCtxt<'a, Cx> {}
151+
146152
/// The arm of a match expression.
147153
#[derive(Debug)]
148-
#[derive(derivative::Derivative)]
149-
#[derivative(Clone(bound = ""), Copy(bound = ""))]
150154
pub struct MatchArm<'p, Cx: TypeCx> {
151155
pub pat: &'p DeconstructedPat<'p, Cx>,
152156
pub has_guard: bool,
153157
pub arm_data: Cx::ArmData,
154158
}
155159

160+
impl<'p, Cx: TypeCx> Clone for MatchArm<'p, Cx> {
161+
fn clone(&self) -> Self {
162+
Self { pat: self.pat, has_guard: self.has_guard, arm_data: self.arm_data }
163+
}
164+
}
165+
166+
impl<'p, Cx: TypeCx> Copy for MatchArm<'p, Cx> {}
167+
156168
/// The entrypoint for this crate. Computes whether a match is exhaustive and which of its arms are
157169
/// useful, and runs some lints.
158170
#[cfg(feature = "rustc")]

‎compiler/rustc_pattern_analysis/src/pat.rs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,24 @@ impl<'p, Cx: TypeCx> fmt::Debug for DeconstructedPat<'p, Cx> {
218218
/// algorithm. Do not use `Wild` to represent a wildcard pattern comping from user input.
219219
///
220220
/// This is morally `Option<&'p DeconstructedPat>` where `None` is interpreted as a wildcard.
221-
#[derive(derivative::Derivative)]
222-
#[derivative(Clone(bound = ""), Copy(bound = ""))]
223221
pub(crate) enum PatOrWild<'p, Cx: TypeCx> {
224222
/// A non-user-provided wildcard, created during specialization.
225223
Wild,
226224
/// A user-provided pattern.
227225
Pat(&'p DeconstructedPat<'p, Cx>),
228226
}
229227

228+
impl<'p, Cx: TypeCx> Clone for PatOrWild<'p, Cx> {
229+
fn clone(&self) -> Self {
230+
match self {
231+
PatOrWild::Wild => PatOrWild::Wild,
232+
PatOrWild::Pat(pat) => PatOrWild::Pat(pat),
233+
}
234+
}
235+
}
236+
237+
impl<'p, Cx: TypeCx> Copy for PatOrWild<'p, Cx> {}
238+
230239
impl<'p, Cx: TypeCx> PatOrWild<'p, Cx> {
231240
pub(crate) fn as_pat(&self) -> Option<&'p DeconstructedPat<'p, Cx>> {
232241
match self {
@@ -289,14 +298,28 @@ impl<'p, Cx: TypeCx> fmt::Debug for PatOrWild<'p, Cx> {
289298

290299
/// Same idea as `DeconstructedPat`, except this is a fictitious pattern built up for diagnostics
291300
/// purposes. As such they don't use interning and can be cloned.
292-
#[derive(derivative::Derivative)]
293-
#[derivative(Debug(bound = ""), Clone(bound = ""))]
294301
pub struct WitnessPat<Cx: TypeCx> {
295302
ctor: Constructor<Cx>,
296303
pub(crate) fields: Vec<WitnessPat<Cx>>,
297304
ty: Cx::Ty,
298305
}
299306

307+
impl<Cx: TypeCx> Clone for WitnessPat<Cx> {
308+
fn clone(&self) -> Self {
309+
Self { ctor: self.ctor.clone(), fields: self.fields.clone(), ty: self.ty.clone() }
310+
}
311+
}
312+
313+
impl<Cx: TypeCx> fmt::Debug for WitnessPat<Cx> {
314+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
315+
fmt.debug_struct("WitnessPat")
316+
.field("ctor", &self.ctor)
317+
.field("fields", &self.fields)
318+
.field("ty", &self.ty)
319+
.finish()
320+
}
321+
}
322+
300323
impl<Cx: TypeCx> WitnessPat<Cx> {
301324
pub(crate) fn new(ctor: Constructor<Cx>, fields: Vec<Self>, ty: Cx::Ty) -> Self {
302325
Self { ctor, fields, ty }

‎compiler/rustc_pattern_analysis/src/rustc.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,15 @@ pub type WitnessPat<'p, 'tcx> = crate::pat::WitnessPat<RustcMatchCheckCtxt<'p, '
4646
///
4747
/// Use `.inner()` or deref to get to the `Ty<'tcx>`.
4848
#[repr(transparent)]
49-
#[derive(derivative::Derivative)]
5049
#[derive(Clone, Copy)]
51-
#[derivative(Debug = "transparent")]
5250
pub struct RevealedTy<'tcx>(Ty<'tcx>);
5351

52+
impl<'tcx> fmt::Debug for RevealedTy<'tcx> {
53+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
54+
self.0.fmt(fmt)
55+
}
56+
}
57+
5458
impl<'tcx> std::ops::Deref for RevealedTy<'tcx> {
5559
type Target = Ty<'tcx>;
5660
fn deref(&self) -> &Self::Target {

‎compiler/rustc_pattern_analysis/src/usefulness.rs

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -731,16 +731,26 @@ pub fn ensure_sufficient_stack<R>(f: impl FnOnce() -> R) -> R {
731731
}
732732

733733
/// Context that provides information local to a place under investigation.
734-
#[derive(derivative::Derivative)]
735-
#[derivative(Debug(bound = ""), Clone(bound = ""), Copy(bound = ""))]
736734
pub(crate) struct PlaceCtxt<'a, Cx: TypeCx> {
737-
#[derivative(Debug = "ignore")]
738735
pub(crate) mcx: MatchCtxt<'a, Cx>,
739736
/// Type of the place under investigation.
740-
#[derivative(Clone(clone_with = "Clone::clone"))] // See rust-derivative#90
741737
pub(crate) ty: &'a Cx::Ty,
742738
}
743739

740+
impl<'a, Cx: TypeCx> Clone for PlaceCtxt<'a, Cx> {
741+
fn clone(&self) -> Self {
742+
Self { mcx: self.mcx, ty: self.ty }
743+
}
744+
}
745+
746+
impl<'a, Cx: TypeCx> Copy for PlaceCtxt<'a, Cx> {}
747+
748+
impl<'a, Cx: TypeCx> fmt::Debug for PlaceCtxt<'a, Cx> {
749+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
750+
fmt.debug_struct("PlaceCtxt").field("ty", self.ty).finish()
751+
}
752+
}
753+
744754
impl<'a, Cx: TypeCx> PlaceCtxt<'a, Cx> {
745755
/// A `PlaceCtxt` when code other than `is_useful` needs one.
746756
#[cfg_attr(not(feature = "rustc"), allow(dead_code))]
@@ -813,8 +823,6 @@ impl fmt::Display for ValidityConstraint {
813823
// The three lifetimes are:
814824
// - 'p coming from the input
815825
// - Cx global compilation context
816-
#[derive(derivative::Derivative)]
817-
#[derivative(Clone(bound = ""))]
818826
struct PatStack<'p, Cx: TypeCx> {
819827
// Rows of len 1 are very common, which is why `SmallVec[_; 2]` works well.
820828
pats: SmallVec<[PatOrWild<'p, Cx>; 2]>,
@@ -824,6 +832,12 @@ struct PatStack<'p, Cx: TypeCx> {
824832
relevant: bool,
825833
}
826834

835+
impl<'p, Cx: TypeCx> Clone for PatStack<'p, Cx> {
836+
fn clone(&self) -> Self {
837+
Self { pats: self.pats.clone(), relevant: self.relevant }
838+
}
839+
}
840+
827841
impl<'p, Cx: TypeCx> PatStack<'p, Cx> {
828842
fn from_pattern(pat: &'p DeconstructedPat<'p, Cx>) -> Self {
829843
PatStack { pats: smallvec![PatOrWild::Pat(pat)], relevant: true }
@@ -1184,10 +1198,20 @@ impl<'p, Cx: TypeCx> fmt::Debug for Matrix<'p, Cx> {
11841198
/// The final `Pair(Some(_), true)` is then the resulting witness.
11851199
///
11861200
/// See the top of the file for more detailed explanations and examples.
1187-
#[derive(derivative::Derivative)]
1188-
#[derivative(Debug(bound = ""), Clone(bound = ""))]
11891201
struct WitnessStack<Cx: TypeCx>(Vec<WitnessPat<Cx>>);
11901202

1203+
impl<Cx: TypeCx> Clone for WitnessStack<Cx> {
1204+
fn clone(&self) -> Self {
1205+
Self(self.0.clone())
1206+
}
1207+
}
1208+
1209+
impl<Cx: TypeCx> fmt::Debug for WitnessStack<Cx> {
1210+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1211+
fmt.debug_tuple("WitnessStack").field(&self.0).finish()
1212+
}
1213+
}
1214+
11911215
impl<Cx: TypeCx> WitnessStack<Cx> {
11921216
/// Asserts that the witness contains a single pattern, and returns it.
11931217
fn single_pattern(self) -> WitnessPat<Cx> {
@@ -1232,18 +1256,28 @@ impl<Cx: TypeCx> WitnessStack<Cx> {
12321256
///
12331257
/// Just as the `Matrix` starts with a single column, by the end of the algorithm, this has a single
12341258
/// column, which contains the patterns that are missing for the match to be exhaustive.
1235-
#[derive(derivative::Derivative)]
1236-
#[derivative(Debug(bound = ""), Clone(bound = ""))]
12371259
struct WitnessMatrix<Cx: TypeCx>(Vec<WitnessStack<Cx>>);
12381260

1261+
impl<Cx: TypeCx> Clone for WitnessMatrix<Cx> {
1262+
fn clone(&self) -> Self {
1263+
Self(self.0.clone())
1264+
}
1265+
}
1266+
1267+
impl<Cx: TypeCx> fmt::Debug for WitnessMatrix<Cx> {
1268+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1269+
fmt.debug_tuple("WitnessMatrix").field(&self.0).finish()
1270+
}
1271+
}
1272+
12391273
impl<Cx: TypeCx> WitnessMatrix<Cx> {
12401274
/// New matrix with no witnesses.
12411275
fn empty() -> Self {
1242-
WitnessMatrix(vec![])
1276+
WitnessMatrix(Vec::new())
12431277
}
12441278
/// New matrix with one `()` witness, i.e. with no columns.
12451279
fn unit_witness() -> Self {
1246-
WitnessMatrix(vec![WitnessStack(vec![])])
1280+
WitnessMatrix(vec![WitnessStack(Vec::new())])
12471281
}
12481282

12491283
/// Whether this has any witnesses.

‎compiler/rustc_resolve/src/def_collector.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,18 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
289289
// we must create two defs.
290290
let closure_def = self.create_def(expr.id, kw::Empty, DefKind::Closure, expr.span);
291291
match closure.coroutine_kind {
292-
Some(coroutine_kind) => self.create_def(
293-
coroutine_kind.closure_id(),
294-
kw::Empty,
295-
DefKind::Closure,
296-
expr.span,
297-
),
292+
Some(coroutine_kind) => {
293+
self.with_parent(closure_def, |this| {
294+
let coroutine_def = this.create_def(
295+
coroutine_kind.closure_id(),
296+
kw::Empty,
297+
DefKind::Closure,
298+
expr.span,
299+
);
300+
this.with_parent(coroutine_def, |this| visit::walk_expr(this, expr));
301+
});
302+
return;
303+
}
298304
None => closure_def,
299305
}
300306
}

‎src/ci/docker/host-x86_64/x86_64-gnu-integration/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,17 @@ ENV CARGO_TARGET_X86_64_FUCHSIA_RUSTFLAGS \
4444

4545
ENV TARGETS=x86_64-fuchsia
4646
ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnu
47+
ENV TARGETS=$TARGETS,wasm32-unknown-unknown
4748

4849
COPY scripts/sccache.sh /scripts/
4950
RUN sh /scripts/sccache.sh
5051

5152
ENV RUST_INSTALL_DIR /checkout/obj/install
5253
RUN mkdir -p $RUST_INSTALL_DIR/etc
5354

55+
# Fuchsia only supports LLVM.
56+
ENV CODEGEN_BACKENDS llvm
57+
5458
ENV RUST_CONFIGURE_ARGS \
5559
--prefix=$RUST_INSTALL_DIR \
5660
--sysconfdir=etc \

‎src/ci/docker/host-x86_64/x86_64-gnu-integration/build-fuchsia.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
set -euf -o pipefail
77

8-
INTEGRATION_SHA=66793c4894bf6204579bbee3b79956335f31c768
8+
INTEGRATION_SHA=56310bca298872ffb5ea02e665956d9b6dc41171
99
PICK_REFS=()
1010

1111
checkout=fuchsia

‎src/ci/github-actions/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ jobs:
478478
# nightly features to compile, and this job would fail if
479479
# executed on beta and stable.
480480
CI_ONLY_WHEN_CHANNEL: nightly
481-
<<: *job-linux-16c
481+
<<: *job-linux-8c
482482

483483
- name: x86_64-gnu-debug
484484
<<: *job-linux-8c

‎src/ci/run.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then
119119
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir"
120120
fi
121121

122-
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-backends=${CODEGEN_BACKENDS:-llvm}"
122+
CODEGEN_BACKENDS="${CODEGEN_BACKENDS:-llvm}"
123+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-backends=$CODEGEN_BACKENDS"
123124
else
124125
# We almost always want debug assertions enabled, but sometimes this takes too
125126
# long for too little benefit, so we just turn them off.
@@ -144,11 +145,12 @@ else
144145
# tests as it will fail them.
145146
if [[ "${ENABLE_GCC_CODEGEN}" == "1" ]]; then
146147
# Test the Cranelift and GCC backends in CI. Bootstrap knows which targets to run tests on.
147-
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-backends=llvm,cranelift,gcc"
148+
CODEGEN_BACKENDS="${CODEGEN_BACKENDS:-llvm,cranelift,gcc}"
148149
else
149150
# Test the Cranelift backend in CI. Bootstrap knows which targets to run tests on.
150-
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-backends=llvm,cranelift"
151+
CODEGEN_BACKENDS="${CODEGEN_BACKENDS:-llvm,cranelift}"
151152
fi
153+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-backends=$CODEGEN_BACKENDS"
152154

153155
# We enable this for non-dist builders, since those aren't trying to produce
154156
# fresh binaries. We currently don't entirely support distributing a fresh

‎src/librustdoc/clean/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,7 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
18361836
TyKind::Slice(ty) => Slice(Box::new(clean_ty(ty, cx))),
18371837
TyKind::Array(ty, ref length) => {
18381838
let length = match length {
1839-
hir::ArrayLen::Infer(_, _) => "_".to_string(),
1839+
hir::ArrayLen::Infer(..) => "_".to_string(),
18401840
hir::ArrayLen::Body(anon_const) => {
18411841
// NOTE(min_const_generics): We can't use `const_eval_poly` for constants
18421842
// as we currently do not supply the parent generics to anonymous constants
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// compile-flags: -Zverbose-internals
2+
// edition:2021
3+
4+
#![feature(async_closure)]
5+
6+
fn main() {
7+
let x = async || {};
8+
//~^ NOTE the expected `async` closure body
9+
let () = x();
10+
//~^ ERROR mismatched types
11+
//~| NOTE this expression has type `{static main::{closure#0}::{closure#0} upvar_tys=
12+
//~| NOTE expected `async` closure body, found `()`
13+
//~| NOTE expected `async` closure body `{static main::{closure#0}::{closure#0}
14+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/def-path.rs:9:9
3+
|
4+
LL | let x = async || {};
5+
| -- the expected `async` closure body
6+
LL |
7+
LL | let () = x();
8+
| ^^ --- this expression has type `{static main::{closure#0}::{closure#0} upvar_tys=?7t witness=?8t}`
9+
| |
10+
| expected `async` closure body, found `()`
11+
|
12+
= note: expected `async` closure body `{static main::{closure#0}::{closure#0} upvar_tys=?7t witness=?8t}`
13+
found unit type `()`
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)
This repository has been archived.