Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1ae720a
Fix spelling of "adaptor"
ctz Sep 16, 2025
325ceef
Fix other uses of "adaptor"
ctz Sep 16, 2025
4320de6
fixes for numerous clippy warnings
hkBst Sep 19, 2025
82eed00
chore(compiletest): Use newest anstyle-svg version
Muscraft Sep 16, 2025
4f02ec2
test: Use SVG for terminal url test
Muscraft Sep 16, 2025
4da5935
[win] Use find-msvc-tools instead of cc to find the linker and rc on …
dpaoliello Sep 19, 2025
bb430f8
mbe: Simplify match in `transcribe_metavar`
joshtriplett Sep 19, 2025
fc41c38
mbe: Factor out a function to transcribe a `ParseNtResult`
joshtriplett Sep 19, 2025
a54111a
mbe: metavar expressions: Use symbols rather than `ident.as_str()`
joshtriplett Sep 20, 2025
2a75cb9
add private module override re-export test
el-ev Sep 20, 2025
1dcba11
Update list of good combinations (inc. beta + nightly)
foxtran Sep 21, 2025
8f1a1f8
Update tests/rustdoc/private-mod-override-re-export.rs
el-ev Sep 22, 2025
52e6998
Move test file
el-ev Sep 22, 2025
bd98e73
Update tests/rustdoc/reexport/private-mod-override-reexport.rs
el-ev Sep 22, 2025
2dc1354
tests/run-make/crate-loading: Rename source files for clarity
Enselic Sep 5, 2025
389a502
Fix a dangling reference in `rustc_thread_pool`
cuviper Sep 20, 2025
9ae7aef
prevent line number from being copied in chrome
el-ev Sep 22, 2025
076ada5
Rollup merge of #146632 - ctz:jbp-adaptor-spelling, r=petrochenkov
matthiaskrgr Sep 23, 2025
ba9d057
Rollup merge of #146731 - Muscraft:svg-test-terminal-url, r=jdonszelmann
matthiaskrgr Sep 23, 2025
8905ad9
Rollup merge of #146775 - hkBst:clippy-fix-11, r=petrochenkov
matthiaskrgr Sep 23, 2025
8f11c4d
Rollup merge of #146784 - dpaoliello:findmsvc, r=wesleywiser
matthiaskrgr Sep 23, 2025
64e81e5
Rollup merge of #146799 - cuviper:dangling-count-latch, r=lcnr
matthiaskrgr Sep 23, 2025
15c323f
Rollup merge of #146802 - joshtriplett:mbe-simplifications, r=petroch…
matthiaskrgr Sep 23, 2025
6d15233
Rollup merge of #146806 - el-ev:issue60926, r=lolbinarycat
matthiaskrgr Sep 23, 2025
35ceb3d
Rollup merge of #146827 - foxtran:doc/linker-plugin-lto, r=nnethercote
matthiaskrgr Sep 23, 2025
c71a2c4
Rollup merge of #146875 - Enselic:better-file-names, r=jieyouxu
matthiaskrgr Sep 23, 2025
8e21b89
Rollup merge of #146877 - el-ev:issue146816, r=fmease,lolbinarycat,Gu…
matthiaskrgr Sep 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ dependencies = [

[[package]]
name = "anstyle-svg"
version = "0.1.10"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc03a770ef506fe1396c0e476120ac0e6523cf14b74218dd5f18cd6833326fa9"
checksum = "26b9ec8c976eada1b0f9747a3d7cc4eae3bef10613e443746e7487f26c872fde"
dependencies = [
"anstyle",
"anstyle-lossy",
Expand Down Expand Up @@ -1332,6 +1332,12 @@ dependencies = [
"windows-sys 0.59.0",
]

[[package]]
name = "find-msvc-tools"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ced73b1dacfc750a6db6c0a0c3a3853c8b41997e2e2c563dc90804ae6867959"

[[package]]
name = "flate2"
version = "1.1.2"
Expand Down Expand Up @@ -3556,7 +3562,7 @@ dependencies = [
"ar_archive_writer",
"bitflags",
"bstr",
"cc",
"find-msvc-tools",
"itertools",
"libc",
"object 0.37.3",
Expand Down Expand Up @@ -4760,7 +4766,7 @@ dependencies = [
name = "rustc_windows_rc"
version = "0.0.0"
dependencies = [
"cc",
"find-msvc-tools",
]

[[package]]
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_codegen_ssa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ edition = "2024"
ar_archive_writer = "0.5"
bitflags = "2.4.1"
bstr = "1.11.3"
# `cc` updates often break things, so we pin it here. Cargo enforces "max 1 semver-compat version
# per crate", so if you change this, you need to also change it in `rustc_llvm` and `rustc_windows_rc`.
cc = "=1.2.16"
find-msvc-tools = "0.1.2"
itertools = "0.12"
pathdiff = "0.2.0"
regex = "1.4"
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::path::{Path, PathBuf};
use std::process::{Output, Stdio};
use std::{env, fmt, fs, io, mem, str};

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

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

Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::io::prelude::*;
use std::path::{Path, PathBuf};
use std::{env, io, iter, mem, str};

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

// If our linker looks like a batch script on Windows then to execute this
// we'll need to spawn `cmd` explicitly. This is primarily done to handle
Expand Down Expand Up @@ -117,7 +117,6 @@ pub(crate) fn get_linker<'a>(
if sess.target.is_like_msvc
&& let Some(ref tool) = msvc_tool
{
cmd.args(tool.args());
for (k, v) in tool.env() {
if k == "PATH" {
new_path.extend(env::split_paths(v));
Expand Down
25 changes: 12 additions & 13 deletions compiler/rustc_expand/src/mbe/metavar_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc_ast_pretty::pprust;
use rustc_errors::{Applicability, PResult};
use rustc_macros::{Decodable, Encodable};
use rustc_session::parse::ParseSess;
use rustc_span::{Ident, Span, Symbol};
use rustc_span::{Ident, Span, Symbol, sym};

use crate::errors;

Expand Down Expand Up @@ -69,15 +69,15 @@ impl MetaVarExpr {
}

let mut iter = args.iter();
let rslt = match ident.as_str() {
"concat" => parse_concat(&mut iter, psess, outer_span, ident.span)?,
"count" => parse_count(&mut iter, psess, ident.span)?,
"ignore" => {
let rslt = match ident.name {
sym::concat => parse_concat(&mut iter, psess, outer_span, ident.span)?,
sym::count => parse_count(&mut iter, psess, ident.span)?,
sym::ignore => {
eat_dollar(&mut iter, psess, ident.span)?;
MetaVarExpr::Ignore(parse_ident(&mut iter, psess, ident.span)?)
}
"index" => MetaVarExpr::Index(parse_depth(&mut iter, psess, ident.span)?),
"len" => MetaVarExpr::Len(parse_depth(&mut iter, psess, ident.span)?),
sym::index => MetaVarExpr::Index(parse_depth(&mut iter, psess, ident.span)?),
sym::len => MetaVarExpr::Len(parse_depth(&mut iter, psess, ident.span)?),
_ => {
let err = errors::MveUnrecognizedExpr {
span: ident.span,
Expand Down Expand Up @@ -119,14 +119,13 @@ fn check_trailing_tokens<'psess>(
}

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

Expand Down
45 changes: 27 additions & 18 deletions compiler/rustc_expand/src/mbe/transcribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,19 @@ fn transcribe_metavar<'tx>(
return Ok(());
};

let MatchedSingle(pnr) = cur_matched else {
// We were unable to descend far enough. This is an error.
return Err(dcx.create_err(MacroVarStillRepeating { span: sp, ident }));
};

transcribe_pnr(tscx, sp, pnr)
}

fn transcribe_pnr<'tx>(
tscx: &mut TranscrCtx<'tx, '_>,
mut sp: Span,
pnr: &ParseNtResult,
) -> PResult<'tx, ()> {
// We wrap the tokens in invisible delimiters, unless they are already wrapped
// in invisible delimiters with the same `MetaVarKind`. Because some proc
// macros can't handle multiple layers of invisible delimiters of the same
Expand Down Expand Up @@ -404,33 +417,33 @@ fn transcribe_metavar<'tx>(
)
};

let tt = match cur_matched {
MatchedSingle(ParseNtResult::Tt(tt)) => {
let tt = match pnr {
ParseNtResult::Tt(tt) => {
// `tt`s are emitted into the output stream directly as "raw tokens",
// without wrapping them into groups. Other variables are emitted into
// the output stream as groups with `Delimiter::Invisible` to maintain
// parsing priorities.
maybe_use_metavar_location(tscx.psess, &tscx.stack, sp, tt, &mut tscx.marker)
}
MatchedSingle(ParseNtResult::Ident(ident, is_raw)) => {
ParseNtResult::Ident(ident, is_raw) => {
tscx.marker.mark_span(&mut sp);
with_metavar_spans(|mspans| mspans.insert(ident.span, sp));
let kind = token::NtIdent(*ident, *is_raw);
TokenTree::token_alone(kind, sp)
}
MatchedSingle(ParseNtResult::Lifetime(ident, is_raw)) => {
ParseNtResult::Lifetime(ident, is_raw) => {
tscx.marker.mark_span(&mut sp);
with_metavar_spans(|mspans| mspans.insert(ident.span, sp));
let kind = token::NtLifetime(*ident, *is_raw);
TokenTree::token_alone(kind, sp)
}
MatchedSingle(ParseNtResult::Item(item)) => {
ParseNtResult::Item(item) => {
mk_delimited(item.span, MetaVarKind::Item, TokenStream::from_ast(item))
}
MatchedSingle(ParseNtResult::Block(block)) => {
ParseNtResult::Block(block) => {
mk_delimited(block.span, MetaVarKind::Block, TokenStream::from_ast(block))
}
MatchedSingle(ParseNtResult::Stmt(stmt)) => {
ParseNtResult::Stmt(stmt) => {
let stream = if let StmtKind::Empty = stmt.kind {
// FIXME: Properly collect tokens for empty statements.
TokenStream::token_alone(token::Semi, stmt.span)
Expand All @@ -439,10 +452,10 @@ fn transcribe_metavar<'tx>(
};
mk_delimited(stmt.span, MetaVarKind::Stmt, stream)
}
MatchedSingle(ParseNtResult::Pat(pat, pat_kind)) => {
ParseNtResult::Pat(pat, pat_kind) => {
mk_delimited(pat.span, MetaVarKind::Pat(*pat_kind), TokenStream::from_ast(pat))
}
MatchedSingle(ParseNtResult::Expr(expr, kind)) => {
ParseNtResult::Expr(expr, kind) => {
let (can_begin_literal_maybe_minus, can_begin_string_literal) = match &expr.kind {
ExprKind::Lit(_) => (true, true),
ExprKind::Unary(UnOp::Neg, e) if matches!(&e.kind, ExprKind::Lit(_)) => {
Expand All @@ -460,31 +473,27 @@ fn transcribe_metavar<'tx>(
TokenStream::from_ast(expr),
)
}
MatchedSingle(ParseNtResult::Literal(lit)) => {
ParseNtResult::Literal(lit) => {
mk_delimited(lit.span, MetaVarKind::Literal, TokenStream::from_ast(lit))
}
MatchedSingle(ParseNtResult::Ty(ty)) => {
ParseNtResult::Ty(ty) => {
let is_path = matches!(&ty.kind, TyKind::Path(None, _path));
mk_delimited(ty.span, MetaVarKind::Ty { is_path }, TokenStream::from_ast(ty))
}
MatchedSingle(ParseNtResult::Meta(attr_item)) => {
ParseNtResult::Meta(attr_item) => {
let has_meta_form = attr_item.meta_kind().is_some();
mk_delimited(
attr_item.span(),
MetaVarKind::Meta { has_meta_form },
TokenStream::from_ast(attr_item),
)
}
MatchedSingle(ParseNtResult::Path(path)) => {
ParseNtResult::Path(path) => {
mk_delimited(path.span, MetaVarKind::Path, TokenStream::from_ast(path))
}
MatchedSingle(ParseNtResult::Vis(vis)) => {
ParseNtResult::Vis(vis) => {
mk_delimited(vis.span, MetaVarKind::Vis, TokenStream::from_ast(vis))
}
MatchedSeq(..) => {
// We were unable to descend far enough. This is an error.
return Err(dcx.create_err(MacroVarStillRepeating { span: sp, ident }));
}
};

tscx.result.push(tt);
Expand Down
72 changes: 33 additions & 39 deletions compiler/rustc_hir_typeck/src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ You can read more about trait objects in the Trait Objects section of the Refere
https://doc.rust-lang.org/reference/types.html#trait-objects";

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

/// Information about the expected type at the top level of type checking a pattern.
Expand Down Expand Up @@ -262,8 +262,9 @@ enum InheritedRefMatchRule {
/// pattern matches a given type:
/// - If the underlying type is not a reference, a reference pattern may eat the inherited reference;
/// - If the underlying type is a reference, a reference pattern matches if it can eat either one
/// of the underlying and inherited references. E.g. a `&mut` pattern is allowed if either the
/// underlying type is `&mut` or the inherited reference is `&mut`.
/// of the underlying and inherited references. E.g. a `&mut` pattern is allowed if either the
/// underlying type is `&mut` or the inherited reference is `&mut`.
///
/// If `false`, a reference pattern is only matched against the underlying type.
/// This is `false` for stable Rust and `true` for both the `ref_pat_eat_one_layer_2024` and
/// `ref_pat_eat_one_layer_2024_structural` feature gates.
Expand Down Expand Up @@ -1069,7 +1070,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{
if !self.tcx.features().mut_ref() {
feature_err(
&self.tcx.sess,
self.tcx.sess,
sym::mut_ref,
pat.span.until(ident.span),
"binding cannot be both mutable and by-reference",
Expand Down Expand Up @@ -1487,31 +1488,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
opt_def_id: Option<hir::def_id::DefId>,
ident: Ident,
) -> bool {
match opt_def_id {
Some(def_id) => match self.tcx.hir_get_if_local(def_id) {
Some(hir::Node::Item(hir::Item {
kind: hir::ItemKind::Const(_, _, _, body_id),
..
})) => match self.tcx.hir_node(body_id.hir_id) {
hir::Node::Expr(expr) => {
if hir::is_range_literal(expr) {
let span = self.tcx.hir_span(body_id.hir_id);
if let Ok(snip) = self.tcx.sess.source_map().span_to_snippet(span) {
e.span_suggestion_verbose(
ident.span,
"you may want to move the range into the match block",
snip,
Applicability::MachineApplicable,
);
return true;
}
}
}
_ => (),
},
_ => (),
},
_ => (),
if let Some(def_id) = opt_def_id
&& let Some(hir::Node::Item(hir::Item {
kind: hir::ItemKind::Const(_, _, _, body_id),
..
})) = self.tcx.hir_get_if_local(def_id)
&& let hir::Node::Expr(expr) = self.tcx.hir_node(body_id.hir_id)
&& hir::is_range_literal(expr)
{
let span = self.tcx.hir_span(body_id.hir_id);
if let Ok(snip) = self.tcx.sess.source_map().span_to_snippet(span) {
e.span_suggestion_verbose(
ident.span,
"you may want to move the range into the match block",
snip,
Applicability::MachineApplicable,
);
return true;
}
}
false
}
Expand All @@ -1529,7 +1523,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

if let Some(span) = self.tcx.hir_res_span(pat_res) {
e.span_label(span, format!("{} defined here", res.descr()));
if let [hir::PathSegment { ident, .. }] = &*segments {
if let [hir::PathSegment { ident, .. }] = segments {
e.span_label(
pat_span,
format!(
Expand Down Expand Up @@ -1557,17 +1551,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ => (None, None),
};

let is_range = match type_def_id.and_then(|id| self.tcx.as_lang_item(id)) {
let is_range = matches!(
type_def_id.and_then(|id| self.tcx.as_lang_item(id)),
Some(
LangItem::Range
| LangItem::RangeFrom
| LangItem::RangeTo
| LangItem::RangeFull
| LangItem::RangeInclusiveStruct
| LangItem::RangeToInclusive,
) => true,
_ => false,
};
| LangItem::RangeFrom
| LangItem::RangeTo
| LangItem::RangeFull
| LangItem::RangeInclusiveStruct
| LangItem::RangeToInclusive,
)
);
if is_range {
if !self.maybe_suggest_range_literal(&mut e, item_def_id, *ident) {
let msg = "constants only support matching by type, \
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_llvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ libc = "0.2.73"

[build-dependencies]
# tidy-alphabetical-start
# `cc` updates often break things, so we pin it here. Cargo enforces "max 1 semver-compat version
# per crate", so if you change this, you need to also change it in `rustc_codegen_ssa` and `rustc_windows_rc`.
# `cc` updates often break things, so we pin it here.
cc = "=1.2.16"
# tidy-alphabetical-end

Expand Down
Loading
Loading