Skip to content

Commit e571544

Browse files
committed
Auto merge of rust-lang#113577 - matthiaskrgr:rollup-vaa83ip, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - rust-lang#112717 (Implement a few more rvalue translation to smir) - rust-lang#113310 (Don't suggest `impl Trait` in path position) - rust-lang#113497 (Support explicit 32-bit MIPS ABI for the synthetic object) - rust-lang#113560 (Lint against misplaced where-clauses on associated types in traits) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0a2681c + 4f5ef52 commit e571544

21 files changed

+498
-66
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4233,6 +4233,7 @@ dependencies = [
42334233
"rustc_hir",
42344234
"rustc_middle",
42354235
"rustc_span",
4236+
"rustc_target",
42364237
"scoped-tls",
42374238
"tracing",
42384239
]

compiler/rustc_ast_passes/src/ast_validation.rs

+16-15
Original file line numberDiff line numberDiff line change
@@ -1300,33 +1300,34 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
13001300
});
13011301
}
13021302
}
1303-
AssocItemKind::Type(box TyAlias {
1304-
generics,
1305-
where_clauses,
1306-
where_predicates_split,
1307-
bounds,
1308-
ty,
1309-
..
1310-
}) => {
1303+
AssocItemKind::Type(box TyAlias { bounds, ty, .. }) => {
13111304
if ty.is_none() {
13121305
self.session.emit_err(errors::AssocTypeWithoutBody {
13131306
span: item.span,
13141307
replace_span: self.ending_semi_or_hi(item.span),
13151308
});
13161309
}
13171310
self.check_type_no_bounds(bounds, "`impl`s");
1318-
if ty.is_some() {
1319-
self.check_gat_where(
1320-
item.id,
1321-
generics.where_clause.predicates.split_at(*where_predicates_split).0,
1322-
*where_clauses,
1323-
);
1324-
}
13251311
}
13261312
_ => {}
13271313
}
13281314
}
13291315

1316+
if let AssocItemKind::Type(box TyAlias {
1317+
generics,
1318+
where_clauses,
1319+
where_predicates_split,
1320+
ty: Some(_),
1321+
..
1322+
}) = &item.kind
1323+
{
1324+
self.check_gat_where(
1325+
item.id,
1326+
generics.where_clause.predicates.split_at(*where_predicates_split).0,
1327+
*where_clauses,
1328+
);
1329+
}
1330+
13301331
if ctxt == AssocCtxt::Trait || self.in_trait_impl {
13311332
self.visibility_not_permitted(&item.vis, errors::VisibilityNotPermittedNote::TraitImpl);
13321333
if let AssocItemKind::Fn(box Fn { sig, .. }) = &item.kind {

compiler/rustc_codegen_ssa/src/back/metadata.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,16 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
243243
s if s.contains("r6") => elf::EF_MIPS_ARCH_32R6,
244244
_ => elf::EF_MIPS_ARCH_32R2,
245245
};
246-
// The only ABI LLVM supports for 32-bit MIPS CPUs is o32.
247-
let mut e_flags = elf::EF_MIPS_CPIC | elf::EF_MIPS_ABI_O32 | arch;
246+
247+
let mut e_flags = elf::EF_MIPS_CPIC | arch;
248+
249+
// If the ABI is explicitly given, use it or default to O32.
250+
match sess.target.options.llvm_abiname.to_lowercase().as_str() {
251+
"n32" => e_flags |= elf::EF_MIPS_ABI2,
252+
"o32" => e_flags |= elf::EF_MIPS_ABI_O32,
253+
_ => e_flags |= elf::EF_MIPS_ABI_O32,
254+
};
255+
248256
if sess.target.options.relocation_model != RelocModel::Static {
249257
e_flags |= elf::EF_MIPS_PIC;
250258
}

compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,18 @@ fn fmt_printer<'a, 'tcx>(infcx: &'a InferCtxt<'tcx>, ns: Namespace) -> FmtPrinte
162162
let mut infcx_inner = infcx.inner.borrow_mut();
163163
let ty_vars = infcx_inner.type_variables();
164164
let var_origin = ty_vars.var_origin(ty_vid);
165-
if let TypeVariableOriginKind::TypeParameterDefinition(name, _) = var_origin.kind
165+
if let TypeVariableOriginKind::TypeParameterDefinition(name, def_id) = var_origin.kind
166166
&& !var_origin.span.from_expansion()
167167
{
168-
Some(name)
168+
let generics = infcx.tcx.generics_of(infcx.tcx.parent(def_id));
169+
let idx = generics.param_def_id_to_index(infcx.tcx, def_id).unwrap();
170+
let generic_param_def = generics.param_at(idx as usize, infcx.tcx);
171+
if let ty::GenericParamDefKind::Type { synthetic: true, .. } = generic_param_def.kind
172+
{
173+
None
174+
} else {
175+
Some(name)
176+
}
169177
} else {
170178
None
171179
}

compiler/rustc_lint_defs/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4084,7 +4084,7 @@ declare_lint! {
40844084
///
40854085
/// ### Explanation
40864086
///
4087-
/// The preferred location for where clauses on associated types in impls
4087+
/// The preferred location for where clauses on associated types
40884088
/// is after the type. However, for most of generic associated types development,
40894089
/// it was only accepted before the equals. To provide a transition period and
40904090
/// further evaluate this change, both are currently accepted. At some point in

compiler/rustc_smir/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ version = "0.0.0"
44
edition = "2021"
55

66
[dependencies]
7-
rustc_hir = { path = "../rustc_hir" }
7+
# Use optional dependencies for rustc_* in order to support building this crate separately.
8+
rustc_hir = { path = "../rustc_hir", optional = true }
89
rustc_middle = { path = "../rustc_middle", optional = true }
910
rustc_span = { path = "../rustc_span", optional = true }
11+
rustc_target = { path = "../rustc_target", optional = true }
1012
tracing = "0.1"
1113
scoped-tls = "1.0"
1214

1315
[features]
1416
default = [
17+
"rustc_hir",
1518
"rustc_middle",
1619
"rustc_span",
20+
"rustc_target",
1721
]
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2023-02-28"
2+
channel = "nightly-2023-06-14"
33
components = [ "rustfmt", "rustc-dev" ]

compiler/rustc_smir/src/lib.rs

+11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@
1313
#![cfg_attr(not(feature = "default"), feature(rustc_private))]
1414
#![feature(local_key_cell_methods)]
1515
#![feature(ptr_metadata)]
16+
#![feature(type_alias_impl_trait)] // Used to define opaque types.
17+
18+
// Declare extern rustc_* crates to enable building this crate separately from the compiler.
19+
#[cfg(not(feature = "default"))]
20+
extern crate rustc_hir;
21+
#[cfg(not(feature = "default"))]
22+
extern crate rustc_middle;
23+
#[cfg(not(feature = "default"))]
24+
extern crate rustc_span;
25+
#[cfg(not(feature = "default"))]
26+
extern crate rustc_target;
1627

1728
pub mod rustc_internal;
1829
pub mod stable_mir;

compiler/rustc_smir/src/rustc_internal/mod.rs

+10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
//! For that, we define APIs that will temporarily be public to 3P that exposes rustc internal APIs
44
//! until stable MIR is complete.
55
6+
use std::fmt::Debug;
7+
use std::string::ToString;
8+
69
use crate::{
710
rustc_smir::Tables,
811
stable_mir::{self, with},
@@ -49,3 +52,10 @@ pub fn crate_num(item: &stable_mir::Crate) -> CrateNum {
4952
pub fn run(tcx: TyCtxt<'_>, f: impl FnOnce()) {
5053
crate::stable_mir::run(Tables { tcx, def_ids: vec![], types: vec![] }, f);
5154
}
55+
56+
/// A type that provides internal information but that can still be used for debug purpose.
57+
pub type Opaque = impl Debug + ToString + Clone;
58+
59+
pub(crate) fn opaque<T: Debug>(value: &T) -> Opaque {
60+
format!("{value:?}")
61+
}

0 commit comments

Comments
 (0)