-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
ty::pretty: prevent infinite recursion for extern crate
paths.
#89738
Merged
Merged
Changes from all commits
Commits
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 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
1 change: 1 addition & 0 deletions
1
src/test/ui/rust-2018/uniform-paths/auxiliary/issue-55779-extern-trait.rs
This file contains 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 @@ | ||
pub trait Trait { fn no_op(&self); } |
3 changes: 3 additions & 0 deletions
3
src/test/ui/rust-2018/uniform-paths/auxiliary/issue-87932-a.rs
This file contains 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,3 @@ | ||
pub trait Deserialize { | ||
fn deserialize(); | ||
} |
This file contains 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,29 @@ | ||
// run-pass | ||
// edition:2018 | ||
// aux-crate:issue_55779_extern_trait=issue-55779-extern-trait.rs | ||
|
||
use issue_55779_extern_trait::Trait; | ||
|
||
struct Local; | ||
struct Helper; | ||
|
||
impl Trait for Local { | ||
fn no_op(&self) | ||
{ | ||
// (Unused) extern crate declaration necessary to reproduce bug | ||
extern crate issue_55779_extern_trait; | ||
|
||
// This one works | ||
// impl Trait for Helper { fn no_op(&self) { } } | ||
|
||
// This one infinite-loops | ||
const _IMPL_SERIALIZE_FOR_HELPER: () = { | ||
// (extern crate can also appear here to reproduce bug, | ||
// as in originating example from serde) | ||
impl Trait for Helper { fn no_op(&self) { } } | ||
}; | ||
|
||
} | ||
} | ||
|
||
fn main() { } |
This file contains 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,15 @@ | ||
// edition:2018 | ||
// aux-crate:issue_87932_a=issue-87932-a.rs | ||
|
||
pub struct A {} | ||
|
||
impl issue_87932_a::Deserialize for A { | ||
fn deserialize() { | ||
extern crate issue_87932_a as _a; | ||
} | ||
} | ||
|
||
fn main() { | ||
A::deserialize(); | ||
//~^ ERROR no function or associated item named `deserialize` found for struct `A` | ||
} |
This file contains 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 @@ | ||
error[E0599]: no function or associated item named `deserialize` found for struct `A` in the current scope | ||
--> $DIR/issue-87932.rs:13:8 | ||
| | ||
LL | pub struct A {} | ||
| ------------ function or associated item `deserialize` not found for this | ||
... | ||
LL | A::deserialize(); | ||
| ^^^^^^^^^^^ function or associated item not found in `A` | ||
| | ||
= help: items from traits can only be used if the trait is in scope | ||
help: the following trait is implemented but not in scope; perhaps add a `use` for it: | ||
| | ||
LL | use <crate::A as issue_87932_a::Deserialize>::deserialize::_a::Deserialize; | ||
| | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0599`. |
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.
Reassigning
self
like this seems somewhat footgunny but looks like its already being done elsewhere…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.
This mess of an API is all "linear" so there's not really any risk - the result has to be used, because a
Self
value has to be returned, and the call consumesself
.