Skip to content

Commit

Permalink
Auto merge of #106757 - matthiaskrgr:rollup-9j8830g, r=matthiaskrgr
Browse files Browse the repository at this point in the history
Rollup of 10 pull requests

Successful merges:

 - #106167 (Fix invalid syntax and incomplete suggestion in impl Trait parameter type suggestions for E0311)
 - #106309 (Prefer non-`[type error]` candidates during selection)
 - #106532 (Allow codegen to unsize `dyn*` to `dyn`)
 - #106596 (Hide more of long types in E0271)
 - #106638 (std tests: use __OsLocalKeyInner from realstd)
 - #106676 (Test that we cannot use trait impl methods arguments as defining uses)
 - #106702 (Conserve cause of `ImplDerivedObligation` in E0599)
 - #106732 (rustc_llvm: replace llvm::makeArrayRef with ArrayRef constructors.)
 - #106733 (Revert "warn newer available version of the x tool")
 - #106748 (Clean up `OnUnimplementedFormatString::verify`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Jan 12, 2023
2 parents 4887cb1 + e8ef83e commit 2b8590e
Show file tree
Hide file tree
Showing 62 changed files with 860 additions and 337 deletions.
21 changes: 10 additions & 11 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5034,18 +5034,18 @@ checksum = "1ef965a420fe14fdac7dd018862966a4c14094f900e1650bbc71ddd7d580c8af"

[[package]]
name = "semver"
version = "1.0.14"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4"
checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1"
dependencies = [
"serde",
]

[[package]]
name = "serde"
version = "1.0.152"
version = "1.0.147"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb"
checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965"
dependencies = [
"serde_derive",
]
Expand All @@ -5062,9 +5062,9 @@ dependencies = [

[[package]]
name = "serde_derive"
version = "1.0.152"
version = "1.0.147"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e"
checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852"
dependencies = [
"proc-macro2",
"quote",
Expand All @@ -5082,9 +5082,9 @@ dependencies = [

[[package]]
name = "serde_json"
version = "1.0.91"
version = "1.0.85"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883"
checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44"
dependencies = [
"indexmap",
"itoa",
Expand Down Expand Up @@ -5400,9 +5400,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"

[[package]]
name = "syn"
version = "1.0.107"
version = "1.0.102"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1"
dependencies = [
"proc-macro2",
"quote",
Expand Down Expand Up @@ -5576,7 +5576,6 @@ dependencies = [
"lazy_static",
"miropt-test-tools",
"regex",
"semver",
"termcolor",
"walkdir",
]
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
(
&ty::Dynamic(ref data_a, _, src_dyn_kind),
&ty::Dynamic(ref data_b, _, target_dyn_kind),
) => {
assert_eq!(src_dyn_kind, target_dyn_kind);

) if src_dyn_kind == target_dyn_kind => {
let old_info =
old_info.expect("unsized_info: missing old info for trait upcasting coercion");
if data_a.principal_def_id() == data_b.principal_def_id() {
Expand Down
18 changes: 17 additions & 1 deletion compiler/rustc_hir_typeck/src/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,23 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {

// Convert the bounds into obligations.
let impl_obligations = traits::predicates_for_generics(
|_, _| cause.clone(),
|_idx, span| {
let misc = traits::ObligationCause::misc(span, self.body_id);
let parent_trait_pred = ty::Binder::dummy(ty::TraitPredicate {
trait_ref: ty::TraitRef::from_method(self.tcx, impl_def_id, substs),
constness: ty::BoundConstness::NotConst,
polarity: ty::ImplPolarity::Positive,
});
misc.derived_cause(parent_trait_pred, |derived| {
traits::ImplDerivedObligation(Box::new(
traits::ImplDerivedObligationCause {
derived,
impl_def_id,
span,
},
))
})
},
self.param_env,
impl_bounds,
);
Expand Down
73 changes: 40 additions & 33 deletions compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.autoderef(span, ty).any(|(ty, _)| matches!(ty.kind(), ty::Slice(..) | ty::Array(..)))
}

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

// Find all the requirements that come from a local `impl` block.
let mut skip_list: FxHashSet<_> = Default::default();
let mut spanned_predicates: FxHashMap<MultiSpan, _> = Default::default();
for (data, p, parent_p, impl_def_id, cause) in unsatisfied_predicates
let mut spanned_predicates = FxHashMap::default();
for (p, parent_p, impl_def_id, cause) in unsatisfied_predicates
.iter()
.filter_map(|(p, parent, c)| c.as_ref().map(|c| (p, parent, c)))
.filter_map(|(p, parent, c)| match c.code() {
ObligationCauseCode::ImplDerivedObligation(data) => {
Some((&data.derived, p, parent, data.impl_def_id, data))
ObligationCauseCode::ImplDerivedObligation(data)
if matches!(p.kind().skip_binder(), ty::PredicateKind::Clause(_)) =>
{
Some((p, parent, data.impl_def_id, data))
}
_ => None,
})
{
let parent_trait_ref = data.parent_trait_pred;
let path = parent_trait_ref.print_modifiers_and_trait_path();
let tr_self_ty = parent_trait_ref.skip_binder().self_ty();
let unsatisfied_msg = "unsatisfied trait bound introduced here";
let derive_msg = "unsatisfied trait bound introduced in this `derive` macro";
match self.tcx.hir().get_if_local(impl_def_id) {
// Unmet obligation comes from a `derive` macro, point at it once to
// avoid multiple span labels pointing at the same place.
Expand All @@ -617,10 +615,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
) =>
{
let span = self_ty.span.ctxt().outer_expn_data().call_site;
let mut spans: MultiSpan = span.into();
spans.push_span_label(span, derive_msg);
let entry = spanned_predicates.entry(spans);
entry.or_insert_with(|| (path, tr_self_ty, Vec::new())).2.push(p);
let entry = spanned_predicates.entry(span);
let entry = entry.or_insert_with(|| {
(FxHashSet::default(), FxHashSet::default(), Vec::new())
});
entry.0.insert(span);
entry.1.insert((
span,
"unsatisfied trait bound introduced in this `derive` macro",
));
entry.2.push(p);
skip_list.insert(p);
}

// Unmet obligation coming from an `impl`.
Expand All @@ -647,8 +652,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
};
err.span_suggestion_verbose(
sp,
"consider relaxing the type parameter's implicit \
`Sized` bound",
"consider relaxing the type parameter's implicit `Sized` bound",
sugg,
Applicability::MachineApplicable,
);
Expand All @@ -659,25 +663,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let _ = format_pred(*pred);
}
skip_list.insert(p);
let mut spans = if cause.span != *item_span {
let mut spans: MultiSpan = cause.span.into();
spans.push_span_label(cause.span, unsatisfied_msg);
spans
let entry = spanned_predicates.entry(self_ty.span);
let entry = entry.or_insert_with(|| {
(FxHashSet::default(), FxHashSet::default(), Vec::new())
});
entry.2.push(p);
if cause.span != *item_span {
entry.0.insert(cause.span);
entry.1.insert((cause.span, "unsatisfied trait bound introduced here"));
} else {
let mut spans = Vec::with_capacity(2);
if let Some(trait_ref) = of_trait {
spans.push(trait_ref.path.span);
entry.0.insert(trait_ref.path.span);
}
spans.push(self_ty.span);
spans.into()
entry.0.insert(self_ty.span);
};
if let Some(trait_ref) = of_trait {
spans.push_span_label(trait_ref.path.span, "");
entry.1.insert((trait_ref.path.span, ""));
}
spans.push_span_label(self_ty.span, "");

let entry = spanned_predicates.entry(spans);
entry.or_insert_with(|| (path, tr_self_ty, Vec::new())).2.push(p);
entry.1.insert((self_ty.span, ""));
}
Some(Node::Item(hir::Item {
kind: hir::ItemKind::Trait(rustc_ast::ast::IsAuto::Yes, ..),
Expand All @@ -694,11 +697,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
let mut spanned_predicates: Vec<_> = spanned_predicates.into_iter().collect();
spanned_predicates.sort_by_key(|(span, (_, _, _))| span.primary_span());
for (span, (_path, _self_ty, preds)) in spanned_predicates {
let mut preds: Vec<_> = preds
.into_iter()
.filter_map(|pred| format_pred(*pred))
spanned_predicates.sort_by_key(|(span, _)| *span);
for (_, (primary_spans, span_labels, predicates)) in spanned_predicates {
let mut preds: Vec<_> = predicates
.iter()
.filter_map(|pred| format_pred(**pred))
.map(|(p, _)| format!("`{}`", p))
.collect();
preds.sort();
Expand All @@ -708,6 +711,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else {
format!("the following trait bounds were not satisfied:\n{}", preds.join("\n"),)
};
let mut span: MultiSpan = primary_spans.into_iter().collect::<Vec<_>>().into();
for (sp, label) in span_labels {
span.push_span_label(sp, label);
}
err.span_note(span, &msg);
unsatisfied_bounds = true;
}
Expand Down
Loading

0 comments on commit 2b8590e

Please sign in to comment.