Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record impl args in the proof tree #124718

Merged
merged 1 commit into from
May 4, 2024
Merged
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
8 changes: 6 additions & 2 deletions compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -888,8 +888,12 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
self.infcx.resolve_vars_if_possible(value)
}

pub(super) fn fresh_args_for_item(&self, def_id: DefId) -> ty::GenericArgsRef<'tcx> {
self.infcx.fresh_args_for_item(DUMMY_SP, def_id)
pub(super) fn fresh_args_for_item(&mut self, def_id: DefId) -> ty::GenericArgsRef<'tcx> {
let args = self.infcx.fresh_args_for_item(DUMMY_SP, def_id);
for arg in args {
self.inspect.add_var_value(arg);
}
args
}

pub(super) fn translate_args(
Expand Down
24 changes: 24 additions & 0 deletions tests/ui/traits/next-solver/diagnostics/point-at-failing-nested.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//@ compile-flags: -Znext-solver

trait Foo {}
trait Bar {}
trait Constrain {
type Output;
}

impl<T, U> Foo for T
where
T: Constrain<Output = U>,
U: Bar,
{
}

impl Constrain for () {
type Output = ();
}

fn needs_foo<T: Foo>() {}
fn main() {
needs_foo::<()>();
//~^ the trait bound `(): Foo` is not satisfied
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
error[E0277]: the trait bound `(): Foo` is not satisfied
--> $DIR/point-at-failing-nested.rs:22:17
|
LL | needs_foo::<()>();
| ^^ the trait `Bar` is not implemented for `()`, which is required by `(): Foo`
Copy link
Member Author

@compiler-errors compiler-errors May 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This used to say:

the trait Sized is not implemented for ()

which is obviously incorrect, but due to ?0: Sized being a nested goal.

This wouldve been fixed by #124690, but then we wouldn't be reporting a nested goal as the failure cause at all.

|
note: required for `()` to implement `Foo`
--> $DIR/point-at-failing-nested.rs:9:12
|
LL | impl<T, U> Foo for T
| ^^^ ^
...
LL | U: Bar,
| --- unsatisfied trait bound introduced here
note: required by a bound in `needs_foo`
--> $DIR/point-at-failing-nested.rs:20:17
|
LL | fn needs_foo<T: Foo>() {}
| ^^^ required by this bound in `needs_foo`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
Loading