Skip to content

Commit 993b819

Browse files
committed
Report infer ty errors during hir ty lowering
This centralizes the placeholder type error reporting in one location, but it also exposes the granularity at which we convert things from hir to ty more. E.g. previously infer types in where bounds were errored together with the function signature, but now they are independent.
1 parent fe5c95d commit 993b819

25 files changed

+327
-602
lines changed

compiler/rustc_hir/src/hir.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3134,6 +3134,15 @@ pub enum TraitItemKind<'hir> {
31343134
/// type.
31353135
Type(GenericBounds<'hir>, Option<&'hir Ty<'hir>>),
31363136
}
3137+
impl TraitItemKind<'_> {
3138+
pub fn descr(&self) -> &'static str {
3139+
match self {
3140+
TraitItemKind::Const(..) => "associated constant",
3141+
TraitItemKind::Fn(..) => "function",
3142+
TraitItemKind::Type(..) => "associated type",
3143+
}
3144+
}
3145+
}
31373146

31383147
// The bodies for items are stored "out of line", in a separate
31393148
// hashmap in the `Crate`. Here we just record the hir-id of the item
@@ -3194,6 +3203,15 @@ pub enum ImplItemKind<'hir> {
31943203
/// An associated type.
31953204
Type(&'hir Ty<'hir>),
31963205
}
3206+
impl ImplItemKind<'_> {
3207+
pub fn descr(&self) -> &'static str {
3208+
match self {
3209+
ImplItemKind::Const(..) => "associated constant",
3210+
ImplItemKind::Fn(..) => "function",
3211+
ImplItemKind::Type(..) => "associated type",
3212+
}
3213+
}
3214+
}
31973215

31983216
/// A constraint on an associated item.
31993217
///
@@ -4517,6 +4535,16 @@ pub enum ForeignItemKind<'hir> {
45174535
Type,
45184536
}
45194537

4538+
impl ForeignItemKind<'_> {
4539+
pub fn descr(&self) -> &'static str {
4540+
match self {
4541+
ForeignItemKind::Fn(..) => "function",
4542+
ForeignItemKind::Static(..) => "static variable",
4543+
ForeignItemKind::Type => "type",
4544+
}
4545+
}
4546+
}
4547+
45204548
/// A variable captured by a closure.
45214549
#[derive(Debug, Copy, Clone, HashStable_Generic)]
45224550
pub struct Upvar {

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
231231
item.name = ? tcx.def_path_str(def_id)
232232
);
233233
crate::collect::lower_item(tcx, item.item_id());
234-
crate::collect::reject_placeholder_type_signatures_in_item(tcx, item);
235234

236235
let res = match item.kind {
237236
// Right now we check that every default trait implementation

0 commit comments

Comments
 (0)