Skip to content

Commit e7a1fbc

Browse files
committed
Don't go into the query for things that can't possibly have lifetimes.
1 parent b85ebef commit e7a1fbc

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

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

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
22
use crate::traits::query::Fallible;
33
use rustc_infer::traits::query::OutlivesBound;
4-
use rustc_middle::ty::{ParamEnvAnd, Ty, TyCtxt};
4+
use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt};
55

66
#[derive(Copy, Clone, Debug, HashStable, TypeFoldable, Lift)]
77
pub struct ImpliedOutlivesBounds<'tcx> {
@@ -13,9 +13,16 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ImpliedOutlivesBounds<'tcx> {
1313

1414
fn try_fast_path(
1515
_tcx: TyCtxt<'tcx>,
16-
_key: &ParamEnvAnd<'tcx, Self>,
16+
key: &ParamEnvAnd<'tcx, Self>,
1717
) -> Option<Self::QueryResponse> {
18-
None
18+
// Don't go into the query for things that can't possibly have lifetimes.
19+
match key.value.ty.kind() {
20+
ty::Tuple(elems) if elems.is_empty() => Some(vec![]),
21+
ty::Never | ty::Str | ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) => {
22+
Some(vec![])
23+
}
24+
_ => None,
25+
}
1926
}
2027

2128
fn perform_query(

0 commit comments

Comments
 (0)