Skip to content

Commit e7c1ba8

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 bb2b765 commit e7c1ba8

25 files changed

+326
-601
lines changed

compiler/rustc_hir/src/hir.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3139,6 +3139,15 @@ pub enum TraitItemKind<'hir> {
31393139
/// type.
31403140
Type(GenericBounds<'hir>, Option<&'hir Ty<'hir>>),
31413141
}
3142+
impl TraitItemKind<'_> {
3143+
pub fn descr(&self) -> &'static str {
3144+
match self {
3145+
TraitItemKind::Const(..) => "associated constant",
3146+
TraitItemKind::Fn(..) => "function",
3147+
TraitItemKind::Type(..) => "associated type",
3148+
}
3149+
}
3150+
}
31423151

31433152
// The bodies for items are stored "out of line", in a separate
31443153
// hashmap in the `Crate`. Here we just record the hir-id of the item
@@ -3199,6 +3208,15 @@ pub enum ImplItemKind<'hir> {
31993208
/// An associated type.
32003209
Type(&'hir Ty<'hir>),
32013210
}
3211+
impl ImplItemKind<'_> {
3212+
pub fn descr(&self) -> &'static str {
3213+
match self {
3214+
ImplItemKind::Const(..) => "associated constant",
3215+
ImplItemKind::Fn(..) => "function",
3216+
ImplItemKind::Type(..) => "associated type",
3217+
}
3218+
}
3219+
}
32023220

32033221
/// A constraint on an associated item.
32043222
///
@@ -4522,6 +4540,16 @@ pub enum ForeignItemKind<'hir> {
45224540
Type,
45234541
}
45244542

4543+
impl ForeignItemKind<'_> {
4544+
pub fn descr(&self) -> &'static str {
4545+
match self {
4546+
ForeignItemKind::Fn(..) => "function",
4547+
ForeignItemKind::Static(..) => "static variable",
4548+
ForeignItemKind::Type => "type",
4549+
}
4550+
}
4551+
}
4552+
45254553
/// A variable captured by a closure.
45264554
#[derive(Debug, Copy, Clone, HashStable_Generic)]
45274555
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)