Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 85caa3e

Browse files
committedMar 10, 2020
Auto merge of #69884 - Centril:rollup-ecbbb1l, r=Centril
Rollup of 6 pull requests Successful merges: - #69122 (Backtrace Debug tweaks) - #69591 (Use TypeRelating for instantiating query responses) - #69760 (Improve expression & attribute parsing) - #69837 (Use smaller discriminants for generators) - #69838 (Expansion-driven outline module parsing) - #69859 (fix #62456) Failed merges: r? @ghost
2 parents 1581278 + 5d10555 commit 85caa3e

File tree

102 files changed

+1850
-1006
lines changed

Some content is hidden

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

102 files changed

+1850
-1006
lines changed
 

‎src/librustc/ty/layout.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -1409,12 +1409,15 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
14091409
// locals as part of the prefix. We compute the layout of all of
14101410
// these fields at once to get optimal packing.
14111411
let discr_index = substs.as_generator().prefix_tys(def_id, tcx).count();
1412-
// FIXME(eddyb) set the correct vaidity range for the discriminant.
1413-
let discr_layout = self.layout_of(substs.as_generator().discr_ty(tcx))?;
1414-
let discr = match &discr_layout.abi {
1415-
Abi::Scalar(s) => s.clone(),
1416-
_ => bug!(),
1417-
};
1412+
1413+
// `info.variant_fields` already accounts for the reserved variants, so no need to add them.
1414+
let max_discr = (info.variant_fields.len() - 1) as u128;
1415+
let discr_int = Integer::fit_unsigned(max_discr);
1416+
let discr_int_ty = discr_int.to_ty(tcx, false);
1417+
let discr = Scalar { value: Primitive::Int(discr_int, false), valid_range: 0..=max_discr };
1418+
let discr_layout = self.tcx.intern_layout(LayoutDetails::scalar(self, discr.clone()));
1419+
let discr_layout = TyLayout { ty: discr_int_ty, details: discr_layout };
1420+
14181421
let promoted_layouts = ineligible_locals
14191422
.iter()
14201423
.map(|local| subst_field(info.field_tys[local]))

‎src/librustc_ast/ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2153,7 +2153,7 @@ impl FnRetTy {
21532153
/// Module declaration.
21542154
///
21552155
/// E.g., `mod foo;` or `mod foo { .. }`.
2156-
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
2156+
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Default)]
21572157
pub struct Mod {
21582158
/// A span from the first token past `{` to the last token until `}`.
21592159
/// For `mod foo;`, the inner span ranges from the first token

0 commit comments

Comments
 (0)
Please sign in to comment.