Skip to content

Commit 2b8590e

Browse files
committed
Auto merge of rust-lang#106757 - matthiaskrgr:rollup-9j8830g, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - rust-lang#106167 (Fix invalid syntax and incomplete suggestion in impl Trait parameter type suggestions for E0311) - rust-lang#106309 (Prefer non-`[type error]` candidates during selection) - rust-lang#106532 (Allow codegen to unsize `dyn*` to `dyn`) - rust-lang#106596 (Hide more of long types in E0271) - rust-lang#106638 (std tests: use __OsLocalKeyInner from realstd) - rust-lang#106676 (Test that we cannot use trait impl methods arguments as defining uses) - rust-lang#106702 (Conserve cause of `ImplDerivedObligation` in E0599) - rust-lang#106732 (rustc_llvm: replace llvm::makeArrayRef with ArrayRef constructors.) - rust-lang#106733 (Revert "warn newer available version of the x tool") - rust-lang#106748 (Clean up `OnUnimplementedFormatString::verify`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4887cb1 + e8ef83e commit 2b8590e

File tree

62 files changed

+860
-337
lines changed

Some content is hidden

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

62 files changed

+860
-337
lines changed

Cargo.lock

+10-11
Original file line numberDiff line numberDiff line change
@@ -5034,18 +5034,18 @@ checksum = "1ef965a420fe14fdac7dd018862966a4c14094f900e1650bbc71ddd7d580c8af"
50345034

50355035
[[package]]
50365036
name = "semver"
5037-
version = "1.0.14"
5037+
version = "1.0.12"
50385038
source = "registry+https://github.com/rust-lang/crates.io-index"
5039-
checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4"
5039+
checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1"
50405040
dependencies = [
50415041
"serde",
50425042
]
50435043

50445044
[[package]]
50455045
name = "serde"
5046-
version = "1.0.152"
5046+
version = "1.0.147"
50475047
source = "registry+https://github.com/rust-lang/crates.io-index"
5048-
checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb"
5048+
checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965"
50495049
dependencies = [
50505050
"serde_derive",
50515051
]
@@ -5062,9 +5062,9 @@ dependencies = [
50625062

50635063
[[package]]
50645064
name = "serde_derive"
5065-
version = "1.0.152"
5065+
version = "1.0.147"
50665066
source = "registry+https://github.com/rust-lang/crates.io-index"
5067-
checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e"
5067+
checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852"
50685068
dependencies = [
50695069
"proc-macro2",
50705070
"quote",
@@ -5082,9 +5082,9 @@ dependencies = [
50825082

50835083
[[package]]
50845084
name = "serde_json"
5085-
version = "1.0.91"
5085+
version = "1.0.85"
50865086
source = "registry+https://github.com/rust-lang/crates.io-index"
5087-
checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883"
5087+
checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44"
50885088
dependencies = [
50895089
"indexmap",
50905090
"itoa",
@@ -5400,9 +5400,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
54005400

54015401
[[package]]
54025402
name = "syn"
5403-
version = "1.0.107"
5403+
version = "1.0.102"
54045404
source = "registry+https://github.com/rust-lang/crates.io-index"
5405-
checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
5405+
checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1"
54065406
dependencies = [
54075407
"proc-macro2",
54085408
"quote",
@@ -5576,7 +5576,6 @@ dependencies = [
55765576
"lazy_static",
55775577
"miropt-test-tools",
55785578
"regex",
5579-
"semver",
55805579
"termcolor",
55815580
"walkdir",
55825581
]

compiler/rustc_codegen_ssa/src/base.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,7 @@ pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
153153
(
154154
&ty::Dynamic(ref data_a, _, src_dyn_kind),
155155
&ty::Dynamic(ref data_b, _, target_dyn_kind),
156-
) => {
157-
assert_eq!(src_dyn_kind, target_dyn_kind);
158-
156+
) if src_dyn_kind == target_dyn_kind => {
159157
let old_info =
160158
old_info.expect("unsized_info: missing old info for trait upcasting coercion");
161159
if data_a.principal_def_id() == data_b.principal_def_id() {

compiler/rustc_hir_typeck/src/method/probe.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,23 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
15561556

15571557
// Convert the bounds into obligations.
15581558
let impl_obligations = traits::predicates_for_generics(
1559-
|_, _| cause.clone(),
1559+
|_idx, span| {
1560+
let misc = traits::ObligationCause::misc(span, self.body_id);
1561+
let parent_trait_pred = ty::Binder::dummy(ty::TraitPredicate {
1562+
trait_ref: ty::TraitRef::from_method(self.tcx, impl_def_id, substs),
1563+
constness: ty::BoundConstness::NotConst,
1564+
polarity: ty::ImplPolarity::Positive,
1565+
});
1566+
misc.derived_cause(parent_trait_pred, |derived| {
1567+
traits::ImplDerivedObligation(Box::new(
1568+
traits::ImplDerivedObligationCause {
1569+
derived,
1570+
impl_def_id,
1571+
span,
1572+
},
1573+
))
1574+
})
1575+
},
15601576
self.param_env,
15611577
impl_bounds,
15621578
);

compiler/rustc_hir_typeck/src/method/suggest.rs

+40-33
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
101101
self.autoderef(span, ty).any(|(ty, _)| matches!(ty.kind(), ty::Slice(..) | ty::Array(..)))
102102
}
103103

104+
#[instrument(level = "debug", skip(self))]
104105
pub fn report_method_error(
105106
&self,
106107
span: Span,
@@ -586,22 +587,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
586587

587588
// Find all the requirements that come from a local `impl` block.
588589
let mut skip_list: FxHashSet<_> = Default::default();
589-
let mut spanned_predicates: FxHashMap<MultiSpan, _> = Default::default();
590-
for (data, p, parent_p, impl_def_id, cause) in unsatisfied_predicates
590+
let mut spanned_predicates = FxHashMap::default();
591+
for (p, parent_p, impl_def_id, cause) in unsatisfied_predicates
591592
.iter()
592593
.filter_map(|(p, parent, c)| c.as_ref().map(|c| (p, parent, c)))
593594
.filter_map(|(p, parent, c)| match c.code() {
594-
ObligationCauseCode::ImplDerivedObligation(data) => {
595-
Some((&data.derived, p, parent, data.impl_def_id, data))
595+
ObligationCauseCode::ImplDerivedObligation(data)
596+
if matches!(p.kind().skip_binder(), ty::PredicateKind::Clause(_)) =>
597+
{
598+
Some((p, parent, data.impl_def_id, data))
596599
}
597600
_ => None,
598601
})
599602
{
600-
let parent_trait_ref = data.parent_trait_pred;
601-
let path = parent_trait_ref.print_modifiers_and_trait_path();
602-
let tr_self_ty = parent_trait_ref.skip_binder().self_ty();
603-
let unsatisfied_msg = "unsatisfied trait bound introduced here";
604-
let derive_msg = "unsatisfied trait bound introduced in this `derive` macro";
605603
match self.tcx.hir().get_if_local(impl_def_id) {
606604
// Unmet obligation comes from a `derive` macro, point at it once to
607605
// avoid multiple span labels pointing at the same place.
@@ -617,10 +615,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
617615
) =>
618616
{
619617
let span = self_ty.span.ctxt().outer_expn_data().call_site;
620-
let mut spans: MultiSpan = span.into();
621-
spans.push_span_label(span, derive_msg);
622-
let entry = spanned_predicates.entry(spans);
623-
entry.or_insert_with(|| (path, tr_self_ty, Vec::new())).2.push(p);
618+
let entry = spanned_predicates.entry(span);
619+
let entry = entry.or_insert_with(|| {
620+
(FxHashSet::default(), FxHashSet::default(), Vec::new())
621+
});
622+
entry.0.insert(span);
623+
entry.1.insert((
624+
span,
625+
"unsatisfied trait bound introduced in this `derive` macro",
626+
));
627+
entry.2.push(p);
628+
skip_list.insert(p);
624629
}
625630

626631
// Unmet obligation coming from an `impl`.
@@ -647,8 +652,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
647652
};
648653
err.span_suggestion_verbose(
649654
sp,
650-
"consider relaxing the type parameter's implicit \
651-
`Sized` bound",
655+
"consider relaxing the type parameter's implicit `Sized` bound",
652656
sugg,
653657
Applicability::MachineApplicable,
654658
);
@@ -659,25 +663,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
659663
let _ = format_pred(*pred);
660664
}
661665
skip_list.insert(p);
662-
let mut spans = if cause.span != *item_span {
663-
let mut spans: MultiSpan = cause.span.into();
664-
spans.push_span_label(cause.span, unsatisfied_msg);
665-
spans
666+
let entry = spanned_predicates.entry(self_ty.span);
667+
let entry = entry.or_insert_with(|| {
668+
(FxHashSet::default(), FxHashSet::default(), Vec::new())
669+
});
670+
entry.2.push(p);
671+
if cause.span != *item_span {
672+
entry.0.insert(cause.span);
673+
entry.1.insert((cause.span, "unsatisfied trait bound introduced here"));
666674
} else {
667-
let mut spans = Vec::with_capacity(2);
668675
if let Some(trait_ref) = of_trait {
669-
spans.push(trait_ref.path.span);
676+
entry.0.insert(trait_ref.path.span);
670677
}
671-
spans.push(self_ty.span);
672-
spans.into()
678+
entry.0.insert(self_ty.span);
673679
};
674680
if let Some(trait_ref) = of_trait {
675-
spans.push_span_label(trait_ref.path.span, "");
681+
entry.1.insert((trait_ref.path.span, ""));
676682
}
677-
spans.push_span_label(self_ty.span, "");
678-
679-
let entry = spanned_predicates.entry(spans);
680-
entry.or_insert_with(|| (path, tr_self_ty, Vec::new())).2.push(p);
683+
entry.1.insert((self_ty.span, ""));
681684
}
682685
Some(Node::Item(hir::Item {
683686
kind: hir::ItemKind::Trait(rustc_ast::ast::IsAuto::Yes, ..),
@@ -694,11 +697,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
694697
}
695698
}
696699
let mut spanned_predicates: Vec<_> = spanned_predicates.into_iter().collect();
697-
spanned_predicates.sort_by_key(|(span, (_, _, _))| span.primary_span());
698-
for (span, (_path, _self_ty, preds)) in spanned_predicates {
699-
let mut preds: Vec<_> = preds
700-
.into_iter()
701-
.filter_map(|pred| format_pred(*pred))
700+
spanned_predicates.sort_by_key(|(span, _)| *span);
701+
for (_, (primary_spans, span_labels, predicates)) in spanned_predicates {
702+
let mut preds: Vec<_> = predicates
703+
.iter()
704+
.filter_map(|pred| format_pred(**pred))
702705
.map(|(p, _)| format!("`{}`", p))
703706
.collect();
704707
preds.sort();
@@ -708,6 +711,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
708711
} else {
709712
format!("the following trait bounds were not satisfied:\n{}", preds.join("\n"),)
710713
};
714+
let mut span: MultiSpan = primary_spans.into_iter().collect::<Vec<_>>().into();
715+
for (sp, label) in span_labels {
716+
span.push_span_label(sp, label);
717+
}
711718
err.span_note(span, &msg);
712719
unsatisfied_bounds = true;
713720
}

0 commit comments

Comments
 (0)