Skip to content

Commit 07dc4aa

Browse files
authored
Rollup merge of #124718 - compiler-errors:record-impl-args, r=lcnr
Record impl args in the proof tree Weren't recording these since they went through a different infcx method r? lcnr
2 parents 79071ee + 50338aa commit 07dc4aa

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -888,8 +888,12 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
888888
self.infcx.resolve_vars_if_possible(value)
889889
}
890890

891-
pub(super) fn fresh_args_for_item(&self, def_id: DefId) -> ty::GenericArgsRef<'tcx> {
892-
self.infcx.fresh_args_for_item(DUMMY_SP, def_id)
891+
pub(super) fn fresh_args_for_item(&mut self, def_id: DefId) -> ty::GenericArgsRef<'tcx> {
892+
let args = self.infcx.fresh_args_for_item(DUMMY_SP, def_id);
893+
for arg in args {
894+
self.inspect.add_var_value(arg);
895+
}
896+
args
893897
}
894898

895899
pub(super) fn translate_args(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//@ compile-flags: -Znext-solver
2+
3+
trait Foo {}
4+
trait Bar {}
5+
trait Constrain {
6+
type Output;
7+
}
8+
9+
impl<T, U> Foo for T
10+
where
11+
T: Constrain<Output = U>,
12+
U: Bar,
13+
{
14+
}
15+
16+
impl Constrain for () {
17+
type Output = ();
18+
}
19+
20+
fn needs_foo<T: Foo>() {}
21+
fn main() {
22+
needs_foo::<()>();
23+
//~^ the trait bound `(): Foo` is not satisfied
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0277]: the trait bound `(): Foo` is not satisfied
2+
--> $DIR/point-at-failing-nested.rs:22:17
3+
|
4+
LL | needs_foo::<()>();
5+
| ^^ the trait `Bar` is not implemented for `()`, which is required by `(): Foo`
6+
|
7+
note: required for `()` to implement `Foo`
8+
--> $DIR/point-at-failing-nested.rs:9:12
9+
|
10+
LL | impl<T, U> Foo for T
11+
| ^^^ ^
12+
...
13+
LL | U: Bar,
14+
| --- unsatisfied trait bound introduced here
15+
note: required by a bound in `needs_foo`
16+
--> $DIR/point-at-failing-nested.rs:20:17
17+
|
18+
LL | fn needs_foo<T: Foo>() {}
19+
| ^^^ required by this bound in `needs_foo`
20+
21+
error: aborting due to 1 previous error
22+
23+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)