Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
5e53d92
fix
bb1yd Jun 28, 2026
a0b3416
add safety section for mem::zeroed
hxuhack Apr 1, 2026
b78c8ac
Provide a `supertrait_def_ids()` function in rustc_type_ir's interner
ChayimFriedman2 Aug 21, 2026
940498d
fix const_item_mutation lint to use needs_drop instead of has_dtor
Rachit2323 Aug 24, 2026
98a157a
Add test for the fn item uniqueness note with late bound lifetimes
zakrad Aug 31, 2026
21228c2
Do not suppress the fn item uniqueness note for late bound lifetimes
zakrad Aug 31, 2026
4c3c97f
std: fix unix socket address panic on a full sun_path
devnexen Sep 13, 2026
ac0e9fa
First pass at windows::fs::FileExt.seek_read_exact()
json420 Sep 16, 2026
88af4fd
First pass at windows::fs::FileExt.seek_write_all()
json420 Sep 16, 2026
535fa77
Fix function signature in seek_read_exact(), duh
json420 Sep 16, 2026
5c56219
First pass at tests for .seek_read_exact(), seek_write_all()
json420 Sep 16, 2026
6df2dd9
Whitespace fix
json420 Sep 16, 2026
482f884
Use hypothetical seek_read_exact_seek_write_all feature also for .see…
json420 Sep 16, 2026
165e755
Tracking issues 162868
json420 Sep 16, 2026
fafa1ee
Oops, fix seek_write_all() doc example, was using write_all_at() still
json420 Sep 17, 2026
d179246
Add mocked test for windows FileExt trait
json420 Sep 17, 2026
c0785e4
Spelling fixes
json420 Sep 17, 2026
2adb748
Expand test for windows FileExt trait to include almost all scenarios
json420 Sep 17, 2026
1ee8475
Split three tests out of file_test_windows_fileext_trait()
json420 Sep 18, 2026
c9c5a06
Remove old versions of those 3 tests
json420 Sep 18, 2026
66a3b72
Split remaining file_test_windows_fileext_trait() into case 4, 5
json420 Sep 18, 2026
71f10b4
More test cleanup, always test expected_offset where possible
json420 Sep 18, 2026
e9aaeef
Test read first for consistency
json420 Sep 18, 2026
c2218a7
Use same doctsring examples as seek_read(), seek_write()
json420 Sep 18, 2026
6ac2b72
Missing period
json420 Sep 18, 2026
ee766dc
post GH comment on types nominations
lqd Sep 18, 2026
75b444d
Constify `impl FromStr for NonZero<T>`
sorairolake Sep 6, 2026
c30f2a4
Use `end_point` for trailing brace in `let...else` diagnostics
lapla-cogito Sep 19, 2026
1b3f10d
add Dir::try_clone
RalfJung Sep 19, 2026
bbdd298
Oops: actually call _exact(), _all() methods in case 2, 3
json420 Sep 19, 2026
6524ec5
Remove incorrect parse error recovery code that mistakes `as` casts f…
fmease Sep 12, 2026
c095a72
add test
inkreasing Sep 18, 2026
fe96227
recover true and false as bool type
inkreasing Sep 18, 2026
8026b7b
bless tests
inkreasing Sep 18, 2026
e224f8f
Further simplify `parse_assoc_op_cast`
fmease Sep 12, 2026
8a0a23d
Trigger "C array" parse error recovery in far fewer cases
fmease Sep 12, 2026
d80ee2c
Add missing seek_read_exact_seek_write_all feature flags in doc examples
json420 Sep 19, 2026
2e15f7b
Better account for `Self` that might be a typo of `self`
estebank Jul 27, 2026
48de0b2
Rollup merge of #158515 - bb1yd:let-else-detect-invisible-delimiter, …
JonathanBrouwer Sep 19, 2026
2071789
Rollup merge of #162726 - devnexen:socket_unix_fix, r=Mark-Simulacrum
JonathanBrouwer Sep 19, 2026
52bf796
Rollup merge of #160028 - estebank:issue-91525, r=jackh726
JonathanBrouwer Sep 19, 2026
0e16e85
Rollup merge of #160097 - Rachit2323:const-mutation-needs-drop, r=jac…
JonathanBrouwer Sep 19, 2026
fe8dca9
Rollup merge of #161435 - ChayimFriedman2:supertraits-query, r=jackh726
JonathanBrouwer Sep 19, 2026
5ffe3b4
Rollup merge of #161894 - zakrad:fix-fn-item-note-late-bound-145558, …
JonathanBrouwer Sep 19, 2026
95bb582
Rollup merge of #162990 - lqd:types-magic, r=Mark-Simulacrum
JonathanBrouwer Sep 19, 2026
e9c7617
Rollup merge of #154665 - safer-rust:fix-doc, r=Mark-Simulacrum
JonathanBrouwer Sep 19, 2026
79b7e6b
Rollup merge of #162700 - fmease:rm-dead-ascr-recov, r=fee1-dead
JonathanBrouwer Sep 19, 2026
d3de247
Rollup merge of #162705 - fmease:fix-c-array-diag, r=JonathanBrouwer
JonathanBrouwer Sep 19, 2026
576fd38
Rollup merge of #162875 - json420:seek_read_exact, r=clarfonthey
JonathanBrouwer Sep 19, 2026
1ed5764
Rollup merge of #162988 - inkreasing:attempt2-fix-162947, r=chenyukang
JonathanBrouwer Sep 19, 2026
123f86c
Rollup merge of #162995 - sorairolake:const-nonzero-from-str, r=jhpratt
JonathanBrouwer Sep 19, 2026
babf40f
Rollup merge of #163006 - lapla-cogito:letelse_fullwidthbrace, r=folk…
JonathanBrouwer Sep 19, 2026
61eaf00
Rollup merge of #163007 - RalfJung:dirfd-clone, r=ChrisDenton
JonathanBrouwer Sep 19, 2026
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
1 change: 1 addition & 0 deletions compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
call_expr_and_args.map_or(expr.span, |(e, _)| e.span),
expr.span,
expr.hir_id,
call_expr_and_args.is_some(),
)
.0
}
Expand Down
56 changes: 45 additions & 11 deletions compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
span: Span,
path_span: Span,
hir_id: HirId,
has_args: bool,
) -> (Ty<'tcx>, Res) {
let tcx = self.tcx;

Expand Down Expand Up @@ -1253,17 +1254,50 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
"the `Self` constructor can only be used with tuple or unit structs",
);
if let Some(adt_def) = ty.normalized.ty_adt_def() {
match adt_def.adt_kind() {
AdtKind::Enum => {
err.help("did you mean to use one of the enum's variants?");
}
AdtKind::Struct | AdtKind::Union => {
err.span_suggestion(
span,
"use curly brackets",
"Self { /* fields */ }",
Applicability::HasPlaceholders,
);
let def_id = self.body_def_id.to_def_id();
if !has_args
&& let Some(assoc) = tcx.opt_associated_item(def_id)
&& assoc.is_method()
{
let self_ty =
tcx.fn_sig(def_id).instantiate_identity().skip_binder().inputs()[0];
let applicability = if let ty::Adt(..) = self_ty.kind() {
// We're within a method that takes ownership of `Self`, likely a
// builder, so this is most likely a typo.
Applicability::MachineApplicable
} else {
// We still might have meant `self` instead of `Self`.
Applicability::MaybeIncorrect
};
err.span_suggestion_verbose(
span,
format!(
"you might have meant to refer to the `self` binding of type \
`{self_ty}`",
),
"self".to_string(),
applicability,
);
} else {
match adt_def.adt_kind() {
AdtKind::Enum => {
err.span_help(
tcx.def_span(adt_def.did()),
if adt_def.variants().is_empty() {
"the enum is unconstructable because it has no variants"
} else {
"you might have meant to use one of the enum's variants"
},
);
}
AdtKind::Struct | AdtKind::Union => {
err.span_suggestion_verbose(
span,
"use curly brackets",
"Self { /* fields */ }",
Applicability::HasPlaceholders,
);
}
}
}
}
Expand Down
11 changes: 7 additions & 4 deletions compiler/rustc_hir_typeck/src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
rustc_hir::PatExprKind::Path(qpath) => {
let (res, opt_ty, segments) =
self.resolve_ty_and_res_fully_qualified_call(qpath, lt.hir_id, lt.span);
self.instantiate_value_path(segments, opt_ty, res, lt.span, lt.span, lt.hir_id).0
self.instantiate_value_path(
segments, opt_ty, res, lt.span, lt.span, lt.hir_id, false,
)
.0
}
};
self.write_ty(lt.hir_id, ty);
Expand Down Expand Up @@ -1624,7 +1627,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

// Find the type of the path pattern, for later checking.
let (pat_ty, pat_res) =
self.instantiate_value_path(segments, opt_ty, res, span, span, path_id);
self.instantiate_value_path(segments, opt_ty, res, span, span, path_id, false);
Ok(ResolvedPat { ty: pat_ty, kind: ResolvedPatKind::Path { res, pat_res, segments } })
}

Expand Down Expand Up @@ -1784,8 +1787,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}

// Type-check the path.
let (pat_ty, res) =
self.instantiate_value_path(segments, opt_ty, res, pat.span, pat.span, pat.hir_id);
let (pat_ty, res) = self
.instantiate_value_path(segments, opt_ty, res, pat.span, pat.span, pat.hir_id, false);
if !pat_ty.is_fn() {
return report_unexpected_res(res);
}
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_middle/src/ty/context/impl_interner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,10 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
self.impl_super_outlives(impl_def_id)
}

fn supertrait_def_ids(self, trait_def_id: DefId) -> impl Iterator<Item = DefId> {
rustc_type_ir::elaborate::supertrait_def_ids(self, trait_def_id)
}

fn impl_is_const(self, def_id: DefId) -> bool {
debug_assert_matches!(self.def_kind(def_id), DefKind::Impl { of_trait: true });
self.is_conditionally_const(def_id)
Expand Down
40 changes: 25 additions & 15 deletions compiler/rustc_mir_transform/src/check_const_item_mutation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use rustc_hir::HirId;
use rustc_lint_defs::builtin::CONST_ITEM_MUTATION;
use rustc_middle::mir::visit::Visitor;
use rustc_middle::mir::*;
use rustc_middle::ty::TyCtxt;
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
use rustc_span::Span;
use rustc_span::def_id::DefId;

Expand Down Expand Up @@ -35,8 +35,9 @@ impl<'tcx> ConstMutationChecker<'_, 'tcx> {
fn is_const_item_without_destructor(&self, local: Local) -> Option<DefId> {
let def_id = self.is_const_item(local)?;

// We avoid linting mutation of a const item if the const's type has a
// Drop impl. The Drop logic observes the mutation which was performed.
// We avoid linting mutation of a const item if the const's type needs
// drop. Any drop logic (including that of fields) may observe the
// mutation which was performed.
//
// pub struct Log { msg: &'static str }
// pub const LOG: Log = Log { msg: "" };
Expand All @@ -46,21 +47,30 @@ impl<'tcx> ConstMutationChecker<'_, 'tcx> {
//
// LOG.msg = "wow"; // prints "wow"
//
// Likewise, if a field of the const type has its own Drop impl, that
// drop logic may also observe the mutation:
//
// struct Inner { val: u32 }
// impl Drop for Inner { fn drop(&mut self) { println!("{}", self.val); } }
// struct Outer { inner: Inner }
// const O: Outer = Outer { inner: Inner { val: 0 } };
//
// O.inner.val = 42; // Inner::drop prints "42"
//
// FIXME(https://github.com/rust-lang/rust/issues/77425):
// Drop this exception once there is a stable attribute to suppress the
// const item mutation lint for a single specific const only. Something
// equivalent to:
//
// #[const_mutation_allowed]
// pub const LOG: Log = Log { msg: "" };
// FIXME: this should not be checking for `Drop` impls,
// but whether it or any field has a Drop impl (`needs_drop`)
// as fields' Drop impls may make this observable, too.
match self.tcx.type_of(def_id).skip_binder().ty_adt_def().map(|adt| adt.has_dtor(self.tcx))
{
Some(true) => None,
Some(false) | None => Some(def_id),
// const item mutation lint for a single specific const only.
let ty = self.tcx.type_of(def_id).instantiate_identity().skip_norm_wip();
// `needs_drop` is overly conservative for types that contain type
// parameters (e.g. `Self` in a trait associated const): it always
// returns `true` because the parameter *might* implement Drop, even
// when the concrete type at the call site does not. In that case we
// cannot suppress the lint, so fall through and warn.
if ty.has_param() {
return Some(def_id);
}
let typing_env = ty::TypingEnv::non_body_analysis(self.tcx, def_id);
if ty.needs_drop(self.tcx, typing_env) { None } else { Some(def_id) }
}

/// If we should lint on this usage, return the [`HirId`], source [`Span`]
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_next_trait_solver/src/solve/trait_goals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,8 @@ where
.auto_traits()
.into_iter()
.chain(a_data.principal_def_id().into_iter().flat_map(|principal_def_id| {
elaborate::supertrait_def_ids(self.cx(), principal_def_id)
self.cx()
.supertrait_def_ids(principal_def_id)
.filter(|def_id| self.cx().trait_is_auto(*def_id))
}))
.collect();
Expand Down
Loading
Loading