Skip to content

Commit afab366

Browse files
committed
Auto merge of rust-lang#112361 - matthiaskrgr:rollup-39zxrw1, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#111250 (Add Terminator conversion from MIR to SMIR, part #2) - rust-lang#112310 (Add new Tier-3 targets: `loongarch64-unknown-none*`) - rust-lang#112334 (Add myself to highfive rotation) - rust-lang#112340 (remove `TyCtxt::has_error_field` helper method) - rust-lang#112343 (Prevent emitting `missing_docs` for `pub extern crate`) - rust-lang#112350 (Avoid duplicate type sanitization of local decls in borrowck) - rust-lang#112356 (Fix comment for `get_region_var_origins`) - rust-lang#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

+2-6
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

+1-3
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

+5-3
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

+5-5
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

+6-2
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

-12
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

+1-4
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
}
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+
}
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

+3
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

src/doc/rustc/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
- [\*-unknown-fuchsia](platform-support/fuchsia.md)
3232
- [\*-kmc-solid_\*](platform-support/kmc-solid.md)
3333
- [loongarch\*-unknown-linux-\*](platform-support/loongarch-linux.md)
34+
- [loongarch\*-unknown-none\*](platform-support/loongarch-none.md)
3435
- [m68k-unknown-linux-gnu](platform-support/m68k-unknown-linux-gnu.md)
3536
- [mips64-openwrt-linux-musl](platform-support/mips64-openwrt-linux-musl.md)
3637
- [mipsel-sony-psx](platform-support/mipsel-sony-psx.md)

src/doc/rustc/src/platform-support.md

+2
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ target | std | host | notes
267267
`i686-uwp-windows-gnu` | ? | |
268268
`i686-uwp-windows-msvc` | ? | |
269269
`i686-wrs-vxworks` | ? | |
270+
[`loongarch64-unknown-none`](platform-support/loongarch-none.md) | * | LoongArch64 Bare-metal (LP64D ABI)
271+
[`loongarch64-unknown-none-softfloat`](platform-support/loongarch-none.md) | * | LoongArch64 Bare-metal (LP64S ABI)
270272
[`m68k-unknown-linux-gnu`](platform-support/m68k-unknown-linux-gnu.md) | ? | | Motorola 680x0 Linux
271273
`mips-unknown-linux-uclibc` | ✓ | | MIPS Linux with uClibc
272274
[`mips64-openwrt-linux-musl`](platform-support/mips64-openwrt-linux-musl.md) | ? | | MIPS64 for OpenWrt Linux MUSL
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# `loongarch*-unknown-none*`
2+
3+
**Tier: 3**
4+
5+
Freestanding/bare-metal LoongArch64 binaries in ELF format: firmware, kernels, etc.
6+
7+
| Target | Descriptions |
8+
|------------------------------------|-------------------------------------------------------|
9+
| loongarch64-unknown-none | LoongArch 64-bit, LP64D ABI (freestanding, hardfloat) |
10+
| loongarch64-unknown-none-softfloat | LoongArch 64-bit, LP64S ABI (freestanding, softfloat) |
11+
12+
## Target maintainers
13+
14+
- [WANG Rui](https://github.com/heiher) `[email protected]`
15+
- [WANG Xuerui](https://github.com/xen0n) `[email protected]`
16+
17+
## Requirements
18+
19+
This target is cross-compiled. There is no support for `std`. There is no
20+
default allocator, but it's possible to use `alloc` by supplying an allocator.
21+
22+
This allows the generated code to run in environments, such as kernels, which
23+
may need to avoid the use of such registers or which may have special considerations
24+
about the use of such registers (e.g. saving and restoring them to avoid breaking
25+
userspace code using the same registers). You can change code generation to use
26+
additional CPU features via the `-C target-feature=` codegen options to rustc, or
27+
via the `#[target_feature]` mechanism within Rust code.
28+
29+
By default, code generated with this target should run on any `loongarch`
30+
hardware; enabling additional target features may raise this baseline.
31+
32+
Code generated with this target will use the `small` code model by default.
33+
You can change this using the `-C code-model=` option to rustc.
34+
35+
On `loongarch64-unknown-none*`, `extern "C"` uses the [standard calling
36+
convention](https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html).
37+
38+
This target generates binaries in the ELF format. Any alternate formats or
39+
special considerations for binary layout will require linker options or linker
40+
scripts.
41+
42+
## Building the target
43+
44+
You can build Rust with support for the target by adding it to the `target`
45+
list in `config.toml`:
46+
47+
```toml
48+
[build]
49+
build-stage = 1
50+
target = ["loongarch64-unknown-none"]
51+
```
52+
53+
## Building Rust programs
54+
55+
```text
56+
# target flag may be used with any cargo or rustc command
57+
cargo build --target loongarch64-unknown-none
58+
```
59+
60+
## Testing
61+
62+
As `loongarch64-unknown-none*` supports a variety of different environments and does
63+
not support `std`, this target does not support running the Rust test suite.
64+
65+
## Cross-compilation toolchains and C code
66+
67+
If you want to compile C code along with Rust (such as for Rust crates with C
68+
dependencies), you will need an appropriate `loongarch` toolchain.
69+
70+
Rust *may* be able to use an `loongarch64-unknown-linux-gnu-` toolchain with
71+
appropriate standalone flags to build for this toolchain (depending on the assumptions
72+
of that toolchain, see below), or you may wish to use a separate
73+
`loongarch64-unknown-none` toolchain.
74+
75+
On some `loongarch` hosts that use ELF binaries, you *may* be able to use the host
76+
C toolchain, if it does not introduce assumptions about the host environment
77+
that don't match the expectations of a standalone environment. Otherwise, you
78+
may need a separate toolchain for standalone/freestanding development, just as
79+
when cross-compiling from a non-`loongarch` platform.

tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr

+2-12
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@ LL | pub struct Dependent<T, const X: T>([(); X]);
66
|
77
= note: type parameters may not be used in the type of const parameters
88

9-
error[E0392]: parameter `T` is never used
10-
--> $DIR/const-param-type-depends-on-type-param.rs:11:22
11-
|
12-
LL | pub struct Dependent<T, const X: T>([(); X]);
13-
| ^ unused parameter
14-
|
15-
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
16-
= help: if you intended `T` to be a const parameter, use `const T: usize` instead
17-
18-
error: aborting due to 2 previous errors
9+
error: aborting due to previous error
1910

20-
Some errors have detailed explanations: E0392, E0770.
21-
For more information about an error, try `rustc --explain E0392`.
11+
For more information about this error, try `rustc --explain E0770`.

tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr

+2-12
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@ LL | pub struct Dependent<T, const X: T>([(); X]);
66
|
77
= note: type parameters may not be used in the type of const parameters
88

9-
error[E0392]: parameter `T` is never used
10-
--> $DIR/const-param-type-depends-on-type-param.rs:11:22
11-
|
12-
LL | pub struct Dependent<T, const X: T>([(); X]);
13-
| ^ unused parameter
14-
|
15-
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
16-
= help: if you intended `T` to be a const parameter, use `const T: usize` instead
17-
18-
error: aborting due to 2 previous errors
9+
error: aborting due to previous error
1910

20-
Some errors have detailed explanations: E0392, E0770.
21-
For more information about an error, try `rustc --explain E0392`.
11+
For more information about this error, try `rustc --explain E0770`.

tests/ui/const-generics/const-param-type-depends-on-type-param.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@
1010

1111
pub struct Dependent<T, const X: T>([(); X]);
1212
//~^ ERROR: the type of const parameters must not depend on other generic parameters
13-
//~| ERROR: parameter `T` is never used
1413

1514
fn main() {}
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub struct Foo;

tests/ui/lint/lint-missing-doc.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// When denying at the crate level, be sure to not get random warnings from the
22
// injected intrinsics by the compiler.
3+
// aux-build:missing_docs.rs
34
#![deny(missing_docs)]
45
#![allow(dead_code)]
56
#![feature(associated_type_defaults, extern_types)]
@@ -8,6 +9,9 @@
89
//! Some garbage docs for the crate here
910
#![doc="More garbage"]
1011

12+
// There should be not "missing_docs" warning on "pub extern crate".
13+
pub extern crate missing_docs;
14+
1115
type Typedef = String;
1216
pub type PubTypedef = String; //~ ERROR: missing documentation for a type alias
1317

0 commit comments

Comments
 (0)