File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -34,12 +34,18 @@ pub struct DeducedParamAttrs {
3434
3535// By default, consider the parameters to be mutated.
3636impl Default for DeducedParamAttrs {
37+ #[ inline]
3738 fn default ( ) -> DeducedParamAttrs {
3839 DeducedParamAttrs { read_only : DeducedReadOnlyParam :: MUTATED }
3940 }
4041}
4142
4243impl DeducedParamAttrs {
44+ #[ inline]
45+ pub fn is_default ( self ) -> bool {
46+ self . read_only . contains ( DeducedReadOnlyParam :: MUTATED )
47+ }
48+
4349 pub fn read_only < ' tcx > (
4450 & self ,
4551 tcx : TyCtxt < ' tcx > ,
Original file line number Diff line number Diff line change @@ -170,16 +170,17 @@ pub(super) fn deduced_param_attrs<'tcx>(
170170 deduce_read_only. visit_body ( body) ;
171171 tracing:: trace!( ?deduce_read_only. read_only) ;
172172
173- let mut deduced_param_attrs = tcx. arena . alloc_from_iter (
173+ let mut deduced_param_attrs: & [ _ ] = tcx. arena . alloc_from_iter (
174174 deduce_read_only. read_only . into_iter ( ) . map ( |read_only| DeducedParamAttrs { read_only } ) ,
175175 ) ;
176176
177177 // Trailing parameters past the size of the `deduced_param_attrs` array are assumed to have the
178178 // default set of attributes, so we don't have to store them explicitly. Pop them off to save a
179179 // few bytes in metadata.
180- while deduced_param_attrs. last ( ) == Some ( & DeducedParamAttrs :: default ( ) ) {
181- let last_index = deduced_param_attrs. len ( ) - 1 ;
182- deduced_param_attrs = & mut deduced_param_attrs[ 0 ..last_index] ;
180+ while let Some ( ( last, rest) ) = deduced_param_attrs. split_last ( )
181+ && last. is_default ( )
182+ {
183+ deduced_param_attrs = rest;
183184 }
184185
185186 deduced_param_attrs
You can’t perform that action at this time.
0 commit comments