Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f3b7dd6

Browse files
committedJun 16, 2023
Add AliasKind::Weak for type aliases.
Only use it when the type alias contains an opaque type. Also does wf-checking on such type aliases.
1 parent 4fdd07f commit f3b7dd6

File tree

86 files changed

+474
-199
lines changed

Some content is hidden

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

86 files changed

+474
-199
lines changed
 

‎compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -1824,12 +1824,13 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
18241824
ty::Alias(ty::Projection, ..) => Some(12),
18251825
ty::Alias(ty::Inherent, ..) => Some(13),
18261826
ty::Alias(ty::Opaque, ..) => Some(14),
1827-
ty::Never => Some(15),
1828-
ty::Adt(..) => Some(16),
1829-
ty::Generator(..) => Some(17),
1830-
ty::Foreign(..) => Some(18),
1831-
ty::GeneratorWitness(..) => Some(19),
1832-
ty::GeneratorWitnessMIR(..) => Some(20),
1827+
ty::Alias(ty::Weak, ..) => Some(15),
1828+
ty::Never => Some(16),
1829+
ty::Adt(..) => Some(17),
1830+
ty::Generator(..) => Some(18),
1831+
ty::Foreign(..) => Some(19),
1832+
ty::GeneratorWitness(..) => Some(20),
1833+
ty::GeneratorWitnessMIR(..) => Some(21),
18331834
ty::Placeholder(..) | ty::Bound(..) | ty::Infer(..) | ty::Error(_) => None,
18341835
}
18351836
}

‎compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+23
Original file line numberDiff line numberDiff line change
@@ -3198,6 +3198,29 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
31983198
)
31993199
});
32003200
}
3201+
ObligationCauseCode::TypeAlias(ref nested, span, def_id) => {
3202+
// #74711: avoid a stack overflow
3203+
ensure_sufficient_stack(|| {
3204+
self.note_obligation_cause_code(
3205+
body_id,
3206+
err,
3207+
predicate,
3208+
param_env,
3209+
nested,
3210+
obligated_types,
3211+
seen_requirements,
3212+
)
3213+
});
3214+
let mut multispan = MultiSpan::from(span);
3215+
multispan.push_span_label(span, "required by this bound");
3216+
err.span_note(
3217+
multispan,
3218+
format!(
3219+
"required by a bound on the type alias `{}`",
3220+
self.infcx.tcx.item_name(def_id)
3221+
),
3222+
);
3223+
}
32013224
ObligationCauseCode::FunctionArgumentObligation {
32023225
arg_hir_id,
32033226
call_hir_id,
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.