Skip to content

Commit a4262dd

Browse files
Add constness field to hir::TraitRef
1 parent f363745 commit a4262dd

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/librustc_ast_lowering/lib.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,13 +1977,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19771977
// ::std::future::Future<future_params>
19781978
let future_path =
19791979
self.std_path(span, &[sym::future, sym::Future], Some(future_params), false);
1980+
let future_trait_ref =
1981+
hir::TraitRef { path: future_path, hir_ref_id: self.next_id(), constness: None };
19801982

19811983
hir::GenericBound::Trait(
1982-
hir::PolyTraitRef {
1983-
trait_ref: hir::TraitRef { path: future_path, hir_ref_id: self.next_id() },
1984-
bound_generic_params: &[],
1985-
span,
1986-
},
1984+
hir::PolyTraitRef { trait_ref: future_trait_ref, bound_generic_params: &[], span },
19871985
hir::TraitBoundModifier::None,
19881986
)
19891987
}
@@ -2149,7 +2147,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21492147
hir::QPath::Resolved(None, path) => path,
21502148
qpath => bug!("lower_trait_ref: unexpected QPath `{:?}`", qpath),
21512149
};
2152-
hir::TraitRef { path, hir_ref_id: self.lower_node_id(p.ref_id) }
2150+
2151+
hir::TraitRef { path, hir_ref_id: self.lower_node_id(p.ref_id), constness: p.constness }
21532152
}
21542153

21552154
fn lower_poly_trait_ref(
@@ -2463,8 +2462,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24632462
Res::Def(DefKind::Trait, _) | Res::Def(DefKind::TraitAlias, _) => {
24642463
let principal = hir::PolyTraitRef {
24652464
bound_generic_params: &[],
2466-
trait_ref: hir::TraitRef { path, hir_ref_id: hir_id },
24672465
span,
2466+
trait_ref: hir::TraitRef { path, hir_ref_id: hir_id, constness: None },
24682467
};
24692468

24702469
// The original ID is taken by the `PolyTraitRef`,

src/librustc_hir/hir.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,6 +2233,8 @@ pub struct TraitRef<'hir> {
22332233
// Don't hash the `ref_id`. It is tracked via the thing it is used to access.
22342234
#[stable_hasher(ignore)]
22352235
pub hir_ref_id: HirId,
2236+
2237+
pub constness: Option<Constness>,
22362238
}
22372239

22382240
impl TraitRef<'_> {
@@ -2247,6 +2249,10 @@ impl TraitRef<'_> {
22472249
_ => unreachable!(),
22482250
}
22492251
}
2252+
2253+
pub fn is_maybe_const(&self) -> bool {
2254+
self.constness == Some(Constness::NotConst)
2255+
}
22502256
}
22512257

22522258
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]

0 commit comments

Comments
 (0)