Skip to content

Commit

Permalink
Auto merge of #113577 - matthiaskrgr:rollup-vaa83ip, r=matthiaskrgr
Browse files Browse the repository at this point in the history
Rollup of 4 pull requests

Successful merges:

 - #112717 (Implement a few more rvalue translation to smir)
 - #113310 (Don't suggest `impl Trait` in path position)
 - #113497 (Support explicit 32-bit MIPS ABI for the synthetic object)
 - #113560 (Lint against misplaced where-clauses on associated types in traits)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Jul 11, 2023
2 parents 0a2681c + 4f5ef52 commit e571544
Show file tree
Hide file tree
Showing 21 changed files with 498 additions and 66 deletions.
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4233,6 +4233,7 @@ dependencies = [
"rustc_hir",
"rustc_middle",
"rustc_span",
"rustc_target",
"scoped-tls",
"tracing",
]
Expand Down
31 changes: 16 additions & 15 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1300,33 +1300,34 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
});
}
}
AssocItemKind::Type(box TyAlias {
generics,
where_clauses,
where_predicates_split,
bounds,
ty,
..
}) => {
AssocItemKind::Type(box TyAlias { bounds, ty, .. }) => {
if ty.is_none() {
self.session.emit_err(errors::AssocTypeWithoutBody {
span: item.span,
replace_span: self.ending_semi_or_hi(item.span),
});
}
self.check_type_no_bounds(bounds, "`impl`s");
if ty.is_some() {
self.check_gat_where(
item.id,
generics.where_clause.predicates.split_at(*where_predicates_split).0,
*where_clauses,
);
}
}
_ => {}
}
}

if let AssocItemKind::Type(box TyAlias {
generics,
where_clauses,
where_predicates_split,
ty: Some(_),
..
}) = &item.kind
{
self.check_gat_where(
item.id,
generics.where_clause.predicates.split_at(*where_predicates_split).0,
*where_clauses,
);
}

if ctxt == AssocCtxt::Trait || self.in_trait_impl {
self.visibility_not_permitted(&item.vis, errors::VisibilityNotPermittedNote::TraitImpl);
if let AssocItemKind::Fn(box Fn { sig, .. }) = &item.kind {
Expand Down
12 changes: 10 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,16 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
s if s.contains("r6") => elf::EF_MIPS_ARCH_32R6,
_ => elf::EF_MIPS_ARCH_32R2,
};
// The only ABI LLVM supports for 32-bit MIPS CPUs is o32.
let mut e_flags = elf::EF_MIPS_CPIC | elf::EF_MIPS_ABI_O32 | arch;

let mut e_flags = elf::EF_MIPS_CPIC | arch;

// If the ABI is explicitly given, use it or default to O32.
match sess.target.options.llvm_abiname.to_lowercase().as_str() {
"n32" => e_flags |= elf::EF_MIPS_ABI2,
"o32" => e_flags |= elf::EF_MIPS_ABI_O32,
_ => e_flags |= elf::EF_MIPS_ABI_O32,
};

if sess.target.options.relocation_model != RelocModel::Static {
e_flags |= elf::EF_MIPS_PIC;
}
Expand Down
12 changes: 10 additions & 2 deletions compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,18 @@ fn fmt_printer<'a, 'tcx>(infcx: &'a InferCtxt<'tcx>, ns: Namespace) -> FmtPrinte
let mut infcx_inner = infcx.inner.borrow_mut();
let ty_vars = infcx_inner.type_variables();
let var_origin = ty_vars.var_origin(ty_vid);
if let TypeVariableOriginKind::TypeParameterDefinition(name, _) = var_origin.kind
if let TypeVariableOriginKind::TypeParameterDefinition(name, def_id) = var_origin.kind
&& !var_origin.span.from_expansion()
{
Some(name)
let generics = infcx.tcx.generics_of(infcx.tcx.parent(def_id));
let idx = generics.param_def_id_to_index(infcx.tcx, def_id).unwrap();
let generic_param_def = generics.param_at(idx as usize, infcx.tcx);
if let ty::GenericParamDefKind::Type { synthetic: true, .. } = generic_param_def.kind
{
None
} else {
Some(name)
}
} else {
None
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4084,7 +4084,7 @@ declare_lint! {
///
/// ### Explanation
///
/// The preferred location for where clauses on associated types in impls
/// The preferred location for where clauses on associated types
/// is after the type. However, for most of generic associated types development,
/// it was only accepted before the equals. To provide a transition period and
/// further evaluate this change, both are currently accepted. At some point in
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_smir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ version = "0.0.0"
edition = "2021"

[dependencies]
rustc_hir = { path = "../rustc_hir" }
# Use optional dependencies for rustc_* in order to support building this crate separately.
rustc_hir = { path = "../rustc_hir", optional = true }
rustc_middle = { path = "../rustc_middle", optional = true }
rustc_span = { path = "../rustc_span", optional = true }
rustc_target = { path = "../rustc_target", optional = true }
tracing = "0.1"
scoped-tls = "1.0"

[features]
default = [
"rustc_hir",
"rustc_middle",
"rustc_span",
"rustc_target",
]
2 changes: 1 addition & 1 deletion compiler/rustc_smir/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2023-02-28"
channel = "nightly-2023-06-14"
components = [ "rustfmt", "rustc-dev" ]
11 changes: 11 additions & 0 deletions compiler/rustc_smir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
#![cfg_attr(not(feature = "default"), feature(rustc_private))]
#![feature(local_key_cell_methods)]
#![feature(ptr_metadata)]
#![feature(type_alias_impl_trait)] // Used to define opaque types.

// Declare extern rustc_* crates to enable building this crate separately from the compiler.
#[cfg(not(feature = "default"))]
extern crate rustc_hir;
#[cfg(not(feature = "default"))]
extern crate rustc_middle;
#[cfg(not(feature = "default"))]
extern crate rustc_span;
#[cfg(not(feature = "default"))]
extern crate rustc_target;

pub mod rustc_internal;
pub mod stable_mir;
Expand Down
10 changes: 10 additions & 0 deletions compiler/rustc_smir/src/rustc_internal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
//! For that, we define APIs that will temporarily be public to 3P that exposes rustc internal APIs
//! until stable MIR is complete.

use std::fmt::Debug;
use std::string::ToString;

use crate::{
rustc_smir::Tables,
stable_mir::{self, with},
Expand Down Expand Up @@ -49,3 +52,10 @@ pub fn crate_num(item: &stable_mir::Crate) -> CrateNum {
pub fn run(tcx: TyCtxt<'_>, f: impl FnOnce()) {
crate::stable_mir::run(Tables { tcx, def_ids: vec![], types: vec![] }, f);
}

/// A type that provides internal information but that can still be used for debug purpose.
pub type Opaque = impl Debug + ToString + Clone;

pub(crate) fn opaque<T: Debug>(value: &T) -> Opaque {
format!("{value:?}")
}

0 comments on commit e571544

Please sign in to comment.