Skip to content

Commit ce6367f

Browse files
authored
Rollup merge of #82240 - matthiaskrgr:qmark, r=Dylan-DPC
remove useless ?s (clippy::needless_question_marks) Example code: ```rust fn opts() -> Option<String> { let s: Option<String> = Some(String::new()); Some(s?) // this can just be "s" } ```
2 parents 53b5c6b + f7b8348 commit ce6367f

File tree

7 files changed

+11
-18
lines changed

7 files changed

+11
-18
lines changed

compiler/rustc_infer/src/infer/canonical/query_response.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -507,12 +507,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
507507

508508
// Unify the original value for each variable with the value
509509
// taken from `query_response` (after applying `result_subst`).
510-
Ok(self.unify_canonical_vars(
511-
cause,
512-
param_env,
513-
original_values,
514-
substituted_query_response,
515-
)?)
510+
self.unify_canonical_vars(cause, param_env, original_values, substituted_query_response)
516511
}
517512

518513
/// Converts the region constraints resulting from a query into an

compiler/rustc_middle/src/ty/codec.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for SubstsRef<'tcx> {
253253
fn decode(decoder: &mut D) -> Result<Self, D::Error> {
254254
let len = decoder.read_usize()?;
255255
let tcx = decoder.tcx();
256-
Ok(tcx.mk_substs((0..len).map(|_| Decodable::decode(decoder)))?)
256+
tcx.mk_substs((0..len).map(|_| Decodable::decode(decoder)))
257257
}
258258
}
259259

@@ -314,7 +314,7 @@ impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for ty::AdtDef {
314314
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for ty::List<Ty<'tcx>> {
315315
fn decode(decoder: &mut D) -> Result<&'tcx Self, D::Error> {
316316
let len = decoder.read_usize()?;
317-
Ok(decoder.tcx().mk_type_list((0..len).map(|_| Decodable::decode(decoder)))?)
317+
decoder.tcx().mk_type_list((0..len).map(|_| Decodable::decode(decoder)))
318318
}
319319
}
320320

@@ -323,9 +323,7 @@ impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D>
323323
{
324324
fn decode(decoder: &mut D) -> Result<&'tcx Self, D::Error> {
325325
let len = decoder.read_usize()?;
326-
Ok(decoder
327-
.tcx()
328-
.mk_poly_existential_predicates((0..len).map(|_| Decodable::decode(decoder)))?)
326+
decoder.tcx().mk_poly_existential_predicates((0..len).map(|_| Decodable::decode(decoder)))
329327
}
330328
}
331329

compiler/rustc_middle/src/ty/print/pretty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ pub trait PrettyPrinter<'tcx>:
607607
return Ok(self);
608608
}
609609

610-
return Ok(with_no_queries(|| {
610+
return with_no_queries(|| {
611611
let def_key = self.tcx().def_key(def_id);
612612
if let Some(name) = def_key.disambiguated_data.data.get_opt_name() {
613613
p!(write("{}", name));
@@ -649,7 +649,7 @@ pub trait PrettyPrinter<'tcx>:
649649
p!(" Sized");
650650
}
651651
Ok(self)
652-
})?);
652+
});
653653
}
654654
ty::Str => p!("str"),
655655
ty::Generator(did, substs, movability) => {

compiler/rustc_middle/src/ty/relate.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pub fn relate_substs<R: TypeRelation<'tcx>>(
154154
relation.relate_with_variance(variance, a, b)
155155
});
156156

157-
Ok(tcx.mk_substs(params)?)
157+
tcx.mk_substs(params)
158158
}
159159

160160
impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
@@ -647,7 +647,7 @@ impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'
647647
_ => Err(TypeError::ExistentialMismatch(expected_found(relation, a, b))),
648648
}
649649
});
650-
Ok(tcx.mk_poly_existential_predicates(v)?)
650+
tcx.mk_poly_existential_predicates(v)
651651
}
652652
}
653653

compiler/rustc_mir/src/interpret/traits.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
118118
.get_raw(vtable_slot.alloc_id)?
119119
.read_ptr_sized(self, vtable_slot)?
120120
.check_init()?;
121-
Ok(self.memory.get_fn(fn_ptr)?)
121+
self.memory.get_fn(fn_ptr)
122122
}
123123

124124
/// Returns the drop fn instance as well as the actual dynamic type.

compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ where
4343
info!("fully_perform({:?})", self);
4444
}
4545

46-
scrape_region_constraints(infcx, || Ok((self.closure)(infcx)?))
46+
scrape_region_constraints(infcx, || (self.closure)(infcx))
4747
}
4848
}
4949

compiler/rustc_typeck/src/check/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11411141
let trait_def_ids: FxHashSet<DefId> = param
11421142
.bounds
11431143
.iter()
1144-
.filter_map(|bound| Some(bound.trait_ref()?.trait_def_id()?))
1144+
.filter_map(|bound| bound.trait_ref()?.trait_def_id())
11451145
.collect();
11461146
if !candidates.iter().any(|t| trait_def_ids.contains(&t.def_id)) {
11471147
err.span_suggestions(

0 commit comments

Comments
 (0)