Skip to content

Rollup of 14 pull requests #142644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
62435f9
impl `Default` for `array::IntoIter`
fee1-dead May 26, 2025
5f0dd44
avoid `&mut P<T>` in `visit_expr` etc methods
fee1-dead Jun 11, 2025
0e1db54
Windows: Use anonymous pipes in Command
ChrisDenton Jun 14, 2025
e8dfd81
linked_list tests: less static mut
hkBst Jun 16, 2025
23e35c6
Add support for repetition to `proc_macro::quote`
moatom May 26, 2025
7d3a1d4
make more CodegenCx function generic
ZuseZ4 Jun 16, 2025
6359123
add and use generic get_const_int function
ZuseZ4 Jun 16, 2025
00c1042
rustdoc: make srcIndex no longer a global variable
lolbinarycat Jun 5, 2025
f1fea6c
don't unwrap in enzyme builds in case of missing llvm-config
ZuseZ4 Jun 17, 2025
de792eb
compiler: Redescribe rustc_target::spec more accurately
workingjubilee Jun 17, 2025
679a2e3
compiler: Redescribe rustc_target search algo more accurately
workingjubilee Jun 17, 2025
2d3a37d
linked_list tests: buff check_links
hkBst Jun 16, 2025
2bbc974
Lint about `console` calls in rustdoc JS
GuillaumeGomez Jun 17, 2025
e3c21dd
Remove a panicking branch in `BorrowedCursor::advance`
a1phyr Jun 17, 2025
1ab8ff5
Add test suggest-remove-semi-in-macro-expansion-issue-142143.rs
xizheyin Jun 17, 2025
3f1de7b
Update cargo
ehuss Jun 17, 2025
72fbf3e
Dont suggest remove semi inside macro expansion for redundant semi lint
xizheyin Jun 17, 2025
a88a32d
Temporarily add back -Zwasm-c-abi=spec
bjorn3 Jun 17, 2025
da985cb
Rollup merge of #141574 - fee1-dead-contrib:push-owzulzmzszzx, r=jhpratt
jhpratt Jun 17, 2025
17ab49a
Rollup merge of #141608 - moatom:proc_macro-140238, r=dtolnay
jhpratt Jun 17, 2025
0772ee7
Rollup merge of #142100 - lolbinarycat:rustdoc-srcIndex-138467, r=Gui…
jhpratt Jun 17, 2025
e95fb09
Rollup merge of #142371 - fee1-dead-contrib:push-xqlkumzurkus, r=petr…
jhpratt Jun 17, 2025
b5fcc90
Rollup merge of #142517 - ChrisDenton:anon-pipe, r=Mark-Simulacrum
jhpratt Jun 17, 2025
eb7d246
Rollup merge of #142520 - hkBst:less-static-mut, r=tgross35
jhpratt Jun 17, 2025
0eb8a66
Rollup merge of #142588 - ZuseZ4:generic-ctx-imprv, r=oli-obk
jhpratt Jun 17, 2025
504b1a1
Rollup merge of #142605 - ZuseZ4:autodiff-check-builds2, r=oli-obk
jhpratt Jun 17, 2025
6acda82
Rollup merge of #142608 - workingjubilee:redescribe-rustc_target-more…
jhpratt Jun 17, 2025
a47b364
Rollup merge of #142618 - GuillaumeGomez:eslint-no-console, r=lolbina…
jhpratt Jun 17, 2025
6148ec9
Rollup merge of #142620 - a1phyr:borrowed_buf_remove_branch, r=jhpratt
jhpratt Jun 17, 2025
f663823
Rollup merge of #142631 - xizheyin:142143, r=Urgau
jhpratt Jun 17, 2025
55b3b66
Rollup merge of #142632 - ehuss:update-cargo, r=ehuss
jhpratt Jun 17, 2025
3ec1451
Rollup merge of #142635 - bjorn3:add_back_wasm_spec_abi, r=workingjub…
jhpratt Jun 17, 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
26 changes: 22 additions & 4 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,12 @@ impl Pat {
}
}

impl From<P<Pat>> for Pat {
fn from(value: P<Pat>) -> Self {
*value
}
}

/// A single field in a struct pattern.
///
/// Patterns like the fields of `Foo { x, ref y, ref mut z }`
Expand Down Expand Up @@ -1553,17 +1559,23 @@ impl Expr {
)
}

/// Creates a dummy `P<Expr>`.
/// Creates a dummy `Expr`.
///
/// Should only be used when it will be replaced afterwards or as a return value when an error was encountered.
pub fn dummy() -> P<Expr> {
P(Expr {
pub fn dummy() -> Expr {
Expr {
id: DUMMY_NODE_ID,
kind: ExprKind::Dummy,
span: DUMMY_SP,
attrs: ThinVec::new(),
tokens: None,
})
}
}
}

impl From<P<Expr>> for Expr {
fn from(value: P<Expr>) -> Self {
*value
}
}

Expand Down Expand Up @@ -2374,6 +2386,12 @@ impl Clone for Ty {
}
}

impl From<P<Ty>> for Ty {
fn from(value: P<Ty>) -> Self {
*value
}
}

impl Ty {
pub fn peel_refs(&self) -> &Self {
let mut final_ty = self;
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_ast/src/mut_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ pub trait MutVisitor: Sized + MutVisitorResult<Result = ()> {
walk_flat_map_arm(self, arm)
}

fn visit_pat(&mut self, p: &mut P<Pat>) {
fn visit_pat(&mut self, p: &mut Pat) {
walk_pat(self, p);
}

fn visit_anon_const(&mut self, c: &mut AnonConst) {
walk_anon_const(self, c);
}

fn visit_expr(&mut self, e: &mut P<Expr>) {
fn visit_expr(&mut self, e: &mut Expr) {
walk_expr(self, e);
}

Expand All @@ -194,7 +194,7 @@ pub trait MutVisitor: Sized + MutVisitorResult<Result = ()> {
walk_generic_arg(self, arg);
}

fn visit_ty(&mut self, t: &mut P<Ty>) {
fn visit_ty(&mut self, t: &mut Ty) {
walk_ty(self, t);
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/cfg_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl CfgEval<'_> {

impl MutVisitor for CfgEval<'_> {
#[instrument(level = "trace", skip(self))]
fn visit_expr(&mut self, expr: &mut P<ast::Expr>) {
fn visit_expr(&mut self, expr: &mut ast::Expr) {
self.0.configure_expr(expr, false);
mut_visit::walk_expr(self, expr);
}
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_builtin_macros/src/deriving/coerce_pointee.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use ast::HasAttrs;
use ast::ptr::P;
use rustc_ast::mut_visit::MutVisitor;
use rustc_ast::visit::BoundKind;
use rustc_ast::{
Expand Down Expand Up @@ -378,11 +377,11 @@ struct TypeSubstitution<'a> {
}

impl<'a> ast::mut_visit::MutVisitor for TypeSubstitution<'a> {
fn visit_ty(&mut self, ty: &mut P<ast::Ty>) {
fn visit_ty(&mut self, ty: &mut ast::Ty) {
if let Some(name) = ty.kind.is_simple_path()
&& name == self.from_name
{
**ty = self.to_ty.clone();
*ty = self.to_ty.clone();
self.rewritten = true;
} else {
ast::mut_visit::walk_ty(self, ty);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_llvm/src/builder/autodiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn match_args_from_caller_to_enzyme<'ll>(
let mul = unsafe {
llvm::LLVMBuildMul(
builder.llbuilder,
cx.get_const_i64(elem_bytes_size),
cx.get_const_int(cx.type_i64(), elem_bytes_size),
next_outer_arg,
UNNAMED,
)
Expand Down Expand Up @@ -385,7 +385,7 @@ fn generate_enzyme_call<'ll>(
if attrs.width > 1 {
let enzyme_width = cx.create_metadata("enzyme_width".to_string()).unwrap();
args.push(cx.get_metadata_value(enzyme_width));
args.push(cx.get_const_i64(attrs.width as u64));
args.push(cx.get_const_int(cx.type_i64(), attrs.width as u64));
}

let has_sret = has_sret(outer_fn);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_llvm/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ impl<'ll, CX: Borrow<SCx<'ll>>> BackendTypes for GenericCx<'ll, CX> {
type DIVariable = &'ll llvm::debuginfo::DIVariable;
}

impl<'ll> CodegenCx<'ll, '_> {
impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> {
pub(crate) fn const_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
let len = u64::try_from(elts.len()).expect("LLVMConstArray2 elements len overflow");
unsafe { llvm::LLVMConstArray2(ty, elts.as_ptr(), len) }
}

pub(crate) fn const_bytes(&self, bytes: &[u8]) -> &'ll Value {
bytes_in_context(self.llcx, bytes)
bytes_in_context(self.llcx(), bytes)
}

pub(crate) fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value {
Expand Down
7 changes: 2 additions & 5 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,11 +679,8 @@ impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> {
llvm::LLVMMetadataAsValue(self.llcx(), metadata)
}

// FIXME(autodiff): We should split `ConstCodegenMethods` to pull the reusable parts
// onto a trait that is also implemented for GenericCx.
pub(crate) fn get_const_i64(&self, n: u64) -> &'ll Value {
let ty = unsafe { llvm::LLVMInt64TypeInContext(self.llcx()) };
unsafe { llvm::LLVMConstInt(ty, n, llvm::False) }
pub(crate) fn get_const_int(&self, ty: &'ll Type, val: u64) -> &'ll Value {
unsafe { llvm::LLVMConstInt(ty, val, llvm::False) }
}

pub(crate) fn get_function(&self, name: &str) -> Option<&'ll Value> {
Expand Down
35 changes: 18 additions & 17 deletions compiler/rustc_expand/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,7 @@ impl InvocationCollectorNode for ast::Crate {
}
}

impl InvocationCollectorNode for P<ast::Ty> {
impl InvocationCollectorNode for ast::Ty {
type OutputTy = P<ast::Ty>;
const KIND: AstFragmentKind = AstFragmentKind::Ty;
fn to_annotatable(self) -> Annotatable {
Expand All @@ -1791,7 +1791,7 @@ impl InvocationCollectorNode for P<ast::Ty> {
}
}

impl InvocationCollectorNode for P<ast::Pat> {
impl InvocationCollectorNode for ast::Pat {
type OutputTy = P<ast::Pat>;
const KIND: AstFragmentKind = AstFragmentKind::Pat;
fn to_annotatable(self) -> Annotatable {
Expand All @@ -1814,11 +1814,11 @@ impl InvocationCollectorNode for P<ast::Pat> {
}
}

impl InvocationCollectorNode for P<ast::Expr> {
impl InvocationCollectorNode for ast::Expr {
type OutputTy = P<ast::Expr>;
const KIND: AstFragmentKind = AstFragmentKind::Expr;
fn to_annotatable(self) -> Annotatable {
Annotatable::Expr(self)
Annotatable::Expr(P(self))
}
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
fragment.make_expr()
Expand Down Expand Up @@ -1955,37 +1955,37 @@ impl DummyAstNode for ast::Crate {
}
}

impl DummyAstNode for P<ast::Ty> {
impl DummyAstNode for ast::Ty {
fn dummy() -> Self {
P(ast::Ty {
ast::Ty {
id: DUMMY_NODE_ID,
kind: TyKind::Dummy,
span: Default::default(),
tokens: Default::default(),
})
}
}
}

impl DummyAstNode for P<ast::Pat> {
impl DummyAstNode for ast::Pat {
fn dummy() -> Self {
P(ast::Pat {
ast::Pat {
id: DUMMY_NODE_ID,
kind: PatKind::Wild,
span: Default::default(),
tokens: Default::default(),
})
}
}
}

impl DummyAstNode for P<ast::Expr> {
impl DummyAstNode for ast::Expr {
fn dummy() -> Self {
ast::Expr::dummy()
}
}

impl DummyAstNode for AstNodeWrapper<P<ast::Expr>, MethodReceiverTag> {
fn dummy() -> Self {
AstNodeWrapper::new(ast::Expr::dummy(), MethodReceiverTag)
AstNodeWrapper::new(P(ast::Expr::dummy()), MethodReceiverTag)
}
}

Expand Down Expand Up @@ -2272,7 +2272,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
}
}

fn visit_node<Node: InvocationCollectorNode<OutputTy = Node> + DummyAstNode>(
fn visit_node<Node: InvocationCollectorNode<OutputTy: Into<Node>> + DummyAstNode>(
&mut self,
node: &mut Node,
) {
Expand All @@ -2297,14 +2297,15 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
*node = self
.collect_attr((attr, pos, derives), n.to_annotatable(), Node::KIND)
.make_ast::<Node>()
.into()
}
},
None if node.is_mac_call() => {
let n = mem::replace(node, Node::dummy());
let (mac, attrs, _) = n.take_mac_call();
self.check_attributes(&attrs, &mac);

*node = self.collect_bang(mac, Node::KIND).make_ast::<Node>()
*node = self.collect_bang(mac, Node::KIND).make_ast::<Node>().into()
}
None if node.delegation().is_some() => unreachable!(),
None => {
Expand Down Expand Up @@ -2414,15 +2415,15 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
self.visit_node(node)
}

fn visit_ty(&mut self, node: &mut P<ast::Ty>) {
fn visit_ty(&mut self, node: &mut ast::Ty) {
self.visit_node(node)
}

fn visit_pat(&mut self, node: &mut P<ast::Pat>) {
fn visit_pat(&mut self, node: &mut ast::Pat) {
self.visit_node(node)
}

fn visit_expr(&mut self, node: &mut P<ast::Expr>) {
fn visit_expr(&mut self, node: &mut ast::Expr) {
// FIXME: Feature gating is performed inconsistently between `Expr` and `OptExpr`.
if let Some(attr) = node.attrs.first() {
self.cfg().maybe_emit_expr_attr_err(attr);
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_expand/src/placeholders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ impl MutVisitor for PlaceholderExpander {
}
}

fn visit_expr(&mut self, expr: &mut P<ast::Expr>) {
fn visit_expr(&mut self, expr: &mut ast::Expr) {
match expr.kind {
ast::ExprKind::MacCall(_) => *expr = self.remove(expr.id).make_expr(),
ast::ExprKind::MacCall(_) => *expr = *self.remove(expr.id).make_expr(),
_ => walk_expr(self, expr),
}
}
Expand Down Expand Up @@ -399,16 +399,16 @@ impl MutVisitor for PlaceholderExpander {
stmts
}

fn visit_pat(&mut self, pat: &mut P<ast::Pat>) {
fn visit_pat(&mut self, pat: &mut ast::Pat) {
match pat.kind {
ast::PatKind::MacCall(_) => *pat = self.remove(pat.id).make_pat(),
ast::PatKind::MacCall(_) => *pat = *self.remove(pat.id).make_pat(),
_ => walk_pat(self, pat),
}
}

fn visit_ty(&mut self, ty: &mut P<ast::Ty>) {
fn visit_ty(&mut self, ty: &mut ast::Ty) {
match ty.kind {
ast::TyKind::MacCall(_) => *ty = self.remove(ty.id).make_ty(),
ast::TyKind::MacCall(_) => *ty = *self.remove(ty.id).make_ty(),
_ => walk_ty(self, ty),
}
}
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_lint/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,8 @@ lint_redundant_semicolons =
[true] semicolons
*[false] semicolon
}
.suggestion = remove {$multiple ->
lint_redundant_semicolons_suggestion = remove {$multiple_semicolons ->
[true] these semicolons
*[false] this semicolon
}
Expand Down
12 changes: 10 additions & 2 deletions compiler/rustc_lint/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1538,8 +1538,16 @@ pub(crate) struct PassByValueDiag {
#[diag(lint_redundant_semicolons)]
pub(crate) struct RedundantSemicolonsDiag {
pub multiple: bool,
#[suggestion(code = "", applicability = "maybe-incorrect")]
pub suggestion: Span,
#[subdiagnostic]
pub suggestion: Option<RedundantSemicolonsSuggestion>,
}

#[derive(Subdiagnostic)]
#[suggestion(lint_redundant_semicolons_suggestion, code = "", applicability = "maybe-incorrect")]
pub(crate) struct RedundantSemicolonsSuggestion {
pub multiple_semicolons: bool,
#[primary_span]
pub span: Span,
}

// traits.rs
Expand Down
13 changes: 9 additions & 4 deletions compiler/rustc_lint/src/redundant_semicolon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use rustc_ast::{Block, StmtKind};
use rustc_session::{declare_lint, declare_lint_pass};
use rustc_span::Span;

use crate::lints::RedundantSemicolonsDiag;
use crate::lints::{RedundantSemicolonsDiag, RedundantSemicolonsSuggestion};
use crate::{EarlyContext, EarlyLintPass, LintContext};

declare_lint! {
Expand Down Expand Up @@ -44,16 +44,21 @@ impl EarlyLintPass for RedundantSemicolons {

fn maybe_lint_redundant_semis(cx: &EarlyContext<'_>, seq: &mut Option<(Span, bool)>) {
if let Some((span, multiple)) = seq.take() {
// FIXME: Find a better way of ignoring the trailing
// semicolon from macro expansion
if span == rustc_span::DUMMY_SP {
return;
}

// Ignore redundant semicolons inside macro expansion.(issue #142143)
let suggestion = if span.from_expansion() {
None
} else {
Some(RedundantSemicolonsSuggestion { multiple_semicolons: multiple, span })
};

cx.emit_span_lint(
REDUNDANT_SEMICOLONS,
span,
RedundantSemicolonsDiag { multiple, suggestion: span },
RedundantSemicolonsDiag { multiple, suggestion },
);
}
}
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4087,7 +4087,7 @@ impl<'a> CondChecker<'a> {
}

impl MutVisitor for CondChecker<'_> {
fn visit_expr(&mut self, e: &mut P<Expr>) {
fn visit_expr(&mut self, e: &mut Expr) {
self.depth += 1;
use ForbiddenLetReason::*;

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ impl<'a> Parser<'a> {
fn make_all_value_bindings_mutable(pat: &mut P<Pat>) -> bool {
struct AddMut(bool);
impl MutVisitor for AddMut {
fn visit_pat(&mut self, pat: &mut P<Pat>) {
fn visit_pat(&mut self, pat: &mut Pat) {
if let PatKind::Ident(BindingMode(ByRef::No, m @ Mutability::Not), ..) =
&mut pat.kind
{
Expand Down
Loading
Loading