Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion compiler/rustc_infer/src/infer/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,10 @@ impl<'a, 'tcx> ty::TypeFolder<TyCtxt<'tcx>> for LowerUniverseFolder<'a, 'tcx> {
match c.kind() {
ty::ConstKind::Infer(ty::InferConst::Var(vid)) => {
let vid = self.infcx.root_const_var(vid);
let universe = self.infcx.try_resolve_const_var(vid).unwrap_err();
let universe = match self.infcx.try_resolve_const_var(vid) {
Ok(value) => return value.fold_with(self),
Err(universe) => universe,
};
if self.for_universe.can_name(universe) {
c
} else {
Expand Down
8 changes: 3 additions & 5 deletions compiler/rustc_next_trait_solver/src/canonical/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,10 @@ where
}

let infcx = self.infcx;
// FIXME: make this a debug_assert.
// Currently proof tree evaluation can unify infer vars in original
// vars while not resolving them.
// See `tests/ui/traits/next-solver/transmute-from-async-closure.rs`
// Proof tree evaluation can unify inference variables in the original
// values without eagerly resolving them.
let a = infcx.shallow_resolve_const(a);
debug_assert_eq!(b, infcx.shallow_resolve_const(b));
let b = infcx.shallow_resolve_const(b);
match (a.kind(), b.kind()) {
(
ty::ConstKind::Infer(ty::InferConst::Var(a_vid)),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//@ compile-flags: -Znext-solver=globally
//@ edition: 2015

#![allow(bare_trait_objects)]

trait Foo {}

struct BarType<const N: usize>;

impl<const N: usize> Foo for BarType {}
//~^ ERROR missing generics for struct `BarType`

fn a(x: &Foo) {
let bar = BarType;
a(bar);
//~^ ERROR mismatched types
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
error[E0107]: missing generics for struct `BarType`
--> $DIR/lower-universe-resolved-const-issue-159703.rs:10:30
|
LL | impl<const N: usize> Foo for BarType {}
| ^^^^^^^ expected 1 generic argument
|
note: struct defined here, with 1 generic parameter: `N`
--> $DIR/lower-universe-resolved-const-issue-159703.rs:8:8
|
LL | struct BarType<const N: usize>;
| ^^^^^^^ --------------
help: add missing generic argument
|
LL | impl<const N: usize> Foo for BarType<N> {}
| +++

error[E0308]: mismatched types
--> $DIR/lower-universe-resolved-const-issue-159703.rs:15:7
|
LL | a(bar);
| - ^^^ expected `&dyn Foo`, found `BarType<_>`
| |
| arguments to this function are incorrect
|
= note: expected reference `&dyn Foo`
found struct `BarType<_>`
note: function defined here
--> $DIR/lower-universe-resolved-const-issue-159703.rs:13:4
|
LL | fn a(x: &Foo) {
| ^ -------
help: consider borrowing here
|
LL | a(&bar);
| +

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0107, E0308.
For more information about an error, try `rustc --explain E0107`.
Loading