Skip to content

Commit 60493b8

Browse files
committed
Auto merge of #137790 - jieyouxu:rollup-jrib20h, r=jieyouxu
Rollup of 9 pull requests Successful merges: - #136424 (fix: overflowing bin hex) - #136824 (solver cycles are coinductive once they have one coinductive step) - #137220 (Support `rust.channel = "auto-detect"`) - #137712 (Clean up TypeckResults::extract_binding_mode) - #137713 (Fix enzyme build errors) - #137748 (Fix method name in `TyCtxt::hir_crate()` documentation) - #137778 (update enzyme to handle range metadata) - #137780 (Fix typo in query expansion documentation) - #137788 (Bump `rustc_{codegen_ssa,llvm}` `cc` to 1.2.16 to fix `x86` Windows jobs on newest Windows SDK) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2f58193 + 46f5dea commit 60493b8

File tree

60 files changed

+791
-551
lines changed

Some content is hidden

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

60 files changed

+791
-551
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,9 @@ version = "0.1.0"
407407

408408
[[package]]
409409
name = "cc"
410-
version = "1.2.13"
410+
version = "1.2.16"
411411
source = "registry+https://github.com/rust-lang/crates.io-index"
412-
checksum = "c7777341816418c02e033934a09f20dc0ccaf65a5201ef8a450ae0105a573fda"
412+
checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c"
413413
dependencies = [
414414
"shlex",
415415
]

compiler/rustc_builtin_macros/src/autodiff.rs

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//! configs (autodiff enabled or disabled), so we have to add cfg's to each import.
44
//! FIXME(ZuseZ4): Remove this once we have a smarter linter.
55
6-
#[cfg(llvm_enzyme)]
76
mod llvm_enzyme {
87
use std::str::FromStr;
98
use std::string::String;
@@ -130,10 +129,14 @@ mod llvm_enzyme {
130129
meta_item: &ast::MetaItem,
131130
mut item: Annotatable,
132131
) -> Vec<Annotatable> {
132+
if cfg!(not(llvm_enzyme)) {
133+
ecx.sess.dcx().emit_err(errors::AutoDiffSupportNotBuild { span: meta_item.span });
134+
return vec![item];
135+
}
133136
let dcx = ecx.sess.dcx();
134137
// first get the annotable item:
135138
let (sig, is_impl): (FnSig, bool) = match &item {
136-
Annotatable::Item(ref iitem) => {
139+
Annotatable::Item(iitem) => {
137140
let sig = match &iitem.kind {
138141
ItemKind::Fn(box ast::Fn { sig, .. }) => sig,
139142
_ => {
@@ -143,7 +146,7 @@ mod llvm_enzyme {
143146
};
144147
(sig.clone(), false)
145148
}
146-
Annotatable::AssocItem(ref assoc_item, _) => {
149+
Annotatable::AssocItem(assoc_item, _) => {
147150
let sig = match &assoc_item.kind {
148151
ast::AssocItemKind::Fn(box ast::Fn { sig, .. }) => sig,
149152
_ => {
@@ -171,8 +174,8 @@ mod llvm_enzyme {
171174
let sig_span = ecx.with_call_site_ctxt(sig.span);
172175

173176
let (vis, primal) = match &item {
174-
Annotatable::Item(ref iitem) => (iitem.vis.clone(), iitem.ident.clone()),
175-
Annotatable::AssocItem(ref assoc_item, _) => {
177+
Annotatable::Item(iitem) => (iitem.vis.clone(), iitem.ident.clone()),
178+
Annotatable::AssocItem(assoc_item, _) => {
176179
(assoc_item.vis.clone(), assoc_item.ident.clone())
177180
}
178181
_ => {
@@ -801,25 +804,4 @@ mod llvm_enzyme {
801804
}
802805
}
803806

804-
#[cfg(not(llvm_enzyme))]
805-
mod ad_fallback {
806-
use rustc_ast::ast;
807-
use rustc_expand::base::{Annotatable, ExtCtxt};
808-
use rustc_span::Span;
809-
810-
use crate::errors;
811-
pub(crate) fn expand(
812-
ecx: &mut ExtCtxt<'_>,
813-
_expand_span: Span,
814-
meta_item: &ast::MetaItem,
815-
item: Annotatable,
816-
) -> Vec<Annotatable> {
817-
ecx.sess.dcx().emit_err(errors::AutoDiffSupportNotBuild { span: meta_item.span });
818-
return vec![item];
819-
}
820-
}
821-
822-
#[cfg(not(llvm_enzyme))]
823-
pub(crate) use ad_fallback::expand;
824-
#[cfg(llvm_enzyme)]
825807
pub(crate) use llvm_enzyme::expand;

compiler/rustc_builtin_macros/src/errors.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,8 @@ pub(crate) struct AllocMustStatics {
144144
pub(crate) span: Span,
145145
}
146146

147-
#[cfg(llvm_enzyme)]
148147
pub(crate) use autodiff::*;
149148

150-
#[cfg(llvm_enzyme)]
151149
mod autodiff {
152150
use super::*;
153151
#[derive(Diagnostic)]
@@ -203,9 +201,7 @@ mod autodiff {
203201
}
204202
}
205203

206-
#[cfg(not(llvm_enzyme))]
207204
pub(crate) use ad_fallback::*;
208-
#[cfg(not(llvm_enzyme))]
209205
mod ad_fallback {
210206
use super::*;
211207
#[derive(Diagnostic)]

compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ pub use self::Enzyme_AD::*;
4242
#[cfg(llvm_enzyme)]
4343
pub mod Enzyme_AD {
4444
use libc::c_void;
45-
extern "C" {
45+
unsafe extern "C" {
4646
pub fn EnzymeSetCLBool(arg1: *mut ::std::os::raw::c_void, arg2: u8);
4747
}
48-
extern "C" {
48+
unsafe extern "C" {
4949
static mut EnzymePrintPerf: c_void;
5050
static mut EnzymePrintActivity: c_void;
5151
static mut EnzymePrintType: c_void;

compiler/rustc_codegen_ssa/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ bitflags = "2.4.1"
1111
bstr = "1.11.3"
1212
# Pinned so `cargo update` bumps don't cause breakage. Please also update the
1313
# `cc` in `rustc_llvm` if you update the `cc` here.
14-
cc = "=1.2.13"
14+
cc = "=1.2.16"
1515
either = "1.5.0"
1616
itertools = "0.12"
1717
pathdiff = "0.2.0"

compiler/rustc_hir/src/hir.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,6 +1683,12 @@ pub enum PatKind<'hir> {
16831683
/// The `HirId` is the canonical ID for the variable being bound,
16841684
/// (e.g., in `Ok(x) | Err(x)`, both `x` use the same canonical ID),
16851685
/// which is the pattern ID of the first `x`.
1686+
///
1687+
/// The `BindingMode` is what's provided by the user, before match
1688+
/// ergonomics are applied. For the binding mode actually in use,
1689+
/// see [`TypeckResults::extract_binding_mode`].
1690+
///
1691+
/// [`TypeckResults::extract_binding_mode`]: ../../rustc_middle/ty/struct.TypeckResults.html#method.extract_binding_mode
16861692
Binding(BindingMode, HirId, Ident, Option<&'hir Pat<'hir>>),
16871693

16881694
/// A struct or struct variant pattern (e.g., `Variant {x, y, ..}`).

compiler/rustc_hir_typeck/src/expr_use_visitor.rs

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -895,48 +895,44 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
895895
match pat.kind {
896896
PatKind::Binding(_, canonical_id, ..) => {
897897
debug!("walk_pat: binding place={:?} pat={:?}", place, pat);
898-
if let Some(bm) = self
898+
let bm = self
899899
.cx
900900
.typeck_results()
901-
.extract_binding_mode(tcx.sess, pat.hir_id, pat.span)
902-
{
903-
debug!("walk_pat: pat.hir_id={:?} bm={:?}", pat.hir_id, bm);
901+
.extract_binding_mode(tcx.sess, pat.hir_id, pat.span);
902+
debug!("walk_pat: pat.hir_id={:?} bm={:?}", pat.hir_id, bm);
904903

905-
// pat_ty: the type of the binding being produced.
906-
let pat_ty = self.node_ty(pat.hir_id)?;
907-
debug!("walk_pat: pat_ty={:?}", pat_ty);
904+
// pat_ty: the type of the binding being produced.
905+
let pat_ty = self.node_ty(pat.hir_id)?;
906+
debug!("walk_pat: pat_ty={:?}", pat_ty);
908907

909-
let def = Res::Local(canonical_id);
910-
if let Ok(ref binding_place) =
911-
self.cat_res(pat.hir_id, pat.span, pat_ty, def)
912-
{
913-
self.delegate.borrow_mut().bind(binding_place, binding_place.hir_id);
914-
}
908+
let def = Res::Local(canonical_id);
909+
if let Ok(ref binding_place) = self.cat_res(pat.hir_id, pat.span, pat_ty, def) {
910+
self.delegate.borrow_mut().bind(binding_place, binding_place.hir_id);
911+
}
915912

916-
// Subtle: MIR desugaring introduces immutable borrows for each pattern
917-
// binding when lowering pattern guards to ensure that the guard does not
918-
// modify the scrutinee.
919-
if has_guard {
920-
self.delegate.borrow_mut().borrow(
921-
place,
922-
discr_place.hir_id,
923-
BorrowKind::Immutable,
924-
);
925-
}
913+
// Subtle: MIR desugaring introduces immutable borrows for each pattern
914+
// binding when lowering pattern guards to ensure that the guard does not
915+
// modify the scrutinee.
916+
if has_guard {
917+
self.delegate.borrow_mut().borrow(
918+
place,
919+
discr_place.hir_id,
920+
BorrowKind::Immutable,
921+
);
922+
}
926923

927-
// It is also a borrow or copy/move of the value being matched.
928-
// In a cases of pattern like `let pat = upvar`, don't use the span
929-
// of the pattern, as this just looks confusing, instead use the span
930-
// of the discriminant.
931-
match bm.0 {
932-
hir::ByRef::Yes(m) => {
933-
let bk = ty::BorrowKind::from_mutbl(m);
934-
self.delegate.borrow_mut().borrow(place, discr_place.hir_id, bk);
935-
}
936-
hir::ByRef::No => {
937-
debug!("walk_pat binding consuming pat");
938-
self.consume_or_copy(place, discr_place.hir_id);
939-
}
924+
// It is also a borrow or copy/move of the value being matched.
925+
// In a cases of pattern like `let pat = upvar`, don't use the span
926+
// of the pattern, as this just looks confusing, instead use the span
927+
// of the discriminant.
928+
match bm.0 {
929+
hir::ByRef::Yes(m) => {
930+
let bk = ty::BorrowKind::from_mutbl(m);
931+
self.delegate.borrow_mut().borrow(place, discr_place.hir_id, bk);
932+
}
933+
hir::ByRef::No => {
934+
debug!("walk_pat binding consuming pat");
935+
self.consume_or_copy(place, discr_place.hir_id);
940936
}
941937
}
942938
}

compiler/rustc_hir_typeck/src/writeback.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,8 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> {
319319
match p.kind {
320320
hir::PatKind::Binding(..) => {
321321
let typeck_results = self.fcx.typeck_results.borrow();
322-
if let Some(bm) =
323-
typeck_results.extract_binding_mode(self.tcx().sess, p.hir_id, p.span)
324-
{
325-
self.typeck_results.pat_binding_modes_mut().insert(p.hir_id, bm);
326-
}
322+
let bm = typeck_results.extract_binding_mode(self.tcx().sess, p.hir_id, p.span);
323+
self.typeck_results.pat_binding_modes_mut().insert(p.hir_id, bm);
327324
}
328325
hir::PatKind::Struct(_, fields, _) => {
329326
for field in fields {

compiler/rustc_lint/src/types/literal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ fn report_bin_hex_error(
186186
lit_no_suffix,
187187
negative_val: actually.clone(),
188188
int_ty: int_ty.name_str(),
189-
uint_ty: int_ty.to_unsigned().name_str(),
189+
uint_ty: Integer::fit_unsigned(val).uint_ty_str(),
190190
})
191191
})
192192
.flatten();

compiler/rustc_llvm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ libc = "0.2.73"
1212
# tidy-alphabetical-start
1313
# Pinned so `cargo update` bumps don't cause breakage. Please also update the
1414
# pinned `cc` in `rustc_codegen_ssa` if you update `cc` here.
15-
cc = "=1.2.13"
15+
cc = "=1.2.16"
1616
# tidy-alphabetical-end

0 commit comments

Comments
 (0)