-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Fix typecks on some spurious fudged function input expectation #150316
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
Open
ShoyuVanilla
wants to merge
3
commits into
rust-lang:main
Choose a base branch
from
ShoyuVanilla:fudge-checks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 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
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
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
22 changes: 22 additions & 0 deletions
22
...ion/fudge-inference/expectated-input-not-satisfying-fn-bounds-issue-149881.current.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[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time | ||
| --> $DIR/expectated-input-not-satisfying-fn-bounds-issue-149881.rs:16:24 | ||
| | | ||
| LL | <[_]>::into_vec(id(Box::new([0, 1, 2]))); | ||
| | -- ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | ||
| | | | ||
| | required by a bound introduced by this call | ||
| | | ||
| = help: the trait `Sized` is not implemented for `[{integer}]` | ||
| note: required by an implicit `Sized` bound in `id` | ||
| --> $DIR/expectated-input-not-satisfying-fn-bounds-issue-149881.rs:11:7 | ||
| | | ||
| LL | fn id<T>(x: Box<T>) -> Box<T> { | ||
| | ^ required by the implicit `Sized` requirement on this type parameter in `id` | ||
| help: consider relaxing the implicit `Sized` restriction | ||
| | | ||
| LL | fn id<T: ?Sized>(x: Box<T>) -> Box<T> { | ||
| | ++++++++ | ||
|
|
||
| error: aborting due to 1 previous error | ||
|
|
||
| For more information about this error, try `rustc --explain E0277`. |
18 changes: 18 additions & 0 deletions
18
tests/ui/coercion/fudge-inference/expectated-input-not-satisfying-fn-bounds-issue-149881.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,18 @@ | ||
| //@ revisions: current next | ||
| //@ ignore-compare-mode-next-solver (explicit revisions) | ||
| //@[next] compile-flags: -Znext-solver | ||
| //@[next] check-pass | ||
|
|
||
| // FIXME(#149379): This should pass, but fails due to fudged expactation | ||
| // types which are potentially not well-formed or for whom the function | ||
| // where-bounds don't actually hold. And this results in weird bugs when | ||
| // later treating these expectations as if they were actually correct.. | ||
|
|
||
| fn id<T>(x: Box<T>) -> Box<T> { | ||
| x | ||
| } | ||
|
|
||
| fn main() { | ||
| <[_]>::into_vec(id(Box::new([0, 1, 2]))); | ||
| //[current]~^ ERROR: the size for values of type `[{integer}]` cannot be known at compilation time | ||
| } |
16 changes: 16 additions & 0 deletions
16
...cion/fudge-inference/expectated-input-not-satisfying-fn-bounds-issue-89299.current.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,16 @@ | ||
| error[E0277]: `dyn Trait + Send` cannot be unpinned | ||
| --> $DIR/expectated-input-not-satisfying-fn-bounds-issue-89299.rs:21:27 | ||
| | | ||
| LL | let _x = Foo(Pin::new(&mut a)); | ||
| | -------- ^^^^^^ the trait `Unpin` is not implemented for `dyn Trait + Send` | ||
| | | | ||
| | required by a bound introduced by this call | ||
| | | ||
| = note: consider using the `pin!` macro | ||
| consider using `Box::pin` if you need to access the pinned value outside of the current scope | ||
| note: required by a bound in `Pin::<Ptr>::new` | ||
| --> $SRC_DIR/core/src/pin.rs:LL:COL | ||
|
|
||
| error: aborting due to 1 previous error | ||
|
|
||
| For more information about this error, try `rustc --explain E0277`. |
23 changes: 23 additions & 0 deletions
23
tests/ui/coercion/fudge-inference/expectated-input-not-satisfying-fn-bounds-issue-89299.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,23 @@ | ||
| //@ revisions: current next | ||
| //@ ignore-compare-mode-next-solver (explicit revisions) | ||
| //@[next] compile-flags: -Znext-solver | ||
| //@[next] check-pass | ||
|
|
||
| // FIXME(#149379): This should pass, but fails due to fudged expactation | ||
| // types which are potentially not well-formed or for whom the function | ||
| // where-bounds don't actually hold. And this results in weird bugs when | ||
| // later treating these expectations as if they were actually correct.. | ||
|
|
||
| use std::pin::Pin; | ||
|
|
||
| trait Trait {} | ||
|
|
||
| impl Trait for i32 {} | ||
|
|
||
| struct Foo<'a>(Pin<&'a mut (dyn Trait + Send)>); | ||
|
|
||
| fn main() { | ||
| let mut a = 1; | ||
| let _x = Foo(Pin::new(&mut a)); | ||
| //[current]~^ ERROR: `dyn Trait + Send` cannot be unpinned | ||
| } |
32 changes: 0 additions & 32 deletions
32
...on/fudge-inference/fn-ret-trait-object-propagated-to-inputs-issue-149379-1.current.stderr
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
...rcion/fudge-inference/fn-ret-trait-object-propagated-to-inputs-issue-149379-1.next.stderr
This file was deleted.
Oops, something went wrong.
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
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.
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.
Unfortunately, checking function's bounds against the expected input tys regresses
tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.rsin the old solver.rust/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.rs
Lines 19 to 70 in 99ff3fb
Evaluating the bounds
for<'b> &'b mut Self: Streamon methodStreamExt::mapxcauses overflow while trying to consider the candidate&'_ mut Map<Map<Map<...>, _>, _>, _>and this ends up with a fatal error 😢