Skip to content

Commit d8f50ab

Browse files
committed
Auto merge of #61789 - Centril:rollup-hhyvopq, r=Centril
Rollup of 9 pull requests Successful merges: - #60376 (Stabilize Option::xor) - #61398 (Stabilize copy_within) - #61629 (Hygienize macros in the standard library) - #61675 (Include frame pointer for bare metal RISC-V targets) - #61750 (Fix x.py install) - #61761 (Add an alias for x86_64-sun-solaris target tuple) - #61762 (rustbuild: fix libtest_stamp) - #61763 (ci: fix ci stats upload condition) - #61776 (Fix typos in error_codes) Failed merges: r? @ghost
2 parents 2887008 + af281d2 commit d8f50ab

22 files changed

+67
-68
lines changed

.azure-pipelines/steps/run.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,6 @@ steps:
155155
- bash: aws s3 cp --acl public-read cpu-usage.csv s3://$DEPLOY_BUCKET/rustc-builds/$BUILD_SOURCEVERSION/cpu-$SYSTEM_JOBNAME.csv
156156
env:
157157
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
158-
condition: contains(variables, 'AWS_SECRET_ACCESS_KEY')
158+
condition: variables['AWS_SECRET_ACCESS_KEY']
159159
continueOnError: true
160160
displayName: Upload CPU usage statistics

src/bootstrap/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ impl<'a> Builder<'a> {
787787

788788
let libtest_stamp = match cmd {
789789
"check" | "clippy" | "fix" => check::libtest_stamp(self, cmp, target),
790-
_ => compile::libstd_stamp(self, cmp, target),
790+
_ => compile::libtest_stamp(self, cmp, target),
791791
};
792792

793793
let librustc_stamp = match cmd {

src/bootstrap/install.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ install!((self, builder, _config),
251251
};
252252
Analysis, "analysis", Self::should_build(_config), only_hosts: false, {
253253
builder.ensure(dist::Analysis {
254-
compiler: self.compiler,
254+
// Find the actual compiler (handling the full bootstrap option) which
255+
// produced the save-analysis data because that data isn't copied
256+
// through the sysroot uplifting.
257+
compiler: builder.compiler_for(builder.top_stage, builder.config.build, self.target),
255258
target: self.target
256259
});
257260
install_analysis(builder, self.compiler.stage, self.target);

src/liballoc/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ macro_rules! vec {
4242
($($x:expr),*) => (
4343
<[_]>::into_vec(box [$($x),*])
4444
);
45-
($($x:expr,)*) => (vec![$($x),*])
45+
($($x:expr,)*) => ($crate::vec![$($x),*])
4646
}
4747

4848
// HACK(japaric): with cfg(test) the inherent `[T]::into_vec` method, which is

src/libcore/macros.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
#[stable(feature = "core", since = "1.6.0")]
77
macro_rules! panic {
88
() => (
9-
panic!("explicit panic")
9+
$crate::panic!("explicit panic")
1010
);
1111
($msg:expr) => ({
1212
$crate::panicking::panic(&($msg, file!(), line!(), __rust_unstable_column!()))
1313
});
1414
($msg:expr,) => (
15-
panic!($msg)
15+
$crate::panic!($msg)
1616
);
1717
($fmt:expr, $($arg:tt)+) => ({
1818
$crate::panicking::panic_fmt(format_args!($fmt, $($arg)*),
@@ -58,7 +58,7 @@ macro_rules! assert_eq {
5858
}
5959
});
6060
($left:expr, $right:expr,) => ({
61-
assert_eq!($left, $right)
61+
$crate::assert_eq!($left, $right)
6262
});
6363
($left:expr, $right:expr, $($arg:tt)+) => ({
6464
match (&($left), &($right)) {
@@ -115,7 +115,7 @@ macro_rules! assert_ne {
115115
}
116116
});
117117
($left:expr, $right:expr,) => {
118-
assert_ne!($left, $right)
118+
$crate::assert_ne!($left, $right)
119119
};
120120
($left:expr, $right:expr, $($arg:tt)+) => ({
121121
match (&($left), &($right)) {
@@ -208,7 +208,7 @@ macro_rules! debug_assert {
208208
#[macro_export]
209209
#[stable(feature = "rust1", since = "1.0.0")]
210210
macro_rules! debug_assert_eq {
211-
($($arg:tt)*) => (if cfg!(debug_assertions) { assert_eq!($($arg)*); })
211+
($($arg:tt)*) => (if cfg!(debug_assertions) { $crate::assert_eq!($($arg)*); })
212212
}
213213

214214
/// Asserts that two expressions are not equal to each other.
@@ -235,7 +235,7 @@ macro_rules! debug_assert_eq {
235235
#[macro_export]
236236
#[stable(feature = "assert_ne", since = "1.13.0")]
237237
macro_rules! debug_assert_ne {
238-
($($arg:tt)*) => (if cfg!(debug_assertions) { assert_ne!($($arg)*); })
238+
($($arg:tt)*) => (if cfg!(debug_assertions) { $crate::assert_ne!($($arg)*); })
239239
}
240240

241241
/// Unwraps a result or propagates its error.
@@ -310,7 +310,7 @@ macro_rules! r#try {
310310
return $crate::result::Result::Err($crate::convert::From::from(err))
311311
}
312312
});
313-
($expr:expr,) => (r#try!($expr));
313+
($expr:expr,) => ($crate::r#try!($expr));
314314
}
315315

316316
/// Writes formatted data into a buffer.
@@ -425,10 +425,10 @@ macro_rules! write {
425425
#[allow_internal_unstable(format_args_nl)]
426426
macro_rules! writeln {
427427
($dst:expr) => (
428-
write!($dst, "\n")
428+
$crate::write!($dst, "\n")
429429
);
430430
($dst:expr,) => (
431-
writeln!($dst)
431+
$crate::writeln!($dst)
432432
);
433433
($dst:expr, $($arg:tt)*) => (
434434
$dst.write_fmt(format_args_nl!($($arg)*))
@@ -494,10 +494,10 @@ macro_rules! unreachable {
494494
panic!("internal error: entered unreachable code")
495495
});
496496
($msg:expr) => ({
497-
unreachable!("{}", $msg)
497+
$crate::unreachable!("{}", $msg)
498498
});
499499
($msg:expr,) => ({
500-
unreachable!($msg)
500+
$crate::unreachable!($msg)
501501
});
502502
($fmt:expr, $($arg:tt)*) => ({
503503
panic!(concat!("internal error: entered unreachable code: ", $fmt), $($arg)*)

src/libcore/option.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,6 @@ impl<T> Option<T> {
725725
/// # Examples
726726
///
727727
/// ```
728-
/// #![feature(option_xor)]
729-
///
730728
/// let x = Some(2);
731729
/// let y: Option<u32> = None;
732730
/// assert_eq!(x.xor(y), Some(2));
@@ -744,7 +742,7 @@ impl<T> Option<T> {
744742
/// assert_eq!(x.xor(y), None);
745743
/// ```
746744
#[inline]
747-
#[unstable(feature = "option_xor", issue = "50512")]
745+
#[stable(feature = "option_xor", since = "1.37.0")]
748746
pub fn xor(self, optb: Option<T>) -> Option<T> {
749747
match (self, optb) {
750748
(Some(a), None) => Some(a),

src/libcore/slice/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -2146,14 +2146,13 @@ impl<T> [T] {
21462146
/// Copying four bytes within a slice:
21472147
///
21482148
/// ```
2149-
/// # #![feature(copy_within)]
21502149
/// let mut bytes = *b"Hello, World!";
21512150
///
21522151
/// bytes.copy_within(1..5, 8);
21532152
///
21542153
/// assert_eq!(&bytes, b"Hello, Wello!");
21552154
/// ```
2156-
#[unstable(feature = "copy_within", issue = "54236")]
2155+
#[stable(feature = "copy_within", since = "1.37.0")]
21572156
pub fn copy_within<R: ops::RangeBounds<usize>>(&mut self, src: R, dest: usize)
21582157
where
21592158
T: Copy,
@@ -2178,8 +2177,8 @@ impl<T> [T] {
21782177
assert!(dest <= self.len() - count, "dest is out of bounds");
21792178
unsafe {
21802179
ptr::copy(
2181-
self.get_unchecked(src_start),
2182-
self.get_unchecked_mut(dest),
2180+
self.as_ptr().add(src_start),
2181+
self.as_mut_ptr().add(dest),
21832182
count,
21842183
);
21852184
}

src/libcore/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#![feature(inner_deref)]
2929
#![feature(slice_internals)]
3030
#![feature(slice_partition_dedup)]
31-
#![feature(copy_within)]
3231
#![feature(int_error_matching)]
3332
#![feature(const_fn)]
3433
#![warn(rust_2018_idioms)]

src/libcore/tests/slice.rs

+14
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,13 @@ fn test_copy_within() {
15121512
let mut bytes = *b"Hello, World!";
15131513
bytes.copy_within(.., 0);
15141514
assert_eq!(&bytes, b"Hello, World!");
1515+
1516+
// Ensure that copying at the end of slice won't cause UB.
1517+
let mut bytes = *b"Hello, World!";
1518+
bytes.copy_within(13..13, 5);
1519+
assert_eq!(&bytes, b"Hello, World!");
1520+
bytes.copy_within(5..5, 13);
1521+
assert_eq!(&bytes, b"Hello, World!");
15151522
}
15161523

15171524
#[test]
@@ -1536,6 +1543,13 @@ fn test_copy_within_panics_src_inverted() {
15361543
// 2 is greater than 1, so this range is invalid.
15371544
bytes.copy_within(2..1, 0);
15381545
}
1546+
#[test]
1547+
#[should_panic(expected = "attempted to index slice up to maximum usize")]
1548+
fn test_copy_within_panics_src_out_of_bounds() {
1549+
let mut bytes = *b"Hello, World!";
1550+
// an inclusive range ending at usize::max_value() would make src_end overflow
1551+
bytes.copy_within(usize::max_value()..=usize::max_value(), 0);
1552+
}
15391553

15401554
#[test]
15411555
fn test_is_sorted() {

src/librustc/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1883,7 +1883,7 @@ This pattern should be rewritten. There are a few possible ways to do this:
18831883
# }
18841884
```
18851885
1886-
The same applies to transmutes to `*mut fn()`, which were observedin practice.
1886+
The same applies to transmutes to `*mut fn()`, which were observed in practice.
18871887
Note though that use of this type is generally incorrect.
18881888
The intention is typically to describe a function pointer, but just `fn()`
18891889
alone suffices for that. `*mut fn()` is a pointer to a fn pointer.

src/librustc_target/spec/mod.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -268,16 +268,16 @@ pub type LinkArgs = BTreeMap<LinkerFlavor, Vec<String>>;
268268
pub type TargetResult = Result<Target, String>;
269269

270270
macro_rules! supported_targets {
271-
( $(($triple:expr, $module:ident),)+ ) => (
272-
$(mod $module;)*
271+
( $(($( $triple:literal, )+ $module:ident ),)+ ) => {
272+
$(mod $module;)+
273273

274274
/// List of supported targets
275-
const TARGETS: &[&str] = &[$($triple),*];
275+
const TARGETS: &[&str] = &[$($($triple),+),+];
276276

277277
fn load_specific(target: &str) -> Result<Target, LoadTargetError> {
278278
match target {
279279
$(
280-
$triple => {
280+
$($triple)|+ => {
281281
let mut t = $module::target()
282282
.map_err(LoadTargetError::Other)?;
283283
t.options.is_builtin = true;
@@ -307,7 +307,7 @@ macro_rules! supported_targets {
307307
mod test_json_encode_decode {
308308
use serialize::json::ToJson;
309309
use super::Target;
310-
$(use super::$module;)*
310+
$(use super::$module;)+
311311

312312
$(
313313
#[test]
@@ -322,9 +322,9 @@ macro_rules! supported_targets {
322322
assert_eq!(original, parsed);
323323
});
324324
}
325-
)*
325+
)+
326326
}
327-
)
327+
};
328328
}
329329

330330
supported_targets! {
@@ -426,7 +426,9 @@ supported_targets! {
426426
("armv7r-none-eabi", armv7r_none_eabi),
427427
("armv7r-none-eabihf", armv7r_none_eabihf),
428428

429-
("x86_64-sun-solaris", x86_64_sun_solaris),
429+
// `x86_64-pc-solaris` is an alias for `x86_64_sun_solaris` for backwards compatibility reasons.
430+
// (See <https://github.com/rust-lang/rust/issues/40531>.)
431+
("x86_64-sun-solaris", "x86_64-pc-solaris", x86_64_sun_solaris),
430432
("sparcv9-sun-solaris", sparcv9_sun_solaris),
431433

432434
("x86_64-pc-windows-gnu", x86_64_pc_windows_gnu),

src/librustc_target/spec/riscv32imac_unknown_none_elf.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub fn target() -> TargetResult {
2525
relocation_model: "static".to_string(),
2626
emit_debug_gdb_scripts: false,
2727
abi_blacklist: super::riscv_base::abi_blacklist(),
28+
eliminate_frame_pointer: false,
2829
.. Default::default()
2930
},
3031
})

src/librustc_target/spec/riscv32imc_unknown_none_elf.rs

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub fn target() -> TargetResult {
2626
relocation_model: "static".to_string(),
2727
emit_debug_gdb_scripts: false,
2828
abi_blacklist: super::riscv_base::abi_blacklist(),
29+
eliminate_frame_pointer: false,
2930
.. Default::default()
3031
},
3132
})

src/librustc_target/spec/riscv64gc_unknown_none_elf.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub fn target() -> TargetResult {
2525
relocation_model: "static".to_string(),
2626
emit_debug_gdb_scripts: false,
2727
abi_blacklist: super::riscv_base::abi_blacklist(),
28+
eliminate_frame_pointer: false,
2829
.. Default::default()
2930
},
3031
})

src/librustc_target/spec/riscv64imac_unknown_none_elf.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub fn target() -> TargetResult {
2525
relocation_model: "static".to_string(),
2626
emit_debug_gdb_scripts: false,
2727
abi_blacklist: super::riscv_base::abi_blacklist(),
28+
eliminate_frame_pointer: false,
2829
.. Default::default()
2930
},
3031
})

src/libstd/macros.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@
5656
#[allow_internal_unstable(__rust_unstable_column, libstd_sys_internals)]
5757
macro_rules! panic {
5858
() => ({
59-
panic!("explicit panic")
59+
$crate::panic!("explicit panic")
6060
});
6161
($msg:expr) => ({
6262
$crate::rt::begin_panic($msg, &(file!(), line!(), __rust_unstable_column!()))
6363
});
6464
($msg:expr,) => ({
65-
panic!($msg)
65+
$crate::panic!($msg)
6666
});
6767
($fmt:expr, $($arg:tt)+) => ({
6868
$crate::rt::begin_panic_fmt(&format_args!($fmt, $($arg)+),
@@ -145,7 +145,7 @@ macro_rules! print {
145145
#[stable(feature = "rust1", since = "1.0.0")]
146146
#[allow_internal_unstable(print_internals, format_args_nl)]
147147
macro_rules! println {
148-
() => (print!("\n"));
148+
() => ($crate::print!("\n"));
149149
($($arg:tt)*) => ({
150150
$crate::io::_print(format_args_nl!($($arg)*));
151151
})
@@ -204,7 +204,7 @@ macro_rules! eprint {
204204
#[stable(feature = "eprint", since = "1.19.0")]
205205
#[allow_internal_unstable(print_internals, format_args_nl)]
206206
macro_rules! eprintln {
207-
() => (eprint!("\n"));
207+
() => ($crate::eprint!("\n"));
208208
($($arg:tt)*) => ({
209209
$crate::io::_eprint(format_args_nl!($($arg)*));
210210
})
@@ -337,23 +337,23 @@ macro_rules! eprintln {
337337
#[stable(feature = "dbg_macro", since = "1.32.0")]
338338
macro_rules! dbg {
339339
() => {
340-
eprintln!("[{}:{}]", file!(), line!());
340+
$crate::eprintln!("[{}:{}]", file!(), line!());
341341
};
342342
($val:expr) => {
343343
// Use of `match` here is intentional because it affects the lifetimes
344344
// of temporaries - https://stackoverflow.com/a/48732525/1063961
345345
match $val {
346346
tmp => {
347-
eprintln!("[{}:{}] {} = {:#?}",
347+
$crate::eprintln!("[{}:{}] {} = {:#?}",
348348
file!(), line!(), stringify!($val), &tmp);
349349
tmp
350350
}
351351
}
352352
};
353353
// Trailing comma with single argument is ignored
354-
($val:expr,) => { dbg!($val) };
354+
($val:expr,) => { $crate::dbg!($val) };
355355
($($val:expr),+ $(,)?) => {
356-
($(dbg!($val)),+,)
356+
($($crate::dbg!($val)),+,)
357357
};
358358
}
359359

src/test/ui/explain.stdout

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ This pattern should be rewritten. There are a few possible ways to do this:
5353
let f: extern "C" fn(*mut i32) = transmute(foo as usize); // works too
5454
```
5555

56-
The same applies to transmutes to `*mut fn()`, which were observedin practice.
56+
The same applies to transmutes to `*mut fn()`, which were observed in practice.
5757
Note though that use of this type is generally incorrect.
5858
The intention is typically to describe a function pointer, but just `fn()`
5959
alone suffices for that. `*mut fn()` is a pointer to a fn pointer.

src/test/ui/hygiene/no_implicit_prelude.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ mod bar {
1313
}
1414
fn f() {
1515
::foo::m!();
16-
println!(); //~ ERROR cannot find macro `print!` in this scope
16+
assert_eq!(0, 0); //~ ERROR cannot find macro `panic!` in this scope
1717
}
1818
}
1919

src/test/ui/hygiene/no_implicit_prelude.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ LL | fn f() { ::bar::m!(); }
77
LL | Vec::new();
88
| ^^^ use of undeclared type or module `Vec`
99

10-
error: cannot find macro `print!` in this scope
10+
error: cannot find macro `panic!` in this scope
1111
--> $DIR/no_implicit_prelude.rs:16:9
1212
|
13-
LL | println!();
14-
| ^^^^^^^^^^^
13+
LL | assert_eq!(0, 0);
14+
| ^^^^^^^^^^^^^^^^^
1515
|
1616
= help: have you added the `#[macro_use]` on the module/import?
1717
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

0 commit comments

Comments
 (0)