Skip to content

Rollup of 8 pull requests #114024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d1380a1
Use erased self type when autoderefing for trait error suggestion
compiler-errors Jul 23, 2023
f355369
Comment stuff in the new solver
compiler-errors Jul 23, 2023
a8f1b72
Remove "-unknown" from `llvm_target` for arm*v7r-none-eabi* targets.
chrisnc Apr 18, 2023
ef89948
Remove redundant `c_enum_min_bits` option from the thumbv4t-none-eabi…
chrisnc Jul 18, 2023
8e54cab
Fix comments about GCC/Clang's enum width for arm-none targets.
chrisnc Jul 18, 2023
c2158a4
generic smir stable impl for Binder
ericmarkmartin Jul 24, 2023
e36b901
Optimize format usage
nyurik Jul 24, 2023
badb617
Dynamic for smir
ericmarkmartin Jul 24, 2023
bb1ad0a
Optimize format usage
nyurik Jul 24, 2023
b787fc0
Remove redundant note.
jonathanpallant Jul 17, 2023
34e01d5
Add clarification about build-std and using newer instructions.
jonathanpallant Jul 17, 2023
8cab95e
Add missing documentation for `Session::time`
GuillaumeGomez Jul 24, 2023
3ad3bb6
lcnr's suggestions
compiler-errors Jul 24, 2023
60a5d2d
Rollup merge of #113969 - ericmarkmartin:smir-ty-dynamic, r=spastorino
matthiaskrgr Jul 24, 2023
15c7234
Rollup merge of #113985 - compiler-errors:issue-113951, r=estebank
matthiaskrgr Jul 24, 2023
2660d5d
Rollup merge of #113987 - compiler-errors:comments, r=lcnr
matthiaskrgr Jul 24, 2023
4d2f98d
Rollup merge of #113992 - chrisnc:arm-none-fixups, r=oli-obk
matthiaskrgr Jul 24, 2023
974a1c2
Rollup merge of #113993 - nyurik:ref_format_errors, r=WaffleLapkin
matthiaskrgr Jul 24, 2023
3723b30
Rollup merge of #113994 - nyurik:parser-fmt-ref, r=davidtwco
matthiaskrgr Jul 24, 2023
4ee3266
Rollup merge of #114006 - jonathanpallant:update-sparc-unknown-readme…
matthiaskrgr Jul 24, 2023
a516425
Rollup merge of #114021 - GuillaumeGomez:session-time-docs, r=lcnr
matthiaskrgr Jul 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,13 @@ impl Diagnostic {
let expected_label = if expected_label.is_empty() {
"expected".to_string()
} else {
format!("expected {}", expected_label)
format!("expected {expected_label}")
};
let found_label = found_label.to_string();
let found_label = if found_label.is_empty() {
"found".to_string()
} else {
format!("found {}", found_label)
format!("found {found_label}")
};
let (found_padding, expected_padding) = if expected_label.len() > found_label.len() {
(expected_label.len() - found_label.len(), 0)
Expand All @@ -439,13 +439,13 @@ impl Diagnostic {
StringPart::Normal(ref s) => (s.to_owned(), Style::NoStyle),
StringPart::Highlighted(ref s) => (s.to_owned(), Style::Highlight),
}));
msg.push((format!("`{}\n", expected_extra), Style::NoStyle));
msg.push((format!("`{expected_extra}\n"), Style::NoStyle));
msg.push((format!("{}{} `", " ".repeat(found_padding), found_label), Style::NoStyle));
msg.extend(found.0.iter().map(|x| match *x {
StringPart::Normal(ref s) => (s.to_owned(), Style::NoStyle),
StringPart::Highlighted(ref s) => (s.to_owned(), Style::Highlight),
}));
msg.push((format!("`{}", found_extra), Style::NoStyle));
msg.push((format!("`{found_extra}"), Style::NoStyle));

// For now, just attach these as notes.
self.highlighted_note(msg);
Expand All @@ -454,7 +454,7 @@ impl Diagnostic {

pub fn note_trait_signature(&mut self, name: Symbol, signature: String) -> &mut Self {
self.highlighted_note(vec![
(format!("`{}` from trait: `", name), Style::NoStyle),
(format!("`{name}` from trait: `"), Style::NoStyle),
(signature, Style::Highlight),
("`".to_string(), Style::NoStyle),
]);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/diagnostic_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl IntoDiagnosticArg for bool {

impl IntoDiagnosticArg for char {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
DiagnosticArgValue::Str(Cow::Owned(format!("{:?}", self)))
DiagnosticArgValue::Str(Cow::Owned(format!("{self:?}")))
}
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,12 @@ pub trait Emitter: Translate {
let msg = if substitution.is_empty() || sugg.style.hide_inline() {
// This substitution is only removal OR we explicitly don't want to show the
// code inline (`hide_inline`). Therefore, we don't show the substitution.
format!("help: {}", &msg)
format!("help: {msg}")
} else {
// Show the default suggestion text with the substitution
format!(
"help: {}{}: `{}`",
&msg,
msg,
if self.source_map().is_some_and(|sm| is_case_difference(
sm,
substitution,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,7 @@ impl HandlerInner {
let _ = self.fatal(errors);
}
(_, _) => {
let _ = self.fatal(format!("{}; {}", &errors, &warnings));
let _ = self.fatal(format!("{errors}; {warnings}"));
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl<'a> Parser<'a> {
_ => unreachable!(),
}
.into();
let invalid = format!("{}=", &sugg);
let invalid = format!("{sugg}=");
self.sess.emit_err(errors::InvalidComparisonOperator {
span: sp,
invalid: invalid.clone(),
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_parse/src/validate_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,32 +157,32 @@ fn emit_malformed_attribute(
matches!(name, sym::doc | sym::ignore | sym::inline | sym::link | sym::test | sym::bench)
};

let error_msg = format!("malformed `{}` attribute input", name);
let error_msg = format!("malformed `{name}` attribute input");
let mut msg = "attribute must be of the form ".to_owned();
let mut suggestions = vec![];
let mut first = true;
let inner = if style == ast::AttrStyle::Inner { "!" } else { "" };
if template.word {
first = false;
let code = format!("#{}[{}]", inner, name);
msg.push_str(&format!("`{}`", &code));
let code = format!("#{inner}[{name}]");
msg.push_str(&format!("`{code}`"));
suggestions.push(code);
}
if let Some(descr) = template.list {
if !first {
msg.push_str(" or ");
}
first = false;
let code = format!("#{}[{}({})]", inner, name, descr);
msg.push_str(&format!("`{}`", &code));
let code = format!("#{inner}[{name}({descr})]");
msg.push_str(&format!("`{code}`"));
suggestions.push(code);
}
if let Some(descr) = template.name_value_str {
if !first {
msg.push_str(" or ");
}
let code = format!("#{}[{} = \"{}\"]", inner, name, descr);
msg.push_str(&format!("`{}`", &code));
let code = format!("#{inner}[{name} = \"{descr}\"]");
msg.push_str(&format!("`{code}`"));
suggestions.push(code);
}
if should_warn(name) {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_session/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ impl Session {
pub fn timer(&self, what: &'static str) -> VerboseTimingGuard<'_> {
self.prof.verbose_generic_activity(what)
}
/// Used by `-Z self-profile`.
pub fn time<R>(&self, what: &'static str, f: impl FnOnce() -> R) -> R {
self.prof.verbose_generic_activity(what).run(f)
}
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_smir/src/rustc_internal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ pub fn br_named_def(did: DefId) -> stable_mir::ty::BrNamedDef {
with_tables(|t| t.br_named_def(did))
}

pub fn trait_def(did: DefId) -> stable_mir::ty::TraitDef {
with_tables(|t| t.trait_def(did))
}

impl<'tcx> Tables<'tcx> {
pub fn item_def_id(&self, item: &stable_mir::CrateItem) -> DefId {
self.def_ids[item.0]
Expand Down Expand Up @@ -100,6 +104,10 @@ impl<'tcx> Tables<'tcx> {
stable_mir::ty::BrNamedDef(self.create_def_id(did))
}

pub fn trait_def(&mut self, did: DefId) -> stable_mir::ty::TraitDef {
stable_mir::ty::TraitDef(self.create_def_id(did))
}

fn create_def_id(&mut self, did: DefId) -> stable_mir::DefId {
// FIXME: this becomes inefficient when we have too many ids
for (i, &d) in self.def_ids.iter().enumerate() {
Expand Down
87 changes: 83 additions & 4 deletions compiler/rustc_smir/src/rustc_smir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,72 @@ impl<'tcx> Stable<'tcx> for ty::AliasTy<'tcx> {
}
}

impl<'tcx> Stable<'tcx> for ty::DynKind {
type T = stable_mir::ty::DynKind;

fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
use ty::DynKind;
match self {
DynKind::Dyn => stable_mir::ty::DynKind::Dyn,
DynKind::DynStar => stable_mir::ty::DynKind::DynStar,
}
}
}

impl<'tcx> Stable<'tcx> for ty::ExistentialPredicate<'tcx> {
type T = stable_mir::ty::ExistentialPredicate;

fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
use stable_mir::ty::ExistentialPredicate::*;
match self {
ty::ExistentialPredicate::Trait(existential_trait_ref) => {
Trait(existential_trait_ref.stable(tables))
}
ty::ExistentialPredicate::Projection(existential_projection) => {
Projection(existential_projection.stable(tables))
}
ty::ExistentialPredicate::AutoTrait(def_id) => AutoTrait(tables.trait_def(*def_id)),
}
}
}

impl<'tcx> Stable<'tcx> for ty::ExistentialTraitRef<'tcx> {
type T = stable_mir::ty::ExistentialTraitRef;

fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
let ty::ExistentialTraitRef { def_id, args } = self;
stable_mir::ty::ExistentialTraitRef {
def_id: tables.trait_def(*def_id),
generic_args: args.stable(tables),
}
}
}

impl<'tcx> Stable<'tcx> for ty::TermKind<'tcx> {
type T = stable_mir::ty::TermKind;

fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
use stable_mir::ty::TermKind;
match self {
ty::TermKind::Ty(ty) => TermKind::Type(tables.intern_ty(*ty)),
ty::TermKind::Const(const_) => TermKind::Const(opaque(const_)),
}
}
}

impl<'tcx> Stable<'tcx> for ty::ExistentialProjection<'tcx> {
type T = stable_mir::ty::ExistentialProjection;

fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
let ty::ExistentialProjection { def_id, args, term } = self;
stable_mir::ty::ExistentialProjection {
def_id: tables.trait_def(*def_id),
generic_args: args.stable(tables),
term: term.unpack().stable(tables),
}
}
}

impl<'tcx> Stable<'tcx> for ty::adjustment::PointerCoercion {
type T = stable_mir::mir::PointerCoercion;
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
Expand Down Expand Up @@ -525,13 +591,17 @@ impl<'tcx> Stable<'tcx> for ty::GenericArgs<'tcx> {
}
}

impl<'tcx> Stable<'tcx> for ty::PolyFnSig<'tcx> {
type T = stable_mir::ty::PolyFnSig;
impl<'tcx, S, V> Stable<'tcx> for ty::Binder<'tcx, S>
where
S: Stable<'tcx, T = V>,
{
type T = stable_mir::ty::Binder<V>;

fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
use stable_mir::ty::Binder;

Binder {
value: self.skip_binder().stable(tables),
value: self.as_ref().skip_binder().stable(tables),
bound_vars: self
.bound_vars()
.iter()
Expand Down Expand Up @@ -671,7 +741,16 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
generic_args.stable(tables),
)),
ty::FnPtr(poly_fn_sig) => TyKind::RigidTy(RigidTy::FnPtr(poly_fn_sig.stable(tables))),
ty::Dynamic(_, _, _) => todo!(),
ty::Dynamic(existential_predicates, region, dyn_kind) => {
TyKind::RigidTy(RigidTy::Dynamic(
existential_predicates
.iter()
.map(|existential_predicate| existential_predicate.stable(tables))
.collect(),
opaque(region),
dyn_kind.stable(tables),
))
}
ty::Closure(def_id, generic_args) => TyKind::RigidTy(RigidTy::Closure(
rustc_internal::closure_def(*def_id),
generic_args.stable(tables),
Expand Down
36 changes: 36 additions & 0 deletions compiler/rustc_smir/src/stable_mir/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub enum RigidTy {
FnPtr(PolyFnSig),
Closure(ClosureDef, GenericArgs),
Generator(GeneratorDef, GenericArgs, Movability),
Dynamic(Vec<Binder<ExistentialPredicate>>, Region, DynKind),
Never,
Tuple(Vec<Ty>),
}
Expand Down Expand Up @@ -98,6 +99,9 @@ pub struct AdtDef(pub(crate) DefId);
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct AliasDef(pub(crate) DefId);

#[derive(Clone, PartialEq, Eq, Debug)]
pub struct TraitDef(pub(crate) DefId);

#[derive(Clone, Debug)]
pub struct GenericArgs(pub Vec<GenericArgKind>);

Expand All @@ -108,6 +112,12 @@ pub enum GenericArgKind {
Const(Const),
}

#[derive(Clone, Debug)]
pub enum TermKind {
Type(Ty),
Const(Const),
}

#[derive(Clone, Debug)]
pub enum AliasKind {
Projection,
Expand Down Expand Up @@ -192,3 +202,29 @@ pub enum BoundRegionKind {
BrNamed(BrNamedDef, String),
BrEnv,
}

#[derive(Clone, Debug)]
pub enum DynKind {
Dyn,
DynStar,
}

#[derive(Clone, Debug)]
pub enum ExistentialPredicate {
Trait(ExistentialTraitRef),
Projection(ExistentialProjection),
AutoTrait(TraitDef),
}

#[derive(Clone, Debug)]
pub struct ExistentialTraitRef {
pub def_id: TraitDef,
pub generic_args: GenericArgs,
}

#[derive(Clone, Debug)]
pub struct ExistentialProjection {
pub def_id: TraitDef,
pub generic_args: GenericArgs,
pub term: TermKind,
}
4 changes: 2 additions & 2 deletions compiler/rustc_target/src/spec/armebv7r_none_eabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, Targ

pub fn target() -> Target {
Target {
llvm_target: "armebv7r-unknown-none-eabi".into(),
llvm_target: "armebv7r-none-eabi".into(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),
Expand All @@ -18,7 +18,7 @@ pub fn target() -> Target {
panic_strategy: PanicStrategy::Abort,
max_atomic_width: Some(64),
emit_debug_gdb_scripts: false,
// GCC and Clang default to 8 for arm-none here
// GCC defaults to 8 for arm-none here.
c_enum_min_bits: Some(8),
..Default::default()
},
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, Targ

pub fn target() -> Target {
Target {
llvm_target: "armebv7r-unknown-none-eabihf".into(),
llvm_target: "armebv7r-none-eabihf".into(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),
Expand All @@ -19,7 +19,7 @@ pub fn target() -> Target {
features: "+vfp3,-d32,-fp16".into(),
max_atomic_width: Some(64),
emit_debug_gdb_scripts: false,
// GCC and Clang default to 8 for arm-none here
// GCC defaults to 8 for arm-none here.
c_enum_min_bits: Some(8),
..Default::default()
},
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_target/src/spec/armv4t_none_eabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ pub fn target() -> Target {
has_thumb_interworking: true,
relocation_model: RelocModel::Static,
panic_strategy: PanicStrategy::Abort,
// from thumb_base, rust-lang/rust#44993.
// From thumb_base, rust-lang/rust#44993.
emit_debug_gdb_scripts: false,
// from thumb_base, apparently gcc/clang give enums a minimum of 8 bits on no-os targets
// From thumb_base, GCC gives enums a minimum of 8 bits on no-os targets.
c_enum_min_bits: Some(8),
..Default::default()
},
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/armv7a_none_eabihf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn target() -> Target {
max_atomic_width: Some(64),
panic_strategy: PanicStrategy::Abort,
emit_debug_gdb_scripts: false,
// GCC and Clang default to 8 for arm-none here
// GCC defaults to 8 for arm-none here.
c_enum_min_bits: Some(8),
..Default::default()
};
Expand Down
Loading