Skip to content

Cannot import impls from diamond-shaped libraries #2242

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

Closed
erickt opened this issue Apr 19, 2012 · 2 comments
Closed

Cannot import impls from diamond-shaped libraries #2242

erickt opened this issue Apr 19, 2012 · 2 comments
Assignees
Labels
A-codegen Area: Code generation A-linkage Area: linking into static, shared libraries and binaries
Milestone

Comments

@erickt
Copy link
Contributor

erickt commented Apr 19, 2012

Here's an example of the bug:

https://gist.github.com/2421363

It seems that libraries re-export the ifaces/impls of libraries they're using, which triggers a duplicate symbol error when libraries are used in a diamond shaped pattern.

@ghost ghost assigned catamorphism Apr 19, 2012
catamorphism added a commit that referenced this issue Jun 20, 2012
@ghost ghost assigned pcwalton Jun 20, 2012
@catamorphism
Copy link
Contributor

This is no longer a duplicate symbol error, but has progressed to being a type error. The problem is that resolve adds an extra _impl into the iscopes list for b's re-export of to_str. I think this is a resolve bug: resolve shouldn't add an _impl twice in two different scopes for an impl with the same def_id. I was able to fix it by making typeck::check::method::lookup::add_candidates_from_scope remove duplicate entries from the iscopes -- but that was a terrible performance regression, and anyway, resolve shouldn't add the same def_id twice.

I checked in the test case as src/test/run-pass/issue-2242-d.rs. Reassigning to @pcwalton , who can hopefully make sure the resolve rewrite doesn't reproduce this bug :-)

@pcwalton
Copy link
Contributor

pcwalton commented Aug 7, 2012

Some combination of resolve3 and coherence fixed this. Un-XFAILed in 793c0a1.

@pcwalton pcwalton closed this as completed Aug 7, 2012
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 22, 2022
Add rustfmt::skip to some files

Extracted from rust-lang/miri#2097.

Five of the files being skipped here are because rustfmt is buggy (rust-lang/rustfmt#5391; see the error messages below). The other two have clearly preferable manual formatting.

```console
error[internal]: left behind trailing whitespace
  --> tests/fail/validity/transmute_through_ptr.rs:18:18:1
   |
18 |
   | ^^^^
   |

warning: rustfmt has failed to format. See previous 1 errors.

error[internal]: left behind trailing whitespace
  --> tests/fail/stacked_borrows/illegal_read2.rs:10:10:1
   |
10 |
   | ^^^^
   |

warning: rustfmt has failed to format. See previous 1 errors.

error[internal]: left behind trailing whitespace
  --> tests/fail/stacked_borrows/illegal_read5.rs:15:15:1
   |
15 |
   | ^^^^
   |

warning: rustfmt has failed to format. See previous 1 errors.

error[internal]: left behind trailing whitespace
  --> tests/fail/stacked_borrows/illegal_read1.rs:10:10:1
   |
10 |
   | ^^^^
   |

warning: rustfmt has failed to format. See previous 1 errors.

error[internal]: left behind trailing whitespace
 --> /git/miri/tests/fail/erroneous_const2.rs:9:9:1
  |
9 |
  | ^^^^
  |

warning: rustfmt has failed to format. See previous 1 errors.
```
BoxyUwU pushed a commit to BoxyUwU/rust that referenced this issue Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-linkage Area: linking into static, shared libraries and binaries
Projects
None yet
Development

No branches or pull requests

3 participants