-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Point at definition of item with type parameters that couldn't be inferred #153890
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,11 @@ LL | impls(rigid); | |
| | | | ||
| | cannot infer type of the type parameter `U` declared on the function `impls` | ||
| | | ||
| note: type must be known for type parameter in this | ||
| --> $DIR/dedup-normalized-2-higher-ranked.rs:25:1 | ||
| | | ||
| LL | fn impls<T: for<'b> Bound<'b, U>, U>(_: T) {} | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
Comment on lines
+9
to
+13
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussion (non-blocking): hm, the phrasing on this stderr looks a little bit strange:
I wonder if it's worth the trouble to say something more like
... or
s/function/$item_kind/ That being said, I don't think this PR needs to block on that. |
||
| = note: cannot satisfy `for<'b> <P as Trait>::Rigid: Bound<'b, _>` | ||
| note: required by a bound in `impls` | ||
| --> $DIR/dedup-normalized-2-higher-ranked.rs:25:13 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,8 @@ error[E0282]: type annotations needed | |
| LL | iter::empty() | ||
| | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty` | ||
| | | ||
| note: type must be known for type parameter in this | ||
| --> $SRC_DIR/core/src/iter/sources/empty.rs:LL:COL | ||
|
Comment on lines
+7
to
+8
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remark [NO-SRC 2/2]: same here, the |
||
| help: consider specifying the generic argument | ||
| | | ||
| LL | iter::empty::<T>() | ||
|
|
@@ -15,6 +17,8 @@ error[E0282]: type annotations needed | |
| LL | iter::empty() | ||
| | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty` | ||
| | | ||
| note: type must be known for type parameter in this | ||
| --> $SRC_DIR/core/src/iter/sources/empty.rs:LL:COL | ||
| help: consider specifying the generic argument | ||
| | | ||
| LL | iter::empty::<T>() | ||
|
|
@@ -26,6 +30,8 @@ error[E0282]: type annotations needed | |
| LL | iter::empty() | ||
| | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty` | ||
| | | ||
| note: type must be known for type parameter in this | ||
| --> $SRC_DIR/core/src/iter/sources/empty.rs:LL:COL | ||
| help: consider specifying the generic argument | ||
| | | ||
| LL | iter::empty::<T>() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,11 @@ error[E0282]: type annotations needed | |
| LL | foo(|| {}); | ||
| | ^^^ cannot infer type of the type parameter `T` declared on the function `foo` | ||
| | | ||
| note: type must be known for type parameter in this | ||
| --> $DIR/issue-99565.rs:3:1 | ||
| | | ||
| LL | fn foo<T, U>(_: U) {} | ||
| | ^^^^^^^^^^^^^^^^^^ | ||
|
Comment on lines
+7
to
+11
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remark: hm, my first reaction when reading this diff is that maybe this is slightly redundant? The inline note above says
which feels a bit redundant with the new outline note
I guess I could see the explicit reference being useful since otherwise the original inline note does not actually point at the definition of EDIT: now I recall you mentioned this specifically in the description lol
|
||
| help: consider specifying the generic arguments | ||
| | | ||
| LL | foo::<T, _>(|| {}); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,11 @@ error[E0284]: type annotations needed | |
| LL | uwu(); | ||
| | ^^^ cannot infer the value of the const parameter `N` declared on the function `uwu` | ||
| | | ||
| note: type must be known for type parameter in this | ||
| --> $DIR/rp_impl_trait_fail.rs:16:1 | ||
| | | ||
| LL | fn uwu<const N: u8>() -> impl Traitor<N> { | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
Comment on lines
+59
to
+63
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: wait hold on, we call |
||
| note: required by a const generic parameter in `uwu` | ||
| --> $DIR/rp_impl_trait_fail.rs:16:8 | ||
| | | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,11 @@ error[E0284]: type annotations needed | |
| LL | println!("{:?}", take_array_from_mut(&mut arr, i)); | ||
| | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `take_array_from_mut` | ||
| | | ||
| note: type must be known for type parameter in this | ||
| --> $DIR/issue-77092.rs:3:1 | ||
| | | ||
| LL | fn take_array_from_mut<T, const N: usize>(data: &mut [T], start: usize) -> &mut [T; N] { | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
Comment on lines
+7
to
+11
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: this is the reason I suggested a wording nit previously, while technically we can say there's 1 type parameter Wait, actually, this note would be slightly misleading then, the one we can't infer is actually the const generic parameter |
||
| note: required by a const generic parameter in `take_array_from_mut` | ||
| --> $DIR/issue-77092.rs:3:27 | ||
| | | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,11 @@ error[E0284]: type annotations needed | |
| LL | let _: [u8; 17] = foo(); | ||
| | ^^^ cannot infer the value of the const parameter `M` declared on the function `foo` | ||
| | | ||
| note: type must be known for type parameter in this | ||
| --> $DIR/one-param-uninferred.rs:2:1 | ||
| | | ||
| LL | fn foo<const N: usize, const M: usize>() -> [u8; N] { | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
Comment on lines
+7
to
+11
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remark: likewise, there are actually two const generic parameters on |
||
| note: required by a const generic parameter in `foo` | ||
| --> $DIR/one-param-uninferred.rs:2:24 | ||
| | | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question (non-blocking) [NO-SRC 1/2]: hm, is this supposed to also show
alloc'sVecdefinition? Though not really a big deal, was wondering if it is intentional theallocsnippet is not available