Skip to content

Commit a67c6f5

Browse files
committed
Auto merge of #146916 - Zalathar:rollup-4o8s63n, r=Zalathar
Rollup of 13 pull requests Successful merges: - #146632 (Fix uses of "adaptor") - #146731 (test: Use SVG for terminal url test) - #146775 (fixes for numerous clippy warnings) - #146784 ([win] Use find-msvc-tools instead of cc to find the linker and rc on Windows) - #146799 (Fix a dangling reference in `rustc_thread_pool`) - #146802 (mbe: Simplifications and refactoring) - #146806 (add private module override re-export test) - #146827 (Linker-plugin-based LTO: update list of good combinations (inc. beta + nightly)) - #146875 (tests/run-make/crate-loading: Rename source files for clarity) - #146896 (rustc-dev-guide subtree update) - #146898 (Update books) - #146899 (Fix a crash/mislex when more than one frontmatter closing possibility is considered) - #146907 (add regression test for issue 146537) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f6092f2 + eaf9939 commit a67c6f5

File tree

63 files changed

+675
-259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+675
-259
lines changed

Cargo.lock

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ dependencies = [
128128

129129
[[package]]
130130
name = "anstyle-svg"
131-
version = "0.1.10"
131+
version = "0.1.11"
132132
source = "registry+https://github.com/rust-lang/crates.io-index"
133-
checksum = "dc03a770ef506fe1396c0e476120ac0e6523cf14b74218dd5f18cd6833326fa9"
133+
checksum = "26b9ec8c976eada1b0f9747a3d7cc4eae3bef10613e443746e7487f26c872fde"
134134
dependencies = [
135135
"anstyle",
136136
"anstyle-lossy",
@@ -1332,6 +1332,12 @@ dependencies = [
13321332
"windows-sys 0.59.0",
13331333
]
13341334

1335+
[[package]]
1336+
name = "find-msvc-tools"
1337+
version = "0.1.2"
1338+
source = "registry+https://github.com/rust-lang/crates.io-index"
1339+
checksum = "1ced73b1dacfc750a6db6c0a0c3a3853c8b41997e2e2c563dc90804ae6867959"
1340+
13351341
[[package]]
13361342
name = "flate2"
13371343
version = "1.1.2"
@@ -3556,7 +3562,7 @@ dependencies = [
35563562
"ar_archive_writer",
35573563
"bitflags",
35583564
"bstr",
3559-
"cc",
3565+
"find-msvc-tools",
35603566
"itertools",
35613567
"libc",
35623568
"object 0.37.3",
@@ -4760,7 +4766,7 @@ dependencies = [
47604766
name = "rustc_windows_rc"
47614767
version = "0.0.0"
47624768
dependencies = [
4763-
"cc",
4769+
"find-msvc-tools",
47644770
]
47654771

47664772
[[package]]

compiler/rustc_codegen_ssa/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ edition = "2024"
88
ar_archive_writer = "0.5"
99
bitflags = "2.4.1"
1010
bstr = "1.11.3"
11-
# `cc` updates often break things, so we pin it here. Cargo enforces "max 1 semver-compat version
12-
# per crate", so if you change this, you need to also change it in `rustc_llvm` and `rustc_windows_rc`.
13-
cc = "=1.2.16"
11+
find-msvc-tools = "0.1.2"
1412
itertools = "0.12"
1513
pathdiff = "0.2.0"
1614
regex = "1.4"

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::path::{Path, PathBuf};
99
use std::process::{Output, Stdio};
1010
use std::{env, fmt, fs, io, mem, str};
1111

12-
use cc::windows_registry;
12+
use find_msvc_tools;
1313
use itertools::Itertools;
1414
use regex::Regex;
1515
use rustc_arena::TypedArena;
@@ -877,9 +877,9 @@ fn link_natively(
877877
// All Microsoft `link.exe` linking ror codes are
878878
// four digit numbers in the range 1000 to 9999 inclusive
879879
if is_msvc_link_exe && (code < 1000 || code > 9999) {
880-
let is_vs_installed = windows_registry::find_vs_version().is_ok();
880+
let is_vs_installed = find_msvc_tools::find_vs_version().is_ok();
881881
let has_linker =
882-
windows_registry::find_tool(&sess.target.arch, "link.exe").is_some();
882+
find_msvc_tools::find_tool(&sess.target.arch, "link.exe").is_some();
883883

884884
sess.dcx().emit_note(errors::LinkExeUnexpectedError);
885885

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::io::prelude::*;
44
use std::path::{Path, PathBuf};
55
use std::{env, io, iter, mem, str};
66

7-
use cc::windows_registry;
7+
use find_msvc_tools;
88
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
99
use rustc_metadata::{
1010
find_native_static_library, try_find_native_dynamic_library, try_find_native_static_library,
@@ -53,7 +53,7 @@ pub(crate) fn get_linker<'a>(
5353
self_contained: bool,
5454
target_cpu: &'a str,
5555
) -> Box<dyn Linker + 'a> {
56-
let msvc_tool = windows_registry::find_tool(&sess.target.arch, "link.exe");
56+
let msvc_tool = find_msvc_tools::find_tool(&sess.target.arch, "link.exe");
5757

5858
// If our linker looks like a batch script on Windows then to execute this
5959
// we'll need to spawn `cmd` explicitly. This is primarily done to handle
@@ -117,7 +117,6 @@ pub(crate) fn get_linker<'a>(
117117
if sess.target.is_like_msvc
118118
&& let Some(ref tool) = msvc_tool
119119
{
120-
cmd.args(tool.args());
121120
for (k, v) in tool.env() {
122121
if k == "PATH" {
123122
new_path.extend(env::split_paths(v));

compiler/rustc_expand/src/mbe/metavar_expr.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_ast_pretty::pprust;
55
use rustc_errors::{Applicability, PResult};
66
use rustc_macros::{Decodable, Encodable};
77
use rustc_session::parse::ParseSess;
8-
use rustc_span::{Ident, Span, Symbol};
8+
use rustc_span::{Ident, Span, Symbol, sym};
99

1010
use crate::errors;
1111

@@ -69,15 +69,15 @@ impl MetaVarExpr {
6969
}
7070

7171
let mut iter = args.iter();
72-
let rslt = match ident.as_str() {
73-
"concat" => parse_concat(&mut iter, psess, outer_span, ident.span)?,
74-
"count" => parse_count(&mut iter, psess, ident.span)?,
75-
"ignore" => {
72+
let rslt = match ident.name {
73+
sym::concat => parse_concat(&mut iter, psess, outer_span, ident.span)?,
74+
sym::count => parse_count(&mut iter, psess, ident.span)?,
75+
sym::ignore => {
7676
eat_dollar(&mut iter, psess, ident.span)?;
7777
MetaVarExpr::Ignore(parse_ident(&mut iter, psess, ident.span)?)
7878
}
79-
"index" => MetaVarExpr::Index(parse_depth(&mut iter, psess, ident.span)?),
80-
"len" => MetaVarExpr::Len(parse_depth(&mut iter, psess, ident.span)?),
79+
sym::index => MetaVarExpr::Index(parse_depth(&mut iter, psess, ident.span)?),
80+
sym::len => MetaVarExpr::Len(parse_depth(&mut iter, psess, ident.span)?),
8181
_ => {
8282
let err = errors::MveUnrecognizedExpr {
8383
span: ident.span,
@@ -119,14 +119,13 @@ fn check_trailing_tokens<'psess>(
119119
}
120120

121121
// `None` for max indicates the arg count must be exact, `Some` indicates a range is accepted.
122-
let (min_or_exact_args, max_args) = match ident.as_str() {
123-
"concat" => panic!("concat takes unlimited tokens but didn't eat them all"),
124-
"ignore" => (1, None),
122+
let (min_or_exact_args, max_args) = match ident.name {
123+
sym::concat => panic!("concat takes unlimited tokens but didn't eat them all"),
124+
sym::ignore => (1, None),
125125
// 1 or 2 args
126-
"count" => (1, Some(2)),
126+
sym::count => (1, Some(2)),
127127
// 0 or 1 arg
128-
"index" => (0, Some(1)),
129-
"len" => (0, Some(1)),
128+
sym::index | sym::len => (0, Some(1)),
130129
other => unreachable!("unknown MVEs should be rejected earlier (got `{other}`)"),
131130
};
132131

compiler/rustc_expand/src/mbe/transcribe.rs

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,19 @@ fn transcribe_metavar<'tx>(
375375
return Ok(());
376376
};
377377

378+
let MatchedSingle(pnr) = cur_matched else {
379+
// We were unable to descend far enough. This is an error.
380+
return Err(dcx.create_err(MacroVarStillRepeating { span: sp, ident }));
381+
};
382+
383+
transcribe_pnr(tscx, sp, pnr)
384+
}
385+
386+
fn transcribe_pnr<'tx>(
387+
tscx: &mut TranscrCtx<'tx, '_>,
388+
mut sp: Span,
389+
pnr: &ParseNtResult,
390+
) -> PResult<'tx, ()> {
378391
// We wrap the tokens in invisible delimiters, unless they are already wrapped
379392
// in invisible delimiters with the same `MetaVarKind`. Because some proc
380393
// macros can't handle multiple layers of invisible delimiters of the same
@@ -404,33 +417,33 @@ fn transcribe_metavar<'tx>(
404417
)
405418
};
406419

407-
let tt = match cur_matched {
408-
MatchedSingle(ParseNtResult::Tt(tt)) => {
420+
let tt = match pnr {
421+
ParseNtResult::Tt(tt) => {
409422
// `tt`s are emitted into the output stream directly as "raw tokens",
410423
// without wrapping them into groups. Other variables are emitted into
411424
// the output stream as groups with `Delimiter::Invisible` to maintain
412425
// parsing priorities.
413426
maybe_use_metavar_location(tscx.psess, &tscx.stack, sp, tt, &mut tscx.marker)
414427
}
415-
MatchedSingle(ParseNtResult::Ident(ident, is_raw)) => {
428+
ParseNtResult::Ident(ident, is_raw) => {
416429
tscx.marker.mark_span(&mut sp);
417430
with_metavar_spans(|mspans| mspans.insert(ident.span, sp));
418431
let kind = token::NtIdent(*ident, *is_raw);
419432
TokenTree::token_alone(kind, sp)
420433
}
421-
MatchedSingle(ParseNtResult::Lifetime(ident, is_raw)) => {
434+
ParseNtResult::Lifetime(ident, is_raw) => {
422435
tscx.marker.mark_span(&mut sp);
423436
with_metavar_spans(|mspans| mspans.insert(ident.span, sp));
424437
let kind = token::NtLifetime(*ident, *is_raw);
425438
TokenTree::token_alone(kind, sp)
426439
}
427-
MatchedSingle(ParseNtResult::Item(item)) => {
440+
ParseNtResult::Item(item) => {
428441
mk_delimited(item.span, MetaVarKind::Item, TokenStream::from_ast(item))
429442
}
430-
MatchedSingle(ParseNtResult::Block(block)) => {
443+
ParseNtResult::Block(block) => {
431444
mk_delimited(block.span, MetaVarKind::Block, TokenStream::from_ast(block))
432445
}
433-
MatchedSingle(ParseNtResult::Stmt(stmt)) => {
446+
ParseNtResult::Stmt(stmt) => {
434447
let stream = if let StmtKind::Empty = stmt.kind {
435448
// FIXME: Properly collect tokens for empty statements.
436449
TokenStream::token_alone(token::Semi, stmt.span)
@@ -439,10 +452,10 @@ fn transcribe_metavar<'tx>(
439452
};
440453
mk_delimited(stmt.span, MetaVarKind::Stmt, stream)
441454
}
442-
MatchedSingle(ParseNtResult::Pat(pat, pat_kind)) => {
455+
ParseNtResult::Pat(pat, pat_kind) => {
443456
mk_delimited(pat.span, MetaVarKind::Pat(*pat_kind), TokenStream::from_ast(pat))
444457
}
445-
MatchedSingle(ParseNtResult::Expr(expr, kind)) => {
458+
ParseNtResult::Expr(expr, kind) => {
446459
let (can_begin_literal_maybe_minus, can_begin_string_literal) = match &expr.kind {
447460
ExprKind::Lit(_) => (true, true),
448461
ExprKind::Unary(UnOp::Neg, e) if matches!(&e.kind, ExprKind::Lit(_)) => {
@@ -460,31 +473,27 @@ fn transcribe_metavar<'tx>(
460473
TokenStream::from_ast(expr),
461474
)
462475
}
463-
MatchedSingle(ParseNtResult::Literal(lit)) => {
476+
ParseNtResult::Literal(lit) => {
464477
mk_delimited(lit.span, MetaVarKind::Literal, TokenStream::from_ast(lit))
465478
}
466-
MatchedSingle(ParseNtResult::Ty(ty)) => {
479+
ParseNtResult::Ty(ty) => {
467480
let is_path = matches!(&ty.kind, TyKind::Path(None, _path));
468481
mk_delimited(ty.span, MetaVarKind::Ty { is_path }, TokenStream::from_ast(ty))
469482
}
470-
MatchedSingle(ParseNtResult::Meta(attr_item)) => {
483+
ParseNtResult::Meta(attr_item) => {
471484
let has_meta_form = attr_item.meta_kind().is_some();
472485
mk_delimited(
473486
attr_item.span(),
474487
MetaVarKind::Meta { has_meta_form },
475488
TokenStream::from_ast(attr_item),
476489
)
477490
}
478-
MatchedSingle(ParseNtResult::Path(path)) => {
491+
ParseNtResult::Path(path) => {
479492
mk_delimited(path.span, MetaVarKind::Path, TokenStream::from_ast(path))
480493
}
481-
MatchedSingle(ParseNtResult::Vis(vis)) => {
494+
ParseNtResult::Vis(vis) => {
482495
mk_delimited(vis.span, MetaVarKind::Vis, TokenStream::from_ast(vis))
483496
}
484-
MatchedSeq(..) => {
485-
// We were unable to descend far enough. This is an error.
486-
return Err(dcx.create_err(MacroVarStillRepeating { span: sp, ident }));
487-
}
488497
};
489498

490499
tscx.result.push(tt);

compiler/rustc_hir_typeck/src/pat.rs

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ You can read more about trait objects in the Trait Objects section of the Refere
4747
https://doc.rust-lang.org/reference/types.html#trait-objects";
4848

4949
fn is_number(text: &str) -> bool {
50-
text.chars().all(|c: char| c.is_digit(10))
50+
text.chars().all(|c: char| c.is_ascii_digit())
5151
}
5252

5353
/// Information about the expected type at the top level of type checking a pattern.
@@ -262,8 +262,9 @@ enum InheritedRefMatchRule {
262262
/// pattern matches a given type:
263263
/// - If the underlying type is not a reference, a reference pattern may eat the inherited reference;
264264
/// - If the underlying type is a reference, a reference pattern matches if it can eat either one
265-
/// of the underlying and inherited references. E.g. a `&mut` pattern is allowed if either the
266-
/// underlying type is `&mut` or the inherited reference is `&mut`.
265+
/// of the underlying and inherited references. E.g. a `&mut` pattern is allowed if either the
266+
/// underlying type is `&mut` or the inherited reference is `&mut`.
267+
///
267268
/// If `false`, a reference pattern is only matched against the underlying type.
268269
/// This is `false` for stable Rust and `true` for both the `ref_pat_eat_one_layer_2024` and
269270
/// `ref_pat_eat_one_layer_2024_structural` feature gates.
@@ -1069,7 +1070,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10691070
{
10701071
if !self.tcx.features().mut_ref() {
10711072
feature_err(
1072-
&self.tcx.sess,
1073+
self.tcx.sess,
10731074
sym::mut_ref,
10741075
pat.span.until(ident.span),
10751076
"binding cannot be both mutable and by-reference",
@@ -1487,31 +1488,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14871488
opt_def_id: Option<hir::def_id::DefId>,
14881489
ident: Ident,
14891490
) -> bool {
1490-
match opt_def_id {
1491-
Some(def_id) => match self.tcx.hir_get_if_local(def_id) {
1492-
Some(hir::Node::Item(hir::Item {
1493-
kind: hir::ItemKind::Const(_, _, _, body_id),
1494-
..
1495-
})) => match self.tcx.hir_node(body_id.hir_id) {
1496-
hir::Node::Expr(expr) => {
1497-
if hir::is_range_literal(expr) {
1498-
let span = self.tcx.hir_span(body_id.hir_id);
1499-
if let Ok(snip) = self.tcx.sess.source_map().span_to_snippet(span) {
1500-
e.span_suggestion_verbose(
1501-
ident.span,
1502-
"you may want to move the range into the match block",
1503-
snip,
1504-
Applicability::MachineApplicable,
1505-
);
1506-
return true;
1507-
}
1508-
}
1509-
}
1510-
_ => (),
1511-
},
1512-
_ => (),
1513-
},
1514-
_ => (),
1491+
if let Some(def_id) = opt_def_id
1492+
&& let Some(hir::Node::Item(hir::Item {
1493+
kind: hir::ItemKind::Const(_, _, _, body_id),
1494+
..
1495+
})) = self.tcx.hir_get_if_local(def_id)
1496+
&& let hir::Node::Expr(expr) = self.tcx.hir_node(body_id.hir_id)
1497+
&& hir::is_range_literal(expr)
1498+
{
1499+
let span = self.tcx.hir_span(body_id.hir_id);
1500+
if let Ok(snip) = self.tcx.sess.source_map().span_to_snippet(span) {
1501+
e.span_suggestion_verbose(
1502+
ident.span,
1503+
"you may want to move the range into the match block",
1504+
snip,
1505+
Applicability::MachineApplicable,
1506+
);
1507+
return true;
1508+
}
15151509
}
15161510
false
15171511
}
@@ -1529,7 +1523,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15291523

15301524
if let Some(span) = self.tcx.hir_res_span(pat_res) {
15311525
e.span_label(span, format!("{} defined here", res.descr()));
1532-
if let [hir::PathSegment { ident, .. }] = &*segments {
1526+
if let [hir::PathSegment { ident, .. }] = segments {
15331527
e.span_label(
15341528
pat_span,
15351529
format!(
@@ -1557,17 +1551,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15571551
_ => (None, None),
15581552
};
15591553

1560-
let is_range = match type_def_id.and_then(|id| self.tcx.as_lang_item(id)) {
1554+
let is_range = matches!(
1555+
type_def_id.and_then(|id| self.tcx.as_lang_item(id)),
15611556
Some(
15621557
LangItem::Range
1563-
| LangItem::RangeFrom
1564-
| LangItem::RangeTo
1565-
| LangItem::RangeFull
1566-
| LangItem::RangeInclusiveStruct
1567-
| LangItem::RangeToInclusive,
1568-
) => true,
1569-
_ => false,
1570-
};
1558+
| LangItem::RangeFrom
1559+
| LangItem::RangeTo
1560+
| LangItem::RangeFull
1561+
| LangItem::RangeInclusiveStruct
1562+
| LangItem::RangeToInclusive,
1563+
)
1564+
);
15711565
if is_range {
15721566
if !self.maybe_suggest_range_literal(&mut e, item_def_id, *ident) {
15731567
let msg = "constants only support matching by type, \

compiler/rustc_lexer/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,14 +599,16 @@ impl Cursor<'_> {
599599
if potential_closing.is_none() {
600600
// a less fortunate recovery if all else fails which finds any dashes preceded by whitespace
601601
// on a standalone line. Might be wrong.
602+
let mut base_index = 0;
602603
while let Some(closing) = rest.find("---") {
603604
let preceding_chars_start = rest[..closing].rfind("\n").map_or(0, |i| i + 1);
604605
if rest[preceding_chars_start..closing].chars().all(is_horizontal_whitespace) {
605606
// candidate found
606-
potential_closing = Some(closing);
607+
potential_closing = Some(closing + base_index);
607608
break;
608609
} else {
609610
rest = &rest[closing + 3..];
611+
base_index += closing + 3;
610612
}
611613
}
612614
}

0 commit comments

Comments
 (0)