Skip to content

fn(&u8) -> &u8 doesn't implement FnOnce(T) -> T: ReInfer(ReSkolemized(.. error message #19127

New issue

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

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

Already on GitHub? # to your account

Closed
japaric opened this issue Nov 20, 2014 · 0 comments · Fixed by #19780
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@japaric
Copy link
Member

japaric commented Nov 20, 2014

Small variation of #19126

STR

#![feature(unboxed_closures)]

fn foo<T, F: FnOnce(T) -> T>(f: F) {}
fn id<'a>(input: &'a u8) -> &'a u8 { input }

fn main() {
    foo(id);
}

Output

reskolemized.rs:7:5: 7:8 error: cannot infer an appropriate lifetime due to conflicting requirements
reskolemized.rs:7     foo(id);
                      ^~~
note: first, the lifetime cannot outlive lifetime ReInfer(ReSkolemized(1, BrNamed(DefId { krate: 0, node: 31 }, "'a"(71))))...
reskolemized.rs:7:5: 7:8 note: ...so that trait type parameters matches those specified on the impl (expected `core::ops::Fn<(&u8,), &u8>`, found `core::ops::Fn<(&u8,), &u8>`)
reskolemized.rs:7     foo(id);
                      ^~~
reskolemized.rs:7:5: 7:8 note: but, the lifetime must be valid for the expression at 7:4...
reskolemized.rs:7     foo(id);
                      ^~~
reskolemized.rs:7:5: 7:8 note: ...so that type parameter instantiated with `&u8`, will meet its declared lifetime bounds.
reskolemized.rs:7     foo(id);
                      ^~~
error: aborting due to previous error

Version

#19113 + #18868 on top of bfaa7bc

Not sure if this should work or not, but the error message could be improved.

cc @nikomatsakis

@ghost ghost added A-diagnostics Area: Messages for errors, warnings, and lints E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. labels Dec 12, 2014
bors added a commit that referenced this issue Dec 18, 2014
Closes #5988.
Closes #10176.
Closes #10456.
Closes #12744.
Closes #13264.
Closes #13324.
Closes #14182.
Closes #15381.
Closes #15444.
Closes #15480.
Closes #15756.
Closes #16822.
Closes #16966.
Closes #17351.
Closes #17503.
Closes #17545.
Closes #17771.
Closes #17816.
Closes #17897.
Closes #17905.
Closes #18188.
Closes #18232.
Closes #18345.
Closes #18389.
Closes #18400.
Closes #18502.
Closes #18611.
Closes #18783.
Closes #19009.
Closes #19081.
Closes #19098.
Closes #19127.
Closes #19135.
lnicola pushed a commit to lnicola/rust that referenced this issue Feb 17, 2025
…eric-args

feat: Refactor path lowering and serve a new path diagnostic
lnicola pushed a commit to lnicola/rust that referenced this issue Feb 17, 2025
I was wrong on rust-lang#19127, I thought hir-def resolver is enough for them, but it turns out not because of paths like `<Enum>::Variant` and `Type::AssocThatIsEnum::Variant`.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant