Skip to content

Commit 76eff8e

Browse files
committed
fix an issue with inferring host param
1 parent 612a114 commit 76eff8e

File tree

6 files changed

+38
-6
lines changed

6 files changed

+38
-6
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2126,7 +2126,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
21262126
kind => bug!("unexpected definition kind {:?} for {:?}", kind, def_id),
21272127
}
21282128

2129-
debug!("path_segs = {:?}", path_segs);
2129+
debug!(?path_segs);
21302130

21312131
path_segs
21322132
}

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1349,10 +1349,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13491349
}
13501350
}
13511351
GenericParamDefKind::Const { has_default } => {
1352-
if !infer_args && has_default {
1353-
tcx.const_param_default(param.def_id)
1354-
.instantiate(tcx, args.unwrap())
1355-
.into()
1352+
// TODO: check if this is always good to be infer var
1353+
let is_host = param.name == sym::host;
1354+
if !infer_args && has_default && !is_host {
1355+
tcx.const_param_default(param.def_id).instantiate(tcx, args.unwrap()).into()
13561356
} else {
13571357
self.fcx.var_for_def(self.span, param)
13581358
}

library/core/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@
257257
#![feature(wasm_target_feature)]
258258
// tidy-alphabetical-end
259259

260+
// TODO
261+
// #![cfg_attr(not(bootstrap), effects)]
262+
260263
// allow using `core::` in intra-doc links
261264
#[allow(unused_extern_crates)]
262265
extern crate self as core;

src/tools/clippy/clippy_lints/src/derive.rs

-1
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,6 @@ fn param_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) ->
519519
params.iter().filter(|&&(_, needs_eq)| needs_eq).map(|&(param, _)| {
520520
ClauseKind::Trait(TraitPredicate {
521521
trait_ref: ty::TraitRef::new(tcx, eq_trait_id, [tcx.mk_param_from_def(param)]),
522-
constness: BoundConstness::NotConst,
523522
polarity: ImplPolarity::Positive,
524523
})
525524
.to_predicate(tcx)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// check-pass
2+
3+
#![feature(const_trait_impl, effects)]
4+
5+
// Host param needs to get infer even if there are generic params supplied
6+
7+
pub const fn hmm<T>() -> usize {
8+
1
9+
}
10+
11+
pub const fn uwu(x: [u8; hmm::<()>()]) {}
12+
13+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// check-pass
2+
3+
// misc tests not directly related to const traits, but encountered
4+
// while implementing effects
5+
6+
#![feature(const_trait_impl, effects)]
7+
8+
// #[const_trait]
9+
pub trait X<Rhs: ?Sized = Self> {}
10+
11+
pub trait Y: X {}
12+
13+
impl X for () {}
14+
15+
impl Y for () {}
16+
17+
fn main() {}

0 commit comments

Comments
 (0)