Skip to content

Rollup of 8 pull requests #112336

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

Closed
wants to merge 18 commits into from
Closed
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
@@ -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",
]
28 changes: 22 additions & 6 deletions compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
Original file line number Diff line number Diff line change
@@ -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;
14 changes: 13 additions & 1 deletion compiler/rustc_hir_typeck/src/check.rs
Original file line number Diff line number Diff line change
@@ -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);
12 changes: 11 additions & 1 deletion compiler/rustc_hir_typeck/src/gather_locals.rs
Original file line number Diff line number Diff line change
@@ -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 {
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/instance.rs
Original file line number Diff line number Diff line change
@@ -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()
}
}

2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/shim.rs
Original file line number Diff line number Diff line change
@@ -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 {
57 changes: 45 additions & 12 deletions compiler/rustc_parse/src/parser/pat.rs
Original file line number Diff line number Diff line change
@@ -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() {
@@ -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);
@@ -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 {
@@ -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))
@@ -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();
}
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(),
@@ -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()
},
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
@@ -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),
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
@@ -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()
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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" }
2 changes: 1 addition & 1 deletion library/std/src/os/unix/process.rs
Original file line number Diff line number Diff line change
@@ -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")] {
11 changes: 7 additions & 4 deletions library/std/src/sys/unix/fd.rs
Original file line number Diff line number Diff line change
@@ -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",
@@ -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(())
}

37 changes: 34 additions & 3 deletions library/std/src/sys/unix/fs.rs
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ use crate::mem;
target_os = "redox",
target_os = "illumos",
target_os = "nto",
target_os = "vita",
))]
use crate::mem::MaybeUninit;
use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd};
@@ -58,6 +59,7 @@ use libc::fstatat64;
target_os = "redox",
target_os = "illumos",
target_os = "nto",
target_os = "vita",
))]
use libc::readdir as readdir64;
#[cfg(target_os = "linux")]
@@ -74,6 +76,7 @@ use libc::readdir64_r;
target_os = "fuchsia",
target_os = "redox",
target_os = "nto",
target_os = "vita",
)))]
use libc::readdir_r as readdir64_r;
#[cfg(target_os = "android")]
@@ -283,6 +286,7 @@ unsafe impl Sync for Dir {}
target_os = "fuchsia",
target_os = "redox",
target_os = "nto",
target_os = "vita"
))]
pub struct DirEntry {
dir: Arc<InnerReadDir>,
@@ -304,10 +308,16 @@ pub struct DirEntry {
target_os = "fuchsia",
target_os = "redox",
target_os = "nto",
target_os = "vita",
))]
struct dirent64_min {
d_ino: u64,
#[cfg(not(any(target_os = "solaris", target_os = "illumos", target_os = "nto")))]
#[cfg(not(any(
target_os = "solaris",
target_os = "illumos",
target_os = "nto",
target_os = "vita"
)))]
d_type: u8,
}

@@ -319,6 +329,7 @@ struct dirent64_min {
target_os = "fuchsia",
target_os = "redox",
target_os = "nto",
target_os = "vita",
)))]
pub struct DirEntry {
dir: Arc<InnerReadDir>,
@@ -520,6 +531,7 @@ impl FileAttr {
target_os = "macos",
target_os = "ios",
target_os = "watchos",
target_os = "vita",
)))]
pub fn created(&self) -> io::Result<SystemTime> {
cfg_has_statx! {
@@ -541,6 +553,11 @@ impl FileAttr {
currently",
))
}

#[cfg(target_os = "vita")]
pub fn created(&self) -> io::Result<SystemTime> {
Ok(SystemTime::new(self.stat.st_ctime as i64, 0))
}
}

#[cfg(target_os = "nto")]
@@ -645,6 +662,7 @@ impl Iterator for ReadDir {
target_os = "redox",
target_os = "illumos",
target_os = "nto",
target_os = "vita",
))]
fn next(&mut self) -> Option<io::Result<DirEntry>> {
if self.end_of_stream {
@@ -725,6 +743,7 @@ impl Iterator for ReadDir {
continue;
}

#[cfg(not(target_os = "vita"))]
let entry = dirent64_min {
d_ino: *offset_ptr!(entry_ptr, d_ino) as u64,
#[cfg(not(any(
@@ -735,6 +754,9 @@ impl Iterator for ReadDir {
d_type: *offset_ptr!(entry_ptr, d_type) as u8,
};

#[cfg(target_os = "vita")]
let entry = dirent64_min { d_ino: 0u64 };

return Some(Ok(DirEntry {
entry,
name: name.to_owned(),
@@ -752,6 +774,7 @@ impl Iterator for ReadDir {
target_os = "redox",
target_os = "illumos",
target_os = "nto",
target_os = "vita",
)))]
fn next(&mut self) -> Option<io::Result<DirEntry>> {
if self.end_of_stream {
@@ -842,6 +865,7 @@ impl DirEntry {
target_os = "haiku",
target_os = "vxworks",
target_os = "nto",
target_os = "vita",
))]
pub fn file_type(&self) -> io::Result<FileType> {
self.metadata().map(|m| m.file_type())
@@ -853,6 +877,7 @@ impl DirEntry {
target_os = "haiku",
target_os = "vxworks",
target_os = "nto",
target_os = "vita",
)))]
pub fn file_type(&self) -> io::Result<FileType> {
match self.entry.d_type {
@@ -939,6 +964,7 @@ impl DirEntry {
target_os = "fuchsia",
target_os = "redox",
target_os = "nto",
target_os = "vita",
)))]
fn name_cstr(&self) -> &CStr {
unsafe { CStr::from_ptr(self.entry.d_name.as_ptr()) }
@@ -951,6 +977,7 @@ impl DirEntry {
target_os = "fuchsia",
target_os = "redox",
target_os = "nto",
target_os = "vita",
))]
fn name_cstr(&self) -> &CStr {
&self.name
@@ -1543,7 +1570,7 @@ pub fn link(original: &Path, link: &Path) -> io::Result<()> {
run_path_with_cstr(original, |original| {
run_path_with_cstr(link, |link| {
cfg_if::cfg_if! {
if #[cfg(any(target_os = "vxworks", target_os = "redox", target_os = "android", target_os = "espidf", target_os = "horizon"))] {
if #[cfg(any(target_os = "vxworks", target_os = "redox", target_os = "android", target_os = "espidf", target_os = "horizon", target_os = "vita"))] {
// VxWorks, Redox and ESP-IDF lack `linkat`, so use `link` instead. POSIX leaves
// it implementation-defined whether `link` follows symlinks, so rely on the
// `symlink_hard_link` test in library/std/src/fs/tests.rs to check the behavior.
@@ -1666,6 +1693,8 @@ fn open_to_and_set_permissions(
.truncate(true)
.open(to)?;
let writer_metadata = writer.metadata()?;
// fchmod is broken on vita
#[cfg(not(target_os = "vita"))]
if writer_metadata.is_file() {
// Set the correct file permissions, in case the file already existed.
// Don't set the permissions on already existing non-files like
@@ -1844,11 +1873,12 @@ pub fn chroot(dir: &Path) -> io::Result<()> {

pub use remove_dir_impl::remove_dir_all;

// Fallback for REDOX, ESP-ID, Horizon, and Miri
// Fallback for REDOX, ESP-ID, Horizon, Vita and Miri
#[cfg(any(
target_os = "redox",
target_os = "espidf",
target_os = "horizon",
target_os = "vita",
target_os = "nto",
miri
))]
@@ -1861,6 +1891,7 @@ mod remove_dir_impl {
target_os = "redox",
target_os = "espidf",
target_os = "horizon",
target_os = "vita",
target_os = "nto",
miri
)))]
12 changes: 4 additions & 8 deletions library/std/src/sys/unix/mod.rs
Original file line number Diff line number Diff line change
@@ -163,12 +163,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
}

unsafe fn reset_sigpipe(#[allow(unused_variables)] sigpipe: u8) {
#[cfg(not(any(
target_os = "emscripten",
target_os = "fuchsia",
target_os = "horizon",
target_os = "vita"
)))]
#[cfg(not(any(target_os = "emscripten", target_os = "fuchsia", target_os = "horizon")))]
{
// We don't want to add this as a public type to std, nor do we
// want to `include!` a file from the compiler (which would break
@@ -206,7 +201,6 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
target_os = "emscripten",
target_os = "fuchsia",
target_os = "horizon",
target_os = "vita"
)))]
static UNIX_SIGPIPE_ATTR_SPECIFIED: crate::sync::atomic::AtomicBool =
crate::sync::atomic::AtomicBool::new(false);
@@ -216,7 +210,6 @@ static UNIX_SIGPIPE_ATTR_SPECIFIED: crate::sync::atomic::AtomicBool =
target_os = "emscripten",
target_os = "fuchsia",
target_os = "horizon",
target_os = "vita",
)))]
pub(crate) fn unix_sigpipe_attr_specified() -> bool {
UNIX_SIGPIPE_ATTR_SPECIFIED.load(crate::sync::atomic::Ordering::Relaxed)
@@ -407,6 +400,9 @@ cfg_if::cfg_if! {
} else if #[cfg(all(target_os = "linux", target_env = "uclibc"))] {
#[link(name = "dl")]
extern "C" {}
} else if #[cfg(target_os = "vita")] {
#[link(name = "pthread", kind = "static", modifiers = "-bundle")]
extern "C" {}
}
}

8 changes: 7 additions & 1 deletion library/std/src/sys/unix/net.rs
Original file line number Diff line number Diff line change
@@ -454,12 +454,18 @@ impl Socket {
Ok(passcred != 0)
}

#[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
#[cfg(not(any(target_os = "solaris", target_os = "illumos", target_os = "vita")))]
pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
let mut nonblocking = nonblocking as libc::c_int;
cvt(unsafe { libc::ioctl(self.as_raw_fd(), libc::FIONBIO, &mut nonblocking) }).map(drop)
}

#[cfg(target_os = "vita")]
pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
let option = nonblocking as libc::c_int;
setsockopt(self, libc::SOL_SOCKET, libc::SO_NONBLOCK, option)
}

#[cfg(any(target_os = "solaris", target_os = "illumos"))]
pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
// FIONBIO is inadequate for sockets on illumos/Solaris, so use the
3 changes: 2 additions & 1 deletion library/std/src/sys/unix/thread_parking/pthread.rs
Original file line number Diff line number Diff line change
@@ -123,7 +123,8 @@ impl Parker {
target_os = "watchos",
target_os = "l4re",
target_os = "android",
target_os = "redox"
target_os = "redox",
target_os = "vita",
))] {
addr_of_mut!((*parker).cvar).write(UnsafeCell::new(libc::PTHREAD_COND_INITIALIZER));
} else if #[cfg(any(target_os = "espidf", target_os = "horizon"))] {
1 change: 1 addition & 0 deletions src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
@@ -298,6 +298,7 @@ target | std | host | notes
`riscv32im-unknown-none-elf` | * | | Bare RISC-V (RV32IM ISA)
[`riscv32imac-unknown-xous-elf`](platform-support/riscv32imac-unknown-xous-elf.md) | ? | | RISC-V Xous (RV32IMAC ISA)
[`riscv32imc-esp-espidf`](platform-support/esp-idf.md) | ✓ | | RISC-V ESP-IDF
[`riscv32imac-esp-espidf`](platform-support/esp-idf.md) | ✓ | | RISC-V ESP-IDF
`riscv64gc-unknown-freebsd` | | | RISC-V FreeBSD
`riscv64gc-unknown-fuchsia` | | | RISC-V Fuchsia
`riscv64gc-unknown-linux-musl` | | | RISC-V Linux (kernel 4.20, musl 1.2.0)
75 changes: 15 additions & 60 deletions src/doc/rustc/src/platform-support/armv7-sony-vita-newlibeabihf.md
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ This tier supports the ARM Cortex A9 processor running on a PlayStation Vita con
Rust support for this target is not affiliated with Sony, and is not derived
from nor used with any official Sony SDK.

## Designated Developers
## Target maintainers

* [@amg98](https://github.com/amg98)
* [@nikarh](https://github.com/nikarh)
@@ -27,53 +27,19 @@ In order to support some APIs, binaries must be linked against `libc` written
for the target, using a linker for the target. These are provided by the
VITASDK toolchain.

This target generates binaries in the ELF format.
This target generates binaries in the ELF format with thumb ISA.

## Building
## Building the target

Rust does not ship pre-compiled artifacts for this target. You can use `build-std` flag to build binaries with `std`:

```sh
cargo build -Z build-std=std,panic_abort --target=armv7-sony-vita-newlibeabihf --release
```

## Cross-compilation

This target can be cross-compiled from `x86_64` on either Windows, MacOS or Linux systems. Other hosts are not supported for cross-compilation.

## Testing

Currently there is no support to run the rustc test suite for this target.

## Building and Running Rust Programs
## Building Rust programs

`std` support for this target relies on newlib. In order to work, newlib must be initialized correctly. The easiest way to achieve this with VITASDK newlib implementation is by compiling your program as a staticlib with and exposing your main function from rust to `_init` function in `crt0`.

Add this to your `Cargo.toml`:

```toml
[lib]
crate-type = ["staticlib"]

[profile.release]
panic = 'abort'
lto = true
opt-level = 3
```

Your entrypoint should look roughly like this, `src/lib.rs`:
```rust,ignore,no_run
#[used]
#[export_name = "_newlib_heap_size_user"]
pub static _NEWLIB_HEAP_SIZE_USER: u32 = 100 * 1024 * 1024; // Default heap size is only 32mb, increase it to something suitable for your application
#[no_mangle]
pub extern "C" fn main() {
println!("Hello, world!");
}
```

To test your developed rust programs on PlayStation Vita, first you must correctly link and package your rust staticlib. These steps can be preformed using tools available in VITASDK, and can be automated using tools like `cargo-make`.
To test your developed rust programs on PlayStation Vita, first you must correctly package your elf. These steps can be preformed using tools available in VITASDK, and can be automated using a tool like `cargo-make`.

First, set up environment variables for `VITASDK`, and it's binaries:

@@ -88,40 +54,21 @@ Use the example below as a template for your project:
[env]
TITLE = "Rust Hello World"
TITLEID = "RUST00001"
# Add other libs required by your project here
LINKER_LIBS = "-lpthread -lm -lmathneon"

# At least a "sce_sys" folder should be place there for app metadata (title, icons, description...)
# You can find sample assets for that on $VITASDK/share/gcc-arm-vita-eabi/samples/hello_world/sce_sys/
STATIC_DIR = "static" # Folder where static assets should be placed (sce_sys folder is at $STATIC_DIR/sce_sys)
CARGO_TARGET_DIR = { script = ["echo ${CARGO_TARGET_DIR:=target}"] }
RUST_TARGET = "armv7-sony-vita-newlibeabihf"
CARGO_OUT_DIR = "${CARGO_TARGET_DIR}/${RUST_TARGET}/release"

TARGET_LINKER = "arm-vita-eabi-gcc"
TARGET_LINKER_FLAGS = "-Wl,-q"

[tasks.build]
description = "Build the project using `cargo` as a static lib."
description = "Build the project using `cargo`."
command = "cargo"
args = ["build", "-Z", "build-std=std,panic_abort", "--target=armv7-sony-vita-newlibeabihf", "--release"]

[tasks.link]
description = "Build an ELF executable using the `vitasdk` linker."
dependencies = ["build"]
script = [
"""
${TARGET_LINKER} ${TARGET_LINKER_FLAGS} \
-L"${CARGO_OUT_DIR}" \
-l"${CARGO_MAKE_CRATE_FS_NAME}" \
${LINKER_LIBS} \
-o"${CARGO_OUT_DIR}/${CARGO_MAKE_CRATE_NAME}.elf"
"""
]

[tasks.strip]
description = "Strip the produced ELF executable."
dependencies = ["link"]
dependencies = ["build"]
command = "arm-vita-eabi-strip"
args = ["-g", '${CARGO_OUT_DIR}/${CARGO_MAKE_CRATE_FS_NAME}.elf']

@@ -194,3 +141,11 @@ script = [
```

After running the above script, you should be able to get a *.vpk file in the same folder your *.elf executable resides. Now you can pick it and install it on your own PlayStation Vita using, or you can use an [Vita3K](https://vita3k.org/) emulator.

## Testing

Currently there is no support to run the rustc test suite for this target.

## Cross-compilation

This target can be cross-compiled from `x86_64` on either Windows, MacOS or Linux systems. Other hosts are not supported for cross-compilation.
9 changes: 5 additions & 4 deletions src/doc/rustc/src/platform-support/esp-idf.md
Original file line number Diff line number Diff line change
@@ -13,11 +13,12 @@ Targets for the [ESP-IDF](https://github.com/espressif/esp-idf) development fram

The target names follow this format: `$ARCH-esp-espidf`, where `$ARCH` specifies the target processor architecture. The following targets are currently defined:

| Target name | Target CPU(s) |
|--------------------------------|-----------------------|
| `riscv32imc-esp-espidf` | [ESP32-C3](https://www.espressif.com/en/products/socs/esp32-c3) |
| Target name | Target CPU(s) | Minimum ESP-IDF version |
|--------------------------------|-----------------------|-------------------------|
| `riscv32imc-esp-espidf` | [ESP32-C3](https://www.espressif.com/en/products/socs/esp32-c3) | `v4.3` |
| `riscv32imac-esp-espidf` | [ESP32-C6](https://www.espressif.com/en/products/socs/esp32-c6) | `v5.1` |

The minimum supported ESP-IDF version is `v4.3`, though it is recommended to use the latest stable release if possible.
It is recommended to use the latest ESP-IDF stable release if possible.

## Building the target

13 changes: 12 additions & 1 deletion src/etc/gdb_load_rust_pretty_printers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Add this folder to the python sys path; GDB Python-interpreter will now find modules in this path
import sys
from os import path
self_dir = path.dirname(path.realpath(__file__))
sys.path.append(self_dir)

import gdb
import gdb_lookup
gdb_lookup.register_printers(gdb.current_objfile())

# current_objfile can be none; even with `gdb foo-app`; sourcing this file after gdb init now works
try:
gdb_lookup.register_printers(gdb.current_objfile())
except Exception:
gdb_lookup.register_printers(gdb.selected_inferior().progspace)
6 changes: 3 additions & 3 deletions src/librustdoc/clean/blanket_impl.rs
Original file line number Diff line number Diff line change
@@ -104,10 +104,10 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
// the post-inference `trait_ref`, as it's more accurate.
trait_: Some(clean_trait_ref_with_bindings(
cx,
ty::Binder::dummy(trait_ref.skip_binder()),
ty::Binder::dummy(trait_ref.subst_identity()),
ThinVec::new(),
)),
for_: clean_middle_ty(ty::Binder::dummy(ty.skip_binder()), cx, None),
for_: clean_middle_ty(ty::Binder::dummy(ty.subst_identity()), cx, None),
items: cx
.tcx
.associated_items(impl_def_id)
@@ -116,7 +116,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
.collect::<Vec<_>>(),
polarity: ty::ImplPolarity::Positive,
kind: ImplKind::Blanket(Box::new(clean_middle_ty(
ty::Binder::dummy(trait_ref.skip_binder().self_ty()),
ty::Binder::dummy(trait_ref.subst_identity().self_ty()),
cx,
None,
))),
8 changes: 4 additions & 4 deletions tests/run-make/x86_64-fortanix-unknown-sgx-lvi/print.checks
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CHECK: print
CHECK: lfence
CHECK: lfence
CHECK: lfence
CHECK: callq 0x{{[[:xdigit:]]*}} <_Unwind_Resume>
CHECK-NEXT: ud2
CHECK: popq
CHECK-NEXT: popq [[REGISTER:%[a-z]+]]
CHECK-NEXT: lfence
CHECK-NEXT: jmpq *[[REGISTER]]
9 changes: 9 additions & 0 deletions tests/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh
Original file line number Diff line number Diff line change
@@ -33,6 +33,15 @@ function check {
${objdump} --disassemble-symbols="${func}" --demangle \
${enclave} > ${asm}
${filecheck} --input-file ${asm} ${checks}

if [ "${func_re}" != "rust_plus_one_global_asm" &&
"${func_re}" != "cmake_plus_one_c_global_asm" ]; then
# The assembler cannot avoid explicit `ret` instructions. Sequences
# of `shlq $0x0, (%rsp); lfence; retq` are used instead.
# https://www.intel.com/content/www/us/en/developer/articles/technical/
# software-security-guidance/technical-documentation/load-value-injection.html
${filecheck} --implicit-check-not ret --input-file ${asm} ${checks}
fi
}

build
28 changes: 28 additions & 0 deletions tests/ui/borrowck/issue-111554.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
struct Foo {}

impl Foo {
pub fn foo(&mut self) {
|| bar(&mut self);
//~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable
}

pub fn baz(&self) {
|| bar(&mut self);
//~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable
//~| ERROR cannot borrow data in a `&` reference as mutable
}

pub fn qux(mut self) {
|| bar(&mut self);
// OK
}

pub fn quux(self) {
|| bar(&mut self);
//~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable
}
}

fn bar(_: &mut Foo) {}

fn main() {}
29 changes: 29 additions & 0 deletions tests/ui/borrowck/issue-111554.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable
--> $DIR/issue-111554.rs:5:16
|
LL | || bar(&mut self);
| ^^^^^^^^^ cannot borrow as mutable

error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable
--> $DIR/issue-111554.rs:10:16
|
LL | || bar(&mut self);
| ^^^^^^^^^ cannot borrow as mutable

error[E0596]: cannot borrow data in a `&` reference as mutable
--> $DIR/issue-111554.rs:10:16
|
LL | || bar(&mut self);
| ^^^^^^^^^ cannot borrow as mutable

error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable
--> $DIR/issue-111554.rs:21:16
|
LL | pub fn quux(self) {
| ---- help: consider changing this to be mutable: `mut self`
LL | || bar(&mut self);
| ^^^^^^^^^ cannot borrow as mutable

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0596`.
9 changes: 9 additions & 0 deletions tests/ui/closures/issue-111932.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
trait Foo: std::fmt::Debug {}

fn print_foos(foos: impl Iterator<Item = dyn Foo>) {
foos.for_each(|foo| { //~ ERROR [E0277]
println!("{:?}", foo); //~ ERROR [E0277]
});
}

fn main() {}
26 changes: 26 additions & 0 deletions tests/ui/closures/issue-111932.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time
--> $DIR/issue-111932.rs:4:20
|
LL | foos.for_each(|foo| {
| ^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `(dyn Foo + 'static)`
= note: all function arguments must have a statically known size
= help: unsized fn params are gated as an unstable feature

error[E0277]: the size for values of type `dyn Foo` cannot be known at compilation time
--> $DIR/issue-111932.rs:5:26
|
LL | println!("{:?}", foo);
| ---- ^^^ doesn't have a size known at compile-time
| |
| required by a bound introduced by this call
|
= help: the trait `Sized` is not implemented for `dyn Foo`
note: required by a bound in `core::fmt::rt::Argument::<'a>::new_debug`
--> $SRC_DIR/core/src/fmt/rt.rs:LL:COL
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
14 changes: 14 additions & 0 deletions tests/ui/parser/issue-112188.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// run-rustfix

#![allow(unused)]

struct Foo { x: i32 }

fn main() {
let f = Foo { x: 0 };
let Foo { .. } = f;
let Foo { .. } = f; //~ ERROR expected `}`, found `,`
let Foo { x, .. } = f;
let Foo { x, .. } = f; //~ ERROR expected `}`, found `,`
let Foo { x, .. } = f; //~ ERROR expected `}`, found `,`
}
14 changes: 14 additions & 0 deletions tests/ui/parser/issue-112188.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// run-rustfix

#![allow(unused)]

struct Foo { x: i32 }

fn main() {
let f = Foo { x: 0 };
let Foo { .. } = f;
let Foo { .., } = f; //~ ERROR expected `}`, found `,`
let Foo { x, .. } = f;
let Foo { .., x } = f; //~ ERROR expected `}`, found `,`
let Foo { .., x, .. } = f; //~ ERROR expected `}`, found `,`
}
37 changes: 37 additions & 0 deletions tests/ui/parser/issue-112188.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
error: expected `}`, found `,`
--> $DIR/issue-112188.rs:10:17
|
LL | let Foo { .., } = f;
| --^
| | |
| | expected `}`
| | help: remove this comma
| `..` must be at the end and cannot have a trailing comma

error: expected `}`, found `,`
--> $DIR/issue-112188.rs:12:17
|
LL | let Foo { .., x } = f;
| --^
| | |
| | expected `}`
| `..` must be at the end and cannot have a trailing comma
|
help: move the `..` to the end of the field list
|
LL - let Foo { .., x } = f;
LL + let Foo { x, .. } = f;
|

error: expected `}`, found `,`
--> $DIR/issue-112188.rs:13:17
|
LL | let Foo { .., x, .. } = f;
| --^-
| | |
| | expected `}`
| `..` must be at the end and cannot have a trailing comma
| help: remove the starting `..`

error: aborting due to 3 previous errors

2 changes: 1 addition & 1 deletion tests/ui/parser/issue-49257.stderr
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ LL | let Point { .., y } = p;
help: move the `..` to the end of the field list
|
LL - let Point { .., y } = p;
LL + let Point { y , .. } = p;
LL + let Point { y, .. } = p;
|

error: expected `}`, found `,`
5 changes: 1 addition & 4 deletions tests/ui/unsized-locals/issue-67981.stderr
Original file line number Diff line number Diff line change
@@ -5,10 +5,7 @@ LL | let f: fn([u8]) = |_| {};
| ^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[u8]`
help: function arguments must have a statically known size, borrowed types always have a known size
|
LL | let f: fn([u8]) = |&_| {};
| +
= note: all function arguments must have a statically known size

error: aborting due to previous error