Skip to content
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

Rollup of 8 pull requests #120512

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c367983
Suggest name value cfg when only value is used for check-cfg
chenyukang Jan 28, 2024
0213c87
limit the names_possiblilities to less than 3
chenyukang Jan 30, 2024
ca243e7
add testcase for more than 3 cfg names
chenyukang Jan 30, 2024
64b6b5b
hir: Simplify `hir_owner_nodes` query
petrochenkov Jan 25, 2024
667d5d3
hir: Add non-optional `hir_owner_nodes` for real `OwnerId`s
petrochenkov Jan 25, 2024
db41f4a
hir: Remove `hir::Map::{owner,expect_owner}`
petrochenkov Jan 25, 2024
f6b21e9
Remove the `abi_amdgpu_kernel` feature
clubby789 Jan 30, 2024
0b2579a
Make `PatternColumn` generic in `Cx`
Nadrieril Jan 24, 2024
cb0e8c5
Limit the use of `PlaceCtxt`
Nadrieril Jan 24, 2024
83e88c6
Repurpose `MatchCtxt` for usefulness only
Nadrieril Jan 24, 2024
6ef8362
Make `PatternColumn` part of the public API
Nadrieril Jan 24, 2024
5903142
Separate `PlaceCtxt` from `UsefulnessCtxt`
Nadrieril Jan 24, 2024
dfbbdda
check `RUST_BOOTSTRAP_CONFIG` in `profile_user_dist` test
onur-ozkan Jan 21, 2024
75f670d
rustdoc: Correctly handle attribute merge if this is a glob reexport
GuillaumeGomez Jan 30, 2024
024364a
Add regression test for #120487
GuillaumeGomez Jan 30, 2024
d34b0fa
Add test for method on unbounded type parameter receiver
estebank Jan 26, 2024
20b1c2a
Account for unbounded type param receiver in suggestions
estebank Jan 26, 2024
9ccc770
fix rebase
estebank Jan 30, 2024
8ebd47e
Mark "unused binding" suggestion as maybe incorrect
estebank Jan 29, 2024
bce474e
Rollup merge of #120207 - onur-ozkan:120202-fix, r=clubby789
matthiaskrgr Jan 30, 2024
045088d
Rollup merge of #120321 - Nadrieril:cleanup-cx, r=compiler-errors
matthiaskrgr Jan 30, 2024
1e3860a
Rollup merge of #120346 - petrochenkov:ownodes, r=oli-obk
matthiaskrgr Jan 30, 2024
3edfd62
Rollup merge of #120396 - estebank:method-on-unbounded-type-param, r=…
matthiaskrgr Jan 30, 2024
37ba7b1
Rollup merge of #120435 - chenyukang:yukang-fix-120427-cfg-name, r=Ur…
matthiaskrgr Jan 30, 2024
5c8e7a2
Rollup merge of #120470 - estebank:issue-54196, r=compiler-errors
matthiaskrgr Jan 30, 2024
dbb5a72
Rollup merge of #120495 - clubby789:remove-amdgpu-kernel, r=oli-obk
matthiaskrgr Jan 30, 2024
77b3b23
Rollup merge of #120501 - GuillaumeGomez:glob-reexport-attr-merge-bug…
matthiaskrgr Jan 30, 2024
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
6 changes: 1 addition & 5 deletions compiler/rustc_codegen_cranelift/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ pub(crate) fn conv_to_call_conv(sess: &Session, c: Conv, default_call_conv: Call
sess.dcx().fatal("C-cmse-nonsecure-call call conv is not yet implemented");
}

Conv::Msp430Intr
| Conv::PtxKernel
| Conv::AmdGpuKernel
| Conv::AvrInterrupt
| Conv::AvrNonBlockingInterrupt => {
Conv::Msp430Intr | Conv::PtxKernel | Conv::AvrInterrupt | Conv::AvrNonBlockingInterrupt => {
unreachable!("tried to use {c:?} call conv which only exists on an unsupported target");
}
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_codegen_llvm/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,6 @@ impl From<Conv> for llvm::CallConv {
Conv::Cold => llvm::ColdCallConv,
Conv::PreserveMost => llvm::PreserveMost,
Conv::PreserveAll => llvm::PreserveAll,
Conv::AmdGpuKernel => llvm::AmdGpuKernel,
Conv::AvrInterrupt => llvm::AvrInterrupt,
Conv::AvrNonBlockingInterrupt => llvm::AvrNonBlockingInterrupt,
Conv::ArmAapcs => llvm::ArmAapcsCallConv,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ pub enum CallConv {
X86_Intr = 83,
AvrNonBlockingInterrupt = 84,
AvrInterrupt = 85,
AmdGpuKernel = 91,
}

/// LLVMRustLinkage
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ declare_features! (
// feature-group-start: removed features
// -------------------------------------------------------------------------

/// Allows using the `amdgpu-kernel` ABI.
(removed, abi_amdgpu_kernel, "CURRENT_RUSTC_VERSION", Some(51575), None),
(removed, advanced_slice_patterns, "1.0.0", Some(62254),
Some("merged into `#![feature(slice_patterns)]`")),
(removed, allocator, "1.0.0", None, None),
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,6 @@ declare_features! (
// feature-group-start: actual feature gates
// -------------------------------------------------------------------------

/// Allows using the `amdgpu-kernel` ABI.
(unstable, abi_amdgpu_kernel, "1.29.0", Some(51575)),
/// Allows `extern "avr-interrupt" fn()` and `extern "avr-non-blocking-interrupt" fn()`.
(unstable, abi_avr_interrupt, "1.45.0", Some(69664)),
/// Allows `extern "C-cmse-nonsecure-call" fn()`.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ pub fn check_function_signature<'tcx>(
fn_id: LocalDefId,
) -> rustc_span::Span {
let mut args = {
let node = tcx.hir().expect_owner(fn_id);
let node = tcx.expect_hir_owner_node(fn_id);
let decl = node.fn_decl().unwrap_or_else(|| bug!("expected fn decl, found {:?}", node));
decl.inputs.iter().map(|t| t.span).chain(std::iter::once(decl.output.span()))
};
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ where
}

fn check_well_formed(tcx: TyCtxt<'_>, def_id: hir::OwnerId) -> Result<(), ErrorGuaranteed> {
let node = tcx.hir().owner(def_id);
let node = tcx.hir_owner_node(def_id);
let mut res = match node {
hir::OwnerNode::Crate(_) => bug!("check_well_formed cannot be applied to the crate root"),
hir::OwnerNode::Item(item) => check_item(tcx, item),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ fn resolve_bound_vars(tcx: TyCtxt<'_>, local_def_id: hir::OwnerId) -> ResolveBou
map: &mut named_variable_map,
scope: &Scope::Root { opt_parent_item: None },
};
match tcx.hir().owner(local_def_id) {
match tcx.hir_owner_node(local_def_id) {
hir::OwnerNode::Item(item) => visitor.visit_item(item),
hir::OwnerNode::ForeignItem(item) => visitor.visit_foreign_item(item),
hir::OwnerNode::TraitItem(item) => {
Expand Down
41 changes: 27 additions & 14 deletions compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
"`count` is defined on `{iterator_trait}`, which `{rcvr_ty}` does not implement"
));
}
} else if !unsatisfied_predicates.is_empty() && matches!(rcvr_ty.kind(), ty::Param(_)) {
// We special case the situation where we are looking for `_` in
// `<TypeParam as _>::method` because otherwise the machinery will look for blanket
// implementations that have unsatisfied trait bounds to suggest, leading us to claim
// things like "we're looking for a trait with method `cmp`, both `Iterator` and `Ord`
// have one, in order to implement `Ord` you need to restrict `TypeParam: FnPtr` so
// that `impl<T: FnPtr> Ord for T` can apply", which is not what we want. We have a type
// parameter, we want to directly say "`Ord::cmp` and `Iterator::cmp` exist, restrict
// `TypeParam: Ord` or `TypeParam: Iterator`"". That is done further down when calling
// `self.suggest_traits_to_import`, so we ignore the `unsatisfied_predicates`
// suggestions.
} else if !unsatisfied_predicates.is_empty() {
let mut type_params = FxIndexMap::default();

Expand Down Expand Up @@ -1325,7 +1336,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
self.note_derefed_ty_has_method(&mut err, source, rcvr_ty, item_name, expected);
return Some(err);
Some(err)
}

fn note_candidates_on_method_error(
Expand Down Expand Up @@ -2918,19 +2929,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// this isn't perfect (that is, there are cases when
// implementing a trait would be legal but is rejected
// here).
unsatisfied_predicates.iter().all(|(p, _, _)| {
match p.kind().skip_binder() {
// Hide traits if they are present in predicates as they can be fixed without
// having to implement them.
ty::PredicateKind::Clause(ty::ClauseKind::Trait(t)) => {
t.def_id() == info.def_id
}
ty::PredicateKind::Clause(ty::ClauseKind::Projection(p)) => {
p.projection_ty.def_id == info.def_id
}
_ => false,
}
}) && (type_is_local || info.def_id.is_local())
(type_is_local || info.def_id.is_local())
&& !self.tcx.trait_is_auto(info.def_id)
&& self
.associated_value(info.def_id, item_name)
Expand Down Expand Up @@ -2978,6 +2977,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
item.visibility(self.tcx).is_public() || info.def_id.is_local()
})
.is_some()
&& (matches!(rcvr_ty.kind(), ty::Param(_))
|| unsatisfied_predicates.iter().all(|(p, _, _)| {
match p.kind().skip_binder() {
// Hide traits if they are present in predicates as they can be fixed without
// having to implement them.
ty::PredicateKind::Clause(ty::ClauseKind::Trait(t)) => {
t.def_id() == info.def_id
}
ty::PredicateKind::Clause(ty::ClauseKind::Projection(p)) => {
p.projection_ty.def_id == info.def_id
}
_ => false,
}
}))
})
.collect::<Vec<_>>();
for span in &arbitrary_rcvr {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_incremental/src/assert_dep_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl<'tcx> IfThisChanged<'tcx> {
None => DepNode::from_def_path_hash(
self.tcx,
def_path_hash,
dep_kinds::hir_owner_nodes,
dep_kinds::opt_hir_owner_nodes,
),
Some(n) => {
match DepNode::from_label_string(self.tcx, n.as_str(), def_path_hash) {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_incremental/src/persist/dirty_clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ const BASE_FN: &[&str] = &[

/// DepNodes for Hir, which is pretty much everything
const BASE_HIR: &[&str] = &[
// hir_owner_nodes should be computed for all nodes
label_strs::hir_owner_nodes,
// opt_hir_owner_nodes should be computed for all nodes
label_strs::opt_hir_owner_nodes,
];

/// `impl` implementation of struct/trait
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2546,7 +2546,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
add_lt_suggs,
new_lt: &new_lt,
};
match self.tcx.hir().expect_owner(lifetime_scope) {
match self.tcx.expect_hir_owner_node(lifetime_scope) {
hir::OwnerNode::Item(i) => visitor.visit_item(i),
hir::OwnerNode::ForeignItem(i) => visitor.visit_foreign_item(i),
hir::OwnerNode::ImplItem(i) => visitor.visit_impl_item(i),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
if let hir::OwnerNode::Item(Item {
kind: ItemKind::Impl(hir::Impl { self_ty, .. }),
..
}) = tcx.hir().owner(impl_did)
}) = tcx.hir_owner_node(impl_did)
{
Some((impl_item.ident, self_ty))
} else {
Expand Down
50 changes: 40 additions & 10 deletions compiler/rustc_lint/src/context/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,23 @@ pub(super) fn builtin(
#[allow(rustc::potential_query_instability)]
let possibilities: Vec<Symbol> =
sess.parse_sess.check_config.expecteds.keys().copied().collect();

let mut names_possibilities: Vec<_> = if value.is_none() {
// We later sort and display all the possibilities, so the order here does not matter.
#[allow(rustc::potential_query_instability)]
sess.parse_sess
.check_config
.expecteds
.iter()
.filter_map(|(k, v)| match v {
ExpectedValues::Some(v) if v.contains(&Some(name)) => Some(k),
_ => None,
})
.collect()
} else {
Vec::new()
};

let is_from_cargo = std::env::var_os("CARGO").is_some();
let mut is_feature_cfg = name == sym::feature;

Expand Down Expand Up @@ -262,17 +279,30 @@ pub(super) fn builtin(
}

is_feature_cfg |= best_match == sym::feature;
} else if !possibilities.is_empty() {
let mut possibilities =
possibilities.iter().map(Symbol::as_str).collect::<Vec<_>>();
possibilities.sort();
let possibilities = possibilities.join("`, `");
} else {
if !names_possibilities.is_empty() && names_possibilities.len() <= 3 {
names_possibilities.sort();
for cfg_name in names_possibilities.iter() {
db.span_suggestion(
name_span,
"found config with similar value",
format!("{cfg_name} = \"{name}\""),
Applicability::MaybeIncorrect,
);
}
}
if !possibilities.is_empty() {
let mut possibilities =
possibilities.iter().map(Symbol::as_str).collect::<Vec<_>>();
possibilities.sort();
let possibilities = possibilities.join("`, `");

// The list of expected names can be long (even by default) and
// so the diagnostic produced can take a lot of space. To avoid
// cloging the user output we only want to print that diagnostic
// once.
db.help_once(format!("expected names are: `{possibilities}`"));
// The list of expected names can be long (even by default) and
// so the diagnostic produced can take a lot of space. To avoid
// cloging the user output we only want to print that diagnostic
// once.
db.help_once(format!("expected names are: `{possibilities}`"));
}
}

let inst = if let Some((value, _value_span)) = value {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ fn shallow_lint_levels_on(tcx: TyCtxt<'_>, owner: hir::OwnerId) -> ShallowLintLe
// Otherwise, we need to visit the attributes in source code order, so we fetch HIR and do
// a standard visit.
// FIXME(#102522) Just iterate on attrs once that iteration order matches HIR's.
_ => match tcx.hir().owner(owner) {
_ => match tcx.hir_owner_node(owner) {
hir::OwnerNode::Item(item) => levels.visit_item(item),
hir::OwnerNode::ForeignItem(item) => levels.visit_foreign_item(item),
hir::OwnerNode::TraitItem(item) => levels.visit_trait_item(item),
Expand Down
Loading
Loading