Skip to content

Commit e46087f

Browse files
committed
Fix lint in a very hacky, fragile way.
1 parent f683b96 commit e46087f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

compiler/rustc_lint/src/types.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,22 @@ fn get_nullable_type<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'tcx>>
10411041
// must use an Option<fn(..) -> _> to represent it.
10421042
ty
10431043
}
1044+
ty::Alias(ty::Projection, alias_ty) => {
1045+
let ty::AliasTy { def_id, .. } = alias_ty;
1046+
debug!("get_nullable_type: alias def_id: {:?}", def_id);
10441047

1048+
let assoc_item = tcx.associated_item(def_id);
1049+
debug!("get_nullable_type: alias associated_item: {:?}", assoc_item);
1050+
1051+
// FIXME: Call `get_nullable_type` with the resolved `alias_ty`.
1052+
if assoc_item.name.as_str() == "NonZeroInner" {
1053+
// `<T as ZeroablePrimitive>::NonZeroInner`'s inner value is the same as `T`.
1054+
return Some(args.type_at(0));
1055+
}
1056+
1057+
debug!("get_nullable_type: unhandled alias: {:?} while checking {:?}", alias_ty, ty);
1058+
return None;
1059+
}
10451060
// We should only ever reach this case if ty_is_known_nonnull is extended
10461061
// to other types.
10471062
ref unhandled => {

0 commit comments

Comments
 (0)