Skip to content

Commit ca92d90

Browse files
committed
Auto merge of #104428 - matthiaskrgr:rollup-jo3078i, r=matthiaskrgr
Rollup of 13 pull requests Successful merges: - #103842 (Adding Fuchsia compiler testing script, docs) - #104354 (Remove leading newlines from `NonZero*` doc examples) - #104372 (Update compiler-builtins) - #104380 (rustdoc: remove unused CSS `code { opacity: 1 }`) - #104381 (Remove dead NoneError diagnostic handling) - #104383 (Remove unused symbols and diagnostic items) - #104391 (Deriving cleanups) - #104403 (Specify language of code comment to generate document) - #104404 (Fix missing minification for static files) - #104413 ([llvm-wrapper] adapt for LLVM API change) - #104415 (rustdoc: fix corner case in search keyboard commands) - #104422 (Fix suggest associated call syntax) - #104426 (Add test for #102154) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 101e182 + 7c7cb71 commit ca92d90

File tree

38 files changed

+1445
-350
lines changed

38 files changed

+1445
-350
lines changed

compiler/rustc_ast/src/ast.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -392,15 +392,7 @@ pub struct Generics {
392392
impl Default for Generics {
393393
/// Creates an instance of `Generics`.
394394
fn default() -> Generics {
395-
Generics {
396-
params: Vec::new(),
397-
where_clause: WhereClause {
398-
has_where_token: false,
399-
predicates: Vec::new(),
400-
span: DUMMY_SP,
401-
},
402-
span: DUMMY_SP,
403-
}
395+
Generics { params: Vec::new(), where_clause: Default::default(), span: DUMMY_SP }
404396
}
405397
}
406398

@@ -415,6 +407,12 @@ pub struct WhereClause {
415407
pub span: Span,
416408
}
417409

410+
impl Default for WhereClause {
411+
fn default() -> WhereClause {
412+
WhereClause { has_where_token: false, predicates: Vec::new(), span: DUMMY_SP }
413+
}
414+
}
415+
418416
/// A single predicate in a where-clause.
419417
#[derive(Clone, Encodable, Decodable, Debug)]
420418
pub enum WherePredicate {

compiler/rustc_builtin_macros/src/deriving/bounds.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::deriving::generic::ty::*;
21
use crate::deriving::generic::*;
32
use crate::deriving::path_std;
43

@@ -19,7 +18,6 @@ pub fn expand_deriving_copy(
1918
path: path_std!(marker::Copy),
2019
skip_path_as_bound: false,
2120
additional_bounds: Vec::new(),
22-
generics: Bounds::empty(),
2321
supports_unions: true,
2422
methods: Vec::new(),
2523
associated_types: Vec::new(),

compiler/rustc_builtin_macros/src/deriving/clone.rs

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ pub fn expand_deriving_clone(
7575
path: path_std!(clone::Clone),
7676
skip_path_as_bound: false,
7777
additional_bounds: bounds,
78-
generics: Bounds::empty(),
7978
supports_unions: true,
8079
methods: vec![MethodDef {
8180
name: sym::clone,

compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ pub fn expand_deriving_eq(
2828
path: path_std!(cmp::Eq),
2929
skip_path_as_bound: false,
3030
additional_bounds: Vec::new(),
31-
generics: Bounds::empty(),
3231
supports_unions: true,
3332
methods: vec![MethodDef {
3433
name: sym::assert_receiver_is_total_eq,

compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub fn expand_deriving_ord(
2222
path: path_std!(cmp::Ord),
2323
skip_path_as_bound: false,
2424
additional_bounds: Vec::new(),
25-
generics: Bounds::empty(),
2625
supports_unions: false,
2726
methods: vec![MethodDef {
2827
name: sym::cmp,

compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ pub fn expand_deriving_partial_eq(
8686
path: path_std!(cmp::PartialEq),
8787
skip_path_as_bound: false,
8888
additional_bounds: Vec::new(),
89-
generics: Bounds::empty(),
9089
supports_unions: false,
9190
methods,
9291
associated_types: Vec::new(),

compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ pub fn expand_deriving_partial_ord(
4040
path: path_std!(cmp::PartialOrd),
4141
skip_path_as_bound: false,
4242
additional_bounds: vec![],
43-
generics: Bounds::empty(),
4443
supports_unions: false,
4544
methods: vec![partial_cmp_def],
4645
associated_types: Vec::new(),

compiler/rustc_builtin_macros/src/deriving/debug.rs

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ pub fn expand_deriving_debug(
2323
path: path_std!(fmt::Debug),
2424
skip_path_as_bound: false,
2525
additional_bounds: Vec::new(),
26-
generics: Bounds::empty(),
2726
supports_unions: false,
2827
methods: vec![MethodDef {
2928
name: sym::fmt,

compiler/rustc_builtin_macros/src/deriving/decodable.rs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ pub fn expand_deriving_rustc_decodable(
2626
path: Path::new_(vec![krate, sym::Decodable], vec![], PathKind::Global),
2727
skip_path_as_bound: false,
2828
additional_bounds: Vec::new(),
29-
generics: Bounds::empty(),
3029
supports_unions: false,
3130
methods: vec![MethodDef {
3231
name: sym::decode,

compiler/rustc_builtin_macros/src/deriving/default.rs

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ pub fn expand_deriving_default(
2727
path: Path::new(vec![kw::Default, sym::Default]),
2828
skip_path_as_bound: has_a_default_variant(item),
2929
additional_bounds: Vec::new(),
30-
generics: Bounds::empty(),
3130
supports_unions: false,
3231
methods: vec![MethodDef {
3332
name: kw::Default,

compiler/rustc_builtin_macros/src/deriving/encodable.rs

-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ pub fn expand_deriving_rustc_encodable(
110110
path: Path::new_(vec![krate, sym::Encodable], vec![], PathKind::Global),
111111
skip_path_as_bound: false,
112112
additional_bounds: Vec::new(),
113-
generics: Bounds::empty(),
114113
supports_unions: false,
115114
methods: vec![MethodDef {
116115
name: sym::encode,

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+31-38
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,6 @@ pub struct TraitDef<'a> {
195195
/// other than the current trait
196196
pub additional_bounds: Vec<Ty>,
197197

198-
/// Any extra lifetimes and/or bounds, e.g., `D: serialize::Decoder`
199-
pub generics: Bounds,
200-
201198
/// Can this trait be derived for unions?
202199
pub supports_unions: bool,
203200

@@ -583,19 +580,21 @@ impl<'a> TraitDef<'a> {
583580
})
584581
});
585582

586-
let Generics { mut params, mut where_clause, .. } =
587-
self.generics.to_generics(cx, self.span, type_ident, generics);
583+
let mut where_clause = ast::WhereClause::default();
588584
where_clause.span = generics.where_clause.span;
589585
let ctxt = self.span.ctxt();
590586
let span = generics.span.with_ctxt(ctxt);
591587

592588
// Create the generic parameters
593-
params.extend(generics.params.iter().map(|param| match &param.kind {
594-
GenericParamKind::Lifetime { .. } => param.clone(),
595-
GenericParamKind::Type { .. } => {
596-
// I don't think this can be moved out of the loop, since
597-
// a GenericBound requires an ast id
598-
let bounds: Vec<_> =
589+
let params: Vec<_> = generics
590+
.params
591+
.iter()
592+
.map(|param| match &param.kind {
593+
GenericParamKind::Lifetime { .. } => param.clone(),
594+
GenericParamKind::Type { .. } => {
595+
// I don't think this can be moved out of the loop, since
596+
// a GenericBound requires an ast id
597+
let bounds: Vec<_> =
599598
// extra restrictions on the generics parameters to the
600599
// type being derived upon
601600
self.additional_bounds.iter().map(|p| {
@@ -608,21 +607,22 @@ impl<'a> TraitDef<'a> {
608607
param.bounds.iter().cloned()
609608
).collect();
610609

611-
cx.typaram(param.ident.span.with_ctxt(ctxt), param.ident, bounds, None)
612-
}
613-
GenericParamKind::Const { ty, kw_span, .. } => {
614-
let const_nodefault_kind = GenericParamKind::Const {
615-
ty: ty.clone(),
616-
kw_span: kw_span.with_ctxt(ctxt),
617-
618-
// We can't have default values inside impl block
619-
default: None,
620-
};
621-
let mut param_clone = param.clone();
622-
param_clone.kind = const_nodefault_kind;
623-
param_clone
624-
}
625-
}));
610+
cx.typaram(param.ident.span.with_ctxt(ctxt), param.ident, bounds, None)
611+
}
612+
GenericParamKind::Const { ty, kw_span, .. } => {
613+
let const_nodefault_kind = GenericParamKind::Const {
614+
ty: ty.clone(),
615+
kw_span: kw_span.with_ctxt(ctxt),
616+
617+
// We can't have default values inside impl block
618+
default: None,
619+
};
620+
let mut param_clone = param.clone();
621+
param_clone.kind = const_nodefault_kind;
622+
param_clone
623+
}
624+
})
625+
.collect();
626626

627627
// and similarly for where clauses
628628
where_clause.predicates.extend(generics.where_clause.predicates.iter().map(|clause| {
@@ -1062,18 +1062,15 @@ impl<'a> MethodDef<'a> {
10621062
trait_.create_struct_field_access_fields(cx, selflike_args, struct_def, true);
10631063
mk_body(cx, selflike_fields)
10641064
} else {
1065-
// Neither packed nor copy. Need to use ref patterns.
1065+
// Packed and not copy. Need to use ref patterns.
10661066
let prefixes: Vec<_> =
10671067
(0..selflike_args.len()).map(|i| format!("__self_{}", i)).collect();
1068-
let addr_of = always_copy;
1069-
let selflike_fields =
1070-
trait_.create_struct_pattern_fields(cx, struct_def, &prefixes, addr_of);
1068+
let selflike_fields = trait_.create_struct_pattern_fields(cx, struct_def, &prefixes);
10711069
let mut body = mk_body(cx, selflike_fields);
10721070

10731071
let struct_path = cx.path(span, vec![Ident::new(kw::SelfUpper, type_ident.span)]);
1074-
let by_ref = ByRef::from(is_packed && !always_copy);
10751072
let patterns =
1076-
trait_.create_struct_patterns(cx, struct_path, struct_def, &prefixes, by_ref);
1073+
trait_.create_struct_patterns(cx, struct_path, struct_def, &prefixes, ByRef::Yes);
10771074

10781075
// Do the let-destructuring.
10791076
let mut stmts: Vec<_> = iter::zip(selflike_args, patterns)
@@ -1254,9 +1251,7 @@ impl<'a> MethodDef<'a> {
12541251
// A single arm has form (&VariantK, &VariantK, ...) => BodyK
12551252
// (see "Final wrinkle" note below for why.)
12561253

1257-
let addr_of = false; // because enums can't be repr(packed)
1258-
let fields =
1259-
trait_.create_struct_pattern_fields(cx, &variant.data, &prefixes, addr_of);
1254+
let fields = trait_.create_struct_pattern_fields(cx, &variant.data, &prefixes);
12601255

12611256
let sp = variant.span.with_ctxt(trait_.span.ctxt());
12621257
let variant_path = cx.path(sp, vec![type_ident, variant.ident]);
@@ -1519,15 +1514,13 @@ impl<'a> TraitDef<'a> {
15191514
cx: &mut ExtCtxt<'_>,
15201515
struct_def: &'a VariantData,
15211516
prefixes: &[String],
1522-
addr_of: bool,
15231517
) -> Vec<FieldInfo> {
15241518
self.create_fields(struct_def, |i, _struct_field, sp| {
15251519
prefixes
15261520
.iter()
15271521
.map(|prefix| {
15281522
let ident = self.mk_pattern_ident(prefix, i);
1529-
let expr = cx.expr_path(cx.path_ident(sp, ident));
1530-
if addr_of { cx.expr_addr_of(sp, expr) } else { expr }
1523+
cx.expr_path(cx.path_ident(sp, ident))
15311524
})
15321525
.collect()
15331526
})

compiler/rustc_builtin_macros/src/deriving/hash.rs

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ pub fn expand_deriving_hash(
2525
path,
2626
skip_path_as_bound: false,
2727
additional_bounds: Vec::new(),
28-
generics: Bounds::empty(),
2928
supports_unions: false,
3029
methods: vec![MethodDef {
3130
name: sym::hash,

0 commit comments

Comments
 (0)