@@ -77,19 +77,17 @@ impl<S: PageSize> Page<S> {
77
77
Ok ( Page :: containing_address ( address) )
78
78
}
79
79
80
- // TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
81
- const_fn ! {
82
- /// Returns the page that starts at the given virtual address.
83
- ///
84
- /// ## Safety
85
- ///
86
- /// The address must be correctly aligned.
87
- #[ inline]
88
- pub unsafe fn from_start_address_unchecked( start_address: VirtAddr ) -> Self {
89
- Page {
90
- start_address,
91
- size: PhantomData ,
92
- }
80
+ /// Returns the page that starts at the given virtual address.
81
+ ///
82
+ /// ## Safety
83
+ ///
84
+ /// The address must be correctly aligned.
85
+ #[ inline]
86
+ #[ rustversion:: attr( since( 1.61 ) , const ) ]
87
+ pub unsafe fn from_start_address_unchecked ( start_address : VirtAddr ) -> Self {
88
+ Page {
89
+ start_address,
90
+ size : PhantomData ,
93
91
}
94
92
}
95
93
@@ -102,78 +100,62 @@ impl<S: PageSize> Page<S> {
102
100
}
103
101
}
104
102
105
- // TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
106
- const_fn ! {
107
- /// Returns the start address of the page.
108
- #[ inline]
109
- pub fn start_address( self ) -> VirtAddr {
110
- self . start_address
111
- }
103
+ /// Returns the start address of the page.
104
+ #[ inline]
105
+ #[ rustversion:: attr( since( 1.61 ) , const ) ]
106
+ pub fn start_address ( self ) -> VirtAddr {
107
+ self . start_address
112
108
}
113
109
114
- // TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
115
- const_fn ! {
116
- /// Returns the size the page (4KB, 2MB or 1GB).
117
- #[ inline]
118
- pub fn size( self ) -> u64 {
119
- S :: SIZE
120
- }
110
+ /// Returns the size the page (4KB, 2MB or 1GB).
111
+ #[ inline]
112
+ #[ rustversion:: attr( since( 1.61 ) , const ) ]
113
+ pub fn size ( self ) -> u64 {
114
+ S :: SIZE
121
115
}
122
116
123
- // TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
124
- const_fn ! {
125
- /// Returns the level 4 page table index of this page.
126
- #[ inline]
127
- pub fn p4_index( self ) -> PageTableIndex {
128
- self . start_address( ) . p4_index( )
129
- }
117
+ /// Returns the level 4 page table index of this page.
118
+ #[ inline]
119
+ #[ rustversion:: attr( since( 1.61 ) , const ) ]
120
+ pub fn p4_index ( self ) -> PageTableIndex {
121
+ self . start_address ( ) . p4_index ( )
130
122
}
131
123
132
- // TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
133
- const_fn ! {
134
- /// Returns the level 3 page table index of this page.
135
- #[ inline]
136
- pub fn p3_index( self ) -> PageTableIndex {
137
- self . start_address( ) . p3_index( )
138
- }
124
+ /// Returns the level 3 page table index of this page.
125
+ #[ inline]
126
+ #[ rustversion:: attr( since( 1.61 ) , const ) ]
127
+ pub fn p3_index ( self ) -> PageTableIndex {
128
+ self . start_address ( ) . p3_index ( )
139
129
}
140
130
141
- // TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
142
- const_fn ! {
143
- /// Returns the table index of this page at the specified level.
144
- #[ inline]
145
- pub fn page_table_index( self , level: PageTableLevel ) -> PageTableIndex {
146
- self . start_address( ) . page_table_index( level)
147
- }
131
+ /// Returns the table index of this page at the specified level.
132
+ #[ inline]
133
+ #[ rustversion:: attr( since( 1.61 ) , const ) ]
134
+ pub fn page_table_index ( self , level : PageTableLevel ) -> PageTableIndex {
135
+ self . start_address ( ) . page_table_index ( level)
148
136
}
149
137
150
- // TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
151
- const_fn ! {
152
- /// Returns a range of pages, exclusive `end`.
153
- #[ inline]
154
- pub fn range( start: Self , end: Self ) -> PageRange <S > {
155
- PageRange { start, end }
156
- }
138
+ /// Returns a range of pages, exclusive `end`.
139
+ #[ inline]
140
+ #[ rustversion:: attr( since( 1.61 ) , const ) ]
141
+ pub fn range ( start : Self , end : Self ) -> PageRange < S > {
142
+ PageRange { start, end }
157
143
}
158
144
159
- // TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
160
- const_fn ! {
161
- /// Returns a range of pages, inclusive `end`.
162
- #[ inline]
163
- pub fn range_inclusive( start: Self , end: Self ) -> PageRangeInclusive <S > {
164
- PageRangeInclusive { start, end }
165
- }
145
+ /// Returns a range of pages, inclusive `end`.
146
+ #[ inline]
147
+ #[ rustversion:: attr( since( 1.61 ) , const ) ]
148
+ pub fn range_inclusive ( start : Self , end : Self ) -> PageRangeInclusive < S > {
149
+ PageRangeInclusive { start, end }
166
150
}
167
151
}
168
152
169
153
impl < S : NotGiantPageSize > Page < S > {
170
- // TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
171
- const_fn ! {
172
- /// Returns the level 2 page table index of this page.
173
- #[ inline]
174
- pub fn p2_index( self ) -> PageTableIndex {
175
- self . start_address( ) . p2_index( )
176
- }
154
+ /// Returns the level 2 page table index of this page.
155
+ #[ inline]
156
+ #[ rustversion:: attr( since( 1.61 ) , const ) ]
157
+ pub fn p2_index ( self ) -> PageTableIndex {
158
+ self . start_address ( ) . p2_index ( )
177
159
}
178
160
}
179
161
0 commit comments