Skip to content

Commit 6317721

Browse files
committed
Auto merge of #69258 - JohnTitor:rollup-n2hljai, r=JohnTitor
Rollup of 8 pull requests Successful merges: - #67272 (recursion_limit parsing handles overflows) - #68597 (Simplify `Skip::nth` and `Skip::last` implementations) - #68767 (macOS: avoid calling pthread_self() twice) - #69175 (Do not ICE when encountering `yield` inside `async` block) - #69223 (Ignore GDB versions with broken str printing.) - #69244 (configure: set LLVM flags with a value) - #69249 (Stabilize {f32, f64}::{LOG2_10, LOG10_2}) - #69252 (Clean out unused directories for extra disk space) Failed merges: r? @ghost
2 parents 0176a9e + c1a05fb commit 6317721

File tree

22 files changed

+167
-31
lines changed

22 files changed

+167
-31
lines changed

src/bootstrap/configure.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ def v(*args):
6262
o("use-libcxx", "llvm.use-libcxx", "build LLVM with libc++")
6363
o("control-flow-guard", "rust.control-flow-guard", "Enable Control Flow Guard")
6464

65-
o("cflags", "llvm.cflags", "build LLVM with these extra compiler flags")
66-
o("cxxflags", "llvm.cxxflags", "build LLVM with these extra compiler flags")
67-
o("ldflags", "llvm.ldflags", "build LLVM with these extra linker flags")
65+
v("llvm-cflags", "llvm.cflags", "build LLVM with these extra compiler flags")
66+
v("llvm-cxxflags", "llvm.cxxflags", "build LLVM with these extra compiler flags")
67+
v("llvm-ldflags", "llvm.ldflags", "build LLVM with these extra linker flags")
6868

6969
o("llvm-libunwind", "rust.llvm-libunwind", "use LLVM libunwind")
7070

src/ci/azure-pipelines/steps/run.yml

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ steps:
3131
- bash: src/ci/scripts/setup-environment.sh
3232
displayName: Setup environment
3333

34+
- bash: src/ci/scripts/clean-disk.sh
35+
displayName: Clean disk
36+
3437
- bash: src/ci/scripts/should-skip-this.sh
3538
displayName: Decide whether to run this job
3639

src/ci/scripts/clean-disk.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
# This script deletes some of the Azure-provided artifacts. We don't use these,
3+
# and disk space is at a premium on our builders.
4+
5+
set -euo pipefail
6+
IFS=$'\n\t'
7+
8+
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
9+
10+
# All the Linux builds happen inside Docker.
11+
if isLinux; then
12+
# 6.7GB
13+
sudo rm -rf /opt/ghc
14+
# 16GB
15+
sudo rm -rf /usr/share/dotnet
16+
fi

src/libcore/iter/adapters/mod.rs

+7-13
Original file line numberDiff line numberDiff line change
@@ -1890,17 +1890,15 @@ where
18901890
#[inline]
18911891
fn nth(&mut self, n: usize) -> Option<I::Item> {
18921892
// Can't just add n + self.n due to overflow.
1893-
if self.n == 0 {
1894-
self.iter.nth(n)
1895-
} else {
1893+
if self.n > 0 {
18961894
let to_skip = self.n;
18971895
self.n = 0;
18981896
// nth(n) skips n+1
18991897
if self.iter.nth(to_skip - 1).is_none() {
19001898
return None;
19011899
}
1902-
self.iter.nth(n)
19031900
}
1901+
self.iter.nth(n)
19041902
}
19051903

19061904
#[inline]
@@ -1916,17 +1914,13 @@ where
19161914

19171915
#[inline]
19181916
fn last(mut self) -> Option<I::Item> {
1919-
if self.n == 0 {
1920-
self.iter.last()
1921-
} else {
1922-
let next = self.next();
1923-
if next.is_some() {
1924-
// recurse. n should be 0.
1925-
self.last().or(next)
1926-
} else {
1927-
None
1917+
if self.n > 0 {
1918+
// nth(n) skips n+1
1919+
if self.iter.nth(self.n - 1).is_none() {
1920+
return None;
19281921
}
19291922
}
1923+
self.iter.last()
19301924
}
19311925

19321926
#[inline]

src/libcore/num/f32.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@ pub mod consts {
130130
pub const LOG2_E: f32 = 1.44269504088896340735992468100189214_f32;
131131

132132
/// log<sub>2</sub>(10)
133-
#[unstable(feature = "extra_log_consts", issue = "50540")]
133+
#[stable(feature = "extra_log_consts", since = "1.43.0")]
134134
pub const LOG2_10: f32 = 3.32192809488736234787031942948939018_f32;
135135

136136
/// log<sub>10</sub>(e)
137137
#[stable(feature = "rust1", since = "1.0.0")]
138138
pub const LOG10_E: f32 = 0.434294481903251827651128918916605082_f32;
139139

140140
/// log<sub>10</sub>(2)
141-
#[unstable(feature = "extra_log_consts", issue = "50540")]
141+
#[stable(feature = "extra_log_consts", since = "1.43.0")]
142142
pub const LOG10_2: f32 = 0.301029995663981195213738894724493027_f32;
143143

144144
/// ln(2)

src/libcore/num/f64.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ pub mod consts {
126126
pub const E: f64 = 2.71828182845904523536028747135266250_f64;
127127

128128
/// log<sub>2</sub>(10)
129-
#[unstable(feature = "extra_log_consts", issue = "50540")]
129+
#[stable(feature = "extra_log_consts", since = "1.43.0")]
130130
pub const LOG2_10: f64 = 3.32192809488736234787031942948939018_f64;
131131

132132
/// log<sub>2</sub>(e)
133133
#[stable(feature = "rust1", since = "1.0.0")]
134134
pub const LOG2_E: f64 = 1.44269504088896340735992468100189214_f64;
135135

136136
/// log<sub>10</sub>(2)
137-
#[unstable(feature = "extra_log_consts", issue = "50540")]
137+
#[stable(feature = "extra_log_consts", since = "1.43.0")]
138138
pub const LOG10_2: f64 = 0.301029995663981195213738894724493027_f64;
139139

140140
/// log<sub>10</sub>(e)

src/librustc/hir/map/hir_id_validator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_hir::intravisit;
77
use rustc_hir::itemlikevisit::ItemLikeVisitor;
88
use rustc_hir::{HirId, ItemLocalId};
99

10-
pub fn check_crate(hir_map: &Map<'_>) {
10+
pub fn check_crate(hir_map: &Map<'_>, sess: &rustc_session::Session) {
1111
hir_map.dep_graph.assert_ignored();
1212

1313
let errors = Lock::new(Vec::new());
@@ -24,7 +24,7 @@ pub fn check_crate(hir_map: &Map<'_>) {
2424

2525
if !errors.is_empty() {
2626
let message = errors.iter().fold(String::new(), |s1, s2| s1 + "\n" + s2);
27-
bug!("{}", message);
27+
sess.delay_span_bug(rustc_span::DUMMY_SP, &message);
2828
}
2929
}
3030

src/librustc/hir/map/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,7 @@ pub fn map_crate<'hir>(
12351235
let map = Map { krate, dep_graph, crate_hash, map, hir_to_node_id, definitions };
12361236

12371237
sess.time("validate_HIR_map", || {
1238-
hir_id_validator::check_crate(&map);
1238+
hir_id_validator::check_crate(&map, sess);
12391239
});
12401240

12411241
map

src/librustc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#![feature(associated_type_bounds)]
4747
#![feature(rustc_attrs)]
4848
#![feature(hash_raw_entry)]
49+
#![feature(int_error_matching)]
4950
#![recursion_limit = "512"]
5051

5152
#[macro_use]

src/librustc/middle/recursion_limit.rs

+40-6
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,60 @@
66
// just peeks and looks for that attribute.
77

88
use crate::session::Session;
9+
use core::num::IntErrorKind;
10+
use rustc::bug;
911
use rustc_span::symbol::{sym, Symbol};
1012
use syntax::ast;
1113

1214
use rustc_data_structures::sync::Once;
1315

1416
pub fn update_limits(sess: &Session, krate: &ast::Crate) {
15-
update_limit(krate, &sess.recursion_limit, sym::recursion_limit, 128);
16-
update_limit(krate, &sess.type_length_limit, sym::type_length_limit, 1048576);
17+
update_limit(sess, krate, &sess.recursion_limit, sym::recursion_limit, 128);
18+
update_limit(sess, krate, &sess.type_length_limit, sym::type_length_limit, 1048576);
1719
}
1820

19-
fn update_limit(krate: &ast::Crate, limit: &Once<usize>, name: Symbol, default: usize) {
21+
fn update_limit(
22+
sess: &Session,
23+
krate: &ast::Crate,
24+
limit: &Once<usize>,
25+
name: Symbol,
26+
default: usize,
27+
) {
2028
for attr in &krate.attrs {
2129
if !attr.check_name(name) {
2230
continue;
2331
}
2432

2533
if let Some(s) = attr.value_str() {
26-
if let Some(n) = s.as_str().parse().ok() {
27-
limit.set(n);
28-
return;
34+
match s.as_str().parse() {
35+
Ok(n) => {
36+
limit.set(n);
37+
return;
38+
}
39+
Err(e) => {
40+
let mut err = sess.struct_span_err(
41+
attr.span,
42+
"`recursion_limit` must be a non-negative integer",
43+
);
44+
45+
let value_span = attr
46+
.meta()
47+
.and_then(|meta| meta.name_value_literal().cloned())
48+
.map(|lit| lit.span)
49+
.unwrap_or(attr.span);
50+
51+
let error_str = match e.kind() {
52+
IntErrorKind::Overflow => "`recursion_limit` is too large",
53+
IntErrorKind::Empty => "`recursion_limit` must be a non-negative integer",
54+
IntErrorKind::InvalidDigit => "not a valid integer",
55+
IntErrorKind::Underflow => bug!("`recursion_limit` should never underflow"),
56+
IntErrorKind::Zero => bug!("zero is a valid `recursion_limit`"),
57+
kind => bug!("unimplemented IntErrorKind variant: {:?}", kind),
58+
};
59+
60+
err.span_label(value_span, error_str);
61+
err.emit();
62+
}
2963
}
3064
}
3165
}

src/libstd/sys/unix/thread.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,9 @@ pub mod guard {
255255

256256
#[cfg(target_os = "macos")]
257257
unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
258-
let stackaddr = libc::pthread_get_stackaddr_np(libc::pthread_self()) as usize
259-
- libc::pthread_get_stacksize_np(libc::pthread_self());
258+
let th = libc::pthread_self();
259+
let stackaddr =
260+
libc::pthread_get_stackaddr_np(th) as usize - libc::pthread_get_stacksize_np(th);
260261
Some(stackaddr as *mut libc::c_void)
261262
}
262263

src/test/debuginfo/empty-string.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// ignore-android: FIXME(#10381)
33
// compile-flags:-g
44
// min-gdb-version: 7.7
5+
// ignore-gdb-version: 7.11.90 - 8.0.9
56
// min-lldb-version: 310
67

78
// === GDB TESTS ===================================================================================
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#![feature(generators)]
2+
// edition:2018
3+
// Regression test for #67158.
4+
fn main() {
5+
async { yield print!(":C") }; //~ ERROR `async` generators are not yet supported
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0727]: `async` generators are not yet supported
2+
--> $DIR/async-generator-issue-67158.rs:5:13
3+
|
4+
LL | async { yield print!(":C") };
5+
| ^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0727`.

src/test/ui/recursion_limit/empty.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Test the parse error for an empty recursion_limit
2+
3+
#![recursion_limit = ""] //~ ERROR `recursion_limit` must be a non-negative integer
4+
//~| `recursion_limit` must be a non-negative integer
5+
6+
fn main() {}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: `recursion_limit` must be a non-negative integer
2+
--> $DIR/empty.rs:3:1
3+
|
4+
LL | #![recursion_limit = ""]
5+
| ^^^^^^^^^^^^^^^^^^^^^--^
6+
| |
7+
| `recursion_limit` must be a non-negative integer
8+
9+
error: aborting due to previous error
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Test the parse error for an invalid digit in recursion_limit
2+
3+
#![recursion_limit = "-100"] //~ ERROR `recursion_limit` must be a non-negative integer
4+
//~| not a valid integer
5+
6+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: `recursion_limit` must be a non-negative integer
2+
--> $DIR/invalid_digit.rs:3:1
3+
|
4+
LL | #![recursion_limit = "-100"]
5+
| ^^^^^^^^^^^^^^^^^^^^^------^
6+
| |
7+
| not a valid integer
8+
9+
error: aborting due to previous error
10+
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Test the parse error for an overflowing recursion_limit
2+
3+
#![recursion_limit = "999999999999999999999999"]
4+
//~^ ERROR `recursion_limit` must be a non-negative integer
5+
//~| `recursion_limit` is too large
6+
7+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: `recursion_limit` must be a non-negative integer
2+
--> $DIR/overflow.rs:3:1
3+
|
4+
LL | #![recursion_limit = "999999999999999999999999"]
5+
| ^^^^^^^^^^^^^^^^^^^^^--------------------------^
6+
| |
7+
| `recursion_limit` is too large
8+
9+
error: aborting due to previous error
10+

src/test/ui/recursion_limit/zero.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Test that a `recursion_limit` of 0 is valid
2+
3+
#![recursion_limit = "0"]
4+
5+
macro_rules! test {
6+
() => {};
7+
($tt:tt) => { test!(); };
8+
}
9+
10+
test!(test); //~ ERROR 10:1: 10:13: recursion limit reached while expanding `test!`
11+
12+
fn main() {}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: recursion limit reached while expanding `test!`
2+
--> $DIR/zero.rs:10:1
3+
|
4+
LL | test!(test);
5+
| ^^^^^^^^^^^^
6+
|
7+
= help: consider adding a `#![recursion_limit="0"]` attribute to your crate (`zero`)
8+
9+
error: aborting due to previous error
10+

0 commit comments

Comments
 (0)