Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 13 pull requests #104428

Merged
merged 33 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e1636b8
Adding Fuchsia compiler testing script, docs
andrewpollack Nov 1, 2022
ce10ac0
remove leading newlines from `NonZero*` doc examples
Nov 13, 2022
cd2fb43
Update compiler-builtins
Ayush1325 Nov 13, 2022
409c3ce
Remove unused diagnostic items
WaffleLapkin Nov 13, 2022
4ed2bf6
Remove unused symbols
WaffleLapkin Nov 13, 2022
25acee5
Remove dead NoneError error handling
Nov 13, 2022
2575e4d
rustdoc: remove unused CSS `code { opacity: 1 }`
notriddle Nov 13, 2022
29fe28f
Fix clippy and rustdoc
WaffleLapkin Nov 13, 2022
9985f46
Clarify `expand_struct_method_body`.
nnethercote Nov 14, 2022
96280b6
Remove `addr_of` argument from `create_struct_pattern_fields`.
nnethercote Nov 14, 2022
111db7d
Remove TraitDef::generics.
nnethercote Nov 14, 2022
a9e4176
Specify language of code comment to generate document
koka831 Nov 14, 2022
e6baae5
Fix missing minification for static files
GuillaumeGomez Nov 14, 2022
212ce1f
[llvm-wrapper] adapt for LLVM API change
krasimirgg Nov 14, 2022
3f697b8
Drive-by: actual -> rcvr_ty
compiler-errors Nov 14, 2022
bf607da
Move logic into method
compiler-errors Nov 14, 2022
5497317
Do autoderef to match impl against rcvr
compiler-errors Nov 14, 2022
540e12f
Add regression test
compiler-errors Nov 14, 2022
7b00534
rustdoc: fix corner case in search keyboard commands
notriddle Nov 14, 2022
9214673
Add test for #102154
aDotInTheVoid Nov 14, 2022
98be657
Rollup merge of #103842 - andrewpollack:add-fuchsia-test-script, r=tm…
matthiaskrgr Nov 15, 2022
1b41a38
Rollup merge of #104354 - lukas-code:blank-lines-2, r=JohnTitor
matthiaskrgr Nov 15, 2022
83b6e85
Rollup merge of #104372 - Ayush1325:compiler-builtins, r=JohnTitor
matthiaskrgr Nov 15, 2022
2eee3a6
Rollup merge of #104380 - rust-lang:notriddle/code-opacity, r=Guillau…
matthiaskrgr Nov 15, 2022
0a3cb1e
Rollup merge of #104381 - mejrs:none_error, r=compiler-errors
matthiaskrgr Nov 15, 2022
2c29b05
Rollup merge of #104383 - WaffleLapkin:rustc_undiagnostic_item, r=com…
matthiaskrgr Nov 15, 2022
aea4c0c
Rollup merge of #104391 - nnethercote:deriving-cleanups, r=jackh726
matthiaskrgr Nov 15, 2022
da2beab
Rollup merge of #104403 - koka831:lint-doc, r=Dylan-DPC
matthiaskrgr Nov 15, 2022
f0978ee
Rollup merge of #104404 - GuillaumeGomez:fix-missing-minification, r=…
matthiaskrgr Nov 15, 2022
f17828d
Rollup merge of #104413 - krasimirgg:llvm-16-mref, r=nikic
matthiaskrgr Nov 15, 2022
5e753ca
Rollup merge of #104415 - notriddle:notriddle/search-keyboard-command…
matthiaskrgr Nov 15, 2022
ce263b7
Rollup merge of #104422 - compiler-errors:fix-suggest_associated_call…
matthiaskrgr Nov 15, 2022
7c7cb71
Rollup merge of #104426 - aDotInTheVoid:test-102154, r=compiler-errors
matthiaskrgr Nov 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,15 +392,7 @@ pub struct Generics {
impl Default for Generics {
/// Creates an instance of `Generics`.
fn default() -> Generics {
Generics {
params: Vec::new(),
where_clause: WhereClause {
has_where_token: false,
predicates: Vec::new(),
span: DUMMY_SP,
},
span: DUMMY_SP,
}
Generics { params: Vec::new(), where_clause: Default::default(), span: DUMMY_SP }
}
}

Expand All @@ -415,6 +407,12 @@ pub struct WhereClause {
pub span: Span,
}

impl Default for WhereClause {
fn default() -> WhereClause {
WhereClause { has_where_token: false, predicates: Vec::new(), span: DUMMY_SP }
}
}

/// A single predicate in a where-clause.
#[derive(Clone, Encodable, Decodable, Debug)]
pub enum WherePredicate {
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_builtin_macros/src/deriving/bounds.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
use crate::deriving::path_std;

Expand All @@ -19,7 +18,6 @@ pub fn expand_deriving_copy(
path: path_std!(marker::Copy),
skip_path_as_bound: false,
additional_bounds: Vec::new(),
generics: Bounds::empty(),
supports_unions: true,
methods: Vec::new(),
associated_types: Vec::new(),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/deriving/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ pub fn expand_deriving_clone(
path: path_std!(clone::Clone),
skip_path_as_bound: false,
additional_bounds: bounds,
generics: Bounds::empty(),
supports_unions: true,
methods: vec![MethodDef {
name: sym::clone,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pub fn expand_deriving_eq(
path: path_std!(cmp::Eq),
skip_path_as_bound: false,
additional_bounds: Vec::new(),
generics: Bounds::empty(),
supports_unions: true,
methods: vec![MethodDef {
name: sym::assert_receiver_is_total_eq,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub fn expand_deriving_ord(
path: path_std!(cmp::Ord),
skip_path_as_bound: false,
additional_bounds: Vec::new(),
generics: Bounds::empty(),
supports_unions: false,
methods: vec![MethodDef {
name: sym::cmp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ pub fn expand_deriving_partial_eq(
path: path_std!(cmp::PartialEq),
skip_path_as_bound: false,
additional_bounds: Vec::new(),
generics: Bounds::empty(),
supports_unions: false,
methods,
associated_types: Vec::new(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ pub fn expand_deriving_partial_ord(
path: path_std!(cmp::PartialOrd),
skip_path_as_bound: false,
additional_bounds: vec![],
generics: Bounds::empty(),
supports_unions: false,
methods: vec![partial_cmp_def],
associated_types: Vec::new(),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/deriving/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub fn expand_deriving_debug(
path: path_std!(fmt::Debug),
skip_path_as_bound: false,
additional_bounds: Vec::new(),
generics: Bounds::empty(),
supports_unions: false,
methods: vec![MethodDef {
name: sym::fmt,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/deriving/decodable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pub fn expand_deriving_rustc_decodable(
path: Path::new_(vec![krate, sym::Decodable], vec![], PathKind::Global),
skip_path_as_bound: false,
additional_bounds: Vec::new(),
generics: Bounds::empty(),
supports_unions: false,
methods: vec![MethodDef {
name: sym::decode,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/deriving/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ pub fn expand_deriving_default(
path: Path::new(vec![kw::Default, sym::Default]),
skip_path_as_bound: has_a_default_variant(item),
additional_bounds: Vec::new(),
generics: Bounds::empty(),
supports_unions: false,
methods: vec![MethodDef {
name: kw::Default,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/deriving/encodable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ pub fn expand_deriving_rustc_encodable(
path: Path::new_(vec![krate, sym::Encodable], vec![], PathKind::Global),
skip_path_as_bound: false,
additional_bounds: Vec::new(),
generics: Bounds::empty(),
supports_unions: false,
methods: vec![MethodDef {
name: sym::encode,
Expand Down
69 changes: 31 additions & 38 deletions compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,6 @@ pub struct TraitDef<'a> {
/// other than the current trait
pub additional_bounds: Vec<Ty>,

/// Any extra lifetimes and/or bounds, e.g., `D: serialize::Decoder`
pub generics: Bounds,

/// Can this trait be derived for unions?
pub supports_unions: bool,

Expand Down Expand Up @@ -583,19 +580,21 @@ impl<'a> TraitDef<'a> {
})
});

let Generics { mut params, mut where_clause, .. } =
self.generics.to_generics(cx, self.span, type_ident, generics);
let mut where_clause = ast::WhereClause::default();
where_clause.span = generics.where_clause.span;
let ctxt = self.span.ctxt();
let span = generics.span.with_ctxt(ctxt);

// Create the generic parameters
params.extend(generics.params.iter().map(|param| match &param.kind {
GenericParamKind::Lifetime { .. } => param.clone(),
GenericParamKind::Type { .. } => {
// I don't think this can be moved out of the loop, since
// a GenericBound requires an ast id
let bounds: Vec<_> =
let params: Vec<_> = generics
.params
.iter()
.map(|param| match &param.kind {
GenericParamKind::Lifetime { .. } => param.clone(),
GenericParamKind::Type { .. } => {
// I don't think this can be moved out of the loop, since
// a GenericBound requires an ast id
let bounds: Vec<_> =
// extra restrictions on the generics parameters to the
// type being derived upon
self.additional_bounds.iter().map(|p| {
Expand All @@ -608,21 +607,22 @@ impl<'a> TraitDef<'a> {
param.bounds.iter().cloned()
).collect();

cx.typaram(param.ident.span.with_ctxt(ctxt), param.ident, bounds, None)
}
GenericParamKind::Const { ty, kw_span, .. } => {
let const_nodefault_kind = GenericParamKind::Const {
ty: ty.clone(),
kw_span: kw_span.with_ctxt(ctxt),

// We can't have default values inside impl block
default: None,
};
let mut param_clone = param.clone();
param_clone.kind = const_nodefault_kind;
param_clone
}
}));
cx.typaram(param.ident.span.with_ctxt(ctxt), param.ident, bounds, None)
}
GenericParamKind::Const { ty, kw_span, .. } => {
let const_nodefault_kind = GenericParamKind::Const {
ty: ty.clone(),
kw_span: kw_span.with_ctxt(ctxt),

// We can't have default values inside impl block
default: None,
};
let mut param_clone = param.clone();
param_clone.kind = const_nodefault_kind;
param_clone
}
})
.collect();

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

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

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

let addr_of = false; // because enums can't be repr(packed)
let fields =
trait_.create_struct_pattern_fields(cx, &variant.data, &prefixes, addr_of);
let fields = trait_.create_struct_pattern_fields(cx, &variant.data, &prefixes);

let sp = variant.span.with_ctxt(trait_.span.ctxt());
let variant_path = cx.path(sp, vec![type_ident, variant.ident]);
Expand Down Expand Up @@ -1519,15 +1514,13 @@ impl<'a> TraitDef<'a> {
cx: &mut ExtCtxt<'_>,
struct_def: &'a VariantData,
prefixes: &[String],
addr_of: bool,
) -> Vec<FieldInfo> {
self.create_fields(struct_def, |i, _struct_field, sp| {
prefixes
.iter()
.map(|prefix| {
let ident = self.mk_pattern_ident(prefix, i);
let expr = cx.expr_path(cx.path_ident(sp, ident));
if addr_of { cx.expr_addr_of(sp, expr) } else { expr }
cx.expr_path(cx.path_ident(sp, ident))
})
.collect()
})
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/deriving/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pub fn expand_deriving_hash(
path,
skip_path_as_bound: false,
additional_bounds: Vec::new(),
generics: Bounds::empty(),
supports_unions: false,
methods: vec![MethodDef {
name: sym::hash,
Expand Down
Loading