Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
c87567c
Add context to compiler error message
Oct 20, 2022
6cb6564
Update tests to match error message changes
Oct 20, 2022
9e36fd9
stabilize `int_log`
Oct 26, 2022
8498e3a
Add examples for `pointer::mask`
WaffleLapkin Oct 28, 2022
f32e678
Rename some variables.
nnethercote Nov 3, 2022
84ca2c3
Clarify range calculations.
nnethercote Nov 3, 2022
34b32b0
Use `Mode` less.
nnethercote Nov 3, 2022
7dbf2c0
Make non-ASCII errors more consistent.
nnethercote Nov 3, 2022
a21c045
Improve comments.
nnethercote Nov 3, 2022
d963686
Refactor `cook_lexer_literal`.
nnethercote Nov 3, 2022
a203482
Inline and remove `validate_int_literal`.
nnethercote Nov 3, 2022
a838952
Remove `unescape_byte_literal`.
nnethercote Nov 4, 2022
43d21b5
Rename some `result` variables as `res`, for consistency.
nnethercote Nov 4, 2022
f67ee43
rustdoc: Add mutable to the description
yancyribbens Nov 7, 2022
8e0cac1
rustdoc: refactor `notable_traits_decl` to just act on the type directly
notriddle Nov 7, 2022
d6c97a3
Simplify `unescape_{char,byte}`.
nnethercote Nov 8, 2022
303653e
rustdoc: use javascript to layout notable traits popups
notriddle Nov 7, 2022
a45151e
rustdoc: fix font color inheritance from body, and test
notriddle Nov 8, 2022
a7a40dd
Simplify some `Autoderef::new` calls
oli-obk Nov 8, 2022
1d93b35
Remove overloaded_span argument from `new`, where it is usually redun…
oli-obk Nov 8, 2022
b745a29
Remove an unused span
oli-obk Nov 8, 2022
ef40824
Update books
ehuss Nov 8, 2022
ba359d8
Add support for custom MIR parsing
JakobDegen Aug 3, 2022
f665847
const Compare Tuples
onestacked Nov 7, 2022
a68ec22
Fix `rustdoc --version` when used with download-rustc
jyn514 Nov 9, 2022
b6c05eb
Cleanup fn trait ref test
onestacked Nov 9, 2022
575f609
Port unknown feature diagnostic to the new framework
SLASHLogin Aug 25, 2022
a54c800
Formatting
SLASHLogin Aug 25, 2022
1c4bd83
locales formatting
SLASHLogin Aug 25, 2022
21b0426
Trailing whitespaces
SLASHLogin Aug 25, 2022
b164790
Change String in structs to &'a str
SLASHLogin Aug 25, 2022
69d412a
Missing lifetime parameter and formatting
SLASHLogin Aug 25, 2022
05ae7ec
Import `error creating import library`
SLASHLogin Aug 25, 2022
4c625dc
Port Instrument coverage requires llvm 12 to the new struct
SLASHLogin Aug 25, 2022
9f0c165
Port `symbol_already_defined` error
SLASHLogin Aug 25, 2022
ec1e101
Fix diag() and formatting
SLASHLogin Aug 25, 2022
59b8aed
Port branch protection on aarch64
SLASHLogin Aug 25, 2022
f031823
Formatting
SLASHLogin Aug 25, 2022
39d363f
Port layout size overflow
SLASHLogin Aug 26, 2022
5d79d3c
Port InvalidMinimumAlignment
SLASHLogin Aug 26, 2022
60ee496
Port LinkageConstOrMutType error
SLASHLogin Aug 26, 2022
02403ee
Reuse SymbolAlreadyDefined
SLASHLogin Aug 26, 2022
978b5f7
Port SanitizerMemtagRequiresMte
SLASHLogin Aug 26, 2022
d32caf9
Port ArchiveBuildFailure
SLASHLogin Aug 26, 2022
ddbb650
Import ErrorWritingDEFFile
SLASHLogin Aug 26, 2022
81f7a8d
Port ErrorCallingDllTool
SLASHLogin Aug 26, 2022
c01546f
Port `DlltoolFailImportLibrary` and implement `IntoDiagnosticArg` for…
SLASHLogin Aug 26, 2022
33ef16f
Port `UnknownArchiveKind`
SLASHLogin Aug 26, 2022
185ef7b
Port `MissingFeatures` and `TargetFeatureDisableOrEnable`
SLASHLogin Aug 26, 2022
1c7a801
Fix CI
SLASHLogin Aug 27, 2022
e9a5329
Correct tests to match errors
SLASHLogin Aug 30, 2022
67394e7
Flatten diagnostic structs
SLASHLogin Oct 30, 2022
3728e95
Port diagnostics created by `Handler`
SLASHLogin Oct 30, 2022
9a15458
Simplify existing Diagnostic implementations
SLASHLogin Oct 30, 2022
b4820a3
Delay diagnostic translation in `rustc_codegen_ssa`
SLASHLogin Nov 2, 2022
3b949eb
Add `replace_args` method for `rustc_errors::diagnostic::Diagnostic`
SLASHLogin Nov 3, 2022
0381e51
Formatting
SLASHLogin Nov 3, 2022
a8a8055
Use `LayoutError`'s implementation of `IntoDiagnostic`
SLASHLogin Nov 4, 2022
0baac88
Update compiler/rustc_codegen_llvm/src/back/archive.rs
SLASHLogin Nov 8, 2022
39895b0
Add constructor for `Diagnostic` that takes `Vec<(DiagnosticMessage, …
SLASHLogin Nov 9, 2022
caada74
Add missing `emitted_at` to the `Diagnostic`
SLASHLogin Nov 9, 2022
edda37a
Rollup merge of #101005 - SLASHLogin:rustc_codegen_llvm_diagnostics, …
Manishearth Nov 9, 2022
bcc1781
Rollup merge of #103307 - b4den:master, r=estebank
Manishearth Nov 9, 2022
25be18b
Rollup merge of #103464 - JakobDegen:mir-parsing, r=oli-obk
Manishearth Nov 9, 2022
147e5df
Rollup merge of #103570 - lukas-code:stabilize-ilog, r=scottmcm
Manishearth Nov 9, 2022
2c75537
Rollup merge of #103694 - WaffleLapkin:mask_doc_example, r=scottmcm
Manishearth Nov 9, 2022
2698b82
Rollup merge of #103919 - nnethercote:unescaping-cleanups, r=matklad
Manishearth Nov 9, 2022
2ad5885
Rollup merge of #104111 - yancyribbens:add-mutable-to-the-description…
Manishearth Nov 9, 2022
57d2005
Rollup merge of #104125 - ink-feather-org:const_cmp_tuples, r=fee1-dead
Manishearth Nov 9, 2022
3a2ab4e
Rollup merge of #104129 - notriddle:notriddle/102576-js-notable-trait…
Manishearth Nov 9, 2022
fd79533
Rollup merge of #104156 - oli-obk:autoderef, r=estebank
Manishearth Nov 9, 2022
ede323e
Rollup merge of #104171 - ehuss:update-books, r=ehuss
Manishearth Nov 9, 2022
aed1890
Rollup merge of #104184 - jyn514:rustdoc-version, r=davidtwco
Manishearth Nov 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rustdoc: refactor notable_traits_decl to just act on the type directly
  • Loading branch information
notriddle committed Nov 7, 2022
commit 8e0cac18cd2951e2679ea55e15242d04e2d410c9
133 changes: 66 additions & 67 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,11 @@ fn assoc_method(
name = name,
generics = g.print(cx),
decl = d.full_print(header_len, indent, cx),
notable_traits = notable_traits_decl(d, cx),
notable_traits = d
.output
.as_return()
.and_then(|output| notable_traits_decl(output, cx))
.unwrap_or_default(),
where_clause = print_where_clause(g, cx, indent, end_newline),
)
}
Expand Down Expand Up @@ -1273,88 +1277,83 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool, tcx: TyCtxt<'_>) ->
}
}

fn notable_traits_decl(decl: &clean::FnDecl, cx: &Context<'_>) -> String {
fn notable_traits_decl(ty: &clean::Type, cx: &Context<'_>) -> Option<String> {
let mut out = Buffer::html();

if let Some((did, ty)) = decl.output.as_return().and_then(|t| Some((t.def_id(cx.cache())?, t)))
let did = ty.def_id(cx.cache())?;

// Box has pass-through impls for Read, Write, Iterator, and Future when the
// boxed type implements one of those. We don't want to treat every Box return
// as being notably an Iterator (etc), though, so we exempt it. Pin has the same
// issue, with a pass-through impl for Future.
if Some(did) == cx.tcx().lang_items().owned_box()
|| Some(did) == cx.tcx().lang_items().pin_type()
{
// Box has pass-through impls for Read, Write, Iterator, and Future when the
// boxed type implements one of those. We don't want to treat every Box return
// as being notably an Iterator (etc), though, so we exempt it. Pin has the same
// issue, with a pass-through impl for Future.
if Some(did) == cx.tcx().lang_items().owned_box()
|| Some(did) == cx.tcx().lang_items().pin_type()
{
return "".to_string();
}
if let Some(impls) = cx.cache().impls.get(&did) {
for i in impls {
let impl_ = i.inner_impl();
if !impl_.for_.without_borrowed_ref().is_same(ty.without_borrowed_ref(), cx.cache())
{
// Two different types might have the same did,
// without actually being the same.
continue;
}
if let Some(trait_) = &impl_.trait_ {
let trait_did = trait_.def_id();

if cx
.cache()
.traits
.get(&trait_did)
.map_or(false, |t| t.is_notable_trait(cx.tcx()))
{
if out.is_empty() {
write!(
&mut out,
"<span class=\"notable\">Notable traits for {}</span>\
<code class=\"content\">",
impl_.for_.print(cx)
);
}
return None;
}
if let Some(impls) = cx.cache().impls.get(&did) {
for i in impls {
let impl_ = i.inner_impl();
if !impl_.for_.without_borrowed_ref().is_same(ty.without_borrowed_ref(), cx.cache()) {
// Two different types might have the same did,
// without actually being the same.
continue;
}
if let Some(trait_) = &impl_.trait_ {
let trait_did = trait_.def_id();

//use the "where" class here to make it small
if cx.cache().traits.get(&trait_did).map_or(false, |t| t.is_notable_trait(cx.tcx()))
{
if out.is_empty() {
write!(
&mut out,
"<span class=\"where fmt-newline\">{}</span>",
impl_.print(false, cx)
"<span class=\"notable\">Notable traits for {}</span>\
<code class=\"content\">",
impl_.for_.print(cx)
);
for it in &impl_.items {
if let clean::AssocTypeItem(ref tydef, ref _bounds) = *it.kind {
out.push_str("<span class=\"where fmt-newline\"> ");
let empty_set = FxHashSet::default();
let src_link =
AssocItemLink::GotoSource(trait_did.into(), &empty_set);
assoc_type(
&mut out,
it,
&tydef.generics,
&[], // intentionally leaving out bounds
Some(&tydef.type_),
src_link,
0,
cx,
);
out.push_str(";</span>");
}
}

//use the "where" class here to make it small
write!(
&mut out,
"<span class=\"where fmt-newline\">{}</span>",
impl_.print(false, cx)
);
for it in &impl_.items {
if let clean::AssocTypeItem(ref tydef, ref _bounds) = *it.kind {
out.push_str("<span class=\"where fmt-newline\"> ");
let empty_set = FxHashSet::default();
let src_link = AssocItemLink::GotoSource(trait_did.into(), &empty_set);
assoc_type(
&mut out,
it,
&tydef.generics,
&[], // intentionally leaving out bounds
Some(&tydef.type_),
src_link,
0,
cx,
);
out.push_str(";</span>");
}
}
}
}
}
}

if !out.is_empty() {
out.insert_str(
0,
"<span class=\"notable-traits\"><span class=\"notable-traits-tooltip\">ⓘ\
<span class=\"notable-traits-tooltiptext\"><span class=\"docblock\">",
);
out.push_str("</code></span></span></span></span>");
if out.is_empty() {
return None;
}

out.into_inner()
out.insert_str(
0,
"<span class=\"notable-traits\"><span class=\"notable-traits-tooltip\">ⓘ\
<span class=\"notable-traits-tooltiptext\"><span class=\"docblock\">",
);
out.push_str("</code></span></span></span></span>");

Some(out.into_inner())
}

#[derive(Clone, Copy, Debug)]
Expand Down
7 changes: 6 additions & 1 deletion src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,12 @@ fn item_function(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, f: &cle
generics = f.generics.print(cx),
where_clause = print_where_clause(&f.generics, cx, 0, Ending::Newline),
decl = f.decl.full_print(header_len, 0, cx),
notable_traits = notable_traits_decl(&f.decl, cx),
notable_traits = f
.decl
.output
.as_return()
.and_then(|output| notable_traits_decl(output, cx))
.unwrap_or_default(),
);
});
});
Expand Down