Skip to content

Commit cf77564

Browse files
committed
Always consider static methods object-safe
This also fixes #18490 as a side-effect by avoiding a later out-of-bounds slice.
1 parent 3327ecc commit cf77564

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/librustc/middle/typeck/check/vtable.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,11 @@ pub fn check_object_safety(tcx: &ty::ctxt, object_trait: &ty::TyTrait, span: Spa
187187
receiver through a trait object", method_name))
188188
}
189189

190-
ty::StaticExplicitSelfCategory |
190+
ty::StaticExplicitSelfCategory => {
191+
// Static methods are always object-safe since they
192+
// can't be called through a trait object
193+
return msgs
194+
}
191195
ty::ByReferenceExplicitSelfCategory(..) |
192196
ty::ByBoxExplicitSelfCategory => {}
193197
}

0 commit comments

Comments
 (0)