Skip to content

Commit 2c9bfbb

Browse files
committed
Auto merge of rust-lang#120512 - matthiaskrgr:rollup-gcqiihd, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#120207 (check `RUST_BOOTSTRAP_CONFIG` in `profile_user_dist` test) - rust-lang#120321 (pattern_analysis: cleanup the contexts) - rust-lang#120346 (hir: Refactor getters for owner nodes) - rust-lang#120396 (Account for unbounded type param receiver in suggestions) - rust-lang#120435 (Suggest name value cfg when only value is used for check-cfg) - rust-lang#120470 (Mark "unused binding" suggestion as maybe incorrect) - rust-lang#120495 (Remove the `abi_amdgpu_kernel` feature) - rust-lang#120501 (rustdoc: Correctly handle attribute merge if this is a glob reexport) r? `@ghost` `@rustbot` modify labels: rollup
2 parents cb4d9a1 + 77b3b23 commit 2c9bfbb

File tree

97 files changed

+1470
-1401
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1470
-1401
lines changed

compiler/rustc_codegen_cranelift/src/abi/mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,7 @@ pub(crate) fn conv_to_call_conv(sess: &Session, c: Conv, default_call_conv: Call
5656
sess.dcx().fatal("C-cmse-nonsecure-call call conv is not yet implemented");
5757
}
5858

59-
Conv::Msp430Intr
60-
| Conv::PtxKernel
61-
| Conv::AmdGpuKernel
62-
| Conv::AvrInterrupt
63-
| Conv::AvrNonBlockingInterrupt => {
59+
Conv::Msp430Intr | Conv::PtxKernel | Conv::AvrInterrupt | Conv::AvrNonBlockingInterrupt => {
6460
unreachable!("tried to use {c:?} call conv which only exists on an unsupported target");
6561
}
6662
}

compiler/rustc_codegen_llvm/src/abi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,6 @@ impl From<Conv> for llvm::CallConv {
590590
Conv::Cold => llvm::ColdCallConv,
591591
Conv::PreserveMost => llvm::PreserveMost,
592592
Conv::PreserveAll => llvm::PreserveAll,
593-
Conv::AmdGpuKernel => llvm::AmdGpuKernel,
594593
Conv::AvrInterrupt => llvm::AvrInterrupt,
595594
Conv::AvrNonBlockingInterrupt => llvm::AvrNonBlockingInterrupt,
596595
Conv::ArmAapcs => llvm::ArmAapcsCallConv,

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ pub enum CallConv {
106106
X86_Intr = 83,
107107
AvrNonBlockingInterrupt = 84,
108108
AvrInterrupt = 85,
109-
AmdGpuKernel = 91,
110109
}
111110

112111
/// LLVMRustLinkage

compiler/rustc_feature/src/removed.rs

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ declare_features! (
3232
// feature-group-start: removed features
3333
// -------------------------------------------------------------------------
3434

35+
/// Allows using the `amdgpu-kernel` ABI.
36+
(removed, abi_amdgpu_kernel, "CURRENT_RUSTC_VERSION", Some(51575), None),
3537
(removed, advanced_slice_patterns, "1.0.0", Some(62254),
3638
Some("merged into `#![feature(slice_patterns)]`")),
3739
(removed, allocator, "1.0.0", None, None),

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,6 @@ declare_features! (
321321
// feature-group-start: actual feature gates
322322
// -------------------------------------------------------------------------
323323

324-
/// Allows using the `amdgpu-kernel` ABI.
325-
(unstable, abi_amdgpu_kernel, "1.29.0", Some(51575)),
326324
/// Allows `extern "avr-interrupt" fn()` and `extern "avr-non-blocking-interrupt" fn()`.
327325
(unstable, abi_avr_interrupt, "1.45.0", Some(69664)),
328326
/// Allows `extern "C-cmse-nonsecure-call" fn()`.

compiler/rustc_hir_analysis/src/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ pub fn check_function_signature<'tcx>(
578578
fn_id: LocalDefId,
579579
) -> rustc_span::Span {
580580
let mut args = {
581-
let node = tcx.hir().expect_owner(fn_id);
581+
let node = tcx.expect_hir_owner_node(fn_id);
582582
let decl = node.fn_decl().unwrap_or_else(|| bug!("expected fn decl, found {:?}", node));
583583
decl.inputs.iter().map(|t| t.span).chain(std::iter::once(decl.output.span()))
584584
};

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ where
188188
}
189189

190190
fn check_well_formed(tcx: TyCtxt<'_>, def_id: hir::OwnerId) -> Result<(), ErrorGuaranteed> {
191-
let node = tcx.hir().owner(def_id);
191+
let node = tcx.hir_owner_node(def_id);
192192
let mut res = match node {
193193
hir::OwnerNode::Crate(_) => bug!("check_well_formed cannot be applied to the crate root"),
194194
hir::OwnerNode::Item(item) => check_item(tcx, item),

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ fn resolve_bound_vars(tcx: TyCtxt<'_>, local_def_id: hir::OwnerId) -> ResolveBou
254254
map: &mut named_variable_map,
255255
scope: &Scope::Root { opt_parent_item: None },
256256
};
257-
match tcx.hir().owner(local_def_id) {
257+
match tcx.hir_owner_node(local_def_id) {
258258
hir::OwnerNode::Item(item) => visitor.visit_item(item),
259259
hir::OwnerNode::ForeignItem(item) => visitor.visit_foreign_item(item),
260260
hir::OwnerNode::TraitItem(item) => {

compiler/rustc_hir_typeck/src/method/suggest.rs

+27-14
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
554554
"`count` is defined on `{iterator_trait}`, which `{rcvr_ty}` does not implement"
555555
));
556556
}
557+
} else if !unsatisfied_predicates.is_empty() && matches!(rcvr_ty.kind(), ty::Param(_)) {
558+
// We special case the situation where we are looking for `_` in
559+
// `<TypeParam as _>::method` because otherwise the machinery will look for blanket
560+
// implementations that have unsatisfied trait bounds to suggest, leading us to claim
561+
// things like "we're looking for a trait with method `cmp`, both `Iterator` and `Ord`
562+
// have one, in order to implement `Ord` you need to restrict `TypeParam: FnPtr` so
563+
// that `impl<T: FnPtr> Ord for T` can apply", which is not what we want. We have a type
564+
// parameter, we want to directly say "`Ord::cmp` and `Iterator::cmp` exist, restrict
565+
// `TypeParam: Ord` or `TypeParam: Iterator`"". That is done further down when calling
566+
// `self.suggest_traits_to_import`, so we ignore the `unsatisfied_predicates`
567+
// suggestions.
557568
} else if !unsatisfied_predicates.is_empty() {
558569
let mut type_params = FxIndexMap::default();
559570

@@ -1325,7 +1336,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13251336
}
13261337
}
13271338
self.note_derefed_ty_has_method(&mut err, source, rcvr_ty, item_name, expected);
1328-
return Some(err);
1339+
Some(err)
13291340
}
13301341

13311342
fn note_candidates_on_method_error(
@@ -2918,19 +2929,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
29182929
// this isn't perfect (that is, there are cases when
29192930
// implementing a trait would be legal but is rejected
29202931
// here).
2921-
unsatisfied_predicates.iter().all(|(p, _, _)| {
2922-
match p.kind().skip_binder() {
2923-
// Hide traits if they are present in predicates as they can be fixed without
2924-
// having to implement them.
2925-
ty::PredicateKind::Clause(ty::ClauseKind::Trait(t)) => {
2926-
t.def_id() == info.def_id
2927-
}
2928-
ty::PredicateKind::Clause(ty::ClauseKind::Projection(p)) => {
2929-
p.projection_ty.def_id == info.def_id
2930-
}
2931-
_ => false,
2932-
}
2933-
}) && (type_is_local || info.def_id.is_local())
2932+
(type_is_local || info.def_id.is_local())
29342933
&& !self.tcx.trait_is_auto(info.def_id)
29352934
&& self
29362935
.associated_value(info.def_id, item_name)
@@ -2978,6 +2977,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
29782977
item.visibility(self.tcx).is_public() || info.def_id.is_local()
29792978
})
29802979
.is_some()
2980+
&& (matches!(rcvr_ty.kind(), ty::Param(_))
2981+
|| unsatisfied_predicates.iter().all(|(p, _, _)| {
2982+
match p.kind().skip_binder() {
2983+
// Hide traits if they are present in predicates as they can be fixed without
2984+
// having to implement them.
2985+
ty::PredicateKind::Clause(ty::ClauseKind::Trait(t)) => {
2986+
t.def_id() == info.def_id
2987+
}
2988+
ty::PredicateKind::Clause(ty::ClauseKind::Projection(p)) => {
2989+
p.projection_ty.def_id == info.def_id
2990+
}
2991+
_ => false,
2992+
}
2993+
}))
29812994
})
29822995
.collect::<Vec<_>>();
29832996
for span in &arbitrary_rcvr {

compiler/rustc_incremental/src/assert_dep_graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl<'tcx> IfThisChanged<'tcx> {
131131
None => DepNode::from_def_path_hash(
132132
self.tcx,
133133
def_path_hash,
134-
dep_kinds::hir_owner_nodes,
134+
dep_kinds::opt_hir_owner_nodes,
135135
),
136136
Some(n) => {
137137
match DepNode::from_label_string(self.tcx, n.as_str(), def_path_hash) {

compiler/rustc_incremental/src/persist/dirty_clean.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ const BASE_FN: &[&str] = &[
5757

5858
/// DepNodes for Hir, which is pretty much everything
5959
const BASE_HIR: &[&str] = &[
60-
// hir_owner_nodes should be computed for all nodes
61-
label_strs::hir_owner_nodes,
60+
// opt_hir_owner_nodes should be computed for all nodes
61+
label_strs::opt_hir_owner_nodes,
6262
];
6363

6464
/// `impl` implementation of struct/trait

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2555,7 +2555,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
25552555
add_lt_suggs,
25562556
new_lt: &new_lt,
25572557
};
2558-
match self.tcx.hir().expect_owner(lifetime_scope) {
2558+
match self.tcx.expect_hir_owner_node(lifetime_scope) {
25592559
hir::OwnerNode::Item(i) => visitor.visit_item(i),
25602560
hir::OwnerNode::ForeignItem(i) => visitor.visit_foreign_item(i),
25612561
hir::OwnerNode::ImplItem(i) => visitor.visit_impl_item(i),

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
443443
if let hir::OwnerNode::Item(Item {
444444
kind: ItemKind::Impl(hir::Impl { self_ty, .. }),
445445
..
446-
}) = tcx.hir().owner(impl_did)
446+
}) = tcx.hir_owner_node(impl_did)
447447
{
448448
Some((impl_item.ident, self_ty))
449449
} else {

compiler/rustc_lint/src/context/diagnostics.rs

+40-10
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,23 @@ pub(super) fn builtin(
188188
#[allow(rustc::potential_query_instability)]
189189
let possibilities: Vec<Symbol> =
190190
sess.parse_sess.check_config.expecteds.keys().copied().collect();
191+
192+
let mut names_possibilities: Vec<_> = if value.is_none() {
193+
// We later sort and display all the possibilities, so the order here does not matter.
194+
#[allow(rustc::potential_query_instability)]
195+
sess.parse_sess
196+
.check_config
197+
.expecteds
198+
.iter()
199+
.filter_map(|(k, v)| match v {
200+
ExpectedValues::Some(v) if v.contains(&Some(name)) => Some(k),
201+
_ => None,
202+
})
203+
.collect()
204+
} else {
205+
Vec::new()
206+
};
207+
191208
let is_from_cargo = std::env::var_os("CARGO").is_some();
192209
let mut is_feature_cfg = name == sym::feature;
193210

@@ -262,17 +279,30 @@ pub(super) fn builtin(
262279
}
263280

264281
is_feature_cfg |= best_match == sym::feature;
265-
} else if !possibilities.is_empty() {
266-
let mut possibilities =
267-
possibilities.iter().map(Symbol::as_str).collect::<Vec<_>>();
268-
possibilities.sort();
269-
let possibilities = possibilities.join("`, `");
282+
} else {
283+
if !names_possibilities.is_empty() && names_possibilities.len() <= 3 {
284+
names_possibilities.sort();
285+
for cfg_name in names_possibilities.iter() {
286+
db.span_suggestion(
287+
name_span,
288+
"found config with similar value",
289+
format!("{cfg_name} = \"{name}\""),
290+
Applicability::MaybeIncorrect,
291+
);
292+
}
293+
}
294+
if !possibilities.is_empty() {
295+
let mut possibilities =
296+
possibilities.iter().map(Symbol::as_str).collect::<Vec<_>>();
297+
possibilities.sort();
298+
let possibilities = possibilities.join("`, `");
270299

271-
// The list of expected names can be long (even by default) and
272-
// so the diagnostic produced can take a lot of space. To avoid
273-
// cloging the user output we only want to print that diagnostic
274-
// once.
275-
db.help_once(format!("expected names are: `{possibilities}`"));
300+
// The list of expected names can be long (even by default) and
301+
// so the diagnostic produced can take a lot of space. To avoid
302+
// cloging the user output we only want to print that diagnostic
303+
// once.
304+
db.help_once(format!("expected names are: `{possibilities}`"));
305+
}
276306
}
277307

278308
let inst = if let Some((value, _value_span)) = value {

compiler/rustc_lint/src/levels.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ fn shallow_lint_levels_on(tcx: TyCtxt<'_>, owner: hir::OwnerId) -> ShallowLintLe
181181
// Otherwise, we need to visit the attributes in source code order, so we fetch HIR and do
182182
// a standard visit.
183183
// FIXME(#102522) Just iterate on attrs once that iteration order matches HIR's.
184-
_ => match tcx.hir().owner(owner) {
184+
_ => match tcx.hir_owner_node(owner) {
185185
hir::OwnerNode::Item(item) => levels.visit_item(item),
186186
hir::OwnerNode::ForeignItem(item) => levels.visit_foreign_item(item),
187187
hir::OwnerNode::TraitItem(item) => levels.visit_trait_item(item),

0 commit comments

Comments
 (0)