-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Fix associated type bound suggestion span issue #154655
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
Merged
rust-bors
merged 2 commits into
rust-lang:main
from
chenyukang:yukang-fix-145586-deserializer-bound-syntax
Apr 1, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
tests/ui/trait-bounds/associated-error-bound-issue-145586.fixed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| //@ run-rustfix | ||
|
|
||
| #![allow(dead_code)] | ||
|
|
||
| use std::marker::PhantomData; | ||
|
|
||
| trait Visitor<'de> { | ||
| type Value; | ||
| } | ||
|
|
||
| trait Deserializer<'de> { | ||
| type Error; | ||
|
|
||
| fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error> | ||
| where | ||
| V: Visitor<'de>; | ||
| } | ||
|
|
||
| struct Wrapper<'de, T, E>(Result<T, E>, PhantomData<&'de ()>); | ||
|
|
||
| impl<'de, T, E> Deserializer<'de> for Wrapper<'de, T, E> | ||
| where | ||
| T: Deserializer<'de, Error = E>, | ||
| { | ||
| type Error = E; | ||
|
|
||
| fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error> | ||
| where | ||
| V: Visitor<'de>, | ||
| { | ||
| match self.0 { | ||
| Ok(deserializer) => deserializer.deserialize_ignored_any(visitor), //~ ERROR mismatched types | ||
| Err(error) => Err(error), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fn main() {} |
38 changes: 38 additions & 0 deletions
38
tests/ui/trait-bounds/associated-error-bound-issue-145586.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| //@ run-rustfix | ||
|
|
||
| #![allow(dead_code)] | ||
|
|
||
| use std::marker::PhantomData; | ||
|
|
||
| trait Visitor<'de> { | ||
| type Value; | ||
| } | ||
|
|
||
| trait Deserializer<'de> { | ||
| type Error; | ||
|
|
||
| fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error> | ||
| where | ||
| V: Visitor<'de>; | ||
| } | ||
|
|
||
| struct Wrapper<'de, T, E>(Result<T, E>, PhantomData<&'de ()>); | ||
|
|
||
| impl<'de, T, E> Deserializer<'de> for Wrapper<'de, T, E> | ||
| where | ||
| T: Deserializer<'de>, | ||
| { | ||
| type Error = E; | ||
|
|
||
| fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error> | ||
| where | ||
| V: Visitor<'de>, | ||
| { | ||
| match self.0 { | ||
| Ok(deserializer) => deserializer.deserialize_ignored_any(visitor), //~ ERROR mismatched types | ||
| Err(error) => Err(error), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fn main() {} |
22 changes: 22 additions & 0 deletions
22
tests/ui/trait-bounds/associated-error-bound-issue-145586.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| error[E0308]: mismatched types | ||
| --> $DIR/associated-error-bound-issue-145586.rs:32:33 | ||
| | | ||
| LL | impl<'de, T, E> Deserializer<'de> for Wrapper<'de, T, E> | ||
| | - expected this type parameter | ||
| ... | ||
| LL | fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error> | ||
| | ----------------------------- expected `Result<<V as Visitor<'de>>::Value, E>` because of return type | ||
| ... | ||
| LL | Ok(deserializer) => deserializer.deserialize_ignored_any(visitor), | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<<V as Visitor<'_>>::Value, E>`, found `Result<<V as Visitor<'_>>::Value, ...>` | ||
| | | ||
| = note: expected enum `Result<_, E>` | ||
| found enum `Result<_, <T as Deserializer<'de>>::Error>` | ||
| help: consider further restricting this bound | ||
| | | ||
| LL | T: Deserializer<'de, Error = E>, | ||
| | +++++++++++ | ||
|
|
||
| error: aborting due to 1 previous error | ||
|
|
||
| For more information about this error, try `rustc --explain E0308`. |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
it's weird to see uppercase in test file name, so fix it by the way.