@@ -381,17 +381,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckItemTypesVisitor<'a, 'tcx> {
381381 }
382382}
383383
384- struct CheckItemSizedTypesVisitor < ' a , ' tcx : ' a > {
385- ccx : & ' a CrateCtxt < ' a , ' tcx >
386- }
387-
388- impl < ' a , ' tcx , ' v > Visitor < ' v > for CheckItemSizedTypesVisitor < ' a , ' tcx > {
389- fn visit_item ( & mut self , i : & ast:: Item ) {
390- check_item_sized ( self . ccx , i) ;
391- visit:: walk_item ( self , i) ;
392- }
393- }
394-
395384pub fn check_item_types ( ccx : & CrateCtxt ) {
396385 let krate = ccx. tcx . map . krate ( ) ;
397386 let mut visit = wf:: CheckTypeWellFormedVisitor :: new ( ccx) ;
@@ -405,9 +394,6 @@ pub fn check_item_types(ccx: &CrateCtxt) {
405394 visit:: walk_crate ( & mut visit, krate) ;
406395
407396 ccx. tcx . sess . abort_if_errors ( ) ;
408-
409- let mut visit = CheckItemSizedTypesVisitor { ccx : ccx } ;
410- visit:: walk_crate ( & mut visit, krate) ;
411397}
412398
413399fn check_bare_fn ( ccx : & CrateCtxt ,
@@ -670,33 +656,6 @@ fn check_for_field_shadowing(tcx: &ty::ctxt,
670656 }
671657}
672658
673- fn check_fields_sized ( tcx : & ty:: ctxt ,
674- struct_def : & ast:: StructDef ) {
675- let len = struct_def. fields . len ( ) ;
676- if len == 0 {
677- return ;
678- }
679- for f in struct_def. fields . slice_to ( len - 1 ) . iter ( ) {
680- let t = ty:: node_id_to_type ( tcx, f. node . id ) ;
681- if !ty:: type_is_sized ( tcx, t) {
682- match f. node . kind {
683- ast:: NamedField ( ident, _) => {
684- span_err ! ( tcx. sess, f. span, E0042 ,
685- "type `{}` is dynamically sized. \
686- dynamically sized types may only \
687- appear as the type of the final \
688- field in a struct",
689- token:: get_ident( ident) ) ;
690- }
691- ast:: UnnamedField ( _) => {
692- span_err ! ( tcx. sess, f. span, E0043 ,
693- "dynamically sized type in field" ) ;
694- }
695- }
696- }
697- }
698- }
699-
700659pub fn check_struct ( ccx : & CrateCtxt , id : ast:: NodeId , span : Span ) {
701660 let tcx = ccx. tcx ;
702661
@@ -711,24 +670,6 @@ pub fn check_struct(ccx: &CrateCtxt, id: ast::NodeId, span: Span) {
711670 }
712671}
713672
714- pub fn check_item_sized ( ccx : & CrateCtxt , it : & ast:: Item ) {
715- debug ! ( "check_item(it.id={}, it.ident={})" ,
716- it. id,
717- ty:: item_path_str( ccx. tcx, local_def( it. id) ) ) ;
718- let _indenter = indenter ( ) ;
719-
720- match it. node {
721- ast:: ItemEnum ( ref enum_definition, _) => {
722- check_enum_variants_sized ( ccx,
723- enum_definition. variants . as_slice ( ) ) ;
724- }
725- ast:: ItemStruct ( ..) => {
726- check_fields_sized ( ccx. tcx , & * ccx. tcx . map . expect_struct ( it. id ) ) ;
727- }
728- _ => { }
729- }
730- }
731-
732673pub fn check_item ( ccx : & CrateCtxt , it : & ast:: Item ) {
733674 debug ! ( "check_item(it.id={}, it.ident={})" ,
734675 it. id,
@@ -4946,39 +4887,6 @@ pub fn check_simd(tcx: &ty::ctxt, sp: Span, id: ast::NodeId) {
49464887 }
49474888}
49484889
4949-
4950- pub fn check_enum_variants_sized ( ccx : & CrateCtxt ,
4951- vs : & [ P < ast:: Variant > ] ) {
4952- for v in vs. iter ( ) {
4953- match v. node . kind {
4954- ast:: TupleVariantKind ( ref args) if args. len ( ) > 0 => {
4955- let ctor_ty = ty:: node_id_to_type ( ccx. tcx , v. node . id ) ;
4956- let arg_tys: Vec < ty:: t > = ty:: ty_fn_args ( ctor_ty) . iter ( ) . map ( |a| * a) . collect ( ) ;
4957- let len = arg_tys. len ( ) ;
4958- if len == 0 {
4959- return ;
4960- }
4961- for ( i, t) in arg_tys. slice_to ( len - 1 ) . iter ( ) . enumerate ( ) {
4962- // Allow the last field in an enum to be unsized.
4963- // We want to do this so that we can support smart pointers.
4964- // A struct value with an unsized final field is itself
4965- // unsized and we must track this in the type system.
4966- if !ty:: type_is_sized ( ccx. tcx , * t) {
4967- span_err ! ( ccx. tcx. sess, args. get( i) . ty. span, E0078 ,
4968- "type `{}` is dynamically sized. dynamically sized types may only \
4969- appear as the final type in a variant",
4970- ppaux:: ty_to_string( ccx. tcx, * t) ) ;
4971- }
4972- }
4973- } ,
4974- ast:: StructVariantKind ( ref struct_def) => {
4975- check_fields_sized ( ccx. tcx , & * * struct_def)
4976- }
4977- _ => { }
4978- }
4979- }
4980- }
4981-
49824890pub fn check_enum_variants ( ccx : & CrateCtxt ,
49834891 sp : Span ,
49844892 vs : & [ P < ast:: Variant > ] ,
0 commit comments