Skip to content

Commit 4f0047e

Browse files
committed
Add a comment on is_trivially_sized about obviously !Sized types
1 parent 8819721 commit 4f0047e

File tree

1 file changed

+6
-0
lines changed
  • compiler/rustc_middle/src/ty

1 file changed

+6
-0
lines changed

compiler/rustc_middle/src/ty/sty.rs

+6
Original file line numberDiff line numberDiff line change
@@ -2280,6 +2280,12 @@ impl<'tcx> TyS<'tcx> {
22802280
///
22812281
/// Returning true means the type is known to be sized. Returning
22822282
/// `false` means nothing -- could be sized, might not be.
2283+
///
2284+
/// Note that we could never rely on the fact that a type such as `[_]` is
2285+
/// trivially `!Sized` because we could be in a type environment with a
2286+
/// bound such as `[_]: Copy`. A function with such a bound obviously never
2287+
/// can be called, but that doesn't mean it shouldn't typecheck. This is why
2288+
/// this method doesn't return `Option<bool>`.
22832289
pub fn is_trivially_sized(&self, tcx: TyCtxt<'tcx>) -> bool {
22842290
match self.kind() {
22852291
ty::Infer(ty::IntVar(_) | ty::FloatVar(_))

0 commit comments

Comments
 (0)