Skip to content

Commit 6c94f99

Browse files
authored
Rollup merge of #92875 - BoxyUwU:infer_arg_opt_const_param_of, r=lcnr
Make `opt_const_param_of` work in the presence of `GenericArg::Infer` highly recommend viewing the first and second commits on their own rather than looking at file changes 🤣 Because we filtered args down to just const args we would ignore `GenericArg::Infer` which made us get a `arg_index` which was wrong by however many const `GenericArg::Infer` came previously [example](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=46dba6a53aca6333028a10908ef16e0b) of the [bugs](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=a8eebced26eefa4119fc2e7ae0c76de6) fixed. r? ```@lcnr```
2 parents 8f41559 + 61c07a9 commit 6c94f99

File tree

6 files changed

+231
-219
lines changed

6 files changed

+231
-219
lines changed

compiler/rustc_hir/src/hir.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,6 @@ impl GenericArg<'_> {
293293
}
294294
}
295295

296-
pub fn is_const(&self) -> bool {
297-
matches!(self, GenericArg::Const(_))
298-
}
299-
300296
pub fn is_synthetic(&self) -> bool {
301297
matches!(self, GenericArg::Lifetime(lifetime) if lifetime.name.ident() == Ident::empty())
302298
}
@@ -318,6 +314,13 @@ impl GenericArg<'_> {
318314
GenericArg::Infer(_) => ast::ParamKindOrd::Infer,
319315
}
320316
}
317+
318+
pub fn is_ty_or_const(&self) -> bool {
319+
match self {
320+
GenericArg::Lifetime(_) => false,
321+
GenericArg::Type(_) | GenericArg::Const(_) | GenericArg::Infer(_) => true,
322+
}
323+
}
321324
}
322325

323326
#[derive(Debug, HashStable_Generic)]

compiler/rustc_middle/src/ty/generics.rs

+7
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ impl GenericParamDefKind {
3131
GenericParamDefKind::Const { .. } => ast::ParamKindOrd::Const,
3232
}
3333
}
34+
35+
pub fn is_ty_or_const(&self) -> bool {
36+
match self {
37+
GenericParamDefKind::Lifetime => false,
38+
GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => true,
39+
}
40+
}
3441
}
3542

3643
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable)]

0 commit comments

Comments
 (0)