Skip to content

Commit 6eac264

Browse files
committed
Auto merge of #120519 - Nadrieril:rollup-fup0akd, r=Nadrieril
Rollup of 12 pull requests Successful merges: - #120207 (check `RUST_BOOTSTRAP_CONFIG` in `profile_user_dist` test) - #120321 (pattern_analysis: cleanup the contexts) - #120323 (On E0277 be clearer about implicit `Sized` bounds on type params and assoc types) - #120355 (document `FromIterator for Vec` allocation behaviors) - #120396 (Account for unbounded type param receiver in suggestions) - #120430 (std: thread_local::register_dtor fix proposal for FreeBSD.) - #120435 (Suggest name value cfg when only value is used for check-cfg) - #120470 (Mark "unused binding" suggestion as maybe incorrect) - #120472 (Make duplicate lang items fatal) - #120490 (Don't hash lints differently to non-lints.) - #120495 (Remove the `abi_amdgpu_kernel` feature) - #120501 (rustdoc: Correctly handle attribute merge if this is a glob reexport) Failed merges: - #120346 (hir: Refactor getters for owner nodes) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 80deabd + f93dbfc commit 6eac264

File tree

112 files changed

+885
-786
lines changed

Some content is hidden

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

112 files changed

+885
-786
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_errors/src/diagnostic.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ pub struct Diagnostic {
109109
/// `span` if there is one. Otherwise, it is `DUMMY_SP`.
110110
pub sort_span: Span,
111111

112-
/// If diagnostic is from Lint, custom hash function ignores children.
113-
/// Otherwise hash is based on the all the fields.
114112
pub is_lint: Option<IsLint>,
115113

116114
/// With `-Ztrack_diagnostics` enabled,
@@ -980,22 +978,24 @@ impl Diagnostic {
980978
) -> (
981979
&Level,
982980
&[(DiagnosticMessage, Style)],
983-
Vec<(&Cow<'static, str>, &DiagnosticArgValue)>,
984981
&Option<ErrCode>,
985-
&Option<IsLint>,
986982
&MultiSpan,
983+
&[SubDiagnostic],
987984
&Result<Vec<CodeSuggestion>, SuggestionsDisabled>,
988-
Option<&[SubDiagnostic]>,
985+
Vec<(&DiagnosticArgName, &DiagnosticArgValue)>,
986+
&Option<IsLint>,
989987
) {
990988
(
991989
&self.level,
992990
&self.messages,
993-
self.args().collect(),
994991
&self.code,
995-
&self.is_lint,
996992
&self.span,
993+
&self.children,
997994
&self.suggestions,
998-
(if self.is_lint.is_some() { None } else { Some(&self.children) }),
995+
self.args().collect(),
996+
// omit self.sort_span
997+
&self.is_lint,
998+
// omit self.emitted_at
999999
)
10001000
}
10011001
}

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/astconv/bounds.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
2828
let tcx = self.tcx();
2929
let sized_def_id = tcx.lang_items().sized_trait();
3030
let mut seen_negative_sized_bound = false;
31+
let mut seen_positive_sized_bound = false;
3132

3233
// Try to find an unbound in bounds.
3334
let mut unbounds: SmallVec<[_; 1]> = SmallVec::new();
@@ -45,6 +46,13 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
4546
seen_negative_sized_bound = true;
4647
}
4748
}
49+
hir::TraitBoundModifier::None => {
50+
if let Some(sized_def_id) = sized_def_id
51+
&& ptr.trait_ref.path.res == Res::Def(DefKind::Trait, sized_def_id)
52+
{
53+
seen_positive_sized_bound = true;
54+
}
55+
}
4856
_ => {}
4957
}
5058
}
@@ -82,11 +90,11 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
8290
);
8391
}
8492

85-
if seen_sized_unbound || seen_negative_sized_bound {
86-
// There was in fact a `?Sized` or `!Sized` bound;
93+
if seen_sized_unbound || seen_negative_sized_bound || seen_positive_sized_bound {
94+
// There was in fact a `?Sized`, `!Sized` or explicit `Sized` bound;
8795
// we don't need to do anything.
8896
} else if sized_def_id.is_some() {
89-
// There was no `?Sized` or `!Sized` bound;
97+
// There was no `?Sized`, `!Sized` or explicit `Sized` bound;
9098
// add `Sized` if it's available.
9199
bounds.push_sized(tcx, self_ty, span);
92100
}

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_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_middle/src/ty/layout.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,6 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: SpecAbi) ->
12471247
PtxKernel
12481248
| Msp430Interrupt
12491249
| X86Interrupt
1250-
| AmdGpuKernel
12511250
| EfiApi
12521251
| AvrInterrupt
12531252
| AvrNonBlockingInterrupt

compiler/rustc_mir_transform/src/ffi_unwind_calls.rs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ fn abi_can_unwind(abi: Abi) -> bool {
2626
PtxKernel
2727
| Msp430Interrupt
2828
| X86Interrupt
29-
| AmdGpuKernel
3029
| EfiApi
3130
| AvrInterrupt
3231
| AvrNonBlockingInterrupt

compiler/rustc_passes/src/errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1739,7 +1739,7 @@ pub struct UnusedVariableTryPrefix {
17391739

17401740
#[derive(Subdiagnostic)]
17411741
pub enum UnusedVariableSugg {
1742-
#[multipart_suggestion(passes_suggestion, applicability = "machine-applicable")]
1742+
#[multipart_suggestion(passes_suggestion, applicability = "maybe-incorrect")]
17431743
TryPrefixSugg {
17441744
#[suggestion_part(code = "_{name}")]
17451745
spans: Vec<Span>,
@@ -1778,7 +1778,7 @@ pub struct UnusedVarTryIgnore {
17781778
}
17791779

17801780
#[derive(Subdiagnostic)]
1781-
#[multipart_suggestion(passes_suggestion, applicability = "machine-applicable")]
1781+
#[multipart_suggestion(passes_suggestion, applicability = "maybe-incorrect")]
17821782
pub struct UnusedVarTryIgnoreSugg {
17831783
#[suggestion_part(code = "{name}: _")]
17841784
pub shorthands: Vec<Span>,

compiler/rustc_passes/src/lang_items.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ impl<'ast, 'tcx> LanguageItemCollector<'ast, 'tcx> {
149149
}
150150
};
151151

152-
self.tcx.dcx().emit_err(DuplicateLangItem {
152+
// When there's a duplicate lang item, something went very wrong and there's no value in recovering or doing anything.
153+
// Give the user the one message to let them debug the mess they created and then wish them farewell.
154+
self.tcx.dcx().emit_fatal(DuplicateLangItem {
153155
local_span: item_span,
154156
lang_item_name,
155157
crate_name,

compiler/rustc_pattern_analysis/src/constructor.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ use self::MaybeInfiniteInt::*;
163163
use self::SliceKind::*;
164164

165165
use crate::index;
166-
use crate::usefulness::PlaceCtxt;
167166
use crate::TypeCx;
168167

169168
/// Whether we have seen a constructor in the column or not.
@@ -818,21 +817,20 @@ impl<Cx: TypeCx> Constructor<Cx> {
818817

819818
/// The number of fields for this constructor. This must be kept in sync with
820819
/// `Fields::wildcards`.
821-
pub(crate) fn arity(&self, pcx: &PlaceCtxt<'_, Cx>) -> usize {
822-
pcx.ctor_arity(self)
820+
pub(crate) fn arity(&self, cx: &Cx, ty: &Cx::Ty) -> usize {
821+
cx.ctor_arity(self, ty)
823822
}
824823

825824
/// Returns whether `self` is covered by `other`, i.e. whether `self` is a subset of `other`.
826825
/// For the simple cases, this is simply checking for equality. For the "grouped" constructors,
827826
/// this checks for inclusion.
828827
// We inline because this has a single call site in `Matrix::specialize_constructor`.
829828
#[inline]
830-
pub(crate) fn is_covered_by(&self, pcx: &PlaceCtxt<'_, Cx>, other: &Self) -> bool {
829+
pub(crate) fn is_covered_by(&self, cx: &Cx, other: &Self) -> bool {
831830
match (self, other) {
832-
(Wildcard, _) => pcx
833-
.mcx
834-
.tycx
835-
.bug(format_args!("Constructor splitting should not have returned `Wildcard`")),
831+
(Wildcard, _) => {
832+
cx.bug(format_args!("Constructor splitting should not have returned `Wildcard`"))
833+
}
836834
// Wildcards cover anything
837835
(_, Wildcard) => true,
838836
// Only a wildcard pattern can match these special constructors.
@@ -873,7 +871,7 @@ impl<Cx: TypeCx> Constructor<Cx> {
873871
(Opaque(self_id), Opaque(other_id)) => self_id == other_id,
874872
(Opaque(..), _) | (_, Opaque(..)) => false,
875873

876-
_ => pcx.mcx.tycx.bug(format_args!(
874+
_ => cx.bug(format_args!(
877875
"trying to compare incompatible constructors {self:?} and {other:?}"
878876
)),
879877
}
@@ -950,10 +948,10 @@ pub enum ConstructorSet<Cx: TypeCx> {
950948
/// of the `ConstructorSet` for the type, yet if we forgot to include them in `present` we would be
951949
/// ignoring any row with `Opaque`s in the algorithm. Hence the importance of point 4.
952950
#[derive(Debug)]
953-
pub(crate) struct SplitConstructorSet<Cx: TypeCx> {
954-
pub(crate) present: SmallVec<[Constructor<Cx>; 1]>,
955-
pub(crate) missing: Vec<Constructor<Cx>>,
956-
pub(crate) missing_empty: Vec<Constructor<Cx>>,
951+
pub struct SplitConstructorSet<Cx: TypeCx> {
952+
pub present: SmallVec<[Constructor<Cx>; 1]>,
953+
pub missing: Vec<Constructor<Cx>>,
954+
pub missing_empty: Vec<Constructor<Cx>>,
957955
}
958956

959957
impl<Cx: TypeCx> ConstructorSet<Cx> {
@@ -962,7 +960,7 @@ impl<Cx: TypeCx> ConstructorSet<Cx> {
962960
/// or slices. This can get subtle; see [`SplitConstructorSet`] for details of this operation
963961
/// and its invariants.
964962
#[instrument(level = "debug", skip(self, ctors), ret)]
965-
pub(crate) fn split<'a>(
963+
pub fn split<'a>(
966964
&self,
967965
ctors: impl Iterator<Item = &'a Constructor<Cx>> + Clone,
968966
) -> SplitConstructorSet<Cx>

0 commit comments

Comments
 (0)