Skip to content

Commit afab366

Browse files
committed
Auto merge of #112361 - matthiaskrgr:rollup-39zxrw1, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #111250 (Add Terminator conversion from MIR to SMIR, part #2) - #112310 (Add new Tier-3 targets: `loongarch64-unknown-none*`) - #112334 (Add myself to highfive rotation) - #112340 (remove `TyCtxt::has_error_field` helper method) - #112343 (Prevent emitting `missing_docs` for `pub extern crate`) - #112350 (Avoid duplicate type sanitization of local decls in borrowck) - #112356 (Fix comment for `get_region_var_origins`) - #112358 (Remove default visitor impl in region constraint generation) r? `@ghost` `@rustbot` modify labels: rollup
2 parents b2b34bd + 63e0423 commit afab366

File tree

20 files changed

+188
-86
lines changed

20 files changed

+188
-86
lines changed

compiler/rustc_borrowck/src/constraint_generation.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use rustc_infer::infer::InferCtxt;
44
use rustc_middle::mir::visit::TyContext;
55
use rustc_middle::mir::visit::Visitor;
66
use rustc_middle::mir::{
7-
BasicBlock, BasicBlockData, Body, Local, Location, Place, PlaceRef, ProjectionElem, Rvalue,
8-
SourceInfo, Statement, StatementKind, Terminator, TerminatorKind, UserTypeProjection,
7+
Body, Local, Location, Place, PlaceRef, ProjectionElem, Rvalue, SourceInfo, Statement,
8+
StatementKind, Terminator, TerminatorKind, UserTypeProjection,
99
};
1010
use rustc_middle::ty::subst::SubstsRef;
1111
use rustc_middle::ty::visit::TypeVisitable;
@@ -49,10 +49,6 @@ struct ConstraintGeneration<'cg, 'tcx> {
4949
}
5050

5151
impl<'cg, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'tcx> {
52-
fn visit_basic_block_data(&mut self, bb: BasicBlock, data: &BasicBlockData<'tcx>) {
53-
self.super_basic_block_data(bb, data);
54-
}
55-
5652
/// We sometimes have `substs` within an rvalue, or within a
5753
/// call. Make them live at the location where they appear.
5854
fn visit_substs(&mut self, substs: &SubstsRef<'tcx>, location: Location) {

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
477477

478478
fn visit_body(&mut self, body: &Body<'tcx>) {
479479
self.sanitize_type(&"return type", body.return_ty());
480-
for local_decl in &body.local_decls {
481-
self.sanitize_type(local_decl, local_decl.ty);
482-
}
480+
// The types of local_decls are checked above which is called in super_body.
483481
self.super_body(body);
484482
}
485483
}

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,9 +1745,11 @@ fn check_variances_for_type_defn<'tcx>(
17451745
item: &hir::Item<'tcx>,
17461746
hir_generics: &hir::Generics<'_>,
17471747
) {
1748-
let ty = tcx.type_of(item.owner_id).subst_identity();
1749-
if tcx.has_error_field(ty) {
1750-
return;
1748+
let identity_substs = ty::InternalSubsts::identity_for_item(tcx, item.owner_id);
1749+
for field in tcx.adt_def(item.owner_id).all_fields() {
1750+
if field.ty(tcx, identity_substs).references_error() {
1751+
return;
1752+
}
17511753
}
17521754

17531755
let ty_predicates = tcx.predicates_of(item.owner_id);

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,15 +1195,15 @@ impl<'tcx> InferCtxt<'tcx> {
11951195
.var_origin(vid)
11961196
}
11971197

1198-
/// Takes ownership of the list of variable regions. This implies
1199-
/// that all the region constraints have already been taken, and
1200-
/// hence that `resolve_regions_and_report_errors` can never be
1201-
/// called. This is used only during NLL processing to "hand off" ownership
1202-
/// of the set of region variables into the NLL region context.
1198+
/// Clone the list of variable regions. This is used only during NLL processing
1199+
/// to put the set of region variables into the NLL region context.
12031200
pub fn get_region_var_origins(&self) -> VarInfos {
12041201
let mut inner = self.inner.borrow_mut();
12051202
let (var_infos, data) = inner
12061203
.region_constraint_storage
1204+
// We clone instead of taking because borrowck still wants to use
1205+
// the inference context after calling this for diagnostics
1206+
// and the new trait solver.
12071207
.clone()
12081208
.expect("regions already resolved")
12091209
.with_log(&mut inner.undo_log)

compiler/rustc_lint/src/builtin.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,12 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
548548

549549
fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
550550
// Previously the Impl and Use types have been excluded from missing docs,
551-
// so we will continue to exclude them for compatibility
552-
if let hir::ItemKind::Impl(..) | hir::ItemKind::Use(..) = it.kind {
551+
// so we will continue to exclude them for compatibility.
552+
//
553+
// The documentation on `ExternCrate` is not used at the moment so no need to warn for it.
554+
if let hir::ItemKind::Impl(..) | hir::ItemKind::Use(..) | hir::ItemKind::ExternCrate(_) =
555+
it.kind
556+
{
553557
return;
554558
}
555559

compiler/rustc_middle/src/ty/util.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,6 @@ impl<'tcx> TyCtxt<'tcx> {
173173
}
174174
}
175175

176-
pub fn has_error_field(self, ty: Ty<'tcx>) -> bool {
177-
if let ty::Adt(def, substs) = *ty.kind() {
178-
for field in def.all_fields() {
179-
let field_ty = field.ty(self, substs);
180-
if let ty::Error(_) = field_ty.kind() {
181-
return true;
182-
}
183-
}
184-
}
185-
false
186-
}
187-
188176
/// Attempts to returns the deeply last field of nested structures, but
189177
/// does not apply any normalization in its search. Returns the same type
190178
/// if input `ty` is not a structure at all.

compiler/rustc_smir/src/rustc_smir/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,7 @@ fn rustc_terminator_to_terminator(
330330
target: target.as_usize(),
331331
unwind: rustc_unwind_to_unwind(unwind),
332332
},
333-
Yield { .. } => todo!(),
334-
GeneratorDrop => Terminator::GeneratorDrop,
335-
FalseEdge { .. } => todo!(),
336-
FalseUnwind { .. } => todo!(),
337333
InlineAsm { .. } => todo!(),
334+
Yield { .. } | GeneratorDrop | FalseEdge { .. } | FalseUnwind { .. } => unreachable!(),
338335
}
339336
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use super::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy};
2+
use super::{Target, TargetOptions};
3+
4+
pub fn target() -> Target {
5+
Target {
6+
llvm_target: "loongarch64-unknown-none".into(),
7+
pointer_width: 64,
8+
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(),
9+
arch: "loongarch64".into(),
10+
options: TargetOptions {
11+
cpu: "generic".into(),
12+
features: "+f,+d".into(),
13+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::No),
14+
llvm_abiname: "lp64d".into(),
15+
max_atomic_width: Some(64),
16+
position_independent_executables: true,
17+
static_position_independent_executables: true,
18+
panic_strategy: PanicStrategy::Abort,
19+
code_model: Some(CodeModel::Small),
20+
..Default::default()
21+
},
22+
}
23+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use super::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy};
2+
use super::{Target, TargetOptions};
3+
4+
pub fn target() -> Target {
5+
Target {
6+
llvm_target: "loongarch64-unknown-none-softfloat".into(),
7+
pointer_width: 64,
8+
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(),
9+
arch: "loongarch64".into(),
10+
options: TargetOptions {
11+
cpu: "generic".into(),
12+
features: "-f,-d".into(),
13+
abi: "softfloat".into(),
14+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::No),
15+
llvm_abiname: "lp64s".into(),
16+
max_atomic_width: Some(64),
17+
position_independent_executables: true,
18+
static_position_independent_executables: true,
19+
panic_strategy: PanicStrategy::Abort,
20+
code_model: Some(CodeModel::Small),
21+
..Default::default()
22+
},
23+
}
24+
}

compiler/rustc_target/src/spec/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,9 @@ supported_targets! {
12941294
("riscv64gc-unknown-linux-gnu", riscv64gc_unknown_linux_gnu),
12951295
("riscv64gc-unknown-linux-musl", riscv64gc_unknown_linux_musl),
12961296

1297+
("loongarch64-unknown-none", loongarch64_unknown_none),
1298+
("loongarch64-unknown-none-softfloat", loongarch64_unknown_none_softfloat),
1299+
12971300
("aarch64-unknown-none", aarch64_unknown_none),
12981301
("aarch64-unknown-none-softfloat", aarch64_unknown_none_softfloat),
12991302

0 commit comments

Comments
 (0)