Uh oh!
There was an error while loading. Please reload this page.
make everybody_loops preserve item declarations - #53002
Conversation
rust-highfive
commented
Aug 2, 2018
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
QuietMisdreavus
commented
Aug 2, 2018
pnkfelix
commented
Aug 3, 2018
I'll make sure to make a decision about this tomorrow. |
pnkfelix
commented
Aug 3, 2018
Thanks for the fun looking at the design options here via live chat over last few days with @QuietMisdreavus and @eddyb I have an alternative approach that is factored slightly differently, but until I see a case where this PR breaks, I'm not going to try to push it. |
pnkfelix
commented
Aug 3, 2018
@bors r+ |
bors
commented
Aug 3, 2018
📌 Commit 7e77d19 has been approved by |
pnkfelix
commented
Aug 3, 2018
For the record, below (in the details block) is an expanded test case that tries to trip up code here. It might be worth trying to adapt into a real test for
Details#![allow(dead_code)]mod a {fnf(){println!("Hello from a::f");}}traitTrait{fnm1(&self);fnm2(&self){}}structS1;structS2;mod b {fnf(){println!("Hello from b::f");}structS3;impl::TraitforS3{fnm1(&self){println!("Hello from S3::m1");}fnm2(&self){println!("Hello from S3::m2");}}}structS4;structS6;fnmain(){mod c {fnf(){println!("Hello from c::f");}}constC:[i32;2] = [1,2];{mod c2 {constC:[i32;2] = [1,2];}};{mod c2 {constC:[i32;2] = [1,2];}}{mod c2 {constC:[i32;{mod uh_oh {}2}] = [1,2];}}{mod c2 {constC:[i32;{mod uh_oh {impl::Traitfor::S6{fnm1(&self){}}}2}] = [1,2];}}structS5;mod d {traitTrait{fnm1(&self);}implTraitfor::S4{fnm1(&self){println!("Hello from <S4 as d::Trait>::m1");}}}implTraitforS4{fnm1(&self){println!("Hello from <S4 as Trait>::m1");}}implTraitforS5{fnm1(&self){println!("Hello from <S4 as Trait>::m1");}}implS1{fnf(){println!("Hello from S1::f");}}implTraitforS1{fnm1(&self){println!("Hello from S1::m1");}fnm2(&self){println!("Hello from S1::m2");}}mod e {fnf(){impl::Traitfor::S2{fnm1(&self){println!("Hello from S2::m1");}fnm2(&self){println!("Hello from S2::m2");}}}}println!("Hello from main");} |
…some-loops, r=pnkfelix make `everybody_loops` preserve item declarations First half of rust-lang#52545. `everybody_loops` is used by rustdoc to ensure we don't contain erroneous references to platform APIs if one of its uses is pulled in by `#[doc(cfg)]`. However, you can also implement traits for public types inside of functions. This is used by Diesel (probably others, but they were the example that was reported) to get around a recent macro hygiene fix, which has caused their crate to fail to document. While this won't make the traits show up in documentation (that step comes later), it will at least allow files to be generated.
bors
commented
Aug 6, 2018
… r=pnkfelix make `everybody_loops` preserve item declarations First half of #52545. `everybody_loops` is used by rustdoc to ensure we don't contain erroneous references to platform APIs if one of its uses is pulled in by `#[doc(cfg)]`. However, you can also implement traits for public types inside of functions. This is used by Diesel (probably others, but they were the example that was reported) to get around a recent macro hygiene fix, which has caused their crate to fail to document. While this won't make the traits show up in documentation (that step comes later), it will at least allow files to be generated.
bors
commented
Aug 6, 2018
☀️ Test successful - status-appveyor, status-travis |
…=GuillaumeGomez rustdoc: collect trait impls as an early pass Fixes#52545, fixes#41480, fixes#36922 Right now, rustdoc pulls all its impl information by scanning a crate's HIR for any items it finds. However, it doesn't recurse into anything other than modules, preventing it from seeing trait impls that may be inside things like functions or consts. Thanks to #53002, now these items actually *exist* for rustdoc to see, but they still weren't getting collected for display. But there was a secret. Whenever we pull in an item from another crate, we don't have any of its impls in the local HIR, so instead we ask the compiler for *everything* and filter out after the fact. This process is only triggered if there's a cross-crate re-export in the crate being documented, which can sometimes leave this info out of the docs. This PR instead moves this collection into an early pass, which occurs immediately after crate cleaning, so that that collection occurs regardless. In addition, by including the HIR's own `trait_impls` in addition to the existing `all_trait_implementations` calls, we can collect all these tricky trait impls without having to scan for them!
…en-trait, r=GuillaumeGomez rustdoc: collect trait impls as an early pass Fixesrust-lang#52545, fixesrust-lang#41480, fixesrust-lang#36922 Right now, rustdoc pulls all its impl information by scanning a crate's HIR for any items it finds. However, it doesn't recurse into anything other than modules, preventing it from seeing trait impls that may be inside things like functions or consts. Thanks to rust-lang#53002, now these items actually *exist* for rustdoc to see, but they still weren't getting collected for display. But there was a secret. Whenever we pull in an item from another crate, we don't have any of its impls in the local HIR, so instead we ask the compiler for *everything* and filter out after the fact. This process is only triggered if there's a cross-crate re-export in the crate being documented, which can sometimes leave this info out of the docs. This PR instead moves this collection into an early pass, which occurs immediately after crate cleaning, so that that collection occurs regardless. In addition, by including the HIR's own `trait_impls` in addition to the existing `all_trait_implementations` calls, we can collect all these tricky trait impls without having to scan for them!
…en-trait, r=GuillaumeGomez rustdoc: collect trait impls as an early pass Fixesrust-lang#52545, fixesrust-lang#41480, fixesrust-lang#36922 Right now, rustdoc pulls all its impl information by scanning a crate's HIR for any items it finds. However, it doesn't recurse into anything other than modules, preventing it from seeing trait impls that may be inside things like functions or consts. Thanks to rust-lang#53002, now these items actually *exist* for rustdoc to see, but they still weren't getting collected for display. But there was a secret. Whenever we pull in an item from another crate, we don't have any of its impls in the local HIR, so instead we ask the compiler for *everything* and filter out after the fact. This process is only triggered if there's a cross-crate re-export in the crate being documented, which can sometimes leave this info out of the docs. This PR instead moves this collection into an early pass, which occurs immediately after crate cleaning, so that that collection occurs regardless. In addition, by including the HIR's own `trait_impls` in addition to the existing `all_trait_implementations` calls, we can collect all these tricky trait impls without having to scan for them!
…=GuillaumeGomez rustdoc: collect trait impls as an early pass Fixes#52545, fixes#41480, fixes#36922 Right now, rustdoc pulls all its impl information by scanning a crate's HIR for any items it finds. However, it doesn't recurse into anything other than modules, preventing it from seeing trait impls that may be inside things like functions or consts. Thanks to #53002, now these items actually *exist* for rustdoc to see, but they still weren't getting collected for display. But there was a secret. Whenever we pull in an item from another crate, we don't have any of its impls in the local HIR, so instead we ask the compiler for *everything* and filter out after the fact. This process is only triggered if there's a cross-crate re-export in the crate being documented, which can sometimes leave this info out of the docs. This PR instead moves this collection into an early pass, which occurs immediately after crate cleaning, so that that collection occurs regardless. In addition, by including the HIR's own `trait_impls` in addition to the existing `all_trait_implementations` calls, we can collect all these tricky trait impls without having to scan for them!
First half of #52545.
everybody_loopsis used by rustdoc to ensure we don't contain erroneous references to platform APIs if one of its uses is pulled in by#[doc(cfg)]. However, you can also implement traits for public types inside of functions. This is used by Diesel (probably others, but they were the example that was reported) to get around a recent macro hygiene fix, which has caused their crate to fail to document. While this won't make the traits show up in documentation (that step comes later), it will at least allow files to be generated.