8000 Auto merge of #116455 - matthiaskrgr:rollup-p226a5u, r=matthiaskrgr · rust-lang/rust@cdca82c · GitHub
[go: up one dir, main page]

Skip to content

Commit cdca82c

Browse files
committed
Auto merge of #116455 - matthiaskrgr:rollup-p226a5u, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #116220 (stabilize `Option::as_`(`mut_`)`slice`) - #116288 (Add Span to various smir types) - #116415 (Move subtyper below reveal_all and change reveal_all) - #116428 (Add a note to duplicate diagnostics) - #116452 (Do not assert that hidden types don't have erased regions.) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3bcad65 + 76d0b79 commit cdca82c
  • session-diagnostic
  • stable-mir
  • ui
  • Some content is hidden

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

    182 files changed

    +762
    -356
    lines changed

    compiler/rustc_errors/src/lib.rs

    Lines changed: 8 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1376,16 +1376,16 @@ impl HandlerInner {
    13761376
    self.emitted_diagnostic_codes.insert(code.clone());
    13771377
    }
    13781378

    1379-
    let already_emitted = |this: &mut Self| {
    1379+
    let already_emitted = {
    13801380
    let mut hasher = StableHasher::new();
    13811381
    diagnostic.hash(&mut hasher);
    13821382
    let diagnostic_hash = hasher.finish();
    1383-
    !this.emitted_diagnostics.insert(diagnostic_hash)
    1383+
    !self.emitted_diagnostics.insert(diagnostic_hash)
    13841384
    };
    13851385

    13861386
    // Only emit the diagnostic if we've been asked to deduplicate or
    13871387
    // haven't already emitted an equivalent diagnostic.
    1388-
    if !(self.flags.deduplicate_diagnostics && already_emitted(self)) {
    1388+
    if !(self.flags.deduplicate_diagnostics && already_emitted) {
    13891389
    debug!(?diagnostic);
    13901390
    debug!(?self.emitted_diagnostics);
    13911391
    let already_emitted_sub = |sub: &mut SubDiagnostic| {
    @@ -1401,6 +1401,11 @@ impl HandlerInner {
    14011401
    };
    14021402

    14031403
    diagnostic.children.extract_if(already_emitted_sub).for_each(|_| {});
    1404+
    if already_emitted {
    1405+
    diagnostic.note(
    1406+
    "duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`",
    1407+
    );
    1408+
    }
    14041409

    14051410
    self.emitter.emit_diagnostic(diagnostic);
    14061411
    if diagnostic.is_error() {

    compiler/rustc_hir_typeck/src/lib.rs

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -5,7 +5,6 @@
    55
    #![feature(box_patterns)]
    66
    #![feature(min_specialization)]
    77
    #![feature(control_flow_enum)]
    8-
    #![feature(option_as_slice)]
    98
    #![recursion_limit = "256"]
    109

    1110
    #[macro_use]

    compiler/rustc_mir_transform/src/add_subtyping_projections.rs

    Lines changed: 5 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -24,6 +24,11 @@ impl<'a, 'tcx> MutVisitor<'tcx> for SubTypeChecker<'a, 'tcx> {
    2424
    rvalue: &mut Rvalue<'tcx>,
    2525
    location: Location,
    2626
    ) {
    27+
    // We don't need to do anything for deref temps as they are
    28+
    // not part of the source code, but used for desugaring purposes.
    29+
    if self.local_decls[place.local].is_deref_temp() {
    30+
    return;
    31+
    }
    2732
    let mut place_ty = place.ty(self.local_decls, self.tcx).ty;
    2833
    let mut rval_ty = rvalue.ty(self.local_decls, self.tcx);
    2934
    // Not erasing this causes `Free Regions` errors in validator,
    @@ -48,7 +53,6 @@ impl<'a, 'tcx> MutVisitor<'tcx> for SubTypeChecker<'a, 'tcx> {
    4853
    // // gets transformed to
    4954
    // let temp: rval_ty = rval;
    5055
    // let place: place_ty = temp as place_ty;
    51-
    //
    5256
    pub fn subtype_finder<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
    5357
    let patch = MirPatch::new(body);
    5458
    let mut checker = SubTypeChecker { tcx, patcher: patch, local_decls: &body.local_decls };

    compiler/rustc_mir_transform/src/lib.rs

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -467,7 +467,6 @@ pub fn run_analysis_to_runtime_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'
    467467
    /// After this series of passes, no lifetime analysis based on borrowing can be done.
    468468
    fn run_analysis_cleanup_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
    469469
    let passes: &[&dyn MirPass<'tcx>] = &[
    470-
    &add_subtyping_projections::Subtyper,
    471470
    &cleanup_post_borrowck::CleanupPostBorrowck,
    472471
    &remove_noop_landing_pads::RemoveNoopLandingPads,
    473472
    &simplify::SimplifyCfg::EarlyOpt,
    @@ -483,6 +482,7 @@ fn run_runtime_lowering_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
    483482
    // These next passes must be executed together
    484483
    &add_call_guards::CriticalCallEdges,
    485484
    &reveal_all::RevealAll, // has to be done before drop elaboration, since we need to drop opaque types, too.
    485+
    &add_subtyping_projections::Subtyper, // calling this after reveal_all ensures that we don't deal with opaque types
    486486
    &elaborate_drops::ElaborateDrops,
    487487
    // This will remove extraneous landing pads which are no longer
    488488
    // necessary as well as well as forcing any call in a non-unwinding

    compiler/rustc_mir_transform/src/reveal_all.rs

    Lines changed: 3 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -46,16 +46,18 @@ impl<'tcx> MutVisitor<'tcx> for RevealAllVisitor<'tcx> {
    4646
    .filter(|elem| !matches!(elem, ProjectionElem::OpaqueCast(_)))
    4747
    .collect::<Vec<_>>(),
    4848
    );
    49+
    self.super_place(place, _context, _location);
    4950
    }
    5051

    5152
    #[inline]
    52-
    fn visit_constant(&mut self, constant: &mut ConstOperand<'tcx>, _: Location) {
    53+
    fn visit_constant(&mut self, constant: &mut ConstOperand<'tcx>, location: Location) {
    5354
    // We have to use `try_normalize_erasing_regions` here, since it's
    5455
    // possible that we visit impossible-to-satisfy where clauses here,
    5556
    // see #91745
    5657
    if let Ok(c) = self.tcx.try_normalize_erasing_regions(self.param_env, constant.const_) {
    5758
    constant.const_ = c;
    5859
    }
    60+
    self.super_constant(constant, location);
    5961
    }
    6062

    6163
    #[inline]

    compiler/rustc_smir/src/rustc_smir/mod.rs

    Lines changed: 116 additions & 59 deletions
    Original file line numberDiff line numberDiff line change
    @@ -15,7 +15,7 @@ use rustc_middle::mir::interpret::{alloc_range, AllocId};
    1515
    use rustc_middle::ty::{self, Ty, TyCtxt, Variance};
    1616
    use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE};
    1717
    use rustc_target::abi::FieldIdx;
    18-
    use stable_mir::mir::{CopyNonOverlapping, UserTypeProjection, VariantIdx};
    18+
    use stable_mir::mir::{CopyNonOverlapping, Statement, UserTypeProjection, VariantIdx};
    1919
    use stable_mir::ty::{FloatTy, GenericParamDef, IntTy, Movability, RigidTy, Span, TyKind, UintTy};
    2020
    use stable_mir::{self, opaque, Context};
    2121
    use tracing::debug;
    @@ -106,7 +106,14 @@ impl<'tcx> Context for Tables<'tcx> {
    106106
    .collect(),
    107107
    })
    108108
    .collect(),
    109-
    locals: mir.local_decls.iter().map(|decl| self.intern_ty(decl.ty)).collect(),
    109+
    locals: mir
    110+
    .local_decls
    111+
    .iter()
    112+
    .map(|decl| stable_mir::mir::LocalDecl {
    113+
    ty: self.intern_ty(decl.ty),
    114+
    span: decl.source_info.span.stable(self),
    115+
    })
    116+
    .collect(),
    110117
    }
    111118
    }
    112119

    @@ -223,41 +230,64 @@ pub(crate) trait Stable<'tcx> {
    223230
    impl<'tcx> Stable<'tcx> for mir::Statement<'tcx> {
    224231
    type T = stable_mir::mir::Statement;
    225232
    fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
    226-
    use rustc_middle::mir::StatementKind::*;
    227-
    match &self.kind {
    228-
    Assign(assign) => {
    229-
    stable_mir::mir::Statement::Assign(assign.0.stable(tables), assign.1.stable(tables))
    230-
    }
    231-
    FakeRead(fake_read_place) => stable_mir::mir::Statement::FakeRead(
    232-
    fake_read_place.0.stable(tables),
    233-
    fake_read_place.1.stable(tables),
    233+
    Statement { kind: self.kind.stable(tables), span: self.source_info.span.stable(tables) }
    234+
    }
    235+
    }
    236+
    237+
    impl<'tcx> Stable<'tcx> for mir::StatementKind<'tcx> {
    238+
    type T = stable_mir::mir::StatementKind;
    239+
    fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
    240+
    match self {
    241+
    mir::StatementKind::Assign(assign) => stable_mir::mir::StatementKind::Assign(
    242+
    assign.0.stable(tables),
    243+
    assign.1.stable(tables),
    234244
    ),
    235-
    SetDiscriminant { place: plc, variant_index: idx } => {
    236-
    stable_mir::mir::Statement::SetDiscriminant {
    237-
    place: plc.as_ref().stable(tables),
    238-
    variant_index: idx.stable(tables),
    245+
    mir::StatementKind::FakeRead(fake_read_place) => {
    246+
    stable_mir::mir::StatementKind::FakeRead(
    247+
    fake_read_place.0.stable(tables),
    248+
    fake_read_place.1.stable(tables),
    249+
    )
    250+
    }
    251+
    mir::StatementKind::SetDiscriminant { place, variant_index } => {
    252+
    stable_mir::mir::StatementKind::SetDiscriminant {
    253+
    place: place.as_ref().stable(tables),
    254+
    variant_index: variant_index.stable(tables),
    239255
    }
    240256
    }
    241-
    Deinit(place) => stable_mir::mir::Statement::Deinit(place.stable(tables)),
    242-
    StorageLive(place) => stable_mir::mir::Statement::StorageLive(place.stable(tables)),
    243-
    StorageDead(place) => stable_mir::mir::Statement::StorageDead(place.stable(tables)),
    244-
    Retag(retag, place) => {
    245-
    stable_mir::mir::Statement::Retag(retag.stable(tables), place.stable(tables))
    257+
    mir::StatementKind::Deinit(place) => {
    258+
    stable_mir::mir::StatementKind::Deinit(place.stable(tables))
    259+
    }
    260+
    261+
    mir::StatementKind::StorageLive(place) => {
    262+
    stable_mir::mir::StatementKind::StorageLive(place.stable(tables))
    263+
    }
    264+
    265+
    mir::StatementKind::StorageDead(place) => {
    266+
    stable_mir::mir::StatementKind::StorageDead(place.stable(tables))
    267+
    }
    4204 268+
    mir::StatementKind::Retag(retag, place) => {
    269+
    stable_mir::mir::StatementKind::Retag(retag.stable(tables), place.stable(tables))
    270+
    }
    271+
    mir::StatementKind::PlaceMention(place) => {
    272+
    stable_mir::mir::StatementKind::PlaceMention(place.stable(tables))
    246273
    }
    247-
    PlaceMention(place) => stable_mir::mir::Statement::PlaceMention(place.stable(tables)),
    248-
    AscribeUserType(place_projection, variance) => {
    249-
    stable_mir::mir::Statement::AscribeUserType {
    274+
    mir::StatementKind::AscribeUserType(place_projection, variance) => {
    275+
    stable_mir::mir::StatementKind::AscribeUserType {
    250276
    place: place_projection.as_ref().0.stable(tables),
    251277
    projections: place_projection.as_ref().1.stable(tables),
    252278
    variance: variance.stable(tables),
    253279
    }
    254280
    }
    255-
    Coverage(coverage) => stable_mir::mir::Statement::Coverage(opaque(coverage)),
    256-
    Intrinsic(intrinstic) => {
    257-
    stable_mir::mir::Statement::Intrinsic(intrinstic.stable(tables))
    281+
    mir::StatementKind::Coverage(coverage) => {
    282+
    stable_mir::mir::StatementKind::Coverage(opaque(coverage))
    283+
    }
    284+
    mir::StatementKind::Intrinsic(intrinstic) => {
    285+
    stable_mir::mir::StatementKind::Intrinsic(intrinstic.stable(tables))
    286+
    }
    287+
    mir::StatementKind::ConstEvalCounter => {
    288+
    stable_mir::mir::StatementKind::ConstEvalCounter
    258289
    }
    259-
    ConstEvalCounter => stable_mir::mir::Statement::ConstEvalCounter,
    260-
    Nop => stable_mir::mir::Statement::Nop,
    290+
    mir::StatementKind::Nop => stable_mir::mir::StatementKind::Nop,
    261291
    }
    262292
    }
    263293
    }
    @@ -806,11 +836,20 @@ impl<'tcx> Stable<'tcx> for mir::InlineAsmOperand<'tcx> {
    806836
    impl<'tcx> Stable<'tcx> for mir::Terminator<'tcx> {
    807837
    type T = stable_mir::mir::Terminator;
    808838
    fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
    809-
    use rustc_middle::mir::TerminatorKind::*;
    810839
    use stable_mir::mir::Terminator;
    811-
    match &self.kind {
    812-
    Goto { target } => Terminator::Goto { target: target.as_usize() },
    813-
    SwitchInt { discr, targets } => Terminator::SwitchInt {
    840+
    Terminator { kind: self.kind.stable(tables), span: self.source_info.span.stable(tables) }
    841+
    }
    842+
    }
    843+
    844+
    impl<'tcx> Stable<'tcx> for mir::TerminatorKind<'tcx> {
    845+
    type T = stable_mir::mir::TerminatorKind;
    846+
    fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
    847+
    use stable_mir::mir::TerminatorKind;
    848+
    match self {
    849+
    mir::TerminatorKind::Goto { target } => {
    850+
    TerminatorKind::Goto { target: target.as_usize() }
    851+
    }
    852+
    mir::TerminatorKind::SwitchInt { discr, targets } => TerminatorKind::SwitchInt {
    814853
    discr: discr.stable(tables),
    815854
    targets: targets
    816855
    .iter()
    @@ -821,42 +860,60 @@ impl<'tcx> Stable<'tcx> for mir::Terminator<'tcx> {
    821860
    .collect(),
    822861
    otherwise: targets.otherwise().as_usize(),
    823862
    },
    824-
    UnwindResume => Terminator::Resume,
    825-
    UnwindTerminate(_) => Terminator::Abort,
    826-
    Return => Terminator::Return,
    827-
    Unreachable => Terminator::Unreachable,
    828-
    Drop { place, target, unwind, replace: _ } => Terminator::Drop {
    829-
    place: place.stable(tables),
    830-
    target: target.as_usize(),
    831-
    unwind: unwind.stable(tables),
    832-
    },
    833-
    Call { func, args, destination, target, unwind, call_source: _, fn_span: _ } => {
    834-
    Terminator::Call {
    835-
    func: func.stable(tables),
    836-
    args: args.iter().map(|arg| arg.stable(tables)).collect(),
    837-
    destination: destination.stable(tables),
    838-
    target: target.map(|t| t.as_usize()),
    863+
    mir::TerminatorKind::UnwindResume => TerminatorKind::Resume,
    864+
    mir::TerminatorKind::UnwindTerminate(_) => TerminatorKind::Abort,
    865+
    mir::TerminatorKind::Return => TerminatorKind::Return,
    866+
    mir::TerminatorKind::Unreachable => TerminatorKind::Unreachable,
    867+
    mir::TerminatorKind::Drop { place, target, unwind, replace: _ } => {
    868+
    TerminatorKind::Drop {
    869+
    place: place.stable(tables),
    870+
    target: target.as_usize(),
    839871
    unwind: unwind.stable(tables),
    840872
    }
    841873
    }
    842-
    Assert { cond, expected, msg, target, unwind } => Terminator::Assert {
    843-
    cond: cond.stable(tables),
    844-
    expected: *expected,
    845-
    msg: msg.stable(tables),
    846-
    target: target.as_usize(),
    874+
    mir::TerminatorKind::Call {
    875+
    func,
    876+
    args,
    877+
    destination,
    878+
    target,
    879+
    unwind,
    880+
    call_source: _,
    881+
    fn_span: _,
    882+
    } => TerminatorKind::Call {
    883+
    func: func.stable(tables),
    884+
    args: args.iter().map(|arg| arg.stable(tables)).collect(),
    885+
    destination: destination.stable(tables),
    886+
    target: target.map(|t| t.as_usize()),
    847887
    unwind: unwind.stable(tables),
    848888
    },
    849-
    InlineAsm { template, operands, options, line_spans, destination, unwind } => {
    850-
    Terminator::InlineAsm {
    851-
    template: format!("{template:?}"),
    852-
    operands: operands.iter().map(|operand| operand.stable(tables)).collect(),
    853-
    options: format!("{options:?}"),
    854-
    line_spans: format!("{line_spans:?}"),
    855-
    destination: destination.map(|d| d.as_usize()),
    889+
    mir::TerminatorKind::Assert { cond, expected, msg, target, unwind } => {
    890+
    TerminatorKind::Assert {
    891+
    cond: cond.stable(tables),
    892+
    expected: *expected,
    893+
    msg: msg.stable(tables),
    894+
    target: target.as_usize(),
    856895
    unwind: unwind.stable(tables),
    857896
    }
    858897
    }
    859-
    Yield { .. } | GeneratorDrop | FalseEdge { .. } | FalseUnwind { .. } => unreachable!(),
    898+
    mir::TerminatorKind::InlineAsm {
    899+
    template,
    900+
    operands,
    901+
    options,
    902+
    line_spans,
    903+
    destination,
    904+
    unwind,
    905+
    } => TerminatorKind::InlineAsm {
    906+
    template: format!("{template:?}"),
    907+
    operands: operands.iter().map(|operand| operand.stable(tables)).collect(),
    908+
    options: format!("{options:?}"),
    909+
    line_spans: format!("{line_spans:?}"),
    910+
    destination: destination.map(|d| d.as_usize()),
    911+
    unwind: unwind.stable(tables),
    912+
    },
    913+
    mir::TerminatorKind::Yield { .. }
    914+
    | mir::TerminatorKind::GeneratorDrop
    915+
    | mir::TerminatorKind::FalseEdge { .. }
    916+
    | mir::TerminatorKind::FalseUnwind { .. } => unreachable!(),
    860917
    }
    861918
    }
    862919
    }

    compiler/rustc_trait_selection/src/traits/select/mod.rs

    Lines changed: 0 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -3116,9 +3116,6 @@ fn bind_generator_hidden_types_above<'tcx>(
    31163116
    bty.instantiate(tcx, args)
    31173117
    })
    31183118
    .collect();
    3119-
    if considering_regions {
    3120-
    debug_assert!(!hidden_types.has_erased_regions());
    3121-
    }
    31223119
    let bound_vars =
    31233120
    tcx.mk_bound_variable_kinds_from_iter(bound_vars.iter().chain(
    31243121
    (num_bound_variables..counter).map(|_| ty::BoundVariableKind::Region(ty::BrAnon)),

    compiler/stable_mir/src/mir/body.rs

    Lines changed: 21 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -5,7 +5,13 @@ use crate::{ty::Ty, Span};
    55
    #[derive(Clone, Debug)]
    66
    pub struct Body {
    77
    pub blocks: Vec<BasicBlock>,
    8-
    pub locals: Vec<Ty>,
    8+
    pub locals: Vec<LocalDecl>,
    9+
    }
    10+
    11+
    #[derive(Clone, Debug)]
    12+
    pub struct LocalDecl {
    13+
    pub ty: Ty,
    14+
    pub span: Span,
    915
    }
    1016

    1117
    #[derive(Clone, Debug)]
    @@ -15,7 +21,13 @@ pub struct BasicBlock {
    1521
    }
    1622

    1723
    #[derive(Clone, Debug)]
    18-
    pub enum Terminator {
    24+
    pub struct Terminator {
    25+
    pub kind: TerminatorKind,
    26+
    pub span: Span,
    27+
    }
    28+
    29+
    #[derive(Clone, Debug)]
    30+
    pub enum TerminatorKind {
    1931
    Goto {
    2032
    target: usize,
    2133
    },
    @@ -179,7 +191,13 @@ pub enum NonDivergingIntrinsic {
    179191
    }
    180192

    181193
    #[derive(Clone, Debug)]
    182-
    pub enum Statement {
    194+
    pub struct Statement {
    195+
    pub kind: StatementKind,
    196+
    pub span: Span,
    197+
    }
    198+
    199+
    #[derive(Clone, Debug)]
    200+
    pub enum StatementKind {
    183201
    Assign(Place, Rvalue),
    184202
    FakeRead(FakeReadCause, Place),
    185203
    SetDiscriminant { place: Place, variant_index: VariantIdx },

    0 commit comments

    Comments
     (0)
    0