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

Projects
None yet
7 participants
@detrumi
Contributor

detrumi commented Dec 20, 2017

Fixes #46727
r? @eddyb

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

@rust-highfive

This comment has been minimized.

Show comment
Hide comment
@rust-highfive

rust-highfive Dec 20, 2017

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.

Collaborator

rust-highfive commented Dec 20, 2017

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 from Const-eval TyArray trait implementors to Const-eval array lengths in rustdoc. Dec 20, 2017

@eddyb

This comment has been minimized.

Show comment
Hide comment
@eddyb
Member

eddyb commented Dec 20, 2017

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Dec 20, 2017

Contributor

📌 Commit d5b1119 has been approved by eddyb

Contributor

bors commented Dec 20, 2017

📌 Commit d5b1119 has been approved by eddyb

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Dec 21, 2017

Member

No tests? :'(

Member

GuillaumeGomez commented Dec 21, 2017

No tests? :'(

@eddyb

This comment has been minimized.

Show comment
Hide comment
@eddyb

eddyb Dec 21, 2017

Member

@bors r-

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

Member

eddyb commented Dec 21, 2017

@bors r-

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

@detrumi

This comment has been minimized.

Show comment
Hide comment
@detrumi

detrumi Dec 21, 2017

Contributor

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@eddyb

eddyb Dec 21, 2017

Member

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

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

This comment has been minimized.

Show comment
Hide comment
@detrumi

detrumi Dec 21, 2017

Contributor

@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)

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@eddyb

eddyb Dec 21, 2017

Member

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?

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

This comment has been minimized.

Show comment
Hide comment
@QuietMisdreavus

QuietMisdreavus Dec 21, 2017

Member

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.

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.

@detrumi

This comment has been minimized.

Show comment
Hide comment
@detrumi

detrumi Dec 23, 2017

Contributor

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@eddyb
Member

eddyb commented Dec 23, 2017

@bors r+

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Dec 23, 2017

Contributor

📌 Commit d10d389 has been approved by eddyb

Contributor

bors commented Dec 23, 2017

📌 Commit d10d389 has been approved by eddyb

kennytm added a commit to kennytm/rust that referenced this pull request Dec 23, 2017

Rollup merge of rust-lang#46894 - detrumi:fix-const-eval-trait, r=eddyb
Const-eval array lengths in rustdoc.

Fixes rust-lang#46727
r? @eddyb

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

bors added a commit that referenced this pull request Dec 23, 2017

Auto merge of #46967 - kennytm:rollup, r=kennytm
Rollup of 10 pull requests

- Successful merges: #46888, #46894, #46910, #46928, #46930, #46933, #46937, #46939, #46940, #46943
- Failed merges: #46924, #46954
@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Dec 24, 2017

Contributor

⌛️ Testing commit d10d389 with merge 304717b...

Contributor

bors commented Dec 24, 2017

⌛️ Testing commit d10d389 with merge 304717b...

bors added a commit that referenced this pull request Dec 24, 2017

Auto merge of #46894 - detrumi:fix-const-eval-trait, r=eddyb
Const-eval array lengths in rustdoc.

Fixes #46727
r? @eddyb

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

This comment has been minimized.

Show comment
Hide comment
@bors

bors Dec 24, 2017

Contributor

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

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

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment