diff options
| author | bors <bors@rust-lang.org> | 2021-12-19 09:31:37 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-12-19 09:31:37 +0000 |
| commit | a41a6925badac7508d7a72cc1fc20f43dc6ad75e (patch) | |
| tree | 224de9d17e4b466061b457662dd9d2dfc9b9ce14 /src/librustdoc/html/render | |
| parent | 8f540619007c1aa62dfc915409d881f52f21dc84 (diff) | |
| parent | b1c934ebb8b881977a93c05c15caa88921792d3b (diff) | |
| download | rust-a41a6925badac7508d7a72cc1fc20f43dc6ad75e.tar.gz rust-a41a6925badac7508d7a72cc1fc20f43dc6ad75e.zip | |
Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obk
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
Diffstat (limited to 'src/librustdoc/html/render')
| -rw-r--r-- | src/librustdoc/html/render/context.rs | 16 | ||||
| -rw-r--r-- | src/librustdoc/html/render/mod.rs | 10 | ||||
| -rw-r--r-- | src/librustdoc/html/render/print_item.rs | 18 | ||||
| -rw-r--r-- | src/librustdoc/html/render/write_shared.rs | 6 |
4 files changed, 25 insertions, 25 deletions
diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 365d959ad9f..c4d326e7711 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -180,7 +180,7 @@ impl<'tcx> Context<'tcx> { fn render_item(&self, it: &clean::Item, is_module: bool) -> String { let mut title = String::new(); if !is_module { - title.push_str(&it.name.unwrap().as_str()); + title.push_str(it.name.unwrap().as_str()); } if !it.is_primitive() && !it.is_keyword() { if !is_module { @@ -315,7 +315,7 @@ impl<'tcx> Context<'tcx> { }; let file = &file; - let symbol; + let krate_sym; let (krate, path) = if cnum == LOCAL_CRATE { if let Some(path) = self.shared.local_sources.get(file) { (self.shared.layout.krate.as_str(), path) @@ -343,8 +343,8 @@ impl<'tcx> Context<'tcx> { let mut fname = file.file_name().expect("source has no filename").to_os_string(); fname.push(".html"); path.push_str(&fname.to_string_lossy()); - symbol = krate.as_str(); - (&*symbol, &path) + krate_sym = krate; + (krate_sym.as_str(), &path) }; let anchor = if with_lines { @@ -549,7 +549,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { fn after_krate(&mut self) -> Result<(), Error> { let crate_name = self.tcx().crate_name(LOCAL_CRATE); - let final_file = self.dst.join(&*crate_name.as_str()).join("all.html"); + let final_file = self.dst.join(crate_name.as_str()).join("all.html"); let settings_file = self.dst.join("settings.html"); let mut root_path = self.dst.to_str().expect("invalid path").to_owned(); @@ -619,9 +619,9 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { if let Some(ref redirections) = self.shared.redirections { if !redirections.borrow().is_empty() { let redirect_map_path = - self.dst.join(&*crate_name.as_str()).join("redirect-map.json"); + self.dst.join(crate_name.as_str()).join("redirect-map.json"); let paths = serde_json::to_string(&*redirections.borrow()).unwrap(); - self.shared.ensure_dir(&self.dst.join(&*crate_name.as_str()))?; + self.shared.ensure_dir(&self.dst.join(crate_name.as_str()))?; self.shared.fs.write(redirect_map_path, paths)?; } } @@ -703,7 +703,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { if !buf.is_empty() { let name = item.name.as_ref().unwrap(); let item_type = item.type_(); - let file_name = &item_path(item_type, &name.as_str()); + let file_name = &item_path(item_type, name.as_str()); self.shared.ensure_dir(&self.dst)?; let joint_dst = self.dst.join(file_name); self.shared.fs.write(joint_dst, buf)?; diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 2432f5cc085..cd89164a254 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -640,9 +640,9 @@ fn short_item_info( // We display deprecation messages for #[deprecated] and #[rustc_deprecated] // but only display the future-deprecation messages for #[rustc_deprecated]. let mut message = if let Some(since) = since { - let since = &since.as_str(); + let since = since.as_str(); if !stability::deprecation_in_effect(&depr) { - if *since == "TBD" { + if since == "TBD" { String::from("Deprecating in a future Rust version") } else { format!("Deprecating in {}", Escape(since)) @@ -658,7 +658,7 @@ fn short_item_info( let note = note.as_str(); let mut ids = cx.id_map.borrow_mut(); let html = MarkdownHtml( - ¬e, + note, &mut ids, error_codes, cx.shared.edition(), @@ -683,7 +683,7 @@ fn short_item_info( let mut message = "<span class=\"emoji\">🔬</span> This is a nightly-only experimental API.".to_owned(); - let mut feature = format!("<code>{}</code>", Escape(&feature.as_str())); + let mut feature = format!("<code>{}</code>", Escape(feature.as_str())); if let (Some(url), Some(issue)) = (&cx.shared.issue_tracker_base_url, issue) { feature.push_str(&format!( " <a href=\"{url}{issue}\">#{issue}</a>", @@ -1414,7 +1414,7 @@ fn render_impl( let source_id = trait_ .and_then(|trait_| { trait_.items.iter().find(|item| { - item.name.map(|n| n.as_str().eq(&name.as_str())).unwrap_or(false) + item.name.map(|n| n.as_str().eq(name.as_str())).unwrap_or(false) }) }) .map(|item| format!("{}.{}", item.type_(), name)); diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 9943e23b928..44a9ec5ea42 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -136,7 +136,7 @@ pub(super) fn print_item( page: page, static_root_path: page.get_static_root_path(), typ: typ, - name: &item.name.as_ref().unwrap().as_str(), + name: item.name.as_ref().unwrap().as_str(), item_type: &item.type_().to_string(), path_components: path_components, stability_since_raw: &stability_since_raw, @@ -239,9 +239,9 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl (true, false) => return Ordering::Greater, } } - let lhs = i1.name.unwrap_or(kw::Empty).as_str(); - let rhs = i2.name.unwrap_or(kw::Empty).as_str(); - compare_names(&lhs, &rhs) + let lhs = i1.name.unwrap_or(kw::Empty); + let rhs = i2.name.unwrap_or(kw::Empty); + compare_names(lhs.as_str(), rhs.as_str()) } if cx.shared.sort_modules_alphabetically { @@ -315,7 +315,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl w, "<div class=\"item-left\"><code>{}extern crate {} as {};", myitem.visibility.print_with_space(myitem.def_id, cx), - anchor(myitem.def_id.expect_def_id(), &*src.as_str(), cx), + anchor(myitem.def_id.expect_def_id(), src.as_str(), cx), myitem.name.as_ref().unwrap(), ), None => write!( @@ -324,7 +324,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl myitem.visibility.print_with_space(myitem.def_id, cx), anchor( myitem.def_id.expect_def_id(), - &*myitem.name.as_ref().unwrap().as_str(), + myitem.name.as_ref().unwrap().as_str(), cx ), ), @@ -405,7 +405,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl add = add, stab = stab.unwrap_or_default(), unsafety_flag = unsafety_flag, - href = item_path(myitem.type_(), &myitem.name.unwrap().as_str()), + href = item_path(myitem.type_(), myitem.name.unwrap().as_str()), title = [full_path(cx, myitem), myitem.type_().to_string()] .iter() .filter_map(|s| if !s.is_empty() { Some(s.as_str()) } else { None }) @@ -1308,7 +1308,7 @@ fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St document_non_exhaustive(w, it); for (index, (field, ty)) in fields.enumerate() { let field_name = - field.name.map_or_else(|| index.to_string(), |sym| (*sym.as_str()).to_string()); + field.name.map_or_else(|| index.to_string(), |sym| sym.as_str().to_string()); let id = cx.derive_id(format!("{}.{}", ItemType::StructField, field_name)); write!( w, @@ -1410,7 +1410,7 @@ crate fn compare_names(mut lhs: &str, mut rhs: &str) -> Ordering { pub(super) fn full_path(cx: &Context<'_>, item: &clean::Item) -> String { let mut s = cx.current.join("::"); s.push_str("::"); - s.push_str(&item.name.unwrap().as_str()); + s.push_str(item.name.unwrap().as_str()); s } diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index 0d5ba8e80d2..563f4ae7385 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -418,7 +418,7 @@ pub(super) fn write_shared( let dst = cx.dst.join(&format!("source-files{}.js", cx.shared.resource_suffix)); let make_sources = || { let (mut all_sources, _krates) = - try_err!(collect(&dst, &krate.name(cx.tcx()).as_str(), "sourcesIndex"), &dst); + try_err!(collect(&dst, krate.name(cx.tcx()).as_str(), "sourcesIndex"), &dst); all_sources.push(format!( "sourcesIndex[\"{}\"] = {};", &krate.name(cx.tcx()), @@ -437,7 +437,7 @@ pub(super) fn write_shared( // Update the search index and crate list. let dst = cx.dst.join(&format!("search-index{}.js", cx.shared.resource_suffix)); let (mut all_indexes, mut krates) = - try_err!(collect_json(&dst, &krate.name(cx.tcx()).as_str()), &dst); + try_err!(collect_json(&dst, krate.name(cx.tcx()).as_str()), &dst); all_indexes.push(search_index); krates.push(krate.name(cx.tcx()).to_string()); krates.sort(); @@ -575,7 +575,7 @@ pub(super) fn write_shared( mydst.push(&format!("{}.{}.js", remote_item_type, remote_path[remote_path.len() - 1])); let (mut all_implementors, _) = - try_err!(collect(&mydst, &krate.name(cx.tcx()).as_str(), "implementors"), &mydst); + try_err!(collect(&mydst, krate.name(cx.tcx()).as_str(), "implementors"), &mydst); all_implementors.push(implementors); // Sort the implementors by crate so the file will be generated // identically even with rustdoc running in parallel. |
