Skip to content
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

Rollup of 8 pull requests #112336

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
57e67e4
Don't suggest changing {ImmRef,MutRef} implicit self to be mutable
jieyouxu May 27, 2023
2a7c6a9
Fix suggestion for matching struct with `..` on both ends
jieyouxu Jun 2, 2023
1f5361b
Added custom risc32-imac for esp-espidf target
Nassiel Jun 4, 2023
c5145dc
Fix #111961 r=Mark-Simulacrum
theIDinside May 25, 2023
62c8c7c
Correct LVI print function test
raoulstrackx May 1, 2023
b35f243
Verify that (almost) all `ret` instructions have been replaced
raoulstrackx Jun 5, 2023
50117af
Std support improvement for ps vita target
nikarh Jun 4, 2023
ac48d49
Simplified bool to int conversion
nikarh Jun 5, 2023
57cbe25
cleanup some skip_binder -> subst_identity
kylematsuda Jun 2, 2023
467bc9f
diagnostics: do not suggest type name tweaks on type-inferred closure…
notriddle Jun 5, 2023
c7e1edc
Rollup merge of #111058 - fortanix:raoul/fix_lvi_mitigations, r=cuviper
matthiaskrgr Jun 6, 2023
8e52ed8
Rollup merge of #111369 - Nassiel:master, r=oli-obk
matthiaskrgr Jun 6, 2023
f06e951
Rollup merge of #111819 - nikarh:vita-improved, r=Amanieu
matthiaskrgr Jun 6, 2023
cfb96d8
Rollup merge of #111962 - theIDinside:better-gdb, r=Mark-Simulacrum
matthiaskrgr Jun 6, 2023
86076cd
Rollup merge of #112019 - jieyouxu:issue-111554, r=compiler-errors
matthiaskrgr Jun 6, 2023
00b2b66
Rollup merge of #112199 - jieyouxu:issue-112188, r=compiler-errors
matthiaskrgr Jun 6, 2023
0d24c6a
Rollup merge of #112220 - kylematsuda:earlybinder-fix, r=compiler-errors
matthiaskrgr Jun 6, 2023
eaa940a
Rollup merge of #112325 - notriddle:notriddle/issue-111932, r=compile…
matthiaskrgr Jun 6, 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
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1902,9 +1902,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"

[[package]]
name = "libc"
version = "0.2.143"
version = "0.2.145"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edc207893e85c5d6be840e969b496b53d94cec8be2d501b214f50daa97fa8024"
checksum = "fc86cde3ff845662b8f4ef6cb50ea0e20c524eb3d29ae048287e06a1b3fa6a81"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down
28 changes: 22 additions & 6 deletions compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,28 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
_,
) = pat.kind
{
err.span_suggestion(
upvar_ident.span,
"consider changing this to be mutable",
format!("mut {}", upvar_ident.name),
Applicability::MachineApplicable,
);
if upvar_ident.name == kw::SelfLower {
for (_, node) in self.infcx.tcx.hir().parent_iter(upvar_hir_id) {
if let Some(fn_decl) = node.fn_decl() {
if !matches!(fn_decl.implicit_self, hir::ImplicitSelfKind::ImmRef | hir::ImplicitSelfKind::MutRef) {
err.span_suggestion(
upvar_ident.span,
"consider changing this to be mutable",
format!("mut {}", upvar_ident.name),
Applicability::MachineApplicable,
);
break;
}
}
}
} else {
err.span_suggestion(
upvar_ident.span,
"consider changing this to be mutable",
format!("mut {}", upvar_ident.name),
Applicability::MachineApplicable,
);
}
}

let tcx = self.infcx.tcx;
Expand Down
14 changes: 13 additions & 1 deletion compiler/rustc_hir_typeck/src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,19 @@ pub(super) fn check_fn<'a, 'tcx>(
// for simple cases like `fn foo(x: Trait)`,
// where we would error once on the parameter as a whole, and once on the binding `x`.
if param.pat.simple_ident().is_none() && !params_can_be_unsized {
fcx.require_type_is_sized(param_ty, param.pat.span, traits::SizedArgumentType(ty_span));
fcx.require_type_is_sized(
param_ty,
param.pat.span,
// ty_span == binding_span iff this is a closure parameter with no type ascription,
// or if it's an implicit `self` parameter
traits::SizedArgumentType(
if ty_span == Some(param.span) && tcx.is_closure(fn_def_id.into()) {
None
} else {
ty_span
},
),
);
}

fcx.write_ty(param.hir_id, param_ty);
Expand Down
12 changes: 11 additions & 1 deletion compiler/rustc_hir_typeck/src/gather_locals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,17 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
self.fcx.require_type_is_sized(
var_ty,
p.span,
traits::SizedArgumentType(Some(ty_span)),
// ty_span == ident.span iff this is a closure parameter with no type
// ascription, or if it's an implicit `self` parameter
traits::SizedArgumentType(
if ty_span == ident.span
&& self.fcx.tcx.is_closure(self.fcx.body_id.into())
{
None
} else {
Some(ty_span)
},
),
);
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ impl<'tcx> Instance<'tcx> {
if let Some(substs) = self.substs_for_mir_body() {
v.subst(tcx, substs)
} else {
v.skip_binder()
v.subst_identity()
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ fn build_call_shim<'tcx>(
let mut sig = if let Some(sig_substs) = sig_substs {
sig.subst(tcx, &sig_substs)
} else {
sig.skip_binder()
sig.subst_identity()
};

if let CallKind::Indirect(fnty) = call_kind {
Expand Down
57 changes: 45 additions & 12 deletions compiler/rustc_parse/src/parser/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,8 @@ impl<'a> Parser<'a> {
let mut etc = false;
let mut ate_comma = true;
let mut delayed_err: Option<DiagnosticBuilder<'a, ErrorGuaranteed>> = None;
let mut etc_span = None;
let mut first_etc_and_maybe_comma_span = None;
let mut last_non_comma_dotdot_span = None;

while self.token != token::CloseDelim(Delimiter::Brace) {
let attrs = match self.parse_outer_attributes() {
Expand Down Expand Up @@ -969,12 +970,27 @@ impl<'a> Parser<'a> {
{
etc = true;
let mut etc_sp = self.token.span;
if first_etc_and_maybe_comma_span.is_none() {
if let Some(comma_tok) = self
.look_ahead(1, |t| if *t == token::Comma { Some(t.clone()) } else { None })
{
let nw_span = self
.sess
.source_map()
.span_extend_to_line(comma_tok.span)
.trim_start(comma_tok.span.shrink_to_lo())
.map(|s| self.sess.source_map().span_until_non_whitespace(s));
first_etc_and_maybe_comma_span = nw_span.map(|s| etc_sp.to(s));
} else {
first_etc_and_maybe_comma_span =
Some(self.sess.source_map().span_until_non_whitespace(etc_sp));
}
}

self.recover_bad_dot_dot();
self.bump(); // `..` || `...` || `_`

if self.token == token::CloseDelim(Delimiter::Brace) {
etc_span = Some(etc_sp);
break;
}
let token_str = super::token_descr(&self.token);
Expand All @@ -996,7 +1012,6 @@ impl<'a> Parser<'a> {
ate_comma = true;
}

etc_span = Some(etc_sp.until(self.token.span));
if self.token == token::CloseDelim(Delimiter::Brace) {
// If the struct looks otherwise well formed, recover and continue.
if let Some(sp) = comma_sp {
Expand Down Expand Up @@ -1040,6 +1055,9 @@ impl<'a> Parser<'a> {
}
}?;
ate_comma = this.eat(&token::Comma);

last_non_comma_dotdot_span = Some(this.prev_token.span);

// We just ate a comma, so there's no need to use
// `TrailingToken::Comma`
Ok((field, TrailingToken::None))
Expand All @@ -1049,15 +1067,30 @@ impl<'a> Parser<'a> {
}

if let Some(mut err) = delayed_err {
if let Some(etc_span) = etc_span {
err.multipart_suggestion(
"move the `..` to the end of the field list",
vec![
(etc_span, String::new()),
(self.token.span, format!("{}.. }}", if ate_comma { "" } else { ", " })),
],
Applicability::MachineApplicable,
);
if let Some(first_etc_span) = first_etc_and_maybe_comma_span {
if self.prev_token == token::DotDot {
// We have `.., x, ..`.
err.multipart_suggestion(
"remove the starting `..`",
vec![(first_etc_span, String::new())],
Applicability::MachineApplicable,
);
} else {
if let Some(last_non_comma_dotdot_span) = last_non_comma_dotdot_span {
// We have `.., x`.
err.multipart_suggestion(
"move the `..` to the end of the field list",
vec![
(first_etc_span, String::new()),
(
self.token.span.to(last_non_comma_dotdot_span.shrink_to_hi()),
format!("{} .. }}", if ate_comma { "" } else { "," }),
),
],
Applicability::MachineApplicable,
);
}
}
}
err.emit();
}
Expand Down
15 changes: 8 additions & 7 deletions compiler/rustc_target/src/spec/armv7_sony_vita_newlibeabihf.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
use crate::abi::Endian;
use crate::spec::{cvs, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
use crate::spec::{cvs, Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions};

/// A base target for PlayStation Vita devices using the VITASDK toolchain (using newlib).
///
/// Requires the VITASDK toolchain on the host system.

pub fn target() -> Target {
let pre_link_args = TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-Wl,-q"]);
let pre_link_args = TargetOptions::link_args(
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
&["-Wl,-q", "-Wl,--pic-veneer"],
);

Target {
llvm_target: "armv7a-vita-eabihf".into(),
llvm_target: "thumbv7a-vita-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 @@ -18,21 +21,19 @@ pub fn target() -> Target {
os: "vita".into(),
endian: Endian::Little,
c_int_width: "32".into(),
dynamic_linking: false,
env: "newlib".into(),
vendor: "sony".into(),
abi: "eabihf".into(),
linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No),
no_default_libraries: false,
cpu: "cortex-a9".into(),
executables: true,
families: cvs!["unix"],
linker: Some("arm-vita-eabi-gcc".into()),
relocation_model: RelocModel::Static,
features: "+v7,+neon".into(),
features: "+v7,+neon,+vfp3,+thumb2,+thumb-mode".into(),
pre_link_args,
exe_suffix: ".elf".into(),
panic_strategy: PanicStrategy::Abort,
has_thumb_interworking: true,
max_atomic_width: Some(64),
..Default::default()
},
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,7 @@ supported_targets! {
("riscv32im-unknown-none-elf", riscv32im_unknown_none_elf),
("riscv32imc-unknown-none-elf", riscv32imc_unknown_none_elf),
("riscv32imc-esp-espidf", riscv32imc_esp_espidf),
("riscv32imac-esp-espidf", riscv32imac_esp_espidf),
("riscv32imac-unknown-none-elf", riscv32imac_unknown_none_elf),
("riscv32imac-unknown-xous-elf", riscv32imac_unknown_xous_elf),
("riscv32gc-unknown-linux-gnu", riscv32gc_unknown_linux_gnu),
Expand Down
31 changes: 31 additions & 0 deletions compiler/rustc_target/src/spec/riscv32imac_esp_espidf.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use crate::spec::{cvs, PanicStrategy, RelocModel, Target, TargetOptions};

pub fn target() -> Target {
Target {
data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(),
llvm_target: "riscv32".into(),
pointer_width: 32,
arch: "riscv32".into(),

options: TargetOptions {
families: cvs!["unix"],
os: "espidf".into(),
env: "newlib".into(),
vendor: "espressif".into(),
linker: Some("riscv32-esp-elf-gcc".into()),
cpu: "generic-rv32".into(),

// As RiscV32IMAC architecture does natively support atomics,
// automatically enable the support for the Rust STD library.
max_atomic_width: Some(64),
atomic_cas: true,

features: "+m,+a,+c".into(),
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
emit_debug_gdb_scripts: false,
eh_frame_header: false,
..Default::default()
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2807,8 +2807,8 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
err.help("unsized locals are gated as an unstable feature");
}
}
ObligationCauseCode::SizedArgumentType(sp) => {
if let Some(span) = sp {
ObligationCauseCode::SizedArgumentType(ty_span) => {
if let Some(span) = ty_span {
if let ty::PredicateKind::Clause(clause) = predicate.kind().skip_binder()
&& let ty::Clause::Trait(trait_pred) = clause
&& let ty::Dynamic(..) = trait_pred.self_ty().kind()
Expand Down
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" }
core = { path = "../core", public = true }
libc = { version = "0.2.143", default-features = false, features = ['rustc-dep-of-std'], public = true }
libc = { version = "0.2.145", default-features = false, features = ['rustc-dep-of-std'], public = true }
compiler_builtins = { version = "0.1.92" }
profiler_builtins = { path = "../profiler_builtins", optional = true }
unwind = { path = "../unwind" }
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/os/unix/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
use cfg_if::cfg_if;

cfg_if! {
if #[cfg(any(target_os = "vxworks", target_os = "espidf", target_os = "horizon"))] {
if #[cfg(any(target_os = "vxworks", target_os = "espidf", target_os = "horizon", target_os = "vita"))] {
type UserId = u16;
type GroupId = u16;
} else if #[cfg(target_os = "nto")] {
Expand Down
11 changes: 7 additions & 4 deletions library/std/src/sys/unix/fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,10 @@ impl FileDesc {
}
}
#[cfg(any(
all(target_env = "newlib", not(any(target_os = "espidf", target_os = "horizon"))),
all(
target_env = "newlib",
not(any(target_os = "espidf", target_os = "horizon", target_os = "vita"))
),
target_os = "solaris",
target_os = "illumos",
target_os = "emscripten",
Expand All @@ -424,10 +427,10 @@ impl FileDesc {
Ok(())
}
}
#[cfg(any(target_os = "espidf", target_os = "horizon"))]
#[cfg(any(target_os = "espidf", target_os = "horizon", target_os = "vita"))]
pub fn set_cloexec(&self) -> io::Result<()> {
// FD_CLOEXEC is not supported in ESP-IDF and Horizon OS but there's no need to,
// because neither supports spawning processes.
// FD_CLOEXEC is not supported in ESP-IDF, Horizon OS and Vita but there's no need to,
// because none of them supports spawning processes.
Ok(())
}

Expand Down
Loading