Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a2dce77
Start documenting autodiff activities
ZuseZ4 Oct 28, 2025
f4efc37
feat: Add `bit_width` for unsigned `NonZero<T>`
sorairolake Nov 10, 2025
740b8ba
Make SIMD intrinsics available in `const`-contexts
sayantn Nov 3, 2025
47384f7
add check for when span is from macro expansion
Kivooeo Nov 12, 2025
f5892da
add autodiff examples
ZuseZ4 Nov 12, 2025
82ff614
Enable const-testing for the ported SIMD intrinsics
sayantn Nov 16, 2025
754a82d
recommend using a HashMap if a HashSet's second generic parameter doe…
Qelxiros Sep 30, 2025
1cfd0b7
Match <OsString as Debug>::fmt to that of str
tamird Aug 7, 2023
eb84efc
Remove <os::Vars as Debug> workaround
tamird Aug 13, 2023
a25950d
feat: Change return type of `NonZero::bit_width`
sorairolake Nov 18, 2025
0b2e02f
autodiff: update formating, improve examples for the unstable-book
ZuseZ4 Nov 19, 2025
847c422
Rollup merge of #147171 - Qelxiros:hashmap_diag, r=fee1-dead
matthiaskrgr Nov 19, 2025
2cc5bf7
Rollup merge of #147421 - Kivooeo:ice-fix51621, r=chenyukang
matthiaskrgr Nov 19, 2025
714f1ce
Rollup merge of #147521 - sayantn:simd-const-intrinsics, r=madsmtm
matthiaskrgr Nov 19, 2025
3732c3c
Rollup merge of #148201 - ZuseZ4:autodiff-activity-docs, r=oli-obk
matthiaskrgr Nov 19, 2025
8b74790
Rollup merge of #148797 - sorairolake:feature/non-zero-uint-bit-width…
matthiaskrgr Nov 19, 2025
48fa913
Rollup merge of #148798 - tamird:esc-single-quote, r=Amanieu
matthiaskrgr Nov 19, 2025
fd88e61
Rollup merge of #149082 - ZuseZ4:autodiff-unstable-book-fmt, r=chenyu…
matthiaskrgr Nov 19, 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
58 changes: 50 additions & 8 deletions compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.note(note);
}

if let ty::Adt(adt_def, _) = rcvr_ty.kind() {
unsatisfied_predicates.iter().find(|(pred, _parent, _cause)| {
if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) =
pred.kind().skip_binder()
{
self.suggest_hashmap_on_unsatisfied_hashset_buildhasher(
err, &pred, *adt_def,
)
} else {
false
}
});
}

*suggested_derive = self.suggest_derive(err, unsatisfied_predicates);
*unsatisfied_bounds = true;
}
Expand Down Expand Up @@ -2990,7 +3004,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.filter_map(|e| match e.obligation.predicate.kind().skip_binder() {
ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) => {
match pred.self_ty().kind() {
ty::Adt(_, _) => Some(pred),
ty::Adt(_, _) => Some((e.root_obligation.predicate, pred)),
_ => None,
}
}
Expand All @@ -3000,18 +3014,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

// Note for local items and foreign items respectively.
let (mut local_preds, mut foreign_preds): (Vec<_>, Vec<_>) =
preds.iter().partition(|&pred| {
preds.iter().partition(|&(_, pred)| {
if let ty::Adt(def, _) = pred.self_ty().kind() {
def.did().is_local()
} else {
false
}
});

local_preds.sort_by_key(|pred: &&ty::TraitPredicate<'_>| pred.trait_ref.to_string());
local_preds.sort_by_key(|(_, pred)| pred.trait_ref.to_string());
let local_def_ids = local_preds
.iter()
.filter_map(|pred| match pred.self_ty().kind() {
.filter_map(|(_, pred)| match pred.self_ty().kind() {
ty::Adt(def, _) => Some(def.did()),
_ => None,
})
Expand All @@ -3024,7 +3038,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
})
.collect::<Vec<_>>()
.into();
for pred in &local_preds {
for (_, pred) in &local_preds {
if let ty::Adt(def, _) = pred.self_ty().kind() {
local_spans.push_span_label(
self.tcx.def_span(def.did()),
Expand All @@ -3033,7 +3047,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
if local_spans.primary_span().is_some() {
let msg = if let [local_pred] = local_preds.as_slice() {
let msg = if let [(_, local_pred)] = local_preds.as_slice() {
format!(
"an implementation of `{}` might be missing for `{}`",
local_pred.trait_ref.print_trait_sugared(),
Expand All @@ -3051,9 +3065,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.span_note(local_spans, msg);
}

foreign_preds.sort_by_key(|pred: &&ty::TraitPredicate<'_>| pred.trait_ref.to_string());
foreign_preds
.sort_by_key(|(_, pred): &(_, ty::TraitPredicate<'_>)| pred.trait_ref.to_string());

for pred in foreign_preds {
for (_, pred) in &foreign_preds {
let ty = pred.self_ty();
let ty::Adt(def, _) = ty.kind() else { continue };
let span = self.tcx.def_span(def.did());
Expand All @@ -3066,6 +3081,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
mspan,
format!("`{ty}` does not implement `{}`", pred.trait_ref.print_trait_sugared()),
);

foreign_preds.iter().find(|&(root_pred, pred)| {
if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(root_pred)) =
root_pred.kind().skip_binder()
&& let Some(root_adt) = root_pred.self_ty().ty_adt_def()
{
self.suggest_hashmap_on_unsatisfied_hashset_buildhasher(err, pred, root_adt)
} else {
false
}
});
}

let preds: Vec<_> = errors
Expand Down Expand Up @@ -4388,6 +4414,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

self.autoderef(span, rcvr_ty).silence_errors().any(|(ty, _)| is_local(ty))
}

fn suggest_hashmap_on_unsatisfied_hashset_buildhasher(
&self,
err: &mut Diag<'_>,
pred: &ty::TraitPredicate<'_>,
adt: ty::AdtDef<'_>,
) -> bool {
if self.tcx.is_diagnostic_item(sym::HashSet, adt.did())
&& self.tcx.is_diagnostic_item(sym::BuildHasher, pred.def_id())
{
err.help("you might have intended to use a HashMap instead");
true
} else {
false
}
}
}

#[derive(Copy, Clone, Debug)]
Expand Down
12 changes: 9 additions & 3 deletions compiler/rustc_lint/src/shadowed_into_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ impl<'tcx> LateLintPass<'tcx> for ShadowedIntoIter {
return;
};

// This check needs to avoid ICE from when `receiver_arg` is from macro expansion
// Which leads to empty span in span arithmetic below
// cc: https://github.com/rust-lang/rust/issues/147408
let span = receiver_arg.span.find_ancestor_in_same_ctxt(expr.span);

// If this expression comes from the `IntoIter::into_iter` inside of a for loop,
// we should just suggest removing the `.into_iter()` or changing it to `.iter()`
// to disambiguate if we want to iterate by-value or by-ref.
Expand All @@ -134,14 +139,15 @@ impl<'tcx> LateLintPass<'tcx> for ShadowedIntoIter {
&& let hir::ExprKind::Call(path, [_]) = &arg.kind
&& let hir::ExprKind::Path(qpath) = path.kind
&& cx.tcx.qpath_is_lang_item(qpath, LangItem::IntoIterIntoIter)
&& let Some(span) = span
{
Some(ShadowedIntoIterDiagSub::RemoveIntoIter {
span: receiver_arg.span.shrink_to_hi().to(expr.span.shrink_to_hi()),
span: span.shrink_to_hi().to(expr.span.shrink_to_hi()),
})
} else if can_suggest_ufcs {
} else if can_suggest_ufcs && let Some(span) = span {
Some(ShadowedIntoIterDiagSub::UseExplicitIntoIter {
start_span: expr.span.shrink_to_lo(),
end_span: receiver_arg.span.shrink_to_hi().to(expr.span.shrink_to_hi()),
end_span: span.shrink_to_hi().to(expr.span.shrink_to_hi()),
})
} else {
None
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ symbols! {
Borrow,
BorrowMut,
Break,
BuildHasher,
C,
CStr,
C_dash_unwind: "C-unwind",
Expand Down
3 changes: 3 additions & 0 deletions library/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ optimize_for_size = []
# Make `RefCell` store additional debugging information, which is printed out when
# a borrow error occurs
debug_refcell = []
llvm_enzyme = []

[lints.rust.unexpected_cfgs]
level = "warn"
Expand All @@ -38,4 +39,6 @@ check-cfg = [
'cfg(target_has_reliable_f16_math)',
'cfg(target_has_reliable_f128)',
'cfg(target_has_reliable_f128_math)',
'cfg(llvm_enzyme)',

]
1 change: 1 addition & 0 deletions library/core/src/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ impl<H: Hasher + ?Sized> Hasher for &mut H {
///
/// [`build_hasher`]: BuildHasher::build_hasher
/// [`HashMap`]: ../../std/collections/struct.HashMap.html
#[cfg_attr(not(test), rustc_diagnostic_item = "BuildHasher")]
#[stable(since = "1.7.0", feature = "build_hasher")]
pub trait BuildHasher {
/// Type of the hasher that will be created.
Expand Down
Loading
Loading