-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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: Populate external_traits with traits only seen in impls #47313
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3291,8 +3291,7 @@ fn spotlight_decl(decl: &clean::FnDecl) -> Result<String, fmt::Error> { | |
if let Some(impls) = c.impls.get(&did) { | ||
for i in impls { | ||
let impl_ = i.inner_impl(); | ||
if impl_.trait_.def_id().and_then(|d| c.traits.get(&d)) | ||
.map_or(false, |t| t.is_spotlight) { | ||
if impl_.trait_.def_id().map_or(false, |d| c.traits[&d].is_spotlight) { | ||
if out.is_empty() { | ||
out.push_str( | ||
&format!("<h3 class=\"important\">Important traits for {}</h3>\ | ||
|
@@ -3458,7 +3457,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi | |
} | ||
|
||
let traits = &cache().traits; | ||
let trait_ = i.trait_did().and_then(|did| traits.get(&did)); | ||
let trait_ = i.trait_did().map(|did| &traits[&did]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's with the change here (and above)? Change the failure mode for missing DefIds? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There now shouldn't be any cases where the trait is missing from the |
||
|
||
if !show_def_docs { | ||
write!(w, "<span class='docblock autohide'>")?; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
pub trait MyTrait { | ||
/// docs for my_trait_method | ||
fn my_trait_method() {} | ||
} | ||
|
||
pub struct MyStruct; | ||
|
||
impl MyTrait for MyStruct {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// aux-build:impl-inline-without-trait.rs | ||
// build-aux-docs | ||
// ignore-cross-compile | ||
|
||
#![crate_name = "foo"] | ||
|
||
extern crate impl_inline_without_trait; | ||
|
||
// @has 'foo/struct.MyStruct.html' | ||
// @has - '//*[@id="method.my_trait_method"]' 'fn my_trait_method()' | ||
// @has - '//*[@class="docblock"]' 'docs for my_trait_method' | ||
pub use impl_inline_without_trait::MyStruct; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice optimization here. 😉