Skip to content

Commit c2f9b51

Browse files
committed
Auto merge of #93738 - m-ou-se:rollup-zjyd2et, r=m-ou-se
Rollup of 13 pull requests Successful merges: - #88313 (Make the pre-commit script pre-push instead) - #91530 (Suggest 1-tuple parentheses on exprs without existing parens) - #92724 (Cleanup c_str.rs) - #93208 (Impl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}Assign<$t> for Wrapping<$t> for rust 1.60.0) - #93394 (Don't allow {} to refer to implicit captures in format_args.) - #93416 (remove `allow_fail` test flag) - #93487 (Fix linking stage1 toolchain in `./x.py setup`) - #93673 (Linkify sidebar headings for sibling items) - #93680 (Drop json::from_reader) - #93682 (Update tracking issue for `const_fn_trait_bound`) - #93722 (Use shallow clones for submodules managed by rustbuild, not just bootstrap.py) - #93723 (Rerun bootstrap's build script when RUSTC changes) - #93737 (bootstrap: prefer using '--config' over 'RUST_BOOTSTRAP_CONFIG') Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 82ecf9e + 15cb10d commit c2f9b51

File tree

10 files changed

+143
-100
lines changed

10 files changed

+143
-100
lines changed

core/src/num/wrapping.rs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,16 @@ macro_rules! wrapping_impl {
239239
}
240240
forward_ref_op_assign! { impl const AddAssign, add_assign for Wrapping<$t>, Wrapping<$t> }
241241

242+
#[stable(feature = "wrapping_int_assign_impl", since = "1.60.0")]
243+
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
244+
impl const AddAssign<$t> for Wrapping<$t> {
245+
#[inline]
246+
fn add_assign(&mut self, other: $t) {
247+
*self = *self + Wrapping(other);
248+
}
249+
}
250+
forward_ref_op_assign! { impl const AddAssign, add_assign for Wrapping<$t>, $t }
251+
242252
#[stable(feature = "rust1", since = "1.0.0")]
243253
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
244254
impl const Sub for Wrapping<$t> {
@@ -262,6 +272,16 @@ macro_rules! wrapping_impl {
262272
}
263273
forward_ref_op_assign! { impl const SubAssign, sub_assign for Wrapping<$t>, Wrapping<$t> }
264274

275+
#[stable(feature = "wrapping_int_assign_impl", since = "1.60.0")]
276+
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
277+
impl const SubAssign<$t> for Wrapping<$t> {
278+
#[inline]
279+
fn sub_assign(&mut self, other: $t) {
280+
*self = *self - Wrapping(other);
281+
}
282+
}
283+
forward_ref_op_assign! { impl const SubAssign, sub_assign for Wrapping<$t>, $t }
284+
265285
#[stable(feature = "rust1", since = "1.0.0")]
266286
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
267287
impl const Mul for Wrapping<$t> {
@@ -285,6 +305,16 @@ macro_rules! wrapping_impl {
285305
}
286306
forward_ref_op_assign! { impl const MulAssign, mul_assign for Wrapping<$t>, Wrapping<$t> }
287307

308+
#[stable(feature = "wrapping_int_assign_impl", since = "1.60.0")]
309+
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
310+
impl const MulAssign<$t> for Wrapping<$t> {
311+
#[inline]
312+
fn mul_assign(&mut self, other: $t) {
313+
*self = *self * Wrapping(other);
314+
}
315+
}
316+
forward_ref_op_assign! { impl const MulAssign, mul_assign for Wrapping<$t>, $t }
317+
288318
#[stable(feature = "wrapping_div", since = "1.3.0")]
289319
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
290320
impl const Div for Wrapping<$t> {
@@ -308,6 +338,16 @@ macro_rules! wrapping_impl {
308338
}
309339
forward_ref_op_assign! { impl const DivAssign, div_assign for Wrapping<$t>, Wrapping<$t> }
310340

341+
#[stable(feature = "wrapping_int_assign_impl", since = "1.60.0")]
342+
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
343+
impl const DivAssign<$t> for Wrapping<$t> {
344+
#[inline]
345+
fn div_assign(&mut self, other: $t) {
346+
*self = *self / Wrapping(other);
347+
}
348+
}
349+
forward_ref_op_assign! { impl const DivAssign, div_assign for Wrapping<$t>, $t }
350+
311351
#[stable(feature = "wrapping_impls", since = "1.7.0")]
312352
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
313353
impl const Rem for Wrapping<$t> {
@@ -331,6 +371,16 @@ macro_rules! wrapping_impl {
331371
}
332372
forward_ref_op_assign! { impl const RemAssign, rem_assign for Wrapping<$t>, Wrapping<$t> }
333373

374+
#[stable(feature = "wrapping_int_assign_impl", since = "1.60.0")]
375+
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
376+
impl const RemAssign<$t> for Wrapping<$t> {
377+
#[inline]
378+
fn rem_assign(&mut self, other: $t) {
379+
*self = *self % Wrapping(other);
380+
}
381+
}
382+
forward_ref_op_assign! { impl const RemAssign, rem_assign for Wrapping<$t>, $t }
383+
334384
#[stable(feature = "rust1", since = "1.0.0")]
335385
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
336386
impl const Not for Wrapping<$t> {
@@ -367,6 +417,16 @@ macro_rules! wrapping_impl {
367417
}
368418
forward_ref_op_assign! { impl const BitXorAssign, bitxor_assign for Wrapping<$t>, Wrapping<$t> }
369419

420+
#[stable(feature = "wrapping_int_assign_impl", since = "1.60.0")]
421+
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
422+
impl const BitXorAssign<$t> for Wrapping<$t> {
423+
#[inline]
424+
fn bitxor_assign(&mut self, other: $t) {
425+
*self = *self ^ Wrapping(other);
426+
}
427+
}
428+
forward_ref_op_assign! { impl const BitXorAssign, bitxor_assign for Wrapping<$t>, $t }
429+
370430
#[stable(feature = "rust1", since = "1.0.0")]
371431
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
372432
impl const BitOr for Wrapping<$t> {
@@ -390,6 +450,16 @@ macro_rules! wrapping_impl {
390450
}
391451
forward_ref_op_assign! { impl const BitOrAssign, bitor_assign for Wrapping<$t>, Wrapping<$t> }
392452

453+
#[stable(feature = "wrapping_int_assign_impl", since = "1.60.0")]
454+
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
455+
impl const BitOrAssign<$t> for Wrapping<$t> {
456+
#[inline]
457+
fn bitor_assign(&mut self, other: $t) {
458+
*self = *self | Wrapping(other);
459+
}
460+
}
461+
forward_ref_op_assign! { impl const BitOrAssign, bitor_assign for Wrapping<$t>, $t }
462+
393463
#[stable(feature = "rust1", since = "1.0.0")]
394464
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
395465
impl const BitAnd for Wrapping<$t> {
@@ -413,6 +483,16 @@ macro_rules! wrapping_impl {
413483
}
414484
forward_ref_op_assign! { impl const BitAndAssign, bitand_assign for Wrapping<$t>, Wrapping<$t> }
415485

486+
#[stable(feature = "wrapping_int_assign_impl", since = "1.60.0")]
487+
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
488+
impl const BitAndAssign<$t> for Wrapping<$t> {
489+
#[inline]
490+
fn bitand_assign(&mut self, other: $t) {
491+
*self = *self & Wrapping(other);
492+
}
493+
}
494+
forward_ref_op_assign! { impl const BitAndAssign, bitand_assign for Wrapping<$t>, $t }
495+
416496
#[stable(feature = "wrapping_neg", since = "1.10.0")]
417497
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
418498
impl const Neg for Wrapping<$t> {

std/src/ffi/c_str.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,15 +1252,16 @@ impl CStr {
12521252
/// assert!(cstr.is_err());
12531253
/// ```
12541254
#[stable(feature = "cstr_from_bytes", since = "1.10.0")]
1255-
pub fn from_bytes_with_nul(bytes: &[u8]) -> Result<&CStr, FromBytesWithNulError> {
1255+
pub fn from_bytes_with_nul(bytes: &[u8]) -> Result<&Self, FromBytesWithNulError> {
12561256
let nul_pos = memchr::memchr(0, bytes);
1257-
if let Some(nul_pos) = nul_pos {
1258-
if nul_pos + 1 != bytes.len() {
1259-
return Err(FromBytesWithNulError::interior_nul(nul_pos));
1257+
match nul_pos {
1258+
Some(nul_pos) if nul_pos + 1 == bytes.len() => {
1259+
// SAFETY: We know there is only one nul byte, at the end
1260+
// of the byte slice.
1261+
Ok(unsafe { Self::from_bytes_with_nul_unchecked(bytes) })
12601262
}
1261-
Ok(unsafe { CStr::from_bytes_with_nul_unchecked(bytes) })
1262-
} else {
1263-
Err(FromBytesWithNulError::not_nul_terminated())
1263+
Some(nul_pos) => Err(FromBytesWithNulError::interior_nul(nul_pos)),
1264+
None => Err(FromBytesWithNulError::not_nul_terminated()),
12641265
}
12651266
}
12661267

test/src/console.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ pub struct ConsoleTestState {
4747
pub passed: usize,
4848
pub failed: usize,
4949
pub ignored: usize,
50-
pub allowed_fail: usize,
5150
pub filtered_out: usize,
5251
pub measured: usize,
5352
pub exec_time: Option<TestSuiteExecTime>,
@@ -71,7 +70,6 @@ impl ConsoleTestState {
7170
passed: 0,
7271
failed: 0,
7372
ignored: 0,
74-
allowed_fail: 0,
7573
filtered_out: 0,
7674
measured: 0,
7775
exec_time: None,
@@ -112,7 +110,6 @@ impl ConsoleTestState {
112110
TestResult::TrFailed => "failed".to_owned(),
113111
TestResult::TrFailedMsg(ref msg) => format!("failed: {}", msg),
114112
TestResult::TrIgnored => "ignored".to_owned(),
115-
TestResult::TrAllowedFail => "failed (allowed)".to_owned(),
116113
TestResult::TrBench(ref bs) => fmt_bench_samples(bs),
117114
TestResult::TrTimedFail => "failed (time limit exceeded)".to_owned(),
118115
},
@@ -126,7 +123,7 @@ impl ConsoleTestState {
126123
}
127124

128125
fn current_test_count(&self) -> usize {
129-
self.passed + self.failed + self.ignored + self.measured + self.allowed_fail
126+
self.passed + self.failed + self.ignored + self.measured
130127
}
131128
}
132129

@@ -191,7 +188,6 @@ fn handle_test_result(st: &mut ConsoleTestState, completed_test: CompletedTest)
191188
st.not_failures.push((test, stdout));
192189
}
193190
TestResult::TrIgnored => st.ignored += 1,
194-
TestResult::TrAllowedFail => st.allowed_fail += 1,
195191
TestResult::TrBench(bs) => {
196192
st.metrics.insert_metric(
197193
test.name.as_slice(),

test/src/formatters/json.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,6 @@ impl<T: Write> OutputFormatter for JsonFormatter<T> {
124124
self.write_event("test", desc.name.as_slice(), "ignored", exec_time, stdout, None)
125125
}
126126

127-
TestResult::TrAllowedFail => self.write_event(
128-
"test",
129-
desc.name.as_slice(),
130-
"allowed_failure",
131-
exec_time,
132-
stdout,
133-
None,
134-
),
135-
136127
TestResult::TrBench(ref bs) => {
137128
let median = bs.ns_iter_summ.median as usize;
138129
let deviation = (bs.ns_iter_summ.max - bs.ns_iter_summ.min) as usize;
@@ -172,14 +163,12 @@ impl<T: Write> OutputFormatter for JsonFormatter<T> {
172163
\"event\": \"{}\", \
173164
\"passed\": {}, \
174165
\"failed\": {}, \
175-
\"allowed_fail\": {}, \
176166
\"ignored\": {}, \
177167
\"measured\": {}, \
178168
\"filtered_out\": {}",
179169
if state.failed == 0 { "ok" } else { "failed" },
180170
state.passed,
181-
state.failed + state.allowed_fail,
182-
state.allowed_fail,
171+
state.failed,
183172
state.ignored,
184173
state.measured,
185174
state.filtered_out,

test/src/formatters/junit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<T: Write> OutputFormatter for JunitFormatter<T> {
121121
))?;
122122
}
123123

124-
TestResult::TrOk | TestResult::TrAllowedFail => {
124+
TestResult::TrOk => {
125125
self.write_message(&*format!(
126126
"<testcase classname=\"{}\" \
127127
name=\"{}\" time=\"{}\"/>",

test/src/formatters/pretty.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ impl<T: Write> PrettyFormatter<T> {
4949
self.write_short_result("ignored", term::color::YELLOW)
5050
}
5151

52-
pub fn write_allowed_fail(&mut self) -> io::Result<()> {
53-
self.write_short_result("FAILED (allowed)", term::color::YELLOW)
54-
}
55-
5652
pub fn write_time_failed(&mut self) -> io::Result<()> {
5753
self.write_short_result("FAILED (time limit exceeded)", term::color::RED)
5854
}
@@ -219,7 +215,6 @@ impl<T: Write> OutputFormatter for PrettyFormatter<T> {
219215
TestResult::TrOk => self.write_ok()?,
220216
TestResult::TrFailed | TestResult::TrFailedMsg(_) => self.write_failed()?,
221217
TestResult::TrIgnored => self.write_ignored()?,
222-
TestResult::TrAllowedFail => self.write_allowed_fail()?,
223218
TestResult::TrBench(ref bs) => {
224219
self.write_bench()?;
225220
self.write_plain(&format!(": {}", fmt_bench_samples(bs)))?;
@@ -263,22 +258,10 @@ impl<T: Write> OutputFormatter for PrettyFormatter<T> {
263258
self.write_pretty("FAILED", term::color::RED)?;
264259
}
265260

266-
let s = if state.allowed_fail > 0 {
267-
format!(
268-
". {} passed; {} failed ({} allowed); {} ignored; {} measured; {} filtered out",
269-
state.passed,
270-
state.failed + state.allowed_fail,
271-
state.allowed_fail,
272-
state.ignored,
273-
state.measured,
274-
state.filtered_out
275-
)
276-
} else {
277-
format!(
278-
". {} passed; {} failed; {} ignored; {} measured; {} filtered out",
279-
state.passed, state.failed, state.ignored, state.measured, state.filtered_out
280-
)
281-
};
261+
let s = format!(
262+
". {} passed; {} failed; {} ignored; {} measured; {} filtered out",
263+
state.passed, state.failed, state.ignored, state.measured, state.filtered_out
264+
);
282265

283266
self.write_plain(&s)?;
284267

test/src/formatters/terse.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ impl<T: Write> TerseFormatter<T> {
5454
self.write_short_result("i", term::color::YELLOW)
5555
}
5656

57-
pub fn write_allowed_fail(&mut self) -> io::Result<()> {
58-
self.write_short_result("a", term::color::YELLOW)
59-
}
60-
6157
pub fn write_bench(&mut self) -> io::Result<()> {
6258
self.write_pretty("bench", term::color::CYAN)
6359
}
@@ -207,7 +203,6 @@ impl<T: Write> OutputFormatter for TerseFormatter<T> {
207203
self.write_failed()
208204
}
209205
TestResult::TrIgnored => self.write_ignored(),
210-
TestResult::TrAllowedFail => self.write_allowed_fail(),
211206
TestResult::TrBench(ref bs) => {
212207
if self.is_multithreaded {
213208
self.write_test_name(desc)?;
@@ -244,22 +239,10 @@ impl<T: Write> OutputFormatter for TerseFormatter<T> {
244239
self.write_pretty("FAILED", term::color::RED)?;
245240
}
246241

247-
let s = if state.allowed_fail > 0 {
248-
format!(
249-
". {} passed; {} failed ({} allowed); {} ignored; {} measured; {} filtered out",
250-
state.passed,
251-
state.failed + state.allowed_fail,
252-
state.allowed_fail,
253-
state.ignored,
254-
state.measured,
255-
state.filtered_out
256-
)
257-
} else {
258-
format!(
259-
". {} passed; {} failed; {} ignored; {} measured; {} filtered out",
260-
state.passed, state.failed, state.ignored, state.measured, state.filtered_out
261-
)
262-
};
242+
let s = format!(
243+
". {} passed; {} failed; {} ignored; {} measured; {} filtered out",
244+
state.passed, state.failed, state.ignored, state.measured, state.filtered_out
245+
);
263246

264247
self.write_plain(&s)?;
265248

test/src/test_result.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub enum TestResult {
1919
TrFailed,
2020
TrFailedMsg(String),
2121
TrIgnored,
22-
TrAllowedFail,
2322
TrBench(BenchSamples),
2423
TrTimedFail,
2524
}
@@ -42,8 +41,6 @@ pub fn calc_result<'a>(
4241

4342
if maybe_panic_str.map(|e| e.contains(msg)).unwrap_or(false) {
4443
TestResult::TrOk
45-
} else if desc.allow_fail {
46-
TestResult::TrAllowedFail
4744
} else if let Some(panic_str) = maybe_panic_str {
4845
TestResult::TrFailedMsg(format!(
4946
r#"panic did not contain expected string
@@ -64,7 +61,6 @@ pub fn calc_result<'a>(
6461
(&ShouldPanic::Yes, Ok(())) | (&ShouldPanic::YesWithMessage(_), Ok(())) => {
6562
TestResult::TrFailedMsg("test did not panic as expected".to_string())
6663
}
67-
_ if desc.allow_fail => TestResult::TrAllowedFail,
6864
_ => TestResult::TrFailed,
6965
};
7066

@@ -90,11 +86,10 @@ pub fn get_result_from_exit_code(
9086
time_opts: &Option<time::TestTimeOptions>,
9187
exec_time: &Option<time::TestExecTime>,
9288
) -> TestResult {
93-
let result = match (desc.allow_fail, code) {
94-
(_, TR_OK) => TestResult::TrOk,
95-
(true, TR_FAILED) => TestResult::TrAllowedFail,
96-
(false, TR_FAILED) => TestResult::TrFailed,
97-
(_, _) => TestResult::TrFailedMsg(format!("got unexpected return code {}", code)),
89+
let result = match code {
90+
TR_OK => TestResult::TrOk,
91+
TR_FAILED => TestResult::TrFailed,
92+
_ => TestResult::TrFailedMsg(format!("got unexpected return code {}", code)),
9893
};
9994

10095
// If test is already failed (or allowed to fail), do not change the result.

0 commit comments

Comments
 (0)