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

Can't compile huge struct #81278

Closed
dylan-bowker opened this issue Jan 22, 2021 · 8 comments
Closed

Can't compile huge struct #81278

dylan-bowker opened this issue Jan 22, 2021 · 8 comments
Labels
A-incr-comp Area: Incremental compilation A-layout Area: Memory layout of types C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dylan-bowker
Copy link

Code

use chrono::NaiveDateTime;
use rust_decimal::Decimal;
use serde::{Deserialize, Serialize};

/// A trip is a combination of two or more consecutive loads handled by one
/// carrier, usually using the same equipment. A booking will group one ore more
/// ocean containers (modeled as loads) that are being handled by an ocean
/// carrier where all containers on the booking must travel on the same vessel
/// sailing.

#[derive(Clone, Debug, PartialEq, PartialOrd, Deserialize, Serialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub struct Trip {
    /// Trip/Booking ID system-assigned ID
    pub trip_id: Decimal,
    /// Optimistic Lock Not in reporting view
    pub opt_lck: Decimal,
    /// Eligible for Trip/Booking Continuation - Current
    pub elgb_cnts_mv_yn: String,
    /// Freight Terms
    pub carr_pymt_terms_enu: Decimal,
    /// Number of Loads
    pub tot_ld_leg: Decimal,
    /// Number of Commodity Hard Committed Loads
    pub num_cdty_cmtd_lds: Decimal,
    /// Commodity Hard Committed
    pub cdty_cmtd_yn: String,
    /// Number of Carrier Hard Committed Loads
    pub num_carr_cmtd_lds: Decimal,
    /// Carrier Hard Committed
    pub carr_cmtd_yn: String,
    /// Service Hard Committed
    pub srvc_cmtd_yn: String,
    /// Number of Service Hard Committed Loads
    pub num_srvc_cmtd_lds: Decimal,
    /// Rating Valid
    pub ratg_vlid_yn: String,
    /// Maximum Number of Shipments
    pub max_num_shpm: Decimal,
    /// Number of Stops
    pub num_stop: Decimal,
    /// Created Date/Time In time zone of system
    pub crtd_dtt: NaiveDateTime,
    /// Logistics Group
    pub lgst_grp_cd: String,
    /// Operational Status Domain 376 used for filtering
    pub cur_optlstat_id: Decimal,
    /// Financial Status Domain 362 used for filtering
    pub cur_fnclstat_id: Decimal,
    /// Far Point Load ID
    pub far_pnt_ld_id: Option<Decimal>,
    /// Trip Started Date/Time (First Load Shipped) In time zone of first
    /// location
    pub trip_strd_dtt: Option<NaiveDateTime>,
    /// Rating - Currency
    pub cncy_typ: Option<Decimal>,
    /// Rating - Exchange Rate
    pub echg_rate_prce: Option<Decimal>,
    /// Rating - Cost Center
    pub cost_ctr_typ: Option<Decimal>,
    /// Direct Distance In system distance UOM
    pub drct_dist: Option<Decimal>,
    /// Out of Route Distance In system distance UOM
    pub outofrout_dist: Option<Decimal>,
    /// Loaded Distance In system distance UOM
    pub ldd_dist: Option<Decimal>,
    /// Maximum Unloaded Direct Distance Between Loads In system distance UOM
    pub lnst_unldd_leg_dist: Option<Decimal>,
    /// Return to Origin Distance In system distance UOM
    pub ret_to_orig_dist: Option<Decimal>,
    /// Total Distance In system distance UOM
    pub tot_dist: Option<Decimal>,
    /// Unloaded Distance In system distance UOM
    pub tot_unldd_dist: Option<Decimal>,
    /// In Transit Unloaded Direct Distance In system distance UOM
    pub in_tnst_unldd_dist: Option<Decimal>,
    /// Origin Location Type
    pub frst_shpgpnt_enu: Option<Decimal>,
    /// Origin Location ID
    pub frst_shpg_loc_cd: Option<String>,
    /// Origin Country
    pub frst_ctry_cd: Option<String>,
    /// Origin State/Province
    pub frst_sta_cd: Option<String>,
    /// Origin City
    pub frst_cty_name: Option<String>,
    /// Origin Zip/Postal Code
    pub frst_pstl_cd: Option<String>,
    /// Destination Location Type
    pub last_shpgpnt_enu: Option<Decimal>,
    /// Destination Location ID
    pub last_shpg_loc_cd: Option<String>,
    /// Destination Country
    pub last_ctry_cd: Option<String>,
    /// Destination State/Province
    pub last_sta_cd: Option<String>,
    /// Destination City
    pub last_cty_name: Option<String>,
    /// Destination Zip/Postal Code
    pub last_pstl_cd: Option<String>,
    /// Hours - Elapsed
    pub elpd_hrs: Option<Decimal>,
    /// Hours - Maximum Waiting at a Stop
    pub max_wait_at_stop_hrs: Option<Decimal>,
    /// Hours - Maximum Waiting Between Loads
    pub max_wait_btwn_lds_hrs: Option<Decimal>,
    /// Suspend Reason
    pub sus_rsn_enu: Option<Decimal>,
    /// Far Point Stop ID
    pub far_pnt_stop_id: Option<Decimal>,
    /// Number of Shipments
    pub tot_num_shpm: Option<Decimal>,
    /// Last Updated Date/Time In time zone of system
    pub updt_dtt: Option<NaiveDateTime>,
    /// Scheduled Date/Time In time zone of first location
    pub scdd_dtt: Option<NaiveDateTime>,
    /// Rate Code
    pub rate_id: Option<String>,
    /// Rating - Rate Code Tariff Number
    pub rate_cd_tff_id: Option<Decimal>,
    /// Service ID
    pub srvc_cd: Option<String>,
    /// Tariff Number
    pub tff_id: Option<Decimal>,
    /// Created By User ID
    pub crtd_usr_cd: Option<String>,
    /// Last Updated By User ID
    pub updt_usr_cd: Option<String>,
    /// Division
    pub div_cd: Option<String>,
    /// Memo ID
    pub mmo_id: Option<Decimal>,
    /// Reference Number Qualifier ID
    pub rfrc_num_qlfr_id: Option<Decimal>,
    /// Commodity Code
    pub cdty_cd: Option<String>,
    /// Load Plan ID
    pub plan_id: Option<Decimal>,
    /// Carrier ID
    pub carr_cd: Option<String>,
    /// A/P Voucher Run Exception ID
    pub vchr_run_excp_ap_id: Option<Decimal>,
    /// Optimization Queue ID
    pub opmr_que_id: Option<Decimal>,
    /// Customer ID
    pub cust_cd: Option<String>,
    /// Bill To Customer ID
    pub bill_to_cust_cd: Option<String>,
    /// Lane Association ID
    pub rout_lane_id: Option<Decimal>,
    /// Rating - UOM (Imperial vs. Metric)
    pub umsrsys_enu: Option<Decimal>,
    /// Rating - Weight UOM
    pub umsrwgt_enu: Option<Decimal>,
    /// Rating - Length UOM
    pub umsrlen_enu: Option<Decimal>,
    /// Rating - Distance UOM
    pub umsrdist_enu: Option<Decimal>,
    /// Maximum Scaled Weight In system weight UOM
    pub max_scld_wgt: Option<Decimal>,
    /// Maximum Volume in system volume UOM
    pub max_vol: Option<Decimal>,
    /// Maximum Order Value In base system currency
    pub max_odr_val_dlr: Option<Decimal>,
    /// Maximum Declared Value In base system currency
    pub max_dcld_val_dlr: Option<Decimal>,
    /// Maximum Nominal Weight In system weight UOM
    pub max_nmnl_wgt: Option<Decimal>,
    /// Maximum Tare Weight In system weight UOM
    pub max_tot_tare_wgt: Option<Decimal>,
    /// Maximum Number of Pieces
    pub max_tot_pce: Option<f64>,
    /// Maximum Number of Pallets
    pub max_tot_skid: Option<f64>,
    /// Maximum Laden Length In system length UOM
    pub max_ldn_len: Option<Decimal>,
    /// Scaled Weight In system weight UOM
    pub tot_scld_wgt: Option<Decimal>,
    /// Volume in system volume UOM
    pub tot_vol: Option<Decimal>,
    /// Order Value In base system currency
    pub tot_odr_val_dlr: Option<Decimal>,
    /// Declared Value In base system currency
    pub tot_dcld_val_dlr: Option<Decimal>,
    /// Nominal Weight In system weight UOM
    pub tot_nmnl_wgt: Option<Decimal>,
    /// Tare Weight In system weight UOM
    pub tot_tot_tare_wgt: Option<Decimal>,
    /// Number of Pieces
    pub tot_tot_pce: Option<f64>,
    /// Number of Pallets
    pub tot_tot_skid: Option<f64>,
    /// Laden Length In system length UOM
    pub tot_ldn_len: Option<Decimal>,
    /// Current Operational Status
    pub cur_optl_stat_id: Option<Decimal>,
    /// Current Financial Status
    pub cur_fncl_stat_id: Option<Decimal>,
    /// Rating - Rate Shop Reason
    pub rshp_rsn_cd_typ: Option<Decimal>,
    /// Entries in Operational Transition Movement List
    pub op_lst_non_emty_yn: String,
    /// Hours - Driving
    pub driving_hrs: Option<Decimal>,
    /// Hours - Waiting
    pub tot_waiting_hrs: Option<Decimal>,
    /// Hours - On Duty
    pub on_duty_hrs: Option<Decimal>,
    /// Hours - Off Duty
    pub off_duty_hrs: Option<Decimal>,
    /// Hours - Loading
    pub loading_hrs: Option<Decimal>,
    /// Hours - Unloading
    pub unloading_hrs: Option<Decimal>,
    /// Origin Location Name
    pub frst_shpg_loc_name: Option<String>,
    /// Destination Location Name
    pub last_shpg_loc_name: Option<String>,
    /// Number of Soft Committed Loads
    pub num_carr_soft_cmtd_lds: f64,
    /// Number of Loads with Commitment Overridden
    pub num_srvc_soft_cmtd_lds: Option<f64>,
    /// Number of Primary Stops
    pub num_pmy_stop: f64,
    /// Distance Engine ID
    pub extl_egin_ver_cd: Option<String>,
    /// Last Rated Tariff Number
    pub last_ratd_tff_id: Option<Decimal>,
    /// Weekend / Holiday Break Time
    pub wknd_hldy_hrs: Option<Decimal>,
    /// Scheduling Active
    pub schd_actv_yn: String,
    /// First Address ID
    pub frst_addr_id: Option<Decimal>,
    /// Last Address ID
    pub last_addr_id: Option<Decimal>,
    /// Shipment Consolidation Class
    pub csld_cls: Option<String>,
    /// Tractor Domicile ID
    pub dmcl_cd_trctr: Option<String>,
    /// Tractor Domicile Hard Committed
    pub dmcl_trctr_cmtd_yn: String,
    /// Tractor Equipment Type Committed
    pub eqmt_trctr_cmtd_yn: String,
    /// Tractor Equipment Type ID
    pub eqmt_typ_cd_trctr: Option<String>,
    /// Number of Tractor Domicile Hard Committed Loads
    pub num_dmcl_trctr_cmtd_lds: Option<f64>,
    /// Number of Tractor Equipment Type Hard Committed Loads
    pub num_eqmt_trctr_cmtd_lds: Option<f64>,
    /// Repositioning Distance
    pub tot_reps_dist: Option<Decimal>,
    /// In Transit Unloaded Distance
    pub in_tnst_unldd_tot_dist: Option<Decimal>,
    /// Unloaded Distance (No Trailer)
    pub trctr_unldd_dist: Option<Decimal>,
    /// Tender Request ID
    pub tdr_req_id: Option<Decimal>,
    /// Extended Weight/Distance
    pub wgt_dist_extd: Option<Decimal>,
    /// Trip Savings Amount Computed
    pub trip_mrgn_yn: String,
    /// Trip Savings Amount
    pub trip_mrgn_dlr: Option<Decimal>,
    /// Trip Savings Percentage
    pub trip_mrgn_pct: Option<Decimal>,
    /// Trip Savings per Hour
    pub trip_mrgn_per_hour_dlr: Option<Decimal>,
    /// Total Individual Load Costs
    pub tot_ld_cost_dlr: Option<Decimal>,
    /// Effective Rating Date Populated by Rating
    pub efct_ratg_dt: Option<NaiveDateTime>,
    /// Reference Number
    pub rfrc_num: Option<String>,
    /// Reference Number ID
    pub rfrc_num_id: Option<Decimal>,
    /// Booking Transit Mode
    pub tnst_md_enu: Decimal,
    /// Vessel Arrival Date/Time In time zone of vessel arrival location
    pub vesl_arvl_dtt: Option<NaiveDateTime>,
    /// Vessel Departure Date/Time In time zone of vessel departure location
    pub vesl_dptr_dtt: Option<NaiveDateTime>,
    /// Vessel
    pub vesl: Option<String>,
    /// Voyage Number
    pub voyg_num: Option<String>,
    /// Booking Service Type
    pub bkg_srvc_typ_enu: Decimal,
    /// Vessel Departure Location ID
    pub dptr_shpg_loc_cd: Option<String>,
    /// Vessel Arrival Location ID
    pub arvl_shpg_loc_cd: Option<String>,
    /// Vessel Departure Location Type
    pub dptr_shpgpnt_enu: Decimal,
    /// Vessel Arrival Location Type
    pub arvl_shpgpnt_enu: Decimal,
    /// Shipping Instruction Date/Time In time zone of vessel departure location
    pub shpg_inst_dtt: Option<NaiveDateTime>,
    /// Container Yard Date/Time In time zone of vessel departure location
    pub cntr_yard_dtt: Option<NaiveDateTime>,
    /// Latest In-Gate Date/Time In time zone of vessel departure location
    pub ltst_ingt_dtt: Option<NaiveDateTime>,
    /// Trip Entity Type
    pub trip_typ_enu: Decimal,
    /// Reference Number 1
    pub rfrc_num1: Option<String>,
    /// Reference Number 2
    pub rfrc_num2: Option<String>,
    /// Reference Number 3
    pub rfrc_num3: Option<String>,
    /// Reference Number 4
    pub rfrc_num4: Option<String>,
    /// Reference Number 5
    pub rfrc_num5: Option<String>,
    /// Reference Number 6
    pub rfrc_num6: Option<String>,
    /// Reference Number 7
    pub rfrc_num7: Option<String>,
    /// Reference Number 8
    pub rfrc_num8: Option<String>,
    /// Reference Number 9
    pub rfrc_num9: Option<String>,
    /// Reference Number 10
    pub rfrc_num10: Option<String>,
    /// Reference Number 11
    pub rfrc_num11: Option<String>,
    /// Reference Number 12
    pub rfrc_num12: Option<String>,
    /// Reference Number 13
    pub rfrc_num13: Option<String>,
    /// Reference Number 14
    pub rfrc_num14: Option<String>,
    /// Reference Number 15
    pub rfrc_num15: Option<String>,
    /// Reference Number 16
    pub rfrc_num16: Option<String>,
    /// Reference Number 17
    pub rfrc_num17: Option<String>,
    /// Reference Number 18
    pub rfrc_num18: Option<String>,
    /// Reference Number 19
    pub rfrc_num19: Option<String>,
    /// Reference Number 20
    pub rfrc_num20: Option<String>,
    /// Reference Number Visibility Configuration Version ID
    pub rfrc_num_vbty_id: Option<Decimal>,
    /// Number of Primary Schedule Hard Committed Loads
    pub num_pmy_schd_cmtd_lds: Decimal,
    /// Primary Schedule Hard Committed
    pub pmy_schd_cmtd_yn: String,
    /// Trip/Booking Source
    pub src_enu: f64,
    /// Eligible for Trip/Booking Continuation - Override
    pub elgb_cnts_mv_enu: Decimal,
    /// Related Vessel
    pub rlat_vesl: Option<String>,
    /// Related Voyage Number
    pub rlat_voyg_num: Option<String>,
    /// Related Vessel Departure Date/Time In time zone of related departure location
    pub rlat_vesl_dptr_dtt: Option<NaiveDateTime>,
    /// Related Vessel Departure Location ID
    pub rlat_dptr_shpg_loc_cd: Option<String>,
    /// Related Vessel Departure Location Type
    pub rlat_dptr_shpgpnt_enu: Decimal,
    /// Apply Resource Constraints Default: 'T'
    pub aply_rsrc_cstr_yn: String,
    /// Include In Resource Usage Count Default: 'T'
    pub incl_rsrc_usg_cnt_yn: String,
    /// First Tender Issued Default: 'F'
    pub frst_tdr_isud_yn: String,
    /// Resource Project ID Default: 0
    pub rsrc_prj_typ: f64,
    /// TP Information
    pub tp_adtn_info: Option<String>,
    /// Booking Revision in Process Default: 'F'
    pub bkg_rvi_proc_yn: String,
    /// Gross Rated Amount Default: 0
    pub tot_sys_calc_amt_dlr: Decimal,
    /// Surcharge/Discount Default: 0
    pub tot_dsct_amt_dlr: Decimal,
    /// Total Freight Charge Default: 0
    pub tot_chgd_amt_dlr: Decimal,
    /// Additional Charge Amount Default: 0
    pub tot_adtn_chrg_dlr: Decimal,
    /// Pre-Purchased Amount Default: 0
    pub tot_precsld_amt_dlr: Decimal,
    /// FEU Factor Default: 0
    pub tot_feu_rsrc_fctr: Decimal,
    /// Number of Diverted Loads Default: 0
    pub tot_dvtd_ld_leg: Decimal,
    /// Carrier Tender Contact ID
    pub carrldtdr_cntc_id: Option<Decimal>,
    /// Sender Tender Contact ID
    pub sndrldtdr_cntc_id: Option<Decimal>,
    /// Tender Response Required By Date/Time In time zone of system
    pub tdr_rsps_by_dtt: Option<NaiveDateTime>,
    /// Reference Number 21
    pub rfrc_num21: Option<String>,
    /// Reference Number 22
    pub rfrc_num22: Option<String>,
    /// Reference Number 23
    pub rfrc_num23: Option<String>,
    /// Reference Number 24
    pub rfrc_num24: Option<String>,
    /// Reference Number 25
    pub rfrc_num25: Option<String>,
    /// Reference Number 26
    pub rfrc_num26: Option<String>,
    /// Reference Number 27
    pub rfrc_num27: Option<String>,
    /// Reference Number 28
    pub rfrc_num28: Option<String>,
    /// Reference Number 29
    pub rfrc_num29: Option<String>,
    /// Reference Number 30
    pub rfrc_num30: Option<String>,
    /// Carrier Tender Contact Name
    pub carrldtdrcntc_name: Option<String>,
    /// Sender Tender Contact Name
    pub sndrldtdrcntc_name: Option<String>,
    /// Number of Driver Assignments Default: 0
    pub num_drvr_assn: Decimal,
    /// Execution Mode Elapsed Time
    pub exec_elpd_hrs: Option<Decimal>,
    /// Execution Mode Hours - Maximum Waiting Between Loads
    pub exec_max_wait_btwn_lds_hrs: Option<Decimal>,
    /// Execution Mode Maximum Waiting Time at a Stop
    pub exec_max_wait_at_stop_hrs: Option<Decimal>,
    /// Execution Mode Driving Time
    pub exec_tot_driving_hrs: Option<Decimal>,
    /// Execution Mode Loading Time
    pub exec_tot_loading_hrs: Option<Decimal>,
    /// Execution Mode Off Duty Hours
    pub exec_tot_off_duty_hrs: Option<Decimal>,
    /// Execution Mode On Duty Hours
    pub exec_tot_on_duty_hrs: Option<Decimal>,
    /// Execution Mode Unloading Time
    pub exec_tot_unloading_hrs: Option<Decimal>,
    /// Execution Mode Waiting Time
    pub exec_tot_wait_hrs: Option<Decimal>,
    /// Execution Mode Weekend / Holiday Break
    pub exec_wknd_hldy_hrs: Option<Decimal>,
    /// Trip/Booking Rating - Last Rated Date/Time In system time zone
    pub ratd_dtt: Option<NaiveDateTime>,
    /// Routing - Destination Zone/Hub could link to either ZN_T.ZN_CD or
    /// HUB_T.SHPG_LOC_CD
    pub rutd_dest_zn_cd: Option<String>,
    /// Routing - Origin Zone/Hub could link to either ZN_T.ZN_CD or
    /// HUB_T.SHPG_LOC_CD
    pub rutd_ori_zn_cd: Option<String>,
    /// Rescheduling Recommended
    pub web_schd_rrs_reqd_yn: String,
    /// Booking Revision RR&S Bypass Flag
    pub bkg_rvi_byp_rrs_yn: Option<String>,
    /// Total Equipment Tare Weight
    pub tot_eqmt_tare_wgt: Option<Decimal>,
    /// Vessel Tracking ID 1
    pub vesl_trkg_id_1: Option<String>,
    /// Vessel Tracking ID 2
    pub vesl_trkg_id_2: Option<String>,
    /// External Service Type
    pub extl_srvc_typ_cd: Option<String>,
    /// Number of Violations
    pub num_soft_viol: f64,
    /// Last Rating Attempt Date/Time
    pub last_ratd_dtt: Option<NaiveDateTime>,
    /// Maximum Flexible Quantity 1 Maximums used for Routing Constraints
    pub max_flex_qnty1: Option<f64>,
    /// Maximum Flexible Quantity 2 Maximums used for Routing Constraints
    pub max_flex_qnty2: Option<f64>,
    /// Maximum Flexible Quantity 3 Maximums used for Routing Constraints
    pub max_flex_qnty3: Option<f64>,
    /// Maximum Flexible Quantity 4 Maximums used for Routing Constraints
    pub max_flex_qnty4: Option<f64>,
    /// Maximum Flexible Quantity 5 Maximums used for Routing Constraints
    pub max_flex_qnty5: Option<f64>,
    /// Flexible Quantity 1
    pub tot_flex_qnty1: Option<f64>,
    /// Flexible Quantity 2
    pub tot_flex_qnty2: Option<f64>,
    /// Flexible Quantity 3
    pub tot_flex_qnty3: Option<f64>,
    /// Flexible Quantity 4
    pub tot_flex_qnty4: Option<f64>,
    /// Flexible Quantity 5
    pub tot_flex_qnty5: Option<f64>,
    /// Execution Mode Scheduling Status Default: 1 (ineligible)
    pub exec_schd_stat_enu: Decimal,
    /// Execution Scheduling Overridden Default 'F'
    pub exec_schd_ovrd_yn: String,
    /// Tariff Restrictions Overridden Default 'F'
    pub tff_rstc_ovrd_yn: String,
} // struct Trip

Meta

rustc --version --verbose:

rustc 1.49.0 (e1884a8e3 2020-12-29)
binary: rustc
commit-hash: e1884a8e3c3e813aada8254edfa120e85bf5ffca
commit-date: 2020-12-29
host: x86_64-pc-windows-msvc
release: 1.49.0

Error output

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `11712`,
 right: `5089`', /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca\compiler\rustc_middle\src\ty\query\on_disk_cache.rs:553:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.49.0 (e1884a8e3 2020-12-29) running on x86_64-pc-windows-msvc

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [codegen_fn_attrs] computing codegen attributes of `command_line::_::_serde::Serialize::serialize`
#1 [codegen_fn_attrs] computing codegen attributes of `table::tms_trip_t::_::<impl command_line::_::_serde::Serialize for table::tms_trip_t::Trip>::serialize`
end of query stack
error: could not compile `x4m`

To learn more, run the command again with --verbose.

Backtrace

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `11712`,
 right: `5089`', /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca\compiler\rustc_middle\src\ty\query\on_disk_cache.rs:553:5
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.49.0 (e1884a8e3 2020-12-29) running on x86_64-pc-windows-msvc

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [codegen_fn_attrs] computing codegen attributes of `command_line::_::_serde::Serialize::serialize`
#1 [codegen_fn_attrs] computing codegen attributes of `table::tms_trip_t::_::<impl command_line::_::_serde::Serialize for table::tms_trip_t::Trip>::serialize`
#2 [check_mod_attrs] checking attributes in module `table::tms_trip_t`
#3 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `x4m`

@dylan-bowker dylan-bowker added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 22, 2021
@dylan-bowker dylan-bowker changed the title rustc_middle\src\ty\query\on_disk_cache.rs:553 Can't compile huge struct Jan 22, 2021
@Aaron1011
Copy link
Member

Aaron1011 commented Jan 22, 2021

When compiling with a local rustc with debug assertions enabled, I got an earlier panic:

thread 'rustc' panicked at 'assertion failed: pos <= u32::MAX as usize', compiler/rustc_middle/src/ty/query/on_disk_cache.rs:147:9
stack backtrace:
   0: rust_begin_unwind
             at /home/aaron/repos/rust/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /home/aaron/repos/rust/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /home/aaron/repos/rust/library/core/src/panicking.rs:50:5
   3: <rustc_middle::ty::query::on_disk_cache::AbsoluteBytePos>::new
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/query/on_disk_cache.rs:147:9
   4: rustc_middle::ty::query::on_disk_cache::encode_query_results::<rustc_middle::ty::query::queries::typeck>::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/query/on_disk_cache.rs:1257:38
   5: <rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, &rustc_middle::ty::context::TypeckResults> as rustc_query_system::query::caches::QueryCache>::iter::<core::result::Result<(), std::io::error::Error>, rustc_query_system::query::plumbing::QueryStateShard<rustc_middle::dep_graph::dep_node::DepKind, rustc_middle::ty::query::Query, rustc_span::def_id::LocalDefId, std::collections::hash::map::HashMap<rustc_span::def_id::LocalDefId, (&rustc_middle::ty::context::TypeckResults, rustc_query_system::dep_graph::graph::DepNodeIndex), core::hash::BuildHasherDefault<rustc_hash::FxHasher>>>, <rustc_query_system::query::plumbing::QueryState<rustc_middle::dep_graph::dep_node::DepKind, rustc_middle::ty::query::Query, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, &rustc_middle::ty::context::TypeckResults>>>::iter_results<core::result::Result<(), std::io::error::Error>, rustc_middle::ty::query::on_disk_cache::encode_query_results<rustc_middle::ty::query::queries::typeck>::{closure#0}>::{closure#0}, rustc_middle::ty::query::on_disk_cache::encode_query_results<rustc_middle::ty::query::queries::typeck>::{closure#0}>
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/query/caches.rs:138:9
   6: <rustc_query_system::query::plumbing::QueryState<rustc_middle::dep_graph::dep_node::DepKind, rustc_middle::ty::query::Query, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, &rustc_middle::ty::context::TypeckResults>>>::iter_results::<core::result::Result<(), std::io::error::Error>, rustc_middle::ty::query::on_disk_cache::encode_query_results<rustc_middle::ty::query::queries::typeck>::{closure#0}>
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/query/plumbing.rs:93:9
   7: rustc_middle::ty::query::on_disk_cache::encode_query_results::<rustc_middle::ty::query::queries::typeck>
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/query/on_disk_cache.rs:1250:5
   8: <rustc_middle::ty::query::on_disk_cache::OnDiskCache>::serialize::{closure#0}::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/query/on_disk_cache.rs:323:17
   9: <rustc_data_structures::profiling::VerboseTimingGuard>::run::<core::result::Result<(), std::io::error::Error>, <rustc_middle::ty::query::on_disk_cache::OnDiskCache>::serialize::{closure#0}::{closure#0}>
             at /home/aaron/repos/rust/compiler/rustc_data_structures/src/profiling.rs:570:9
  10: <rustc_session::session::Session>::time::<core::result::Result<(), std::io::error::Error>, <rustc_middle::ty::query::on_disk_cache::OnDiskCache>::serialize::{closure#0}::{closure#0}>
             at /home/aaron/repos/rust/compiler/rustc_session/src/utils.rs:9:9
  11: <rustc_middle::ty::query::on_disk_cache::OnDiskCache>::serialize::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/query/on_disk_cache.rs:307:13
  12: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<<rustc_middle::ty::query::on_disk_cache::OnDiskCache>::serialize::{closure#0}, core::result::Result<(), std::io::error::Error>>::{closure#0}::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/dep_graph/mod.rs:77:46
  13: rustc_middle::ty::context::tls::enter_context::<<rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps<<rustc_middle::ty::query::on_disk_cache::OnDiskCache>::serialize::{closure#0}, core::result::Result<(), std::io::error::Error>>::{closure#0}::{closure#0}, core::result::Result<(), std::io::error::Error>>::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1712:50
  14: rustc_middle::ty::context::tls::set_tlv::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps<<rustc_middle::ty::query::on_disk_cache::OnDiskCache>::serialize::{closure#0}, core::result::Result<(), std::io::error::Error>>::{closure#0}::{closure#0}, core::result::Result<(), std::io::error::Error>>::{closure#0}, core::result::Result<(), std::io::error::Error>>
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1696:9
  15: rustc_middle::ty::context::tls::enter_context::<<rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps<<rustc_middle::ty::query::on_disk_cache::OnDiskCache>::serialize::{closure#0}, core::result::Result<(), std::io::error::Error>>::{closure#0}::{closure#0}, core::result::Result<(), std::io::error::Error>>
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1712:9
  16: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<<rustc_middle::ty::query::on_disk_cache::OnDiskCache>::serialize::{closure#0}, core::result::Result<(), std::io::error::Error>>::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/dep_graph/mod.rs:77:13
  17: rustc_middle::ty::context::tls::with_context::<<rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps<<rustc_middle::ty::query::on_disk_cache::OnDiskCache>::serialize::{closure#0}, core::result::Result<(), std::io::error::Error>>::{closure#0}, core::result::Result<(), std::io::error::Error>>::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1740:40
  18: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_context<<rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps<<rustc_middle::ty::query::on_disk_cache::OnDiskCache>::serialize::{closure#0}, core::result::Result<(), std::io::error::Error>>::{closure#0}, core::result::Result<(), std::io::error::Error>>::{closure#0}, core::result::Result<(), std::io::error::Error>>
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1729:22
  19: rustc_middle::ty::context::tls::with_context::<<rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps<<rustc_middle::ty::query::on_disk_cache::OnDiskCache>::serialize::{closure#0}, core::result::Result<(), std::io::error::Error>>::{closure#0}, core::result::Result<(), std::io::error::Error>>
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1740:9
  20: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<<rustc_middle::ty::query::on_disk_cache::OnDiskCache>::serialize::{closure#0}, core::result::Result<(), std::io::error::Error>>
             at /home/aaron/repos/rust/compiler/rustc_middle/src/dep_graph/mod.rs:74:9
  21: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_ignore::<<rustc_middle::ty::query::on_disk_cache::OnDiskCache>::serialize::{closure#0}, core::result::Result<(), std::io::error::Error>>
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/dep_graph/graph.rs:208:9
  22: <rustc_middle::ty::query::on_disk_cache::OnDiskCache>::serialize
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/query/on_disk_cache.rs:255:9
  23: <rustc_middle::ty::context::TyCtxt>::serialize_query_result_cache::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1321:64
  24: <core::option::Option<&rustc_middle::ty::query::on_disk_cache::OnDiskCache>>::map_or::<core::result::Result<(), std::io::error::Error>, <rustc_middle::ty::context::TyCtxt>::serialize_query_result_cache::{closure#0}>
             at /home/aaron/repos/rust/library/core/src/option.rs:480:24
  25: <rustc_middle::ty::context::TyCtxt>::serialize_query_result_cache
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1321:9
  26: rustc_incremental::persist::save::encode_query_cache::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_incremental/src/persist/save.rs:178:58
  27: <rustc_data_structures::profiling::VerboseTimingGuard>::run::<core::result::Result<(), std::io::error::Error>, rustc_incremental::persist::save::encode_query_cache::{closure#0}>
             at /home/aaron/repos/rust/compiler/rustc_data_structures/src/profiling.rs:570:9
  28: <rustc_session::session::Session>::time::<core::result::Result<(), std::io::error::Error>, rustc_incremental::persist::save::encode_query_cache::{closure#0}>
             at /home/aaron/repos/rust/compiler/rustc_session/src/utils.rs:9:9
  29: rustc_incremental::persist::save::encode_query_cache
             at /home/aaron/repos/rust/compiler/rustc_incremental/src/persist/save.rs:178:5
  30: rustc_incremental::persist::save::save_dep_graph::{closure#0}::{closure#0}::{closure#0}::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_incremental/src/persist/save.rs:36:72
  31: rustc_incremental::persist::save::save_in::<rustc_incremental::persist::save::save_dep_graph::{closure#0}::{closure#0}::{closure#0}::{closure#0}>
             at /home/aaron/repos/rust/compiler/rustc_incremental/src/persist/save.rs:134:23
  32: rustc_incremental::persist::save::save_dep_graph::{closure#0}::{closure#0}::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_incremental/src/persist/save.rs:36:21
  33: <rustc_data_structures::profiling::VerboseTimingGuard>::run::<(), rustc_incremental::persist::save::save_dep_graph::{closure#0}::{closure#0}::{closure#0}>
             at /home/aaron/repos/rust/compiler/rustc_data_structures/src/profiling.rs:570:9
  34: <rustc_session::session::Session>::time::<(), rustc_incremental::persist::save::save_dep_graph::{closure#0}::{closure#0}::{closure#0}>
             at /home/aaron/repos/rust/compiler/rustc_session/src/utils.rs:9:9
  35: rustc_incremental::persist::save::save_dep_graph::{closure#0}::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_incremental/src/persist/save.rs:35:17
  36: rustc_data_structures::sync::join::<rustc_incremental::persist::save::save_dep_graph::{closure#0}::{closure#0}, rustc_incremental::persist::save::save_dep_graph::{closure#0}::{closure#1}, (), ()>
             at /home/aaron/repos/rust/compiler/rustc_data_structures/src/sync.rs:159:14
  37: rustc_incremental::persist::save::save_dep_graph::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_incremental/src/persist/save.rs:33:9
  38: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<rustc_incremental::persist::save::save_dep_graph::{closure#0}, ()>::{closure#0}::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/dep_graph/mod.rs:77:46
  39: rustc_middle::ty::context::tls::enter_context::<<rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps<rustc_incremental::persist::save::save_dep_graph::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1712:50
  40: rustc_middle::ty::context::tls::set_tlv::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps<rustc_incremental::persist::save::save_dep_graph::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#0}, ()>
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1696:9
  41: rustc_middle::ty::context::tls::enter_context::<<rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps<rustc_incremental::persist::save::save_dep_graph::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1712:9
  42: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<rustc_incremental::persist::save::save_dep_graph::{closure#0}, ()>::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/dep_graph/mod.rs:77:13
  43: rustc_middle::ty::context::tls::with_context::<<rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps<rustc_incremental::persist::save::save_dep_graph::{closure#0}, ()>::{closure#0}, ()>::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1740:40
  44: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_context<<rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps<rustc_incremental::persist::save::save_dep_graph::{closure#0}, ()>::{closure#0}, ()>::{closure#0}, ()>
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1729:22
  45: rustc_middle::ty::context::tls::with_context::<<rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps<rustc_incremental::persist::save::save_dep_graph::{closure#0}, ()>::{closure#0}, ()>
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1740:9
  46: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<rustc_incremental::persist::save::save_dep_graph::{closure#0}, ()>
             at /home/aaron/repos/rust/compiler/rustc_middle/src/dep_graph/mod.rs:74:9
  47: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_ignore::<rustc_incremental::persist::save::save_dep_graph::{closure#0}, ()>
             at /home/aaron/repos/rust/compiler/rustc_query_system/src/dep_graph/graph.rs:208:9
  48: rustc_incremental::persist::save::save_dep_graph
             at /home/aaron/repos/rust/compiler/rustc_incremental/src/persist/save.rs:20:5
  49: rustc_interface::passes::start_codegen::{closure#2}
             at /home/aaron/repos/rust/compiler/rustc_interface/src/passes.rs:1018:45
  50: <rustc_data_structures::profiling::VerboseTimingGuard>::run::<(), rustc_interface::passes::start_codegen::{closure#2}>
             at /home/aaron/repos/rust/compiler/rustc_data_structures/src/profiling.rs:570:9
  51: <rustc_session::session::Session>::time::<(), rustc_interface::passes::start_codegen::{closure#2}>
             at /home/aaron/repos/rust/compiler/rustc_session/src/utils.rs:9:9
  52: rustc_interface::passes::start_codegen
             at /home/aaron/repos/rust/compiler/rustc_interface/src/passes.rs:1018:5
  53: <rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_interface/src/queries.rs:286:20
  54: <rustc_interface::passes::QueryContext>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_errors::ErrorReported>>::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_interface/src/passes.rs:742:42
  55: rustc_middle::ty::context::tls::enter_context::<<rustc_interface::passes::QueryContext>::enter<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_errors::ErrorReported>>::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_errors::ErrorReported>>::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1712:50
  56: rustc_middle::ty::context::tls::set_tlv::<rustc_middle::ty::context::tls::enter_context<<rustc_interface::passes::QueryContext>::enter<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_errors::ErrorReported>>::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_errors::ErrorReported>>::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_errors::ErrorReported>>
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1696:9
  57: rustc_middle::ty::context::tls::enter_context::<<rustc_interface::passes::QueryContext>::enter<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_errors::ErrorReported>>::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_errors::ErrorReported>>
             at /home/aaron/repos/rust/compiler/rustc_middle/src/ty/context.rs:1712:9
  58: <rustc_interface::passes::QueryContext>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_errors::ErrorReported>>
             at /home/aaron/repos/rust/compiler/rustc_interface/src/passes.rs:742:9
  59: <rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_interface/src/queries.rs:277:13
  60: <rustc_interface::queries::Query<alloc::boxed::Box<dyn core::any::Any>>>::compute::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}>
             at /home/aaron/repos/rust/compiler/rustc_interface/src/queries.rs:39:28
  61: <rustc_interface::queries::Queries>::ongoing_codegen
             at /home/aaron/repos/rust/compiler/rustc_interface/src/queries.rs:275:9
  62: rustc_driver::run_compiler::{closure#3}::{closure#2}
             at /home/aaron/repos/rust/compiler/rustc_driver/src/lib.rs:446:13
  63: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#3}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorReported>>
             at /home/aaron/repos/rust/compiler/rustc_interface/src/queries.rs:418:19
  64: rustc_driver::run_compiler::{closure#3}
             at /home/aaron/repos/rust/compiler/rustc_driver/src/lib.rs:341:22
  65: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#3}>::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_interface/src/interface.rs:197:13
  66: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#3}>::{closure#0}>
             at /home/aaron/repos/rust/compiler/rustc_span/src/lib.rs:787:5
  67: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#3}>
             at /home/aaron/repos/rust/compiler/rustc_interface/src/interface.rs:191:5
  68: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#3}>::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_interface/src/interface.rs:213:12
  69: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#3}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_interface/src/util.rs:152:13
  70: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#3}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
             at /home/aaron/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137:9
  71: rustc_span::with_session_globals::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#3}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}>
             at /home/aaron/repos/rust/compiler/rustc_span/src/lib.rs:103:5
  72: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#3}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_interface/src/util.rs:150:9
  73: rustc_interface::util::scoped_thread::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#3}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}
             at /home/aaron/repos/rust/compiler/rustc_interface/src/util.rs:125:24
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.51.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `huge_struct`

@osa1
Copy link
Contributor

osa1 commented Jan 23, 2021

Cargo.toml for the repro:

[package]
name = "issue81278"
version = "0.1.0"
authors = []
edition = "2018"

[dependencies]
chrono = { version = "0.4.19", features = ["serde"] }
serde = { version = "1.0.120", features = ["derive"] }
rust_decimal = "1.9.0"

@osa1
Copy link
Contributor

osa1 commented Jan 23, 2021

I can't reproduce this locally with stable or nightly builds installed with rustup, but I can with stage 1 build (34b3d41).

@jyn514 jyn514 added the A-layout Area: Memory layout of types label Jan 24, 2021
@tmiasko
Copy link
Contributor

tmiasko commented Jan 25, 2021

This test case generates almost 8GB of incremental cache data, while the current implementation appears to support only 4GB due to the use of u32 for file offsets.

The deeply nested closures in PartialOrd would be my first suspect after looking at the logs and either way it seems like a low hanging fruit in terms of possible improvement. @dotdash is this something you are planning to change maybe?

@osa1
Copy link
Contributor

osa1 commented Jan 25, 2021

This test case generates almost 8GB of incremental cache data, while the current implementation appears to support only 4GB due to the use of u32 for file offsets.

Shouldn't this cause "add with overflow" etc. errors in the compiler? Or do we also explicitly allow overflows/underflows when computing file offsets?

@tmiasko
Copy link
Contributor

tmiasko commented Jan 25, 2021

With changes from #81384 that remove problematic closures from PartialOrd, the size of incremental directory is reduced from ~8GB to ~2MB.

Shouldn't this cause "add with overflow" etc. errors in the compiler?

There is a debug assertion plus an unchecked as cast, but based on this report I would say this deserves to be checked in release mode as well (maybe once at the end?).

bors added a commit to rust-lang-ci/rust that referenced this issue Feb 9, 2021
Fix derived PartialOrd operators

The derived implementation of `partial_cmp` compares matching fields one
by one, stopping the computation when the result of a comparison is not
equal to `Some(Equal)`.

On the other hand the derived implementation for `lt`, `le`, `gt` and
`ge` continues the computation when the result of a field comparison is
`None`, consequently those operators are not transitive and inconsistent
with `partial_cmp`.

Fix the inconsistency by using the default implementation that fall-backs
to the `partial_cmp`. This also avoids creating very deeply nested
closures that were quite costly to compile.

Fixes rust-lang#81373.
Helps with rust-lang#81278, rust-lang#80118.
@tmiasko
Copy link
Contributor

tmiasko commented Feb 10, 2021

The nightly-2021-02-10 is the first build that avoids the issue. The compilation time is now ~1s rather than >60s (I was testing with all dependencies removed, and NaiveDateTime & Decimal fields replaced with u64, since they weren't essential part of the issue). The original problem remains.

@rustbot modify labels +A-incr-comp

@rustbot rustbot added the A-incr-comp Area: Incremental compilation label Feb 10, 2021
@saethlin
Copy link
Member

saethlin commented Sep 4, 2023

I turned the problematic as mentioned above into a checked operation in #110632 then between #113562 and #113542 rustc should be more capable generally of handling large crates.

@saethlin saethlin closed this as completed Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-incr-comp Area: Incremental compilation A-layout Area: Memory layout of types C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants