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 6 pull requests #97909

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions compiler/rustc_expand/src/mbe/quoted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ fn parse_tree(
sess,
&Token { kind: token::Dollar, span },
);
} else {
maybe_emit_macro_metavar_expr_feature(features, sess, span);
}
TokenTree::token(token::Dollar, span)
}
Expand Down
46 changes: 23 additions & 23 deletions compiler/rustc_infer/src/infer/combine.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
///////////////////////////////////////////////////////////////////////////
// # Type combining
//
// There are four type combiners: equate, sub, lub, and glb. Each
// implements the trait `Combine` and contains methods for combining
// two instances of various things and yielding a new instance. These
// combiner methods always yield a `Result<T>`. There is a lot of
// common code for these operations, implemented as default methods on
// the `Combine` trait.
//
// Each operation may have side-effects on the inference context,
// though these can be unrolled using snapshots. On success, the
// LUB/GLB operations return the appropriate bound. The Eq and Sub
// operations generally return the first operand.
//
// ## Contravariance
//
// When you are relating two things which have a contravariant
// relationship, you should use `contratys()` or `contraregions()`,
// rather than inversing the order of arguments! This is necessary
// because the order of arguments is not relevant for LUB and GLB. It
// is also useful to track which value is the "expected" value in
// terms of error reporting.
//! There are four type combiners: [Equate], [Sub], [Lub], and [Glb].
//! Each implements the trait [TypeRelation] and contains methods for
//! combining two instances of various things and yielding a new instance.
//! These combiner methods always yield a `Result<T>`. To relate two
//! types, you can use `infcx.at(cause, param_env)` which then allows
//! you to use the relevant methods of [At](super::at::At).
//!
//! Combiners mostly do their specific behavior and then hand off the
//! bulk of the work to [InferCtxt::super_combine_tys] and
//! [InferCtxt::super_combine_consts].
//!
//! Combining two types may have side-effects on the inference contexts
//! which can be undone by using snapshots. You probably want to use
//! either [InferCtxt::commit_if_ok] or [InferCtxt::probe].
//!
//! On success, the LUB/GLB operations return the appropriate bound. The
//! return value of `Equate` or `Sub` shouldn't really be used.
//!
//! ## Contravariance
//!
//! We explicitly track which argument is expected using
//! [TypeRelation::a_is_expected], so when dealing with contravariance
//! this should be correctly updated.

use super::equate::Equate;
use super::glb::Glb;
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_target/src/spec/mipsel_sony_psp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const LINKER_SCRIPT: &str = include_str!("./mipsel_sony_psp_linker_script.ld");

pub fn target() -> Target {
let mut pre_link_args = LinkArgs::new();
pre_link_args.insert(LinkerFlavor::Lld(LldFlavor::Ld), vec!["--emit-relocs".into()]);
pre_link_args
.insert(LinkerFlavor::Lld(LldFlavor::Ld), vec!["--emit-relocs".into(), "--nmagic".into()]);

Target {
llvm_target: "mipsel-sony-psp".into(),
Expand Down
21 changes: 16 additions & 5 deletions compiler/rustc_target/src/spec/mipsel_sony_psp_linker_script.ld
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ SECTIONS
/* Sort stubs for convenient ordering */
.sceStub.text : { *(.sceStub.text) *(SORT(.sceStub.text.*)) }

/* PSP import library stub sections. Bundles together `.lib.stub.entry.*`
* sections for better `--gc-sections` support. */
.lib.stub.top : { *(.lib.stub.top) }
.lib.stub : { *(.lib.stub) *(.lib.stub.entry.*) }
.lib.stub.btm : { *(.lib.stub.btm) }

/* Keep these sections around, even though they may appear unused to the linker */
.lib.ent.top : { KEEP(*(.lib.ent.top)) }
.lib.ent : { KEEP(*(.lib.ent)) }
.lib.ent.btm : { KEEP(*(.lib.ent.btm)) }
.lib.stub.top : { KEEP(*(.lib.stub.top)) }
.lib.stub : { KEEP(*(.lib.stub)) }
.lib.stub.btm : { KEEP(*(.lib.stub.btm)) }
.eh_frame_hdr : { KEEP(*(.eh_frame_hdr)) }

.eh_frame_hdr : { *(.eh_frame_hdr) }

/* Add symbols for LLVM's libunwind */
__eh_frame_hdr_start = SIZEOF(.eh_frame_hdr) > 0 ? ADDR(.eh_frame_hdr) : 0;
Expand All @@ -27,8 +31,15 @@ SECTIONS
}

/* These are explicitly listed to avoid being merged into .rodata */
.rodata.sceResident : { *(.rodata.sceResident) }
.rodata.sceResident : { *(.rodata.sceResident) *(.rodata.sceResident.*) }
.rodata.sceModuleInfo : { *(.rodata.sceModuleInfo) }
/* Sort NIDs for convenient ordering */
.rodata.sceNid : { *(.rodata.sceNid) *(SORT(.rodata.sceNid.*)) }

.rodata : { *(.rodata .rodata.*) }
.data : { *(.data .data.*) }
.gcc_except_table : { *(.gcc_except_table .gcc_except_table.*) }
.bss : { *(.bss .bss.*) }

/DISCARD/ : { *(.rel.sceStub.text .MIPS.abiflags .reginfo) }
}
13 changes: 5 additions & 8 deletions library/panic_unwind/src/emcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ extern "C" fn exception_cleanup(ptr: *mut libc::c_void) -> *mut libc::c_void {
}
}

// This is required by the compiler to exist (e.g., it's a lang item), but it's
// never actually called by the compiler. Emscripten EH doesn't use a
// personality function at all, it instead uses __cxa_find_matching_catch.
// Wasm error handling would use __gxx_personality_wasm0.
#[lang = "eh_personality"]
unsafe extern "C" fn rust_eh_personality(
version: c_int,
Expand All @@ -113,7 +117,7 @@ unsafe extern "C" fn rust_eh_personality(
exception_object: *mut uw::_Unwind_Exception,
context: *mut uw::_Unwind_Context,
) -> uw::_Unwind_Reason_Code {
__gxx_personality_v0(version, actions, exception_class, exception_object, context)
core::intrinsics::abort()
}

extern "C" {
Expand All @@ -125,11 +129,4 @@ extern "C" {
tinfo: *const TypeInfo,
dest: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void,
) -> !;
fn __gxx_personality_v0(
version: c_int,
actions: uw::_Unwind_Action,
exception_class: uw::_Unwind_Exception_Class,
exception_object: *mut uw::_Unwind_Exception,
context: *mut uw::_Unwind_Context,
) -> uw::_Unwind_Reason_Code;
}
48 changes: 48 additions & 0 deletions library/std/src/io/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ mod tests;

use crate::alloc::Allocator;
use crate::cmp;
use crate::collections::VecDeque;
use crate::fmt;
use crate::io::{
self, BufRead, ErrorKind, IoSlice, IoSliceMut, Read, ReadBuf, Seek, SeekFrom, Write,
Expand Down Expand Up @@ -410,3 +411,50 @@ impl<A: Allocator> Write for Vec<u8, A> {
Ok(())
}
}

/// Read is implemented for `VecDeque<u8>` by consuming bytes from the front of the `VecDeque`.
#[stable(feature = "vecdeque_read_write", since = "1.63.0")]
impl<A: Allocator> Read for VecDeque<u8, A> {
/// Fill `buf` with the contents of the "front" slice as returned by
/// [`as_slices`][`VecDeque::as_slices`]. If the contained byte slices of the `VecDeque` are
/// discontiguous, multiple calls to `read` will be needed to read the entire content.
#[inline]
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
let (ref mut front, _) = self.as_slices();
let n = Read::read(front, buf)?;
self.drain(..n);
Ok(n)
}

#[inline]
fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> io::Result<()> {
let (ref mut front, _) = self.as_slices();
let n = cmp::min(buf.remaining(), front.len());
Read::read_buf(front, buf)?;
self.drain(..n);
Ok(())
}
}

/// Write is implemented for `VecDeque<u8>` by appending to the `VecDeque`, growing it as needed.
#[stable(feature = "vecdeque_read_write", since = "1.63.0")]
impl<A: Allocator> Write for VecDeque<u8, A> {
#[inline]
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.reserve(buf.len());
self.extend(buf);
Ok(buf.len())
}

#[inline]
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
self.reserve(buf.len());
self.extend(buf);
Ok(())
}

#[inline]
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
}
6 changes: 3 additions & 3 deletions src/test/assembly/asm/hexagon-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ macro_rules! check_reg {

// CHECK-LABEL: sym_static:
// CHECK: InlineAsm Start
// CHECK: r0 = #extern_static
// CHECK: r0 = {{#+}}extern_static
// CHECK: InlineAsm End
#[no_mangle]
pub unsafe fn sym_static() {
Expand All @@ -88,7 +88,7 @@ pub unsafe fn sym_static() {

// CHECK-LABEL: sym_fn:
// CHECK: InlineAsm Start
// CHECK: r0 = #extern_func
// CHECK: r0 = {{#+}}extern_func
// CHECK: InlineAsm End
#[no_mangle]
pub unsafe fn sym_fn() {
Expand All @@ -108,7 +108,7 @@ pub unsafe fn sym_fn() {
// CHECK: InlineAsm Start
// CHECK: {
// CHECK: r{{[0-9]+}} = r0
// CHECK: memw(r1) = r{{[0-9]+}}
// CHECK: memw(r1{{(\+#0)?}}) = r{{[0-9]+}}
// CHECK: }
// CHECK: InlineAsm End
#[no_mangle]
Expand Down
12 changes: 12 additions & 0 deletions src/test/ui/macros/rfc-3086-metavar-expr/allowed-features.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// check-pass

macro_rules! dollar_dollar {
() => {
macro_rules! bar {
( $$( $$any:tt )* ) => { $$( $$any )* };
}
};
}

fn main() {
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@ macro_rules! count {
};
}

macro_rules! dollar_dollar {
() => {
macro_rules! bar {
( $$( $$any:tt )* ) => { $$( $$any )* };
//~^ ERROR meta-variable expressions are unstable
//~| ERROR meta-variable expressions are unstable
//~| ERROR meta-variable expressions are unstable
//~| ERROR meta-variable expressions are unstable
}
};
}

macro_rules! index {
( $( $e:stmt ),* ) => {
$( ${ignore(e)} ${index()} )*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:3:10
--> $DIR/required-features.rs:3:10
|
LL | ${ count(e) }
| ^^^^^^^^^^^^
Expand All @@ -8,43 +8,7 @@ LL | ${ count(e) }
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:11:16
|
LL | ( $$( $$any:tt )* ) => { $$( $$any )* };
| ^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:11:20
|
LL | ( $$( $$any:tt )* ) => { $$( $$any )* };
| ^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:11:39
|
LL | ( $$( $$any:tt )* ) => { $$( $$any )* };
| ^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:11:43
|
LL | ( $$( $$any:tt )* ) => { $$( $$any )* };
| ^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:22:13
--> $DIR/required-features.rs:10:13
|
LL | $( ${ignore(e)} ${index()} )*
| ^^^^^^^^^^^
Expand All @@ -53,7 +17,7 @@ LL | $( ${ignore(e)} ${index()} )*
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:22:26
--> $DIR/required-features.rs:10:26
|
LL | $( ${ignore(e)} ${index()} )*
| ^^^^^^^^^
Expand All @@ -62,7 +26,7 @@ LL | $( ${ignore(e)} ${index()} )*
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:30:19
--> $DIR/required-features.rs:18:19
|
LL | 0 $( + 1 ${ignore(i)} )*
| ^^^^^^^^^^^
Expand All @@ -71,7 +35,7 @@ LL | 0 $( + 1 ${ignore(i)} )*
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:37:13
--> $DIR/required-features.rs:25:13
|
LL | $( ${ignore(e)} ${length()} )*
| ^^^^^^^^^^^
Expand All @@ -80,14 +44,14 @@ LL | $( ${ignore(e)} ${length()} )*
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error[E0658]: meta-variable expressions are unstable
--> $DIR/required-feature.rs:37:26
--> $DIR/required-features.rs:25:26
|
LL | $( ${ignore(e)} ${length()} )*
| ^^^^^^^^^^
|
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable

error: aborting due to 10 previous errors
error: aborting due to 6 previous errors

For more information about this error, try `rustc --explain E0658`.