Skip to content

Commit 60493b8

Browse files
committed
Auto merge of rust-lang#137790 - jieyouxu:rollup-jrib20h, r=jieyouxu
Rollup of 9 pull requests Successful merges: - rust-lang#136424 (fix: overflowing bin hex) - rust-lang#136824 (solver cycles are coinductive once they have one coinductive step) - rust-lang#137220 (Support `rust.channel = "auto-detect"`) - rust-lang#137712 (Clean up TypeckResults::extract_binding_mode) - rust-lang#137713 (Fix enzyme build errors) - rust-lang#137748 (Fix method name in `TyCtxt::hir_crate()` documentation) - rust-lang#137778 (update enzyme to handle range metadata) - rust-lang#137780 (Fix typo in query expansion documentation) - rust-lang#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

+2-2
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

+8-26
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

-4
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

+2-2
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

+1-1
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

+6
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

+32-36
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

+2-5
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

+1-1
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

+1-1
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

compiler/rustc_middle/src/query/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ rustc_queries! {
143143

144144
/// Represents crate as a whole (as distinct from the top-level crate module).
145145
///
146-
/// If you call `hir_crate` (e.g., indirectly by calling `tcx.hir().krate()`),
146+
/// If you call `hir_crate` (e.g., indirectly by calling `tcx.hir_crate()`),
147147
/// we will have to assume that any change means that you need to be recompiled.
148148
/// This is because the `hir_crate` query gives you access to all other items.
149-
/// To avoid this fate, do not call `tcx.hir().krate()`; instead,
150-
/// prefer wrappers like `tcx.visit_all_items_in_krate()`.
149+
/// To avoid this fate, do not call `tcx.hir_crate()`; instead,
150+
/// prefer wrappers like [`TyCtxt::hir_visit_all_item_likes_in_crate`].
151151
query hir_crate(key: ()) -> &'tcx Crate<'tcx> {
152152
arena_cache
153153
eval_always

compiler/rustc_middle/src/query/plumbing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ macro_rules! query_if_arena {
258258
};
259259
}
260260

261-
/// If `separate_provide_if_extern`, then the key can be projected to its
261+
/// If `separate_provide_extern`, then the key can be projected to its
262262
/// local key via `<$K as AsLocalKey>::LocalKey`.
263263
macro_rules! local_key_if_separate_extern {
264264
([] $($K:tt)*) => {

compiler/rustc_middle/src/ty/context.rs

+4
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,10 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
594594
self.trait_is_auto(trait_def_id)
595595
}
596596

597+
fn trait_is_coinductive(self, trait_def_id: DefId) -> bool {
598+
self.trait_is_coinductive(trait_def_id)
599+
}
600+
597601
fn trait_is_alias(self, trait_def_id: DefId) -> bool {
598602
self.trait_is_alias(trait_def_id)
599603
}

compiler/rustc_middle/src/ty/predicate.rs

-16
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use rustc_data_structures::intern::Interned;
44
use rustc_hir::def_id::DefId;
55
use rustc_macros::{HashStable, extension};
66
use rustc_type_ir as ir;
7-
use tracing::instrument;
87

98
use crate::ty::{
109
self, DebruijnIndex, EarlyBinder, PredicatePolarity, Ty, TyCtxt, TypeFlags, Upcast, UpcastFrom,
@@ -51,10 +50,6 @@ impl<'tcx> rustc_type_ir::inherent::Predicate<TyCtxt<'tcx>> for Predicate<'tcx>
5150
self.as_clause()
5251
}
5352

54-
fn is_coinductive(self, interner: TyCtxt<'tcx>) -> bool {
55-
self.is_coinductive(interner)
56-
}
57-
5853
fn allow_normalization(self) -> bool {
5954
self.allow_normalization()
6055
}
@@ -119,17 +114,6 @@ impl<'tcx> Predicate<'tcx> {
119114
Some(tcx.mk_predicate(kind))
120115
}
121116

122-
#[instrument(level = "debug", skip(tcx), ret)]
123-
pub fn is_coinductive(self, tcx: TyCtxt<'tcx>) -> bool {
124-
match self.kind().skip_binder() {
125-
ty::PredicateKind::Clause(ty::ClauseKind::Trait(data)) => {
126-
tcx.trait_is_coinductive(data.def_id())
127-
}
128-
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => true,
129-
_ => false,
130-
}
131-
}
132-
133117
/// Whether this projection can be soundly normalized.
134118
///
135119
/// Wf predicates must not be normalized, as normalization

compiler/rustc_middle/src/ty/typeck_results.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,10 @@ impl<'tcx> TypeckResults<'tcx> {
394394
matches!(self.type_dependent_defs().get(expr.hir_id), Some(Ok((DefKind::AssocFn, _))))
395395
}
396396

397-
pub fn extract_binding_mode(&self, s: &Session, id: HirId, sp: Span) -> Option<BindingMode> {
398-
self.pat_binding_modes().get(id).copied().or_else(|| {
397+
/// Returns the computed binding mode for a `PatKind::Binding` pattern
398+
/// (after match ergonomics adjustments).
399+
pub fn extract_binding_mode(&self, s: &Session, id: HirId, sp: Span) -> BindingMode {
400+
self.pat_binding_modes().get(id).copied().unwrap_or_else(|| {
399401
s.dcx().span_bug(sp, "missing binding mode");
400402
})
401403
}

0 commit comments

Comments
 (0)