Skip to content
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

Const-eval array lengths in rustdoc. #46894

Merged
merged 2 commits into from Dec 24, 2017

Conversation

detrumi
Copy link
Member

@detrumi detrumi commented Dec 20, 2017

Fixes #46727
r? @eddyb

Big thanks to @eddyb for helping me figure this out.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @eddyb (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@eddyb eddyb changed the title Const-eval TyArray trait implementors Const-eval array lengths in rustdoc. Dec 20, 2017
@eddyb
Copy link
Member

eddyb commented Dec 20, 2017

@bors r+

cc @GuillaumeGomez

@bors
Copy link
Contributor

bors commented Dec 20, 2017

📌 Commit d5b1119 has been approved by eddyb

@GuillaumeGomez
Copy link
Member

No tests? :'(

@kennytm kennytm added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Dec 21, 2017
@eddyb
Copy link
Member

eddyb commented Dec 21, 2017

@bors r-

@GuillaumeGomez Can you help with the tests? I have no idea how rustdoc tests work.

@detrumi
Copy link
Member Author

detrumi commented Dec 21, 2017

Creating a test at src/test/rustdoc/issue-46727.rs seems straightforward enough.

I have more problems with reproducing the problem in a test case.
When trying to use the array_impl_foo macro for some Foo trait, the docs show it as Implementations on Foreign Types instead of Implementors, and it won't reproduce the problem.

@eddyb
Copy link
Member

eddyb commented Dec 21, 2017

@detrumi Try impl Foo for Bar<[T; 1 + 1 + 1]> {} where Foo and Bar are defined in the test.

@detrumi
Copy link
Member Author

detrumi commented Dec 21, 2017

@eddyb You mean this?

pub trait Foo {}
pub struct Bar<T> { x: T }
impl<T> Foo for Bar<[T; 1 + 1 + 1]> {}

That just produces impl<T> Foo for Bar<[T; 3]>

Unless I'm mistaken, the problem only occurs because of the macro. However, this doesn't trigger it:

pub trait Foo {}
pub struct Bar<T> { x: T }
macro_rules! impl_foo {
    {$n:expr, $t:ident $($ts:ident)*} => {
        impl<T> Foo for Bar<[T; $n]> {}
        impl_foo!{($n - 1), $($ts)*}
    };
    {$n:expr,} => {
        impl<T> Foo for Bar<[T; $n]> {}
    };
}
impl_foo!{32, T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T}

(adapted from the macro here)

@eddyb
Copy link
Member

eddyb commented Dec 21, 2017

The macro shouldn't affect it at all. I guess it's because of cross-crate inlining, so maybe just #[doc(inline)] a reexport with one of those impls from libcore and it might show up?

@QuietMisdreavus
Copy link
Member

QuietMisdreavus commented Dec 21, 2017

You can set up auxiliary builds in rustdoc tests to test for this. Set up the impls in src/test/rustdoc/auxiliary/issue-46727.rs, and then in src/test/rustdoc/issue-46727.rs, add a // aux-build:issue-46727.rs comment to the top so compiletest will link it in properly. You may need to add a #![crate_name="something"] to one or both crates to make sure their names don't clash. Then you can re-export whatever you need in src/test/rustdoc/issue-46727.rs and make tests off it in there.

EDIT: Here's an example of a really simple auxiliary build, for the doc(include) stuff.

@kennytm kennytm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 21, 2017
@detrumi
Copy link
Member Author

detrumi commented Dec 23, 2017

Re-exporting did the trick, without needing #[doc(inline)].
I couldn't get #![crate_name="something"] working in this instance, but using compile-flags: -Cmetadata=aux, which was used in other auxiliary tests, made it work.

@eddyb
Copy link
Member

eddyb commented Dec 23, 2017

@bors r+

@bors
Copy link
Contributor

bors commented Dec 23, 2017

📌 Commit d10d389 has been approved by eddyb

@kennytm kennytm added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 23, 2017
kennytm added a commit to kennytm/rust that referenced this pull request Dec 23, 2017
Const-eval array lengths in rustdoc.

Fixes rust-lang#46727
r? @eddyb

Big thanks to @eddyb for helping me figure this out.
@bors
Copy link
Contributor

bors commented Dec 24, 2017

⌛ Testing commit d10d389 with merge 304717b...

bors added a commit that referenced this pull request Dec 24, 2017
Const-eval array lengths in rustdoc.

Fixes #46727
r? @eddyb

Big thanks to @eddyb for helping me figure this out.
@bors
Copy link
Contributor

bors commented Dec 24, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: eddyb
Pushing 304717b to master...

@bors bors merged commit d10d389 into rust-lang:master Dec 24, 2017
@detrumi detrumi deleted the fix-const-eval-trait branch January 31, 2021 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants