diff options
| author | bors <bors@rust-lang.org> | 2025-07-22 08:52:53 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-07-22 08:52:53 +0000 |
| commit | 1a8eaa852507b134fcd0557547b35308273b4b74 (patch) | |
| tree | 5656ed7794f557ce02b603c2aebafeeef5e4c31a /compiler/rustc_resolve/src/rustdoc.rs | |
| parent | 9748d87dc70a9a6725c5dbd76ce29d04752b4f90 (diff) | |
| parent | 8a5bcdde9d8668f92bd2f323898d5da1bdc5df5b (diff) | |
| download | rust-try.tar.gz rust-try.zip | |
Auto merge of #144287 - nnethercote:Symbol-with_interner, r=<try> try
Introduce `Symbol::with_interner`. It lets you get the contents of multiple symbols with a single TLS lookup and interner lock, instead of one per symbol. r? `@ghost`
Diffstat (limited to 'compiler/rustc_resolve/src/rustdoc.rs')
| -rw-r--r-- | compiler/rustc_resolve/src/rustdoc.rs | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/compiler/rustc_resolve/src/rustdoc.rs b/compiler/rustc_resolve/src/rustdoc.rs index 24e15ded94f..49920bdd913 100644 --- a/compiler/rustc_resolve/src/rustdoc.rs +++ b/compiler/rustc_resolve/src/rustdoc.rs @@ -141,26 +141,32 @@ pub fn unindent_doc_fragments(docs: &mut [DocFragment]) { // In here, the `min_indent` is 1 (because non-sugared fragment are always counted with minimum // 1 whitespace), meaning that "hello!" will be considered a codeblock because it starts with 4 // (5 - 1) whitespaces. - let Some(min_indent) = docs - .iter() - .map(|fragment| { - fragment - .doc - .as_str() - .lines() - .filter(|line| line.chars().any(|c| !c.is_whitespace())) - .map(|line| { - // Compare against either space or tab, ignoring whether they are - // mixed or not. - let whitespace = line.chars().take_while(|c| *c == ' ' || *c == '\t').count(); - whitespace - + (if fragment.kind == DocFragmentKind::SugaredDoc { 0 } else { add }) + let Some(min_indent) = ({ + Symbol::with_interner(|interner| { + docs.iter() + .map(|fragment| { + interner + .get_str(fragment.doc) + .lines() + .filter(|line| line.chars().any(|c| !c.is_whitespace())) + .map(|line| { + // Compare against either space or tab, ignoring whether they are + // mixed or not. + let whitespace = + line.chars().take_while(|c| *c == ' ' || *c == '\t').count(); + whitespace + + (if fragment.kind == DocFragmentKind::SugaredDoc { + 0 + } else { + add + }) + }) + .min() + .unwrap_or(usize::MAX) }) .min() - .unwrap_or(usize::MAX) }) - .min() - else { + }) else { return; }; |
