Skip to content

Commit 8bfcae7

Browse files
committed
Auto merge of rust-lang#128109 - matthiaskrgr:rollup-gc7kopi, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#125886 (Migrate run make issue 15460) - rust-lang#126898 (Migrate `run-make/link-framework` to `rmake.rs`) - rust-lang#126994 (Support lists and stylings in more places for `rustc --explain`) - rust-lang#127990 (Migrate `lto-linkage-used-attr`, `no-duplicate-libs` and `pgo-gen-no-imp-symbols` `run-make` tests to rmake) - rust-lang#128060 (Fix inclusion of `wasm-component-ld` in dist artifacts) - rust-lang#128082 (Note closure captures when reporting cast to fn ptr failed) - rust-lang#128098 (make it possible to disable download-rustc if it's incompatible) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 84c257e + 041b8c4 commit 8bfcae7

File tree

24 files changed

+251
-112
lines changed

24 files changed

+251
-112
lines changed

compiler/rustc_error_codes/src/error_codes/E0373.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ fn spawn<F: Future + Send + 'static>(future: F) {
7070

7171
Similarly to closures, `async` blocks are not executed immediately and may
7272
capture closed-over data by reference. For more information, see
73-
https://rust-lang.github.io/async-book/03_async_await/01_chapter.html.
73+
<https://rust-lang.github.io/async-book/03_async_await/01_chapter.html>.

compiler/rustc_error_codes/src/error_codes/E0378.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ where
2020

2121
The `DispatchFromDyn` trait currently can only be implemented for
2222
builtin pointer types and structs that are newtype wrappers around them
23-
— that is, the struct must have only one field (except for`PhantomData`),
23+
— that is, the struct must have only one field (except for `PhantomData`),
2424
and that field must itself implement `DispatchFromDyn`.
2525

2626
```

compiler/rustc_errors/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#![feature(box_patterns)]
1616
#![feature(error_reporter)]
1717
#![feature(extract_if)]
18+
#![feature(if_let_guard)]
1819
#![feature(let_chains)]
1920
#![feature(negative_impls)]
2021
#![feature(never_type)]

compiler/rustc_errors/src/markdown/parse.rs

+34-28
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ const CBK: &[u8] = b"```";
1010
const CIL: &[u8] = b"`";
1111
const CMT_E: &[u8] = b"-->";
1212
const CMT_S: &[u8] = b"<!--";
13-
const EMP: &[u8] = b"_";
13+
const EMP_U: &[u8] = b"_";
14+
const EMP_A: &[u8] = b"*";
1415
const HDG: &[u8] = b"#";
1516
const LNK_CHARS: &str = "$-_.+!*'()/&?=:%";
1617
const LNK_E: &[u8] = b"]";
1718
const LNK_S: &[u8] = b"[";
18-
const STG: &[u8] = b"**";
19+
const STG_U: &[u8] = b"__";
20+
const STG_A: &[u8] = b"**";
1921
const STK: &[u8] = b"~~";
20-
const UL1: &[u8] = b"* ";
21-
const UL2: &[u8] = b"- ";
2222

2323
/// Pattern replacements
2424
const REPLACEMENTS: &[(&str, &str)] = &[
@@ -100,22 +100,29 @@ fn parse_recursive<'a>(buf: &'a [u8], ctx: Context) -> MdStream<'_> {
100100
};
101101

102102
let res: ParseResult<'_> = match (top_blk, prev) {
103-
(_, Newline | Whitespace) if loop_buf.starts_with(CMT_S) => {
103+
_ if loop_buf.starts_with(CMT_S) => {
104104
parse_simple_pat(loop_buf, CMT_S, CMT_E, Po::TrimNoEsc, MdTree::Comment)
105105
}
106106
(true, Newline) if loop_buf.starts_with(CBK) => Some(parse_codeblock(loop_buf)),
107-
(_, Newline | Whitespace) if loop_buf.starts_with(CIL) => parse_codeinline(loop_buf),
107+
_ if loop_buf.starts_with(CIL) => parse_codeinline(loop_buf),
108108
(true, Newline | Whitespace) if loop_buf.starts_with(HDG) => parse_heading(loop_buf),
109109
(true, Newline) if loop_buf.starts_with(BRK) => {
110110
Some((MdTree::HorizontalRule, parse_to_newline(loop_buf).1))
111111
}
112-
(_, Newline | Whitespace) if loop_buf.starts_with(EMP) => {
113-
parse_simple_pat(loop_buf, EMP, EMP, Po::None, MdTree::Emphasis)
112+
(_, Newline) if unordered_list_start(loop_buf) => Some(parse_unordered_li(loop_buf)),
113+
(_, Newline | Whitespace) if loop_buf.starts_with(STG_U) => {
114+
parse_simple_pat(loop_buf, STG_U, STG_U, Po::None, MdTree::Strong)
114115
}
115-
(_, Newline | Whitespace) if loop_buf.starts_with(STG) => {
116-
parse_simple_pat(loop_buf, STG, STG, Po::None, MdTree::Strong)
116+
_ if loop_buf.starts_with(STG_A) => {
117+
parse_simple_pat(loop_buf, STG_A, STG_A, Po::None, MdTree::Strong)
117118
}
118-
(_, Newline | Whitespace) if loop_buf.starts_with(STK) => {
119+
(_, Newline | Whitespace) if loop_buf.starts_with(EMP_U) => {
120+
parse_simple_pat(loop_buf, EMP_U, EMP_U, Po::None, MdTree::Emphasis)
121+
}
122+
_ if loop_buf.starts_with(EMP_A) => {
123+
parse_simple_pat(loop_buf, EMP_A, EMP_A, Po::None, MdTree::Emphasis)
124+
}
125+
_ if loop_buf.starts_with(STK) => {
119126
parse_simple_pat(loop_buf, STK, STK, Po::None, MdTree::Strikethrough)
120127
}
121128
(_, Newline | Whitespace) if loop_buf.starts_with(ANC_S) => {
@@ -130,11 +137,8 @@ fn parse_recursive<'a>(buf: &'a [u8], ctx: Context) -> MdStream<'_> {
130137
_ => None,
131138
}
132139
}
133-
(_, Newline) if (loop_buf.starts_with(UL1) || loop_buf.starts_with(UL2)) => {
134-
Some(parse_unordered_li(loop_buf))
135-
}
136140
(_, Newline) if ord_list_start(loop_buf).is_some() => Some(parse_ordered_li(loop_buf)),
137-
(_, Newline | Whitespace) if loop_buf.starts_with(LNK_S) => {
141+
_ if loop_buf.starts_with(LNK_S) => {
138142
parse_any_link(loop_buf, top_blk && prev == Prev::Newline)
139143
}
140144
(_, Escape | _) => None,
@@ -251,7 +255,6 @@ fn parse_heading(buf: &[u8]) -> ParseResult<'_> {
251255

252256
/// Bulleted list
253257
fn parse_unordered_li(buf: &[u8]) -> Parsed<'_> {
254-
debug_assert!(buf.starts_with(b"* ") || buf.starts_with(b"- "));
255258
let (txt, rest) = get_indented_section(&buf[2..]);
256259
let ctx = Context { top_block: false, prev: Prev::Whitespace };
257260
let stream = parse_recursive(trim_ascii_start(txt), ctx);
@@ -267,25 +270,28 @@ fn parse_ordered_li(buf: &[u8]) -> Parsed<'_> {
267270
(MdTree::OrderedListItem(num, stream), rest)
268271
}
269272

270-
/// Find first line that isn't empty or doesn't start with whitespace, that will
271-
/// be our contents
272273
fn get_indented_section(buf: &[u8]) -> (&[u8], &[u8]) {
273-
let mut end = buf.len();
274-
for (idx, window) in buf.windows(2).enumerate() {
275-
let &[ch, next_ch] = window else { unreachable!("always 2 elements") };
276-
if idx >= buf.len().saturating_sub(2) && next_ch == b'\n' {
277-
// End of stream
278-
end = buf.len().saturating_sub(1);
279-
break;
280-
} else if ch == b'\n' && (!next_ch.is_ascii_whitespace() || next_ch == b'\n') {
281-
end = idx;
282-
break;
274+
let mut lines = buf.split(|&byte| byte == b'\n');
275+
let mut end = lines.next().map_or(0, |line| line.len());
276+
for line in lines {
277+
if let Some(first) = line.first() {
278+
if unordered_list_start(line) || !first.is_ascii_whitespace() {
279+
break;
280+
}
283281
}
282+
end += line.len() + 1;
284283
}
285284

286285
(&buf[..end], &buf[end..])
287286
}
288287

288+
fn unordered_list_start(mut buf: &[u8]) -> bool {
289+
while let [b' ', rest @ ..] = buf {
290+
buf = rest;
291+
}
292+
matches!(buf, [b'*' | b'-', b' ', ..])
293+
}
294+
289295
/// Verify a valid ordered list start (e.g. `1.`) and parse it. Returns the
290296
/// parsed number and offset of character after the dot.
291297
fn ord_list_start(buf: &[u8]) -> Option<(u16, usize)> {

compiler/rustc_errors/src/markdown/tests/parse.rs

+59-6
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ use ParseOpt as PO;
44
#[test]
55
fn test_parse_simple() {
66
let buf = "**abcd** rest";
7-
let (t, r) = parse_simple_pat(buf.as_bytes(), STG, STG, PO::None, MdTree::Strong).unwrap();
7+
let (t, r) = parse_simple_pat(buf.as_bytes(), b"**", b"**", PO::None, MdTree::Strong).unwrap();
88
assert_eq!(t, MdTree::Strong("abcd"));
99
assert_eq!(r, b" rest");
1010

1111
// Escaping should fail
1212
let buf = r"**abcd\** rest";
13-
let res = parse_simple_pat(buf.as_bytes(), STG, STG, PO::None, MdTree::Strong);
13+
let res = parse_simple_pat(buf.as_bytes(), b"**", b"**", PO::None, MdTree::Strong);
1414
assert!(res.is_none());
1515
}
1616

@@ -141,12 +141,12 @@ fn test_indented_section() {
141141
assert_eq!(str::from_utf8(r).unwrap(), "\nnot ind");
142142

143143
let (txt, rest) = get_indented_section(IND2.as_bytes());
144-
assert_eq!(str::from_utf8(txt).unwrap(), "test end of stream\n 1\n 2");
145-
assert_eq!(str::from_utf8(rest).unwrap(), "\n");
144+
assert_eq!(str::from_utf8(txt).unwrap(), "test end of stream\n 1\n 2\n");
145+
assert_eq!(str::from_utf8(rest).unwrap(), "");
146146

147147
let (txt, rest) = get_indented_section(IND3.as_bytes());
148-
assert_eq!(str::from_utf8(txt).unwrap(), "test empty lines\n 1\n 2");
149-
assert_eq!(str::from_utf8(rest).unwrap(), "\n\nnot ind");
148+
assert_eq!(str::from_utf8(txt).unwrap(), "test empty lines\n 1\n 2\n");
149+
assert_eq!(str::from_utf8(rest).unwrap(), "\nnot ind");
150150
}
151151

152152
const HBT: &str = r"# Heading
@@ -310,3 +310,56 @@ fn test_code_at_start() {
310310
let res = entrypoint(CODE_STARTLINE);
311311
assert_eq!(res, expected);
312312
}
313+
314+
#[test]
315+
fn test_code_in_parens() {
316+
let expected =
317+
vec![MdTree::PlainText("("), MdTree::CodeInline("Foo"), MdTree::PlainText(")")].into();
318+
let res = entrypoint("(`Foo`)");
319+
assert_eq!(res, expected);
320+
}
321+
322+
const LIST_WITH_SPACE: &str = "
323+
para
324+
* l1
325+
* l2
326+
";
327+
328+
#[test]
329+
fn test_list_with_space() {
330+
let expected = vec![
331+
MdTree::PlainText("para"),
332+
MdTree::ParagraphBreak,
333+
MdTree::UnorderedListItem(vec![MdTree::PlainText("l1")].into()),
334+
MdTree::LineBreak,
335+
MdTree::UnorderedListItem(vec![MdTree::PlainText("l2")].into()),
336+
]
337+
.into();
338+
let res = entrypoint(LIST_WITH_SPACE);
339+
assert_eq!(res, expected);
340+
}
341+
342+
const SNAKE_CASE: &str = "
343+
foo*bar*
344+
foo**bar**
345+
foo_bar_
346+
foo__bar__
347+
";
348+
349+
#[test]
350+
fn test_snake_case() {
351+
let expected = vec![
352+
MdTree::PlainText("foo"),
353+
MdTree::Emphasis("bar"),
354+
MdTree::PlainText(" "),
355+
MdTree::PlainText("foo"),
356+
MdTree::Strong("bar"),
357+
MdTree::PlainText(" "),
358+
MdTree::PlainText("foo_bar_"),
359+
MdTree::PlainText(" "),
360+
MdTree::PlainText("foo__bar__"),
361+
]
362+
.into();
363+
let res = entrypoint(SNAKE_CASE);
364+
assert_eq!(res, expected);
365+
}

compiler/rustc_hir_typeck/src/cast.rs

+1
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
495495
err.span_label(self.span, "invalid cast");
496496
}
497497

498+
fcx.suggest_no_capture_closure(&mut err, self.cast_ty, self.expr_ty);
498499
self.try_suggest_collection_to_bool(fcx, &mut err);
499500

500501
err.emit();

src/bootstrap/src/core/build_steps/dist.rs

+5
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,11 @@ impl Step for Rustc {
472472
);
473473
}
474474
}
475+
if builder.build_wasm_component_ld() {
476+
let src_dir = builder.sysroot_libdir(compiler, host).parent().unwrap().join("bin");
477+
let ld = exe("wasm-component-ld", compiler.host);
478+
builder.copy_link(&src_dir.join(&ld), &dst_dir.join(&ld));
479+
}
475480

476481
// Man pages
477482
t!(fs::create_dir_all(image.join("share/man/man1")));

src/bootstrap/src/core/config/config.rs

+25-11
Original file line numberDiff line numberDiff line change
@@ -1570,11 +1570,22 @@ impl Config {
15701570
let mut is_user_configured_rust_channel = false;
15711571

15721572
if let Some(rust) = toml.rust {
1573-
config.download_rustc_commit =
1574-
config.download_ci_rustc_commit(rust.download_rustc.clone());
1575-
1576-
if config.download_rustc_commit.is_some() {
1577-
check_incompatible_options_for_ci_rustc(&rust);
1573+
if let Some(commit) = config.download_ci_rustc_commit(rust.download_rustc.clone()) {
1574+
// Primarily used by CI runners to avoid handling download-rustc incompatible
1575+
// options one by one on shell scripts.
1576+
let disable_ci_rustc_if_incompatible =
1577+
env::var_os("DISABLE_CI_RUSTC_IF_INCOMPATIBLE")
1578+
.is_some_and(|s| s == "1" || s == "true");
1579+
1580+
if let Err(e) = check_incompatible_options_for_ci_rustc(&rust) {
1581+
if disable_ci_rustc_if_incompatible {
1582+
config.download_rustc_commit = None;
1583+
} else {
1584+
panic!("{}", e);
1585+
}
1586+
} else {
1587+
config.download_rustc_commit = Some(commit);
1588+
}
15781589
}
15791590

15801591
let Rust {
@@ -2612,14 +2623,15 @@ impl Config {
26122623

26132624
/// Checks the CI rustc incompatible options by destructuring the `Rust` instance
26142625
/// and makes sure that no rust options from config.toml are missed.
2615-
fn check_incompatible_options_for_ci_rustc(rust: &Rust) {
2626+
fn check_incompatible_options_for_ci_rustc(rust: &Rust) -> Result<(), String> {
26162627
macro_rules! err {
26172628
($name:expr) => {
2618-
assert!(
2619-
$name.is_none(),
2620-
"ERROR: Setting `rust.{}` is incompatible with `rust.download-rustc`.",
2621-
stringify!($name).replace("_", "-")
2622-
);
2629+
if $name.is_some() {
2630+
return Err(format!(
2631+
"ERROR: Setting `rust.{}` is incompatible with `rust.download-rustc`.",
2632+
stringify!($name).replace("_", "-")
2633+
));
2634+
}
26232635
};
26242636
}
26252637

@@ -2715,6 +2727,8 @@ fn check_incompatible_options_for_ci_rustc(rust: &Rust) {
27152727
warn!(channel);
27162728
warn!(description);
27172729
warn!(incremental);
2730+
2731+
Ok(())
27182732
}
27192733

27202734
fn set<T>(field: &mut T, val: Option<T>) {

src/tools/compiletest/src/runtest.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3378,6 +3378,7 @@ impl<'test> TestCx<'test> {
33783378
cmd.env("IS_MSVC", "1")
33793379
.env("IS_WINDOWS", "1")
33803380
.env("MSVC_LIB", format!("'{}' -nologo", lib.display()))
3381+
.env("MSVC_LIB_PATH", format!("{}", lib.display()))
33813382
.env("CC", format!("'{}' {}", self.config.cc, cflags))
33823383
.env("CXX", format!("'{}' {}", &self.config.cxx, cxxflags));
33833384
} else {
@@ -3748,6 +3749,7 @@ impl<'test> TestCx<'test> {
37483749
cmd.env("IS_MSVC", "1")
37493750
.env("IS_WINDOWS", "1")
37503751
.env("MSVC_LIB", format!("'{}' -nologo", lib.display()))
3752+
.env("MSVC_LIB_PATH", format!("{}", lib.display()))
37513753
// Note: we diverge from legacy run_make and don't lump `CC` the compiler and
37523754
// default flags together.
37533755
.env("CC_DEFAULT_FLAGS", &cflags)

src/tools/tidy/src/allowed_run_make_makefiles.txt

-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ run-make/foreign-rust-exceptions/Makefile
2727
run-make/incr-add-rust-src-component/Makefile
2828
run-make/incr-foreign-head-span/Makefile
2929
run-make/interdependent-c-libraries/Makefile
30-
run-make/issue-15460/Makefile
3130
run-make/issue-35164/Makefile
3231
run-make/issue-36710/Makefile
3332
run-make/issue-47551/Makefile
@@ -40,21 +39,17 @@ run-make/libtest-json/Makefile
4039
run-make/libtest-junit/Makefile
4140
run-make/libtest-thread-limit/Makefile
4241
run-make/link-cfg/Makefile
43-
run-make/link-framework/Makefile
4442
run-make/long-linker-command-lines-cmd-exe/Makefile
4543
run-make/long-linker-command-lines/Makefile
46-
run-make/lto-linkage-used-attr/Makefile
4744
run-make/macos-deployment-target/Makefile
4845
run-make/min-global-align/Makefile
4946
run-make/native-link-modifier-bundle/Makefile
5047
run-make/native-link-modifier-whole-archive/Makefile
5148
run-make/no-alloc-shim/Makefile
5249
run-make/no-builtins-attribute/Makefile
53-
run-make/no-duplicate-libs/Makefile
5450
run-make/panic-abort-eh_frame/Makefile
5551
run-make/pdb-buildinfo-cl-cmd/Makefile
5652
run-make/pgo-gen-lto/Makefile
57-
run-make/pgo-gen-no-imp-symbols/Makefile
5853
run-make/pgo-indirect-call-promotion/Makefile
5954
run-make/pointer-auth-link-with-c/Makefile
6055
run-make/print-calling-conventions/Makefile

tests/run-make/issue-15460/Makefile

-7
This file was deleted.

tests/run-make/link-framework/Makefile

-23
This file was deleted.

0 commit comments

Comments
 (0)