This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 9 files changed +13
-47
lines changed
librustc_infer/traits/specialize Expand file tree Collapse file tree 9 files changed +13
-47
lines changed Original file line number Diff line number Diff line change @@ -365,11 +365,7 @@ unsafe impl<'a> ReverseSearcher<'a> for CharSearcher<'a> {
365
365
let haystack = self . haystack . as_bytes ( ) ;
366
366
loop {
367
367
// get the haystack up to but not including the last character searched
368
- let bytes = if let Some ( slice) = haystack. get ( self . finger ..self . finger_back ) {
369
- slice
370
- } else {
371
- return None ;
372
- } ;
368
+ let bytes = haystack. get ( self . finger ..self . finger_back ) ?;
373
369
// the last byte of the utf8 encoded needle
374
370
// SAFETY: we have an invariant that `utf8_size < 5`
375
371
let last_byte = unsafe { * self . utf8_encoded . get_unchecked ( self . utf8_size - 1 ) } ;
@@ -575,11 +571,12 @@ macro_rules! pattern_methods {
575
571
576
572
#[ inline]
577
573
fn is_suffix_of( self , haystack: & ' a str ) -> bool
578
- where $t: ReverseSearcher <' a>
574
+ where
575
+ $t: ReverseSearcher <' a>,
579
576
{
580
577
( $pmap) ( self ) . is_suffix_of( haystack)
581
578
}
582
- }
579
+ } ;
583
580
}
584
581
585
582
macro_rules! searcher_methods {
@@ -614,7 +611,7 @@ macro_rules! searcher_methods {
614
611
fn next_reject_back( & mut self ) -> Option <( usize , usize ) > {
615
612
self . 0 . next_reject_back( )
616
613
}
617
- }
614
+ } ;
618
615
}
619
616
620
617
/////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change @@ -298,7 +298,7 @@ impl<'hir> Map<'hir> {
298
298
}
299
299
300
300
pub fn def_kind ( & self , hir_id : HirId ) -> Option < DefKind > {
301
- let node = if let Some ( node ) = self . find ( hir_id) { node } else { return None } ;
301
+ let node = self . find ( hir_id) ? ;
302
302
303
303
Some ( match node {
304
304
Node :: Item ( item) => match item. kind {
Original file line number Diff line number Diff line change @@ -346,12 +346,7 @@ impl<'tcx> TyCtxt<'tcx> {
346
346
adt_did : DefId ,
347
347
validate : & mut dyn FnMut ( Self , DefId ) -> Result < ( ) , ErrorReported > ,
348
348
) -> Option < ty:: Destructor > {
349
- let drop_trait = if let Some ( def_id) = self . lang_items ( ) . drop_trait ( ) {
350
- def_id
351
- } else {
352
- return None ;
353
- } ;
354
-
349
+ let drop_trait = self . lang_items ( ) . drop_trait ( ) ?;
355
350
self . ensure ( ) . coherent_trait ( drop_trait) ;
356
351
357
352
let mut dtor_did = None ;
Original file line number Diff line number Diff line change @@ -1120,12 +1120,7 @@ fn extra_compiler_flags() -> Option<(Vec<String>, bool)> {
1120
1120
return None ;
1121
1121
}
1122
1122
1123
- let matches = if let Some ( matches) = handle_options ( & args) {
1124
- matches
1125
- } else {
1126
- return None ;
1127
- } ;
1128
-
1123
+ let matches = handle_options ( & args) ?;
1129
1124
let mut result = Vec :: new ( ) ;
1130
1125
let mut excluded_cargo_defaults = false ;
1131
1126
for flag in ICE_REPORT_COMPILER_FLAGS {
Original file line number Diff line number Diff line change @@ -413,12 +413,7 @@ pub(super) fn specialization_graph_provider(
413
413
fn to_pretty_impl_header ( tcx : TyCtxt < ' _ > , impl_def_id : DefId ) -> Option < String > {
414
414
use std:: fmt:: Write ;
415
415
416
- let trait_ref = if let Some ( tr) = tcx. impl_trait_ref ( impl_def_id) {
417
- tr
418
- } else {
419
- return None ;
420
- } ;
421
-
416
+ let trait_ref = tcx. impl_trait_ref ( impl_def_id) ?;
422
417
let mut w = "impl" . to_owned ( ) ;
423
418
424
419
let substs = InternalSubsts :: identity_for_item ( tcx, impl_def_id) ;
Original file line number Diff line number Diff line change @@ -2778,12 +2778,8 @@ impl<'a> Resolver<'a> {
2778
2778
} else {
2779
2779
let crate_id = if !speculative {
2780
2780
self . crate_loader . process_path_extern ( ident. name , ident. span )
2781
- } else if let Some ( crate_id) =
2782
- self . crate_loader . maybe_process_path_extern ( ident. name , ident. span )
2783
- {
2784
- crate_id
2785
2781
} else {
2786
- return None ;
2782
+ self . crate_loader . maybe_process_path_extern ( ident . name , ident . span ) ?
2787
2783
} ;
2788
2784
let crate_root = self . get_module ( DefId { krate : crate_id, index : CRATE_DEF_INDEX } ) ;
2789
2785
Some (
Original file line number Diff line number Diff line change @@ -1167,11 +1167,7 @@ impl SourceFile {
1167
1167
}
1168
1168
1169
1169
let begin = {
1170
- let line = if let Some ( line) = self . lines . get ( line_number) {
1171
- line
1172
- } else {
1173
- return None ;
1174
- } ;
1170
+ let line = self . lines . get ( line_number) ?;
1175
1171
let begin: BytePos = * line - self . start_pos ;
1176
1172
begin. to_usize ( )
1177
1173
} ;
Original file line number Diff line number Diff line change @@ -42,11 +42,7 @@ pub fn try_inline(
42
42
attrs : Option < Attrs < ' _ > > ,
43
43
visited : & mut FxHashSet < DefId > ,
44
44
) -> Option < Vec < clean:: Item > > {
45
- let did = if let Some ( did) = res. opt_def_id ( ) {
46
- did
47
- } else {
48
- return None ;
49
- } ;
45
+ let did = res. opt_def_id ( ) ?;
50
46
if did. is_local ( ) {
51
47
return None ;
52
48
}
Original file line number Diff line number Diff line change @@ -844,11 +844,7 @@ pub fn plain_summary_line(md: &str) -> String {
844
844
type Item = String ;
845
845
846
846
fn next ( & mut self ) -> Option < String > {
847
- let next_event = self . inner . next ( ) ;
848
- if next_event. is_none ( ) {
849
- return None ;
850
- }
851
- let next_event = next_event. unwrap ( ) ;
847
+ let next_event = self . inner . next ( ) ?;
852
848
let ( ret, is_in) = match next_event {
853
849
Event :: Start ( Tag :: Paragraph ) => ( None , 1 ) ,
854
850
Event :: Start ( Tag :: Heading ( _) ) => ( None , 1 ) ,
You can’t perform that action at this time.
0 commit comments