Skip to content

Rollup of 10 pull requests #144502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Jul 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4304b7b
add rdg push git config entry for git protocol pushers (again)
tshepang Jul 21, 2025
c8ef211
already documented elsewhere
tshepang Jul 21, 2025
ff2bfe0
Merge pull request #2514 from rust-lang/tshepang/for-ssh-protocol
Kobzol Jul 21, 2025
9ae298c
typo
tshepang Jul 21, 2025
44bec00
Merge pull request #2515 from rust-lang/tshepang-patch-1
tshepang Jul 21, 2025
acb0e71
Make lints work with `allow_internal_unstable`
Jules-Bertholet Oct 30, 2023
6c96e7a
Update josh sync documentation
Kobzol Jul 23, 2025
8a1b20e
Disable non_exhaustive_omitted_patterns within matches! macro
jplatte Jul 22, 2025
0e30629
Add regression test for matches! + non_exhaustive_omitted_patterns lint
jplatte Jul 23, 2025
78fc7c3
Suggest unwrapping when private method name is available in inner type
estebank Jul 23, 2025
1115345
Prepare for merging from rust-lang/rust
invalid-email-address Jul 24, 2025
e5b1e7d
Merge ref 'efd420c770bb' from rust-lang/rust
invalid-email-address Jul 24, 2025
1ecb68d
Merge pull request #2517 from Kobzol/josh-sync
Kobzol Jul 24, 2025
a2b3d81
Call `is_parsed_attribute` rather than keeping track of a list of par…
JonathanBrouwer Jul 24, 2025
97676e6
Allow setting `release-blog-post` label with rustbot
BoxyUwU Jul 24, 2025
e69303f
Merge pull request #2518 from rust-lang/rustc-pull
tshepang Jul 25, 2025
cf4d793
Limit defaultness to impl of trait
camsteffen Jul 24, 2025
b96f238
rename ext_tool_checks to extra_checks and use mod.rs
lolbinarycat Jul 25, 2025
e01753d
change_tracker: fix a typo
ognevny Jul 25, 2025
4ef18ab
Allow pretty printing paths with `-Zself-profile-events=args`
Kobzol Jul 25, 2025
25ed288
Update mir-opt expected output for matches! macro
jplatte Jul 25, 2025
2c65790
resolve: Minimize borrow scopes for `resolutions`
petrochenkov Jul 25, 2025
e820112
resolve: Do not create `NameResolution`s on access unless necessary
petrochenkov Jul 25, 2025
c9541a2
Rollup merge of #144331 - jplatte:matches-allow-non_exhaustive_omitte…
matthiaskrgr Jul 26, 2025
43096cc
Rollup merge of #144376 - estebank:issue-143795, r=lcnr
matthiaskrgr Jul 26, 2025
b2659bf
Rollup merge of #144421 - JonathanBrouwer:cleanup-malformed-list, r=o…
matthiaskrgr Jul 26, 2025
86fbbb8
Rollup merge of #144424 - BoxyUwU:release_blog_post_unauthorized_user…
matthiaskrgr Jul 26, 2025
d2d002e
Rollup merge of #144427 - lolbinarycat:tidy-extra_checks-rename, r=Ko…
matthiaskrgr Jul 26, 2025
e2a5862
Rollup merge of #144435 - tshepang:rdg-sync, r=jieyouxu
matthiaskrgr Jul 26, 2025
d88aa06
Rollup merge of #144448 - camsteffen:defaultness-impl-trait-only, r=c…
matthiaskrgr Jul 26, 2025
576af9b
Rollup merge of #144462 - Kobzol:pretty-print-self-profile-args, r=Ra…
matthiaskrgr Jul 26, 2025
093d726
Rollup merge of #144463 - ognevny:change-tracker-typo, r=Kobzol
matthiaskrgr Jul 26, 2025
429cc9a
Rollup merge of #144468 - petrochenkov:resolution, r=lqd,SparrowLii
matthiaskrgr Jul 26, 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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4255,6 +4255,7 @@ dependencies = [
"rustc-literal-escaper",
"rustc_ast",
"rustc_ast_pretty",
"rustc_attr_parsing",
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_data_structures/src/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,11 @@ impl SelfProfilerRef {
pub fn get_self_profiler(&self) -> Option<Arc<SelfProfiler>> {
self.profiler.clone()
}

/// Is expensive recording of query keys and/or function arguments enabled?
pub fn is_args_recording_enabled(&self) -> bool {
self.enabled() && self.event_filter_mask.intersects(EventFilter::ARGS)
}
}

/// A helper for recording costly arguments to self-profiling events. Used with
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.span_label(within_macro_span, "due to this macro variable");
}
self.suggest_valid_traits(&mut err, item_name, out_of_scope_traits, true);
self.suggest_unwrapping_inner_self(&mut err, source, rcvr_ty, item_name);
err.emit()
}

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_lint/src/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
fn check_gated_lint(&self, lint_id: LintId, span: Span, lint_from_cli: bool) -> bool {
let feature = if let Some(feature) = lint_id.lint.feature_gate
&& !self.features.enabled(feature)
&& !span.allows_unstable(feature)
{
// Lint is behind a feature that is not enabled; eventually return false.
feature
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2124,11 +2124,11 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
};
let def_id = id.owner_id.to_def_id();

self.tables.defaultness.set_some(def_id.index, tcx.defaultness(def_id));

if of_trait && let Some(header) = tcx.impl_trait_header(def_id) {
record!(self.tables.impl_trait_header[def_id] <- header);

self.tables.defaultness.set_some(def_id.index, tcx.defaultness(def_id));

let trait_ref = header.trait_ref.instantiate_identity();
let simplified_self_ty = fast_reject::simplify_type(
self.tcx,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_parse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ bitflags = "2.4.1"
rustc-literal-escaper = "0.0.5"
rustc_ast = { path = "../rustc_ast" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_feature = { path = "../rustc_feature" }
Expand Down
65 changes: 4 additions & 61 deletions compiler/rustc_parse/src/validate_attr.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
//! Meta-syntax validation logic of attributes for post-expansion.

use std::slice;

use rustc_ast::token::Delimiter;
use rustc_ast::tokenstream::DelimSpan;
use rustc_ast::{
self as ast, AttrArgs, Attribute, DelimArgs, MetaItem, MetaItemInner, MetaItemKind, NodeId,
Path, Safety,
};
use rustc_attr_parsing::{AttributeParser, Late};
use rustc_errors::{Applicability, DiagCtxtHandle, FatalError, PResult};
use rustc_feature::{AttributeSafety, AttributeTemplate, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute};
use rustc_session::errors::report_lit_error;
Expand Down Expand Up @@ -266,67 +269,7 @@ pub fn check_builtin_meta_item(
) {
if !is_attr_template_compatible(&template, &meta.kind) {
// attrs with new parsers are locally validated so excluded here
if matches!(
name,
sym::inline
| sym::export_stable
| sym::ffi_const
| sym::ffi_pure
| sym::rustc_std_internal_symbol
| sym::may_dangle
| sym::rustc_as_ptr
| sym::rustc_pub_transparent
| sym::rustc_const_stable_indirect
| sym::rustc_force_inline
| sym::rustc_confusables
| sym::rustc_skip_during_method_dispatch
| sym::rustc_pass_by_value
| sym::rustc_deny_explicit_impl
| sym::rustc_do_not_implement_via_object
| sym::rustc_coinductive
| sym::const_trait
| sym::stable
| sym::unstable
| sym::rustc_allowed_through_unstable_modules
| sym::rustc_specialization_trait
| sym::rustc_unsafe_specialization_marker
| sym::rustc_allow_incoherent_impl
| sym::rustc_coherence_is_core
| sym::marker
| sym::fundamental
| sym::rustc_paren_sugar
| sym::type_const
| sym::repr
// FIXME(#82232, #143834): temporarily renamed to mitigate `#[align]` nameres
// ambiguity
| sym::rustc_align
| sym::deprecated
| sym::optimize
| sym::pointee
| sym::cold
| sym::target_feature
| sym::rustc_allow_const_fn_unstable
| sym::macro_use
| sym::macro_escape
| sym::naked
| sym::no_mangle
| sym::non_exhaustive
| sym::omit_gdb_pretty_printer_section
| sym::path
| sym::ignore
| sym::must_use
| sym::track_caller
| sym::link_name
| sym::link_ordinal
| sym::export_name
| sym::rustc_macro_transparency
| sym::link_section
| sym::rustc_layout_scalar_valid_range_start
| sym::rustc_layout_scalar_valid_range_end
| sym::no_implicit_prelude
| sym::automatically_derived
| sym::coverage
) {
if AttributeParser::<Late>::is_parsed_attribute(slice::from_ref(&name)) {
return;
}
emit_malformed_attribute(psess, style, meta.span, name, template);
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_resolve/src/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,10 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
self.r.per_ns(|this, ns| {
if !type_ns_only || ns == TypeNS {
let key = BindingKey::new(target, ns);
let mut resolution = this.resolution(current_module, key).borrow_mut();
resolution.single_imports.insert(import);
this.resolution_or_default(current_module, key)
.borrow_mut()
.single_imports
.insert(import);
}
});
}
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_resolve/src/check_unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,7 @@ impl Resolver<'_, '_> {
let mut check_redundant_imports = FxIndexSet::default();
for module in self.arenas.local_modules().iter() {
for (_key, resolution) in self.resolutions(*module).borrow().iter() {
let resolution = resolution.borrow();

if let Some(binding) = resolution.best_binding()
if let Some(binding) = resolution.borrow().best_binding()
&& let NameBindingKind::Import { import, .. } = binding.kind
&& let ImportKind::Single { id, .. } = import.kind
{
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2659,10 +2659,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
return None;
}

let resolutions = self.resolutions(crate_module).borrow();
let binding_key = BindingKey::new(ident, MacroNS);
let resolution = resolutions.get(&binding_key)?;
let binding = resolution.borrow().binding()?;
let binding = self.resolution(crate_module, binding_key)?.binding()?;
let Res::Def(DefKind::Macro(MacroKind::Bang), _) = binding.res() else {
return None;
};
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_resolve/src/effective_visibilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ impl<'a, 'ra, 'tcx> EffectiveVisibilitiesVisitor<'a, 'ra, 'tcx> {
/// including their whole reexport chains.
fn set_bindings_effective_visibilities(&mut self, module_id: LocalDefId) {
let module = self.r.expect_module(module_id.to_def_id());
let resolutions = self.r.resolutions(module);

for (_, name_resolution) in resolutions.borrow().iter() {
for (_, name_resolution) in self.r.resolutions(module).borrow().iter() {
let Some(mut binding) = name_resolution.borrow().binding() else {
continue;
};
Expand Down
9 changes: 7 additions & 2 deletions compiler/rustc_resolve/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,8 +848,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
};

let key = BindingKey::new(ident, ns);
let resolution =
self.resolution(module, key).try_borrow_mut().map_err(|_| (Determined, Weak::No))?; // This happens when there is a cycle of imports.
// `try_borrow_mut` is required to ensure exclusive access, even if the resulting binding
// doesn't need to be mutable. It will fail when there is a cycle of imports, and without
// the exclusive access infinite recursion will crash the compiler with stack overflow.
let resolution = &*self
.resolution_or_default(module, key)
.try_borrow_mut()
.map_err(|_| (Determined, Weak::No))?;

// If the primary binding is unusable, search further and return the shadowed glob
// binding if it exists. What we really want here is having two separate scopes in
Expand Down
68 changes: 32 additions & 36 deletions compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// Ensure that `resolution` isn't borrowed when defining in the module's glob importers,
// during which the resolution might end up getting re-defined via a glob cycle.
let (binding, t, warn_ambiguity) = {
let resolution = &mut *self.resolution(module, key).borrow_mut();
let resolution = &mut *self.resolution_or_default(module, key).borrow_mut();
let old_binding = resolution.binding();

let t = f(self, resolution);
Expand Down Expand Up @@ -651,7 +651,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
for module in self.arenas.local_modules().iter() {
for (key, resolution) in self.resolutions(*module).borrow().iter() {
let resolution = resolution.borrow();

let Some(binding) = resolution.best_binding() else { continue };

if let NameBindingKind::Import { import, .. } = binding.kind
Expand Down Expand Up @@ -1202,41 +1201,39 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
});

return if all_ns_failed {
let resolutions = match module {
ModuleOrUniformRoot::Module(module) => Some(self.resolutions(module).borrow()),
_ => None,
};
let resolutions = resolutions.as_ref().into_iter().flat_map(|r| r.iter());
let names = resolutions
.filter_map(|(BindingKey { ident: i, .. }, resolution)| {
if i.name == ident.name {
return None;
} // Never suggest the same name
match *resolution.borrow() {
ref resolution
if let Some(name_binding) = resolution.best_binding() =>
{
match name_binding.kind {
NameBindingKind::Import { binding, .. } => {
match binding.kind {
// Never suggest the name that has binding error
// i.e., the name that cannot be previously resolved
NameBindingKind::Res(Res::Err) => None,
_ => Some(i.name),
let names = match module {
ModuleOrUniformRoot::Module(module) => {
self.resolutions(module)
.borrow()
.iter()
.filter_map(|(BindingKey { ident: i, .. }, resolution)| {
if i.name == ident.name {
return None;
} // Never suggest the same name

let resolution = resolution.borrow();
if let Some(name_binding) = resolution.best_binding() {
match name_binding.kind {
NameBindingKind::Import { binding, .. } => {
match binding.kind {
// Never suggest the name that has binding error
// i.e., the name that cannot be previously resolved
NameBindingKind::Res(Res::Err) => None,
_ => Some(i.name),
}
}
_ => Some(i.name),
}
_ => Some(i.name),
} else if resolution.single_imports.is_empty() {
None
} else {
Some(i.name)
}
}
NameResolution { ref single_imports, .. }
if single_imports.is_empty() =>
{
None
}
_ => Some(i.name),
}
})
.collect::<Vec<Symbol>>();
})
.collect()
}
_ => Vec::new(),
};

let lev_suggestion =
find_best_match_for_name(&names, ident.name, None).map(|suggestion| {
Expand Down Expand Up @@ -1517,8 +1514,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
let imported_binding = self.import(binding, import);
let warn_ambiguity = self
.resolution(import.parent_scope.module, key)
.borrow()
.binding()
.and_then(|r| r.binding())
.is_some_and(|binding| binding.warn_ambiguity_recursive());
let _ = self.try_define(
import.parent_scope.module,
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3449,8 +3449,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
};
ident.span.normalize_to_macros_2_0_and_adjust(module.expansion);
let key = BindingKey::new(ident, ns);
let mut binding =
self.r.resolution(module, key).try_borrow().ok().and_then(|r| r.best_binding());
let mut binding = self.r.resolution(module, key).and_then(|r| r.best_binding());
debug!(?binding);
if binding.is_none() {
// We could not find the trait item in the correct namespace.
Expand All @@ -3461,8 +3460,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
_ => ns,
};
let key = BindingKey::new(ident, ns);
binding =
self.r.resolution(module, key).try_borrow().ok().and_then(|r| r.best_binding());
binding = self.r.resolution(module, key).and_then(|r| r.best_binding());
debug!(?binding);
}

Expand Down
13 changes: 8 additions & 5 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1461,15 +1461,17 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
if let PathResult::Module(ModuleOrUniformRoot::Module(module)) =
self.resolve_path(mod_path, None, None)
{
let resolutions = self.r.resolutions(module).borrow();
let targets: Vec<_> = resolutions
let targets: Vec<_> = self
.r
.resolutions(module)
.borrow()
.iter()
.filter_map(|(key, resolution)| {
resolution
.borrow()
.best_binding()
.map(|binding| binding.res())
.and_then(|res| if filter_fn(res) { Some((key, res)) } else { None })
.and_then(|res| if filter_fn(res) { Some((*key, res)) } else { None })
})
.collect();
if let [target] = targets.as_slice() {
Expand Down Expand Up @@ -2300,8 +2302,9 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
return None;
}

let resolutions = self.r.resolutions(*module);
let targets = resolutions
let targets = self
.r
.resolutions(*module)
.borrow()
.iter()
.filter_map(|(key, res)| {
Expand Down
13 changes: 10 additions & 3 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#![recursion_limit = "256"]
// tidy-alphabetical-end

use std::cell::{Cell, RefCell};
use std::cell::{Cell, Ref, RefCell};
use std::collections::BTreeSet;
use std::fmt;
use std::sync::Arc;
Expand Down Expand Up @@ -1905,9 +1905,16 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
&mut self,
module: Module<'ra>,
key: BindingKey,
) -> Option<Ref<'ra, NameResolution<'ra>>> {
self.resolutions(module).borrow().get(&key).map(|resolution| resolution.borrow())
}

fn resolution_or_default(
&mut self,
module: Module<'ra>,
key: BindingKey,
) -> &'ra RefCell<NameResolution<'ra>> {
*self
.resolutions(module)
self.resolutions(module)
.borrow_mut()
.entry(key)
.or_insert_with(|| self.arenas.alloc_name_resolution())
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ impl Session {
|| self.opts.unstable_opts.query_dep_graph
|| self.opts.unstable_opts.dump_mir.is_some()
|| self.opts.unstable_opts.unpretty.is_some()
|| self.prof.is_args_recording_enabled()
|| self.opts.output_types.contains_key(&OutputType::Mir)
|| std::env::var_os("RUSTC_LOG").is_some()
{
Expand Down
Loading
Loading