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

rustdoc: Implementors of a trait is not const-evaled, thus showing [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1] #46727

Closed
kennytm opened this issue Dec 14, 2017 · 7 comments
Labels
C-bug Category: This is a bug. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@kennytm
Copy link
Member

kennytm commented Dec 14, 2017

Repro steps:

  1. Go to https://doc.rust-lang.org/1.22.1/std/default/trait.Default.html or https://doc.rust-lang.org/nightly/std/default/trait.Default.html
  2. Scroll down.
  3. Notice the amusement.

screenshot_2017-12-14 19 53 05_jfu5c0-fs8

The array lengths are normal in 1.21.0, but it is not clear whether this is the effect of performing const evaluation or the macro generating these impl changed in the new version.

@kennytm kennytm added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Dec 14, 2017
@KamilaBorowska
Copy link
Contributor

The array lengths are normal in 1.21.0, but it is not clear whether this is the effect of performing const evaluation or the macro generating these impl changed in the new version.

The macro in question is the same for 2 years, as seen with blame. Here is a commit that introduced it: 975a8ed.

@kennytm kennytm added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. and removed A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools labels Dec 14, 2017
@kennytm
Copy link
Member Author

kennytm commented Dec 14, 2017

Thanks for checking @xfix! Considering it's not due to change of generating macro, untagging T-doc and tagging regression-from-stable-to-stable.

@hanna-kruppe
Copy link
Contributor

Likely because array types now contain a constant expression instead of a fully evaluated usize. cc @eddyb

@hanna-kruppe
Copy link
Contributor

@eddyb
Copy link
Member

eddyb commented Dec 14, 2017

We attempt to const-evaluate when we get the type from HIR:

let n = cx.tcx.const_eval(param_env.and((def_id, substs))).unwrap();

But not from Ty:

ty::TyArray(ty, n) => {
let n = if let ConstVal::Integral(ConstInt::Usize(n)) = n.val {

So a few lines from the former should be copied to the latter.

@eddyb eddyb added the E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. label Dec 14, 2017
@GuillaumeGomez
Copy link
Member

Is anyone picking it up or should I wait a bit more before fixing it?

@detrumi
Copy link
Member

detrumi commented Dec 20, 2017

This doesn't look too difficult, so I'll have a go at it.

kennytm added a commit to kennytm/rust that referenced this issue 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 added a commit that referenced this issue Dec 24, 2017
Const-eval array lengths in rustdoc.

Fixes #46727
r? @eddyb

Big thanks to @eddyb for helping me figure this out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants