// Field 5 would be the first element, so memory_index is i:
// Note: if we didn't optimize, it's already right.
- let memory_index;
- if optimize {
- memory_index = invert_mapping(&inverse_memory_index);
- } else {
- memory_index = inverse_memory_index;
- }
+ let memory_index =
+ if optimize { invert_mapping(&inverse_memory_index) } else { inverse_memory_index };
let size = min_size.align_to(align.abi);
let mut abi = Abi::Aggregate { sized };
let offset = st[i].fields.offset(field_index) + niche.offset;
let size = st[i].size;
- let mut abi = match st[i].abi {
- Abi::Scalar(_) => Abi::Scalar(niche_scalar.clone()),
- Abi::ScalarPair(ref first, ref second) => {
- // We need to use scalar_unit to reset the
- // valid range to the maximal one for that
- // primitive, because only the niche is
- // guaranteed to be initialised, not the
- // other primitive.
- if offset.bytes() == 0 {
- Abi::ScalarPair(
- niche_scalar.clone(),
- scalar_unit(second.value),
- )
- } else {
- Abi::ScalarPair(
- scalar_unit(first.value),
- niche_scalar.clone(),
- )
+ let abi = if st.iter().all(|v| v.abi.is_uninhabited()) {
+ Abi::Uninhabited
+ } else {
+ match st[i].abi {
+ Abi::Scalar(_) => Abi::Scalar(niche_scalar.clone()),
+ Abi::ScalarPair(ref first, ref second) => {
+ // We need to use scalar_unit to reset the
+ // valid range to the maximal one for that
+ // primitive, because only the niche is
+ // guaranteed to be initialised, not the
+ // other primitive.
+ if offset.bytes() == 0 {
+ Abi::ScalarPair(
+ niche_scalar.clone(),
+ scalar_unit(second.value),
+ )
+ } else {
+ Abi::ScalarPair(
+ scalar_unit(first.value),
+ niche_scalar.clone(),
+ )
+ }
}
+ _ => Abi::Aggregate { sized: true },
}
- _ => Abi::Aggregate { sized: true },
};
- if st.iter().all(|v| v.abi.is_uninhabited()) {
- abi = Abi::Uninhabited;
- }
-
let largest_niche =
Niche::from_scalar(dl, offset, niche_scalar.clone());
{
if pat_snippet.starts_with('&') {
let pat_snippet = pat_snippet[1..].trim_start();
- let suggestion;
- let to_remove;
- if pat_snippet.starts_with("mut")
+ let (suggestion, to_remove) = if pat_snippet.starts_with("mut")
&& pat_snippet["mut".len()..].starts_with(rustc_lexer::is_whitespace)
{
- suggestion = pat_snippet["mut".len()..].trim_start();
- to_remove = "&mut";
+ (pat_snippet["mut".len()..].trim_start(), "&mut")
} else {
- suggestion = pat_snippet;
- to_remove = "&";
- }
+ (pat_snippet, "&")
+ };
suggestions.push((pat_span, to_remove, suggestion.to_owned()));
}
}
);
assert_eq!(block, builder.return_block());
- let mut spread_arg = None;
- if abi == Abi::RustCall {
+ let spread_arg = if abi == Abi::RustCall {
// RustCall pseudo-ABI untuples the last argument.
- spread_arg = Some(Local::new(arguments.len()));
- }
+ Some(Local::new(arguments.len()))
+ } else {
+ None
+ };
debug!("fn_id {:?} has attrs {:?}", fn_def_id, tcx.get_attrs(fn_def_id));
let mut body = builder.finish();
// If this is a tuple or unit struct, define a name
// in the value namespace as well.
if let Some(ctor_node_id) = vdata.ctor_id() {
- let mut ctor_vis = vis;
// If the structure is marked as non_exhaustive then lower the visibility
// to within the crate.
- if vis == ty::Visibility::Public
+ let mut ctor_vis = if vis == ty::Visibility::Public
&& attr::contains_name(&item.attrs, sym::non_exhaustive)
{
- ctor_vis = ty::Visibility::Restricted(DefId::local(CRATE_DEF_INDEX));
- }
+ ty::Visibility::Restricted(DefId::local(CRATE_DEF_INDEX))
+ } else {
+ vis
+ };
+
for field in vdata.fields() {
// NOTE: The field may be an expansion placeholder, but expansion sets
// correct visibilities for unnamed field placeholders specifically, so the
visit::$walk(self, node);
}
}
- }
+ };
}
impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {