Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
cbae956
Fix tests for big-endian
fneddy Oct 20, 2025
0246980
Fix not applicable on while for replace_is_method_with_if_let_method
A4-Tacks Oct 27, 2025
e7fb68a
Properly support opaques
ChayimFriedman2 Oct 24, 2025
023c4ef
When renaming `self` to other name, change callers method method call…
ChayimFriedman2 Aug 2, 2025
ec84b26
Merge pull request #20369 from ChayimFriedman2/rename-self2
ChayimFriedman2 Oct 27, 2025
74b2a94
Consider all matches for flyimport even when searched with a qualifier
ChayimFriedman2 Oct 27, 2025
3009a73
fix: Resolve `target-dir` more precisely
ShoyuVanilla Oct 27, 2025
512abf6
Merge pull request #20919 from ChayimFriedman2/qualifier-many-flyimport
ShoyuVanilla Oct 27, 2025
506341b
Avoid calling `specializes()` query on crates that do not define `#![…
ChayimFriedman2 Oct 27, 2025
778a318
Merge pull request #20921 from ChayimFriedman2/specialization-ns2
ChayimFriedman2 Oct 27, 2025
0c108b1
perf: Reduce `client_commands` allocations in proto conversion
Veykril Oct 27, 2025
0e60684
Merge pull request #20922 from Veykril/veykril/push-pznvunxxozkq
Veykril Oct 27, 2025
540df3d
Provide an option to not show derives near the ADT for "Goto Implemen…
ChayimFriedman2 Jul 6, 2025
6aed15e
Merge pull request #20186 from ChayimFriedman2/goto-impl-no-derive
ChayimFriedman2 Oct 28, 2025
ae2818d
fix: Canonicalize flycheck output path
ShoyuVanilla Oct 28, 2025
5fc223d
Merge pull request #20915 from A4-Tacks/is-method-with-while-let
ShoyuVanilla Oct 28, 2025
a6f4d1d
Merge pull request #20906 from ChayimFriedman2/opaques-ns
ShoyuVanilla Oct 28, 2025
13834a0
Fix handling of blocks modules that are not the root module
ChayimFriedman2 Oct 28, 2025
4d338cb
Support memory profiling with dhat
ChayimFriedman2 Oct 28, 2025
360720b
Merge pull request #20930 from ChayimFriedman2/builtin-res-block
ShoyuVanilla Oct 28, 2025
0ceb668
Show proper async function signatures in the signature help
SomeoneToIgnore Oct 27, 2025
7c62a30
Merge pull request #20931 from SomeoneToIgnore/async-signature
ChayimFriedman2 Oct 28, 2025
5f0c7c2
fix: Improve error recovery when parsing malformed function return types
Veykril Oct 29, 2025
d9c3ba7
Merge pull request #20934 from Veykril/veykril/push-qtzmsqkzntpo
Veykril Oct 29, 2025
008c60d
minor: Cleanup `map_rust_child_diagnostics` a bit
Veykril Aug 2, 2025
ad13b1a
Merge pull request #20366 from Veykril/push-lmmtrpptrxom
Veykril Oct 30, 2025
2ac9a9a
fix: Do not make false positive syntax errors on frontmatter
ShoyuVanilla Oct 30, 2025
1c07f88
Merge pull request #20942 from ShoyuVanilla/frontmatter-err
ShoyuVanilla Oct 30, 2025
fd378ce
Fix typos, backtick errors/omissions
jhpratt Oct 31, 2025
be6574b
Merge pull request #20945 from jhpratt/master
ShoyuVanilla Oct 31, 2025
7a33724
Merge pull request #20927 from ChayimFriedman2/dhat
ShoyuVanilla Oct 31, 2025
60c230b
compiler: Fix a couple issues around cargo feature unification
jyn514 Oct 31, 2025
599c379
Fix building with DHAT
ChayimFriedman2 Nov 1, 2025
39cc97c
Merge pull request #20956 from ChayimFriedman2/fix-dhat
ChayimFriedman2 Nov 1, 2025
103f094
Merge pull request #20920 from ShoyuVanilla/target-dirs
ShoyuVanilla Nov 2, 2025
365798d
Fix missing other assoc items for generate_blanket_trait_impl
A4-Tacks Nov 2, 2025
116bd92
Always point at trait assoc item when generics don't match
estebank Jan 16, 2025
0d7ef4f
Look at the current `impl` before suggesting adding a lifetime
estebank Jan 16, 2025
04804c7
Tweak wording in associated type with anon lifetime error
estebank Jan 17, 2025
0a27256
review comments
estebank Aug 12, 2025
4e09cd1
fix tidy
estebank Nov 3, 2025
817cf4b
fix tests
estebank Nov 3, 2025
449576a
Prepare for merging from rust-lang/rust
invalid-email-address Nov 3, 2025
3dae6b6
Merge ref 'c5dabe8cf798' from rust-lang/rust
invalid-email-address Nov 3, 2025
1625b1e
Merge pull request #20957 from A4-Tacks/blanket-assoc-items
ShoyuVanilla Nov 3, 2025
236b89e
Add more expression to 'in_value'
A4-Tacks Nov 3, 2025
fdaf4fa
fix: Expand literals with wrong suffixes into `LitKind::Err`
ShoyuVanilla Nov 3, 2025
f311196
fix: Canonicalize `custom-target.json` paths when fetching sysroot me…
ShoyuVanilla Nov 3, 2025
493829c
Merge pull request #20964 from ShoyuVanilla/canonicalize-tgts
Veykril Nov 3, 2025
94f3ded
Merge pull request #20963 from ShoyuVanilla/lit-suffix
Veykril Nov 3, 2025
9533fd7
Merge pull request #20961 from A4-Tacks/more-in-value
ShoyuVanilla Nov 4, 2025
9e9ea26
Add ide-assist: convert_range_for_to_while
A4-Tacks Aug 29, 2025
a925768
Add dynamic assistant description
A4-Tacks Nov 4, 2025
9cec431
Merge pull request #20565 from A4-Tacks/conv-range-for-to-while
ShoyuVanilla Nov 4, 2025
fe6abc7
Fix test name
ChayimFriedman2 Nov 4, 2025
934b58e
Merge pull request #20966 from ChayimFriedman2/fix-test-name
ChayimFriedman2 Nov 4, 2025
d81d5f0
Fix test URL
lnicola Nov 4, 2025
5873327
Merge pull request #20960 from rust-lang/rustc-pull
lnicola Nov 4, 2025
7e5bb04
Rollup merge of #145314 - estebank:issue-135589-all, r=Nadrieril
matthiaskrgr Nov 4, 2025
b5378a1
Rollup merge of #147925 - fneddy:fix_big_endian_GVN_tests, r=saethlin
matthiaskrgr Nov 4, 2025
5157b60
Rollup merge of #148341 - jyn514:feature-unification, r=BoxyUwU
matthiaskrgr Nov 4, 2025
3615a26
Rollup merge of #148471 - lnicola:sync-from-ra, r=lnicola
matthiaskrgr Nov 4, 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
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1097,14 +1097,14 @@ fn check_region_bounds_on_impl_item<'tcx>(
.expect("expected impl item to have generics or else we can't compare them")
.span;

let mut generics_span = None;
let mut generics_span = tcx.def_span(trait_m.def_id);
let mut bounds_span = vec![];
let mut where_span = None;

if let Some(trait_node) = tcx.hir_get_if_local(trait_m.def_id)
&& let Some(trait_generics) = trait_node.generics()
{
generics_span = Some(trait_generics.span);
generics_span = trait_generics.span;
// FIXME: we could potentially look at the impl's bounds to not point at bounds that
// *are* present in the impl.
for p in trait_generics.predicates {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ pub(crate) struct LifetimesOrBoundsMismatchOnTrait {
#[label]
pub span: Span,
#[label(hir_analysis_generics_label)]
pub generics_span: Option<Span>,
pub generics_span: Span,
#[label(hir_analysis_where_label)]
pub where_span: Option<Span>,
#[label(hir_analysis_bounds_label)]
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_index/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2024"
rustc_index_macros = { path = "../rustc_index_macros" }
rustc_macros = { path = "../rustc_macros", optional = true }
rustc_serialize = { path = "../rustc_serialize", optional = true }
smallvec = "1.8.1"
smallvec = { version = "1.8.1", optional = true }
# tidy-alphabetical-end

[features]
Expand All @@ -17,6 +17,7 @@ default = ["nightly"]
nightly = [
"dep:rustc_macros",
"dep:rustc_serialize",
"dep:smallvec",
"rustc_index_macros/nightly",
]
rustc_randomized_layouts = []
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_resolve/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ resolve_added_macro_use =
resolve_ancestor_only =
visibilities can only be restricted to ancestor modules

resolve_anonymous_lifetime_non_gat_report_error =
in the trait associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
resolve_anonymous_lifetime_non_gat_report_error = missing lifetime in associated type
.label = this lifetime must come from the implemented type
.note = in the trait the associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type

resolve_arguments_macro_use_not_allowed = arguments to `macro_use` are not allowed here

Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_resolve/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,8 @@ pub(crate) struct AnonymousLifetimeNonGatReportError {
#[primary_span]
#[label]
pub(crate) lifetime: Span,
#[note]
pub(crate) decl: MultiSpan,
}

#[derive(Subdiagnostic)]
Expand Down
110 changes: 95 additions & 15 deletions compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::assert_matches::debug_assert_matches;
use std::borrow::Cow;
use std::collections::hash_map::Entry;
use std::mem::{replace, swap, take};
use std::ops::ControlFlow;

use rustc_ast::visit::{
AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor, try_visit, visit_opt, walk_list,
Expand All @@ -19,21 +20,21 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
use rustc_data_structures::unord::{UnordMap, UnordSet};
use rustc_errors::codes::*;
use rustc_errors::{
Applicability, Diag, DiagArgValue, ErrorGuaranteed, IntoDiagArg, StashKey, Suggestions,
pluralize,
Applicability, Diag, DiagArgValue, ErrorGuaranteed, IntoDiagArg, MultiSpan, StashKey,
Suggestions, pluralize,
};
use rustc_hir::def::Namespace::{self, *};
use rustc_hir::def::{self, CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS};
use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LOCAL_CRATE, LocalDefId};
use rustc_hir::{MissingLifetimeKind, PrimTy, TraitCandidate};
use rustc_middle::middle::resolve_bound_vars::Set1;
use rustc_middle::ty::{DelegationFnSig, Visibility};
use rustc_middle::ty::{AssocTag, DelegationFnSig, Visibility};
use rustc_middle::{bug, span_bug};
use rustc_session::config::{CrateType, ResolveDocLinks};
use rustc_session::lint;
use rustc_session::parse::feature_err;
use rustc_span::source_map::{Spanned, respan};
use rustc_span::{BytePos, Ident, Span, Symbol, SyntaxContext, kw, sym};
use rustc_span::{BytePos, DUMMY_SP, Ident, Span, Symbol, SyntaxContext, kw, sym};
use smallvec::{SmallVec, smallvec};
use thin_vec::ThinVec;
use tracing::{debug, instrument, trace};
Expand Down Expand Up @@ -373,11 +374,14 @@ enum LifetimeBinderKind {
FnPtrType,
PolyTrait,
WhereBound,
// Item covers foreign items, ADTs, type aliases, trait associated items and
// trait alias associated items.
Item,
ConstItem,
Function,
Closure,
ImplBlock,
// Covers only `impl` associated types.
ImplAssocType,
}

Expand Down Expand Up @@ -724,6 +728,9 @@ pub(crate) struct DiagMetadata<'ast> {
/// The current impl items (used to suggest).
current_impl_items: Option<&'ast [Box<AssocItem>]>,

/// The current impl items (used to suggest).
current_impl_item: Option<&'ast AssocItem>,

/// When processing impl trait
currently_processing_impl_trait: Option<(TraitRef, Ty)>,

Expand Down Expand Up @@ -1880,9 +1887,31 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
ty: ty.span,
});
} else {
let decl = if !trait_id.is_local()
&& let Some(assoc) = self.diag_metadata.current_impl_item
&& let AssocItemKind::Type(_) = assoc.kind
&& let assocs = self.r.tcx.associated_items(trait_id)
&& let Some(ident) = assoc.kind.ident()
&& let Some(assoc) = assocs.find_by_ident_and_kind(
self.r.tcx,
ident,
AssocTag::Type,
trait_id,
) {
let mut decl: MultiSpan =
self.r.tcx.def_span(assoc.def_id).into();
decl.push_span_label(
self.r.tcx.def_span(trait_id),
String::new(),
);
decl
} else {
DUMMY_SP.into()
};
let mut err = self.r.dcx().create_err(
errors::AnonymousLifetimeNonGatReportError {
lifetime: lifetime.ident.span,
decl,
},
);
self.point_at_impl_lifetimes(&mut err, i, lifetime.ident.span);
Expand Down Expand Up @@ -1924,17 +1953,13 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
}

fn point_at_impl_lifetimes(&mut self, err: &mut Diag<'_>, i: usize, lifetime: Span) {
let Some((rib, span)) = self.lifetime_ribs[..i]
.iter()
.rev()
.skip(1)
.filter_map(|rib| match rib.kind {
let Some((rib, span)) =
self.lifetime_ribs[..i].iter().rev().find_map(|rib| match rib.kind {
LifetimeRibKind::Generics { span, kind: LifetimeBinderKind::ImplBlock, .. } => {
Some((rib, span))
}
_ => None,
})
.next()
else {
return;
};
Expand All @@ -1956,11 +1981,63 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
);
}
} else {
err.span_label(
span,
"you could add a lifetime on the impl block, if the trait or the self type can \
have one",
);
struct AnonRefFinder;
impl<'ast> Visitor<'ast> for AnonRefFinder {
type Result = ControlFlow<Span>;

fn visit_ty(&mut self, ty: &'ast ast::Ty) -> Self::Result {
if let ast::TyKind::Ref(None, mut_ty) = &ty.kind {
return ControlFlow::Break(mut_ty.ty.span.shrink_to_lo());
}
visit::walk_ty(self, ty)
}

fn visit_lifetime(
&mut self,
lt: &'ast ast::Lifetime,
_cx: visit::LifetimeCtxt,
) -> Self::Result {
if lt.ident.name == kw::UnderscoreLifetime {
return ControlFlow::Break(lt.ident.span);
}
visit::walk_lifetime(self, lt)
}
}

if let Some(ty) = &self.diag_metadata.current_self_type
&& let ControlFlow::Break(sp) = AnonRefFinder.visit_ty(ty)
{
err.multipart_suggestion_verbose(
"add a lifetime to the impl block and use it in the self type and associated \
type",
vec![
(span, "<'a>".to_string()),
(sp, "'a ".to_string()),
(lifetime.shrink_to_hi(), "'a ".to_string()),
],
Applicability::MaybeIncorrect,
);
} else if let Some(item) = &self.diag_metadata.current_item
&& let ItemKind::Impl(impl_) = &item.kind
&& let Some(of_trait) = &impl_.of_trait
&& let ControlFlow::Break(sp) = AnonRefFinder.visit_trait_ref(&of_trait.trait_ref)
{
err.multipart_suggestion_verbose(
"add a lifetime to the impl block and use it in the trait and associated type",
vec![
(span, "<'a>".to_string()),
(sp, "'a".to_string()),
(lifetime.shrink_to_hi(), "'a ".to_string()),
],
Applicability::MaybeIncorrect,
);
} else {
err.span_label(
span,
"you could add a lifetime on the impl block, if the trait or the self type \
could have one",
);
}
}
}

Expand Down Expand Up @@ -3304,6 +3381,8 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
) {
use crate::ResolutionError::*;
self.resolve_doc_links(&item.attrs, MaybeExported::ImplItem(trait_id.ok_or(&item.vis)));
let prev = self.diag_metadata.current_impl_item.take();
self.diag_metadata.current_impl_item = Some(&item);
match &item.kind {
AssocItemKind::Const(box ast::ConstItem {
ident,
Expand Down Expand Up @@ -3452,6 +3531,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
panic!("unexpanded macro in resolve!")
}
}
self.diag_metadata.current_impl_item = prev;
}

fn check_trait_item<F>(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_type_ir_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ proc-macro = true
# tidy-alphabetical-start
proc-macro2 = "1"
quote = "1"
syn = { version = "2.0.9", features = ["full"] }
syn = { version = "2.0.9", features = ["full", "visit-mut"] }
synstructure = "0.13.0"
# tidy-alphabetical-end
1 change: 1 addition & 0 deletions src/tools/rust-analyzer/.typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ trivias = "trivias"
thir = "thir"
jod = "jod"
tructure = "tructure"
taits = "taits"

[default.extend-identifiers]
anc = "anc"
Expand Down
32 changes: 31 additions & 1 deletion src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,22 @@ dependencies = [
"syn",
]

[[package]]
name = "dhat"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98cd11d84628e233de0ce467de10b8633f4ddaecafadefc86e13b84b8739b827"
dependencies = [
"backtrace",
"lazy_static",
"mintex",
"parking_lot",
"rustc-hash 1.1.0",
"serde",
"serde_json",
"thousands",
]

[[package]]
name = "dirs"
version = "6.0.0"
Expand Down Expand Up @@ -1383,6 +1399,12 @@ dependencies = [
"adler2",
]

[[package]]
name = "mintex"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c505b3e17ed6b70a7ed2e67fbb2c560ee327353556120d6e72f5232b6880d536"

[[package]]
name = "mio"
version = "1.1.0"
Expand Down Expand Up @@ -1452,7 +1474,7 @@ version = "0.50.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
dependencies = [
"windows-sys 0.60.2",
"windows-sys 0.61.0",
]

[[package]]
Expand Down Expand Up @@ -2011,6 +2033,7 @@ dependencies = [
"cargo_metadata 0.21.0",
"cfg",
"crossbeam-channel",
"dhat",
"dirs",
"dissimilar",
"expect-test",
Expand Down Expand Up @@ -2047,6 +2070,7 @@ dependencies = [
"serde",
"serde_derive",
"serde_json",
"smallvec",
"stdx",
"syntax",
"syntax-bridge",
Expand Down Expand Up @@ -2528,6 +2552,12 @@ dependencies = [
"syn",
]

[[package]]
name = "thousands"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820"

[[package]]
name = "thread_local"
version = "1.1.9"
Expand Down
Loading
Loading