Skip to content

Commit a0411e2

Browse files
committed
Auto merge of #97910 - JohnTitor:rollup-gu3k0xl, r=JohnTitor
Rollup of 5 pull requests Successful merges: - #95632 (impl Read and Write for VecDeque<u8>) - #95860 (Stabilize `$$` in Rust 1.63.0) - #97838 (hexagon: adapt test for upstream output changes) - #97843 (Relax mipsel-sony-psp's linker script) - #97874 (rewrite combine doc comment) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents be16c61 + 141b0a4 commit a0411e2

File tree

9 files changed

+111
-89
lines changed

9 files changed

+111
-89
lines changed

compiler/rustc_expand/src/mbe/quoted.rs

-2
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,6 @@ fn parse_tree(
234234
sess,
235235
&Token { kind: token::Dollar, span },
236236
);
237-
} else {
238-
maybe_emit_macro_metavar_expr_feature(features, sess, span);
239237
}
240238
TokenTree::token(token::Dollar, span)
241239
}

compiler/rustc_infer/src/infer/combine.rs

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
///////////////////////////////////////////////////////////////////////////
2-
// # Type combining
3-
//
4-
// There are four type combiners: equate, sub, lub, and glb. Each
5-
// implements the trait `Combine` and contains methods for combining
6-
// two instances of various things and yielding a new instance. These
7-
// combiner methods always yield a `Result<T>`. There is a lot of
8-
// common code for these operations, implemented as default methods on
9-
// the `Combine` trait.
10-
//
11-
// Each operation may have side-effects on the inference context,
12-
// though these can be unrolled using snapshots. On success, the
13-
// LUB/GLB operations return the appropriate bound. The Eq and Sub
14-
// operations generally return the first operand.
15-
//
16-
// ## Contravariance
17-
//
18-
// When you are relating two things which have a contravariant
19-
// relationship, you should use `contratys()` or `contraregions()`,
20-
// rather than inversing the order of arguments! This is necessary
21-
// because the order of arguments is not relevant for LUB and GLB. It
22-
// is also useful to track which value is the "expected" value in
23-
// terms of error reporting.
1+
//! There are four type combiners: [Equate], [Sub], [Lub], and [Glb].
2+
//! Each implements the trait [TypeRelation] and contains methods for
3+
//! combining two instances of various things and yielding a new instance.
4+
//! These combiner methods always yield a `Result<T>`. To relate two
5+
//! types, you can use `infcx.at(cause, param_env)` which then allows
6+
//! you to use the relevant methods of [At](super::at::At).
7+
//!
8+
//! Combiners mostly do their specific behavior and then hand off the
9+
//! bulk of the work to [InferCtxt::super_combine_tys] and
10+
//! [InferCtxt::super_combine_consts].
11+
//!
12+
//! Combining two types may have side-effects on the inference contexts
13+
//! which can be undone by using snapshots. You probably want to use
14+
//! either [InferCtxt::commit_if_ok] or [InferCtxt::probe].
15+
//!
16+
//! On success, the LUB/GLB operations return the appropriate bound. The
17+
//! return value of `Equate` or `Sub` shouldn't really be used.
18+
//!
19+
//! ## Contravariance
20+
//!
21+
//! We explicitly track which argument is expected using
22+
//! [TypeRelation::a_is_expected], so when dealing with contravariance
23+
//! this should be correctly updated.
2424
2525
use super::equate::Equate;
2626
use super::glb::Glb;

compiler/rustc_target/src/spec/mipsel_sony_psp.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ const LINKER_SCRIPT: &str = include_str!("./mipsel_sony_psp_linker_script.ld");
66

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

1112
Target {
1213
llvm_target: "mipsel-sony-psp".into(),

compiler/rustc_target/src/spec/mipsel_sony_psp_linker_script.ld

+16-5
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ SECTIONS
77
/* Sort stubs for convenient ordering */
88
.sceStub.text : { *(.sceStub.text) *(SORT(.sceStub.text.*)) }
99

10+
/* PSP import library stub sections. Bundles together `.lib.stub.entry.*`
11+
* sections for better `--gc-sections` support. */
12+
.lib.stub.top : { *(.lib.stub.top) }
13+
.lib.stub : { *(.lib.stub) *(.lib.stub.entry.*) }
14+
.lib.stub.btm : { *(.lib.stub.btm) }
15+
1016
/* Keep these sections around, even though they may appear unused to the linker */
1117
.lib.ent.top : { KEEP(*(.lib.ent.top)) }
1218
.lib.ent : { KEEP(*(.lib.ent)) }
1319
.lib.ent.btm : { KEEP(*(.lib.ent.btm)) }
14-
.lib.stub.top : { KEEP(*(.lib.stub.top)) }
15-
.lib.stub : { KEEP(*(.lib.stub)) }
16-
.lib.stub.btm : { KEEP(*(.lib.stub.btm)) }
17-
.eh_frame_hdr : { KEEP(*(.eh_frame_hdr)) }
20+
21+
.eh_frame_hdr : { *(.eh_frame_hdr) }
1822

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

2933
/* These are explicitly listed to avoid being merged into .rodata */
30-
.rodata.sceResident : { *(.rodata.sceResident) }
34+
.rodata.sceResident : { *(.rodata.sceResident) *(.rodata.sceResident.*) }
3135
.rodata.sceModuleInfo : { *(.rodata.sceModuleInfo) }
3236
/* Sort NIDs for convenient ordering */
3337
.rodata.sceNid : { *(.rodata.sceNid) *(SORT(.rodata.sceNid.*)) }
38+
39+
.rodata : { *(.rodata .rodata.*) }
40+
.data : { *(.data .data.*) }
41+
.gcc_except_table : { *(.gcc_except_table .gcc_except_table.*) }
42+
.bss : { *(.bss .bss.*) }
43+
44+
/DISCARD/ : { *(.rel.sceStub.text .MIPS.abiflags .reginfo) }
3445
}

library/std/src/io/impls.rs

+48
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ mod tests;
33

44
use crate::alloc::Allocator;
55
use crate::cmp;
6+
use crate::collections::VecDeque;
67
use crate::fmt;
78
use crate::io::{
89
self, BufRead, ErrorKind, IoSlice, IoSliceMut, Read, ReadBuf, Seek, SeekFrom, Write,
@@ -410,3 +411,50 @@ impl<A: Allocator> Write for Vec<u8, A> {
410411
Ok(())
411412
}
412413
}
414+
415+
/// Read is implemented for `VecDeque<u8>` by consuming bytes from the front of the `VecDeque`.
416+
#[stable(feature = "vecdeque_read_write", since = "1.63.0")]
417+
impl<A: Allocator> Read for VecDeque<u8, A> {
418+
/// Fill `buf` with the contents of the "front" slice as returned by
419+
/// [`as_slices`][`VecDeque::as_slices`]. If the contained byte slices of the `VecDeque` are
420+
/// discontiguous, multiple calls to `read` will be needed to read the entire content.
421+
#[inline]
422+
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
423+
let (ref mut front, _) = self.as_slices();
424+
let n = Read::read(front, buf)?;
425+
self.drain(..n);
426+
Ok(n)
427+
}
428+
429+
#[inline]
430+
fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> io::Result<()> {
431+
let (ref mut front, _) = self.as_slices();
432+
let n = cmp::min(buf.remaining(), front.len());
433+
Read::read_buf(front, buf)?;
434+
self.drain(..n);
435+
Ok(())
436+
}
437+
}
438+
439+
/// Write is implemented for `VecDeque<u8>` by appending to the `VecDeque`, growing it as needed.
440+
#[stable(feature = "vecdeque_read_write", since = "1.63.0")]
441+
impl<A: Allocator> Write for VecDeque<u8, A> {
442+
#[inline]
443+
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
444+
self.reserve(buf.len());
445+
self.extend(buf);
446+
Ok(buf.len())
447+
}
448+
449+
#[inline]
450+
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
451+
self.reserve(buf.len());
452+
self.extend(buf);
453+
Ok(())
454+
}
455+
456+
#[inline]
457+
fn flush(&mut self) -> io::Result<()> {
458+
Ok(())
459+
}
460+
}

src/test/assembly/asm/hexagon-types.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ macro_rules! check_reg {
7373

7474
// CHECK-LABEL: sym_static:
7575
// CHECK: InlineAsm Start
76-
// CHECK: r0 = #extern_static
76+
// CHECK: r0 = {{#+}}extern_static
7777
// CHECK: InlineAsm End
7878
#[no_mangle]
7979
pub unsafe fn sym_static() {
@@ -88,7 +88,7 @@ pub unsafe fn sym_static() {
8888

8989
// CHECK-LABEL: sym_fn:
9090
// CHECK: InlineAsm Start
91-
// CHECK: r0 = #extern_func
91+
// CHECK: r0 = {{#+}}extern_func
9292
// CHECK: InlineAsm End
9393
#[no_mangle]
9494
pub unsafe fn sym_fn() {
@@ -108,7 +108,7 @@ pub unsafe fn sym_fn() {
108108
// CHECK: InlineAsm Start
109109
// CHECK: {
110110
// CHECK: r{{[0-9]+}} = r0
111-
// CHECK: memw(r1) = r{{[0-9]+}}
111+
// CHECK: memw(r1{{(\+#0)?}}) = r{{[0-9]+}}
112112
// CHECK: }
113113
// CHECK: InlineAsm End
114114
#[no_mangle]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// check-pass
2+
3+
macro_rules! dollar_dollar {
4+
() => {
5+
macro_rules! bar {
6+
( $$( $$any:tt )* ) => { $$( $$any )* };
7+
}
8+
};
9+
}
10+
11+
fn main() {
12+
}

src/test/ui/macros/rfc-3086-metavar-expr/required-feature.rs renamed to src/test/ui/macros/rfc-3086-metavar-expr/required-features.rs

-12
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,6 @@ macro_rules! count {
55
};
66
}
77

8-
macro_rules! dollar_dollar {
9-
() => {
10-
macro_rules! bar {
11-
( $$( $$any:tt )* ) => { $$( $$any )* };
12-
//~^ ERROR meta-variable expressions are unstable
13-
//~| ERROR meta-variable expressions are unstable
14-
//~| ERROR meta-variable expressions are unstable
15-
//~| ERROR meta-variable expressions are unstable
16-
}
17-
};
18-
}
19-
208
macro_rules! index {
219
( $( $e:stmt ),* ) => {
2210
$( ${ignore(e)} ${index()} )*
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: meta-variable expressions are unstable
2-
--> $DIR/required-feature.rs:3:10
2+
--> $DIR/required-features.rs:3:10
33
|
44
LL | ${ count(e) }
55
| ^^^^^^^^^^^^
@@ -8,43 +8,7 @@ LL | ${ count(e) }
88
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable
99

1010
error[E0658]: meta-variable expressions are unstable
11-
--> $DIR/required-feature.rs:11:16
12-
|
13-
LL | ( $$( $$any:tt )* ) => { $$( $$any )* };
14-
| ^
15-
|
16-
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
17-
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable
18-
19-
error[E0658]: meta-variable expressions are unstable
20-
--> $DIR/required-feature.rs:11:20
21-
|
22-
LL | ( $$( $$any:tt )* ) => { $$( $$any )* };
23-
| ^
24-
|
25-
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
26-
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable
27-
28-
error[E0658]: meta-variable expressions are unstable
29-
--> $DIR/required-feature.rs:11:39
30-
|
31-
LL | ( $$( $$any:tt )* ) => { $$( $$any )* };
32-
| ^
33-
|
34-
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
35-
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable
36-
37-
error[E0658]: meta-variable expressions are unstable
38-
--> $DIR/required-feature.rs:11:43
39-
|
40-
LL | ( $$( $$any:tt )* ) => { $$( $$any )* };
41-
| ^
42-
|
43-
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
44-
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable
45-
46-
error[E0658]: meta-variable expressions are unstable
47-
--> $DIR/required-feature.rs:22:13
11+
--> $DIR/required-features.rs:10:13
4812
|
4913
LL | $( ${ignore(e)} ${index()} )*
5014
| ^^^^^^^^^^^
@@ -53,7 +17,7 @@ LL | $( ${ignore(e)} ${index()} )*
5317
= help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable
5418

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

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

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

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

91-
error: aborting due to 10 previous errors
55+
error: aborting due to 6 previous errors
9256

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

0 commit comments

Comments
 (0)