From 6c254ed6dca48ebbd83209493df0ffc1d2584f38 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Mon, 2 Jan 2023 17:26:16 -0800 Subject: [PATCH 01/11] rustdoc: allow popover child links to work No need to prevent default click behavior on a
, it will also disable all child click behavior. --- src/librustdoc/html/static/js/main.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 60e4e7492240c..92baa68b5befb 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -1040,9 +1040,6 @@ function loadCss(cssUrl) { help_button.appendChild(container); container.onblur = helpBlurHandler; - container.onclick = event => { - event.preventDefault(); - }; help_button.onblur = helpBlurHandler; help_button.children[0].onblur = helpBlurHandler; } From 59eee74ce8b2b056c44f8743fd1661e4858cc12b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 3 Jan 2023 18:10:32 +0100 Subject: [PATCH 02/11] Fix link generation for local primitive types in rustdoc JSON output --- src/librustdoc/json/conversions.rs | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index d7184053c87a4..4a81a9d2d61a5 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -8,8 +8,9 @@ use std::convert::From; use std::fmt; use rustc_ast::ast; -use rustc_hir::{def::CtorKind, def_id::DefId}; +use rustc_hir::{def::CtorKind, def::DefKind, def_id::DefId}; use rustc_middle::ty::{self, TyCtxt}; +use rustc_span::symbol::sym; use rustc_span::{Pos, Symbol}; use rustc_target::spec::abi::Abi as RustcAbi; @@ -217,13 +218,27 @@ pub(crate) fn from_item_id_with_name(item_id: ItemId, tcx: TyCtxt<'_>, name: Opt impl<'a> fmt::Display for DisplayDefId<'a> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let name = match self.2 { + let DisplayDefId(def_id, tcx, name) = self; + let name = match name { Some(name) => format!(":{}", name.as_u32()), - None => self - .1 - .opt_item_name(self.0) - .map(|n| format!(":{}", n.as_u32())) - .unwrap_or_default(), + None => { + // We need this workaround because primitive types' DefId actually refers to + // their parent module, which isn't present in the output JSON items. So + // instead, we directly get the primitive symbol and convert it to u32 to + // generate the ID. + if matches!(tcx.def_kind(def_id), DefKind::Mod) && + let Some(prim) = tcx.get_attrs(*def_id, sym::doc) + .flat_map(|attr| attr.meta_item_list().unwrap_or_default()) + .filter(|attr| attr.has_name(sym::primitive)) + .find_map(|attr| attr.value_str()) { + format!(":{}", prim.as_u32()) + } else { + tcx + .opt_item_name(*def_id) + .map(|n| format!(":{}", n.as_u32())) + .unwrap_or_default() + } + } }; write!(f, "{}:{}{}", self.0.krate.as_u32(), u32::from(self.0.index), name) } From f69fee4fea59fb84582a021d929fd6ecee37db8a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 3 Jan 2023 18:29:40 +0100 Subject: [PATCH 03/11] Add regression test for #104064 --- .../primitives/local_primitive.rs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/test/rustdoc-json/primitives/local_primitive.rs diff --git a/src/test/rustdoc-json/primitives/local_primitive.rs b/src/test/rustdoc-json/primitives/local_primitive.rs new file mode 100644 index 0000000000000..f27e6a2adeca6 --- /dev/null +++ b/src/test/rustdoc-json/primitives/local_primitive.rs @@ -0,0 +1,21 @@ +// Regression test for . + +#![feature(no_core)] +#![feature(rustc_attrs)] +#![feature(rustdoc_internals)] +#![no_core] +#![rustc_coherence_is_core] + +//! Link to [i32][prim@i32] [i64][prim@i64] + +#[doc(primitive = "i32")] +mod prim_i32 {} + +// @set local_i32 = "$.index[*][?(@.name=='i32')].id" + +// @has "$.index[*][?(@.name=='local_primitive')]" +// @ismany "$.index[*][?(@.name=='local_primitive')].inner.items[*]" $local_i32 +// @is "$.index[*][?(@.name=='local_primitive')].links['prim@i32']" $local_i32 + +// Let's ensure the `prim_i32` module isn't present in the output JSON: +// @!has "$.index[*][?(@.name=='prim_i32')]" From 3534e0a393b447791fffaa84a97114dd3c761890 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Tue, 3 Jan 2023 04:13:19 +0000 Subject: [PATCH 04/11] Fix a few clippy lints in libtest - Remove unnecessary references and dereferences - Use `.contains` instead of `a <= x && x <= b` - Use `mem::take` instead of `mem::replace` where possible --- library/test/src/console.rs | 6 +++--- library/test/src/formatters/json.rs | 18 +++++++++--------- library/test/src/formatters/junit.rs | 16 ++++++++-------- library/test/src/formatters/pretty.rs | 16 ++++++++-------- library/test/src/formatters/terse.rs | 20 ++++++++++---------- library/test/src/lib.rs | 2 +- library/test/src/term/terminfo/mod.rs | 6 +++--- library/test/src/term/terminfo/parm.rs | 8 ++++---- library/test/src/term/terminfo/searcher.rs | 4 ++-- library/test/src/test_result.rs | 4 ++-- library/test/src/types.rs | 2 +- 11 files changed, 51 insertions(+), 51 deletions(-) diff --git a/library/test/src/console.rs b/library/test/src/console.rs index a3c39f71f08b8..24cbe035f2fa7 100644 --- a/library/test/src/console.rs +++ b/library/test/src/console.rs @@ -147,7 +147,7 @@ pub fn list_tests_console(opts: &TestOpts, tests: Vec) -> io::Res let mut ntest = 0; let mut nbench = 0; - for test in filter_tests(&opts, tests).into_iter() { + for test in filter_tests(opts, tests).into_iter() { use crate::TestFn::*; let TestDescAndFn { desc: TestDesc { name, .. }, testfn } = test; @@ -244,7 +244,7 @@ fn on_test_event( let stdout = &completed_test.stdout; st.write_log_result(test, result, exec_time.as_ref())?; - out.write_result(test, result, exec_time.as_ref(), &*stdout, st)?; + out.write_result(test, result, exec_time.as_ref(), stdout, st)?; handle_test_result(st, completed_test); } } @@ -262,7 +262,7 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec) -> io::Resu let max_name_len = tests .iter() - .max_by_key(|t| len_if_padded(*t)) + .max_by_key(|t| len_if_padded(t)) .map(|t| t.desc.name.as_slice().len()) .unwrap_or(0); diff --git a/library/test/src/formatters/json.rs b/library/test/src/formatters/json.rs index 5526aadb67ffb..95d2faf25060f 100644 --- a/library/test/src/formatters/json.rs +++ b/library/test/src/formatters/json.rs @@ -40,20 +40,20 @@ impl JsonFormatter { extra: Option<&str>, ) -> io::Result<()> { // A doc test's name includes a filename which must be escaped for correct json. - self.write_message(&*format!( + self.write_message(&format!( r#"{{ "type": "{}", "name": "{}", "event": "{}""#, ty, EscapedString(name), evt ))?; if let Some(exec_time) = exec_time { - self.write_message(&*format!(r#", "exec_time": {}"#, exec_time.0.as_secs_f64()))?; + self.write_message(&format!(r#", "exec_time": {}"#, exec_time.0.as_secs_f64()))?; } if let Some(stdout) = stdout { - self.write_message(&*format!(r#", "stdout": "{}""#, EscapedString(stdout)))?; + self.write_message(&format!(r#", "stdout": "{}""#, EscapedString(stdout)))?; } if let Some(extra) = extra { - self.write_message(&*format!(r#", {extra}"#))?; + self.write_message(&format!(r#", {extra}"#))?; } self.writeln_message(" }") } @@ -66,13 +66,13 @@ impl OutputFormatter for JsonFormatter { } else { String::new() }; - self.writeln_message(&*format!( + self.writeln_message(&format!( r#"{{ "type": "suite", "event": "started", "test_count": {test_count}{shuffle_seed_json} }}"# )) } fn write_test_start(&mut self, desc: &TestDesc) -> io::Result<()> { - self.writeln_message(&*format!( + self.writeln_message(&format!( r#"{{ "type": "test", "event": "started", "name": "{}" }}"#, EscapedString(desc.name.as_slice()) )) @@ -151,20 +151,20 @@ impl OutputFormatter for JsonFormatter { mbps ); - self.writeln_message(&*line) + self.writeln_message(&line) } } } fn write_timeout(&mut self, desc: &TestDesc) -> io::Result<()> { - self.writeln_message(&*format!( + self.writeln_message(&format!( r#"{{ "type": "test", "event": "timeout", "name": "{}" }}"#, EscapedString(desc.name.as_slice()) )) } fn write_run_finish(&mut self, state: &ConsoleTestState) -> io::Result { - self.write_message(&*format!( + self.write_message(&format!( "{{ \"type\": \"suite\", \ \"event\": \"{}\", \ \"passed\": {}, \ diff --git a/library/test/src/formatters/junit.rs b/library/test/src/formatters/junit.rs index e6fb4f5707b35..7a40ce33cb741 100644 --- a/library/test/src/formatters/junit.rs +++ b/library/test/src/formatters/junit.rs @@ -64,7 +64,7 @@ impl OutputFormatter for JunitFormatter { fn write_run_finish(&mut self, state: &ConsoleTestState) -> io::Result { self.write_message("")?; - self.write_message(&*format!( + self.write_message(&format!( " OutputFormatter for JunitFormatter { >", state.failed, state.total, state.ignored ))?; - for (desc, result, duration) in std::mem::replace(&mut self.results, Vec::new()) { + for (desc, result, duration) in std::mem::take(&mut self.results) { let (class_name, test_name) = parse_class_name(&desc); match result { TestResult::TrIgnored => { /* no-op */ } TestResult::TrFailed => { - self.write_message(&*format!( + self.write_message(&format!( "", class_name, @@ -90,19 +90,19 @@ impl OutputFormatter for JunitFormatter { } TestResult::TrFailedMsg(ref m) => { - self.write_message(&*format!( + self.write_message(&format!( "", class_name, test_name, duration.as_secs_f64() ))?; - self.write_message(&*format!(""))?; + self.write_message(&format!(""))?; self.write_message("")?; } TestResult::TrTimedFail => { - self.write_message(&*format!( + self.write_message(&format!( "", class_name, @@ -114,7 +114,7 @@ impl OutputFormatter for JunitFormatter { } TestResult::TrBench(ref b) => { - self.write_message(&*format!( + self.write_message(&format!( "", class_name, test_name, b.ns_iter_summ.sum @@ -122,7 +122,7 @@ impl OutputFormatter for JunitFormatter { } TestResult::TrOk => { - self.write_message(&*format!( + self.write_message(&format!( "", class_name, diff --git a/library/test/src/formatters/pretty.rs b/library/test/src/formatters/pretty.rs index 0299c8b543359..247778e515f0d 100644 --- a/library/test/src/formatters/pretty.rs +++ b/library/test/src/formatters/pretty.rs @@ -134,7 +134,7 @@ impl PrettyFormatter { let mut results = Vec::new(); let mut stdouts = String::new(); - for &(ref f, ref stdout) in inputs { + for (f, stdout) in inputs { results.push(f.name.to_string()); if !stdout.is_empty() { stdouts.push_str(&format!("---- {} stdout ----\n", f.name)); @@ -171,9 +171,9 @@ impl PrettyFormatter { fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> { let name = desc.padded_name(self.max_name_len, desc.name.padding()); if let Some(test_mode) = desc.test_mode() { - self.write_plain(&format!("test {name} - {test_mode} ... "))?; + self.write_plain(format!("test {name} - {test_mode} ... "))?; } else { - self.write_plain(&format!("test {name} ... "))?; + self.write_plain(format!("test {name} ... "))?; } Ok(()) @@ -188,7 +188,7 @@ impl OutputFormatter for PrettyFormatter { } else { String::new() }; - self.write_plain(&format!("\nrunning {test_count} {noun}{shuffle_seed_msg}\n")) + self.write_plain(format!("\nrunning {test_count} {noun}{shuffle_seed_msg}\n")) } fn write_test_start(&mut self, desc: &TestDesc) -> io::Result<()> { @@ -221,7 +221,7 @@ impl OutputFormatter for PrettyFormatter { TestResult::TrIgnored => self.write_ignored(desc.ignore_message)?, TestResult::TrBench(ref bs) => { self.write_bench()?; - self.write_plain(&format!(": {}", fmt_bench_samples(bs)))?; + self.write_plain(format!(": {}", fmt_bench_samples(bs)))?; } TestResult::TrTimedFail => self.write_time_failed()?, } @@ -231,7 +231,7 @@ impl OutputFormatter for PrettyFormatter { } fn write_timeout(&mut self, desc: &TestDesc) -> io::Result<()> { - self.write_plain(&format!( + self.write_plain(format!( "test {} has been running for over {} seconds\n", desc.name, time::TEST_WARN_TIMEOUT_S @@ -267,11 +267,11 @@ impl OutputFormatter for PrettyFormatter { state.passed, state.failed, state.ignored, state.measured, state.filtered_out ); - self.write_plain(&s)?; + self.write_plain(s)?; if let Some(ref exec_time) = state.exec_time { let time_str = format!("; finished in {exec_time}"); - self.write_plain(&time_str)?; + self.write_plain(time_str)?; } self.write_plain("\n\n")?; diff --git a/library/test/src/formatters/terse.rs b/library/test/src/formatters/terse.rs index 5dace8baef7f8..0837ab1690513 100644 --- a/library/test/src/formatters/terse.rs +++ b/library/test/src/formatters/terse.rs @@ -70,7 +70,7 @@ impl TerseFormatter { // screen when dealing with line-buffered output (e.g., piping to // `stamp` in the rust CI). let out = format!(" {}/{}\n", self.test_count + 1, self.total_test_count); - self.write_plain(&out)?; + self.write_plain(out)?; } self.test_count += 1; @@ -106,7 +106,7 @@ impl TerseFormatter { self.write_plain("\nsuccesses:\n")?; let mut successes = Vec::new(); let mut stdouts = String::new(); - for &(ref f, ref stdout) in &state.not_failures { + for (f, stdout) in &state.not_failures { successes.push(f.name.to_string()); if !stdout.is_empty() { stdouts.push_str(&format!("---- {} stdout ----\n", f.name)); @@ -132,7 +132,7 @@ impl TerseFormatter { self.write_plain("\nfailures:\n")?; let mut failures = Vec::new(); let mut fail_out = String::new(); - for &(ref f, ref stdout) in &state.failures { + for (f, stdout) in &state.failures { failures.push(f.name.to_string()); if !stdout.is_empty() { fail_out.push_str(&format!("---- {} stdout ----\n", f.name)); @@ -157,9 +157,9 @@ impl TerseFormatter { fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> { let name = desc.padded_name(self.max_name_len, desc.name.padding()); if let Some(test_mode) = desc.test_mode() { - self.write_plain(&format!("test {name} - {test_mode} ... "))?; + self.write_plain(format!("test {name} - {test_mode} ... "))?; } else { - self.write_plain(&format!("test {name} ... "))?; + self.write_plain(format!("test {name} ... "))?; } Ok(()) @@ -175,7 +175,7 @@ impl OutputFormatter for TerseFormatter { } else { String::new() }; - self.write_plain(&format!("\nrunning {test_count} {noun}{shuffle_seed_msg}\n")) + self.write_plain(format!("\nrunning {test_count} {noun}{shuffle_seed_msg}\n")) } fn write_test_start(&mut self, desc: &TestDesc) -> io::Result<()> { @@ -209,13 +209,13 @@ impl OutputFormatter for TerseFormatter { self.write_test_name(desc)?; } self.write_bench()?; - self.write_plain(&format!(": {}\n", fmt_bench_samples(bs))) + self.write_plain(format!(": {}\n", fmt_bench_samples(bs))) } } } fn write_timeout(&mut self, desc: &TestDesc) -> io::Result<()> { - self.write_plain(&format!( + self.write_plain(format!( "test {} has been running for over {} seconds\n", desc.name, time::TEST_WARN_TIMEOUT_S @@ -245,11 +245,11 @@ impl OutputFormatter for TerseFormatter { state.passed, state.failed, state.ignored, state.measured, state.filtered_out ); - self.write_plain(&s)?; + self.write_plain(s)?; if let Some(ref exec_time) = state.exec_time { let time_str = format!("; finished in {exec_time}"); - self.write_plain(&time_str)?; + self.write_plain(time_str)?; } self.write_plain("\n\n")?; diff --git a/library/test/src/lib.rs b/library/test/src/lib.rs index f6a41bbb88c85..30dc4ff855315 100644 --- a/library/test/src/lib.rs +++ b/library/test/src/lib.rs @@ -789,7 +789,7 @@ fn run_test_in_spawned_subprocess( } }); let record_result2 = record_result.clone(); - panic::set_hook(Box::new(move |info| record_result2(Some(&info)))); + panic::set_hook(Box::new(move |info| record_result2(Some(info)))); if let Err(message) = testfn() { panic!("{}", message); } diff --git a/library/test/src/term/terminfo/mod.rs b/library/test/src/term/terminfo/mod.rs index 355859019714b..67ba89410cd99 100644 --- a/library/test/src/term/terminfo/mod.rs +++ b/library/test/src/term/terminfo/mod.rs @@ -149,7 +149,7 @@ impl Terminal for TerminfoTerminal { // are there any terminals that have color/attrs and not sgr0? // Try falling back to sgr, then op let cmd = match ["sgr0", "sgr", "op"].iter().find_map(|cap| self.ti.strings.get(*cap)) { - Some(op) => match expand(&op, &[], &mut Variables::new()) { + Some(op) => match expand(op, &[], &mut Variables::new()) { Ok(cmd) => cmd, Err(e) => return Err(io::Error::new(io::ErrorKind::InvalidData, e)), }, @@ -180,12 +180,12 @@ impl TerminfoTerminal { } fn dim_if_necessary(&self, color: color::Color) -> color::Color { - if color >= self.num_colors && color >= 8 && color < 16 { color - 8 } else { color } + if color >= self.num_colors && (8..16).contains(&color) { color - 8 } else { color } } fn apply_cap(&mut self, cmd: &str, params: &[Param]) -> io::Result { match self.ti.strings.get(cmd) { - Some(cmd) => match expand(&cmd, params, &mut Variables::new()) { + Some(cmd) => match expand(cmd, params, &mut Variables::new()) { Ok(s) => self.out.write_all(&s).and(Ok(true)), Err(e) => Err(io::Error::new(io::ErrorKind::InvalidData, e)), }, diff --git a/library/test/src/term/terminfo/parm.rs b/library/test/src/term/terminfo/parm.rs index 0756c8374aa67..2815f6cfc77fe 100644 --- a/library/test/src/term/terminfo/parm.rs +++ b/library/test/src/term/terminfo/parm.rs @@ -282,14 +282,14 @@ pub(crate) fn expand( ); } SetVar => { - if cur >= 'A' && cur <= 'Z' { + if cur.is_ascii_uppercase() { if let Some(arg) = stack.pop() { let idx = (cur as u8) - b'A'; vars.sta_va[idx as usize] = arg; } else { return Err("stack is empty".to_string()); } - } else if cur >= 'a' && cur <= 'z' { + } else if cur.is_ascii_lowercase() { if let Some(arg) = stack.pop() { let idx = (cur as u8) - b'a'; vars.dyn_va[idx as usize] = arg; @@ -301,10 +301,10 @@ pub(crate) fn expand( } } GetVar => { - if cur >= 'A' && cur <= 'Z' { + if cur.is_ascii_uppercase() { let idx = (cur as u8) - b'A'; stack.push(vars.sta_va[idx as usize].clone()); - } else if cur >= 'a' && cur <= 'z' { + } else if cur.is_ascii_lowercase() { let idx = (cur as u8) - b'a'; stack.push(vars.dyn_va[idx as usize].clone()); } else { diff --git a/library/test/src/term/terminfo/searcher.rs b/library/test/src/term/terminfo/searcher.rs index 68e181a689579..87b91f34498a3 100644 --- a/library/test/src/term/terminfo/searcher.rs +++ b/library/test/src/term/terminfo/searcher.rs @@ -22,7 +22,7 @@ pub(crate) fn get_dbpath_for_term(term: &str) -> Option { if let Ok(dirs) = env::var("TERMINFO_DIRS") { for i in dirs.split(':') { - if i == "" { + if i.is_empty() { dirs_to_search.push(PathBuf::from("/usr/share/terminfo")); } else { dirs_to_search.push(PathBuf::from(i)); @@ -49,7 +49,7 @@ pub(crate) fn get_dbpath_for_term(term: &str) -> Option { for mut p in dirs_to_search { if fs::metadata(&p).is_ok() { p.push(&first_char.to_string()); - p.push(&term); + p.push(term); if fs::metadata(&p).is_ok() { return Some(p); } diff --git a/library/test/src/test_result.rs b/library/test/src/test_result.rs index 7c5b0d6c0f721..1da238e3e8c0f 100644 --- a/library/test/src/test_result.rs +++ b/library/test/src/test_result.rs @@ -33,7 +33,7 @@ pub fn calc_result<'a>( ) -> TestResult { let result = match (&desc.should_panic, task_result) { (&ShouldPanic::No, Ok(())) | (&ShouldPanic::Yes, Err(_)) => TestResult::TrOk, - (&ShouldPanic::YesWithMessage(msg), Err(ref err)) => { + (&ShouldPanic::YesWithMessage(msg), Err(err)) => { let maybe_panic_str = err .downcast_ref::() .map(|e| &**e) @@ -52,7 +52,7 @@ pub fn calc_result<'a>( r#"expected panic with string value, found non-string value: `{:?}` expected substring: `{:?}`"#, - (**err).type_id(), + (*err).type_id(), msg )) } diff --git a/library/test/src/types.rs b/library/test/src/types.rs index 888afff7921d9..6f2e033095a37 100644 --- a/library/test/src/types.rs +++ b/library/test/src/types.rs @@ -47,7 +47,7 @@ impl TestName { match *self { StaticTestName(s) => s, DynTestName(ref s) => s, - AlignedTestName(ref s, _) => &*s, + AlignedTestName(ref s, _) => s, } } From 49111eced698e7df62756af364f799609cae3aa7 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 3 Jan 2023 19:46:40 -0700 Subject: [PATCH 05/11] rustdoc: fix buggy JS check for absolute URL The old code did the wrong thing when faced with a crate named "http". --- src/librustdoc/html/static/js/main.js | 2 +- src/test/rustdoc-gui/implementors.goml | 6 ++++++ src/test/rustdoc-gui/search-filter.goml | 2 ++ src/test/rustdoc-gui/sidebar-source-code.goml | 2 +- src/test/rustdoc-gui/source-code-page.goml | 2 +- src/test/rustdoc-gui/src/lib2/Cargo.lock | 8 ++++++++ src/test/rustdoc-gui/src/lib2/Cargo.toml | 1 + src/test/rustdoc-gui/src/lib2/http/Cargo.toml | 7 +++++++ src/test/rustdoc-gui/src/lib2/http/lib.rs | 1 + src/test/rustdoc-gui/src/lib2/implementors/Cargo.toml | 3 +++ src/test/rustdoc-gui/src/lib2/implementors/lib.rs | 2 ++ 11 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 src/test/rustdoc-gui/src/lib2/http/Cargo.toml create mode 100644 src/test/rustdoc-gui/src/lib2/http/lib.rs diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 60e4e7492240c..d47b095317980 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -563,7 +563,7 @@ function loadCss(cssUrl) { onEachLazy(code.getElementsByTagName("a"), elem => { const href = elem.getAttribute("href"); - if (href && href.indexOf("http") !== 0) { + if (href && !/^(?:[a-z+]+:)?\/\//.test(href)) { elem.setAttribute("href", window.rootPath + href); } }); diff --git a/src/test/rustdoc-gui/implementors.goml b/src/test/rustdoc-gui/implementors.goml index 4999283dc8b91..997c0ed8f017c 100644 --- a/src/test/rustdoc-gui/implementors.goml +++ b/src/test/rustdoc-gui/implementors.goml @@ -33,3 +33,9 @@ goto: "file://" + |DOC_PATH| + "/lib2/trait.TraitToReexport.html" assert-count: ("#implementors-list .impl", 1) goto: "file://" + |DOC_PATH| + "/implementors/trait.TraitToReexport.html" assert-count: ("#implementors-list .impl", 1) + +// Now check that the link is properly rewritten for a crate called `http`. +// An older version of rustdoc had a buggy check for absolute links. +goto: "file://" + |DOC_PATH| + "/http/trait.HttpTrait.html" +assert-count: ("#implementors-list .impl", 1) +assert-attribute: ("#implementors-list .impl a.trait", {"href": "../http/trait.HttpTrait.html"}) diff --git a/src/test/rustdoc-gui/search-filter.goml b/src/test/rustdoc-gui/search-filter.goml index e556da0c54eba..5bc6e87d6d24d 100644 --- a/src/test/rustdoc-gui/search-filter.goml +++ b/src/test/rustdoc-gui/search-filter.goml @@ -15,6 +15,7 @@ click: "#crate-search" press-key: "ArrowDown" press-key: "ArrowDown" press-key: "ArrowDown" +press-key: "ArrowDown" press-key: "Enter" // Waiting for the search results to appear... wait-for: "#search-tabs" @@ -39,6 +40,7 @@ click: "#crate-search" press-key: "ArrowUp" press-key: "ArrowUp" press-key: "ArrowUp" +press-key: "ArrowUp" press-key: "Enter" // Waiting for the search results to appear... wait-for: "#search-tabs" diff --git a/src/test/rustdoc-gui/sidebar-source-code.goml b/src/test/rustdoc-gui/sidebar-source-code.goml index d5f57ed6102c7..6bc07fbae04da 100644 --- a/src/test/rustdoc-gui/sidebar-source-code.goml +++ b/src/test/rustdoc-gui/sidebar-source-code.goml @@ -73,7 +73,7 @@ assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']" // Only "another_folder" should be "open" in "lib2". assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']" // All other trees should be collapsed. -assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 7) +assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 8) // We now switch to mobile mode. size: (600, 600) diff --git a/src/test/rustdoc-gui/source-code-page.goml b/src/test/rustdoc-gui/source-code-page.goml index aa79219696020..e0397890519bb 100644 --- a/src/test/rustdoc-gui/source-code-page.goml +++ b/src/test/rustdoc-gui/source-code-page.goml @@ -102,7 +102,7 @@ assert: ".source-sidebar-expanded" // We check that the first entry of the sidebar is collapsed assert-property: ("#source-sidebar details:first-of-type", {"open": "false"}) -assert-text: ("#source-sidebar details:first-of-type > summary", "huge_logo") +assert-text: ("#source-sidebar details:first-of-type > summary", "http") // We now click on it. click: "#source-sidebar details:first-of-type > summary" assert-property: ("#source-sidebar details:first-of-type", {"open": "true"}) diff --git a/src/test/rustdoc-gui/src/lib2/Cargo.lock b/src/test/rustdoc-gui/src/lib2/Cargo.lock index a5873ceb3256a..425a3ae7e5c92 100644 --- a/src/test/rustdoc-gui/src/lib2/Cargo.lock +++ b/src/test/rustdoc-gui/src/lib2/Cargo.lock @@ -2,13 +2,21 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "http" +version = "0.1.0" + [[package]] name = "implementors" version = "0.1.0" +dependencies = [ + "http", +] [[package]] name = "lib2" version = "0.1.0" dependencies = [ + "http", "implementors", ] diff --git a/src/test/rustdoc-gui/src/lib2/Cargo.toml b/src/test/rustdoc-gui/src/lib2/Cargo.toml index 2e37f3f667a02..8bca77ff834d8 100644 --- a/src/test/rustdoc-gui/src/lib2/Cargo.toml +++ b/src/test/rustdoc-gui/src/lib2/Cargo.toml @@ -8,3 +8,4 @@ path = "lib.rs" [dependencies] implementors = { path = "./implementors" } +http = { path = "./http" } diff --git a/src/test/rustdoc-gui/src/lib2/http/Cargo.toml b/src/test/rustdoc-gui/src/lib2/http/Cargo.toml new file mode 100644 index 0000000000000..fa719efa52635 --- /dev/null +++ b/src/test/rustdoc-gui/src/lib2/http/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "http" +version = "0.1.0" +edition = "2018" + +[lib] +path = "lib.rs" diff --git a/src/test/rustdoc-gui/src/lib2/http/lib.rs b/src/test/rustdoc-gui/src/lib2/http/lib.rs new file mode 100644 index 0000000000000..204e07494275b --- /dev/null +++ b/src/test/rustdoc-gui/src/lib2/http/lib.rs @@ -0,0 +1 @@ +pub trait HttpTrait {} diff --git a/src/test/rustdoc-gui/src/lib2/implementors/Cargo.toml b/src/test/rustdoc-gui/src/lib2/implementors/Cargo.toml index 7ef1052c49fd2..9dafc43df5f80 100644 --- a/src/test/rustdoc-gui/src/lib2/implementors/Cargo.toml +++ b/src/test/rustdoc-gui/src/lib2/implementors/Cargo.toml @@ -5,3 +5,6 @@ edition = "2018" [lib] path = "lib.rs" + +[dependencies] +http = { path = "../http/" } diff --git a/src/test/rustdoc-gui/src/lib2/implementors/lib.rs b/src/test/rustdoc-gui/src/lib2/implementors/lib.rs index 1620e84229191..2842ac50dc1e8 100644 --- a/src/test/rustdoc-gui/src/lib2/implementors/lib.rs +++ b/src/test/rustdoc-gui/src/lib2/implementors/lib.rs @@ -10,6 +10,8 @@ impl Whatever for Struct { type Foo = u8; } +impl http::HttpTrait for Struct {} + mod traits { pub trait TraitToReexport { fn method() {} From 2399df288ef5af538a331a974b037b889be5cfd2 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Tue, 3 Jan 2023 20:38:07 -0800 Subject: [PATCH 06/11] Add test case to click popover child link --- src/test/rustdoc-gui/help-page.goml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/rustdoc-gui/help-page.goml b/src/test/rustdoc-gui/help-page.goml index 80203901ed3c4..050cf325bb82c 100644 --- a/src/test/rustdoc-gui/help-page.goml +++ b/src/test/rustdoc-gui/help-page.goml @@ -61,3 +61,11 @@ click: "#help-button > a" assert-css: ("#help", {"display": "none"}) compare-elements-property-false: (".sub", "#help", ["offsetWidth"]) compare-elements-position-false: (".sub", "#help", ("x")) + +// This test ensures that the "the rustdoc book" anchor link within the help popover works. +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +size: (1000, 1000) // Popover only appears when the screen width is >700px. +assert-false: "#help" +click: "#help-button > a" +click: ".popover a[href='https://doc.rust-lang.org/rustdoc/']" +assert-document-property: {"URL": "https://doc.rust-lang.org/rustdoc/"} From 9792c9affb55e44bd93957c166a971007c66b5a2 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Tue, 3 Jan 2023 23:44:35 -0800 Subject: [PATCH 07/11] Add hardcoded wait time for external navigation to load --- src/test/rustdoc-gui/help-page.goml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/rustdoc-gui/help-page.goml b/src/test/rustdoc-gui/help-page.goml index 050cf325bb82c..83f2556fd8f26 100644 --- a/src/test/rustdoc-gui/help-page.goml +++ b/src/test/rustdoc-gui/help-page.goml @@ -68,4 +68,5 @@ size: (1000, 1000) // Popover only appears when the screen width is >700px. assert-false: "#help" click: "#help-button > a" click: ".popover a[href='https://doc.rust-lang.org/rustdoc/']" +wait-for: 2000 assert-document-property: {"URL": "https://doc.rust-lang.org/rustdoc/"} From ac4426c093b5e7a457e0e32cc6ea2d3fb99c3148 Mon Sep 17 00:00:00 2001 From: Giacomo Pasini Date: Sat, 31 Dec 2022 13:45:22 +0100 Subject: [PATCH 08/11] Merge borrowck permission checks Merge `check_access_permission` and `check_if_reassignment_to_immutable_state`. The goal of this commit is twofold: First, we simplify the codebase by removing duplicate logic. Second, we avoid duplicate reporting of illegal reassignment errors by reusing the exiting de-duplicating logic of access_place. --- compiler/rustc_borrowck/src/lib.rs | 48 +++++++----------------------- 1 file changed, 11 insertions(+), 37 deletions(-) diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index ae1bea008b6ce..278ffed07477b 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -863,7 +863,6 @@ enum WriteKind { /// local place can be mutated. // // FIXME: @nikomatsakis suggested that this flag could be removed with the following modifications: -// - Merge `check_access_permissions()` and `check_if_reassignment_to_immutable_state()`. // - Split `is_mutable()` into `is_assignable()` (can be directly assigned) and // `is_declared_mutable()`. // - Take flow state into consideration in `is_assignable()` for local variables. @@ -1132,20 +1131,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // Write of P[i] or *P requires P init'd. self.check_if_assigned_path_is_moved(location, place_span, flow_state); - // Special case: you can assign an immutable local variable - // (e.g., `x = ...`) so long as it has never been initialized - // before (at this point in the flow). - if let Some(local) = place_span.0.as_local() { - if let Mutability::Not = self.body.local_decls[local].mutability { - // check for reassignments to immutable local variables - self.check_if_reassignment_to_immutable_state( - location, local, place_span, flow_state, - ); - return; - } - } - - // Otherwise, use the normal access permission rules. self.access_place( location, place_span, @@ -1554,24 +1539,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } } - fn check_if_reassignment_to_immutable_state( - &mut self, - location: Location, - local: Local, - place_span: (Place<'tcx>, Span), - flow_state: &Flows<'cx, 'tcx>, - ) { - debug!("check_if_reassignment_to_immutable_state({:?})", local); - - // Check if any of the initializations of `local` have happened yet: - if let Some(init_index) = self.is_local_ever_initialized(local, flow_state) { - // And, if so, report an error. - let init = &self.move_data.inits[init_index]; - let span = init.span(&self.body); - self.report_illegal_reassignment(location, place_span, span, place_span.0); - } - } - fn check_if_full_path_is_moved( &mut self, location: Location, @@ -2037,12 +2004,19 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // partial initialization, do not complain about mutability // errors except for actual mutation (as opposed to an attempt // to do a partial initialization). - let previously_initialized = - self.is_local_ever_initialized(place.local, flow_state).is_some(); + let previously_initialized = self.is_local_ever_initialized(place.local, flow_state); // at this point, we have set up the error reporting state. - if previously_initialized { - self.report_mutability_error(place, span, the_place_err, error_access, location); + if let Some(init_index) = previously_initialized { + if let (AccessKind::Mutate, Some(_)) = (error_access, place.as_local()) { + // If this is a mutate access to an immutable local variable with no projections + // report the error as an illegal reassignment + let init = &self.move_data.inits[init_index]; + let assigned_span = init.span(&self.body); + self.report_illegal_reassignment(location, (place, span), assigned_span, place); + } else { + self.report_mutability_error(place, span, the_place_err, error_access, location) + } true } else { false From 7ffcedf6659d30c4a076d89b2586b385ad2f2d16 Mon Sep 17 00:00:00 2001 From: Caio Date: Wed, 4 Jan 2023 16:44:30 -0300 Subject: [PATCH 09/11] Move tests --- src/test/ui/{issues => associated-consts}/issue-105330.rs | 0 src/test/ui/{issues => associated-consts}/issue-105330.stderr | 0 src/test/ui/{issues => associated-types}/issue-25700-1.rs | 0 src/test/ui/{issues => associated-types}/issue-25700-2.rs | 0 src/test/ui/{issues => associated-types}/issue-25700.rs | 0 src/test/ui/{issues => associated-types}/issue-25700.stderr | 0 src/test/ui/{issues => codegen}/issue-82859-slice-miscompile.rs | 0 src/test/ui/{issues => command}/issue-10626.rs | 0 src/test/ui/{issues => drop}/issue-2734.rs | 0 src/test/ui/{issues => dropck}/issue-34053.rs | 0 src/test/ui/{issues => enum-discriminant}/issue-72554.rs | 0 src/test/ui/{issues => enum-discriminant}/issue-72554.stderr | 0 src/test/ui/{issues => extern}/issue-13655.rs | 0 src/test/ui/{issues => macros}/issue-10536.rs | 0 src/test/ui/{issues => macros}/issue-10536.stderr | 0 src/test/ui/{issues => nll}/issue-54189.rs | 0 src/test/ui/{issues => nll}/issue-54189.stderr | 0 src/test/ui/{issues => traits}/issue-99875.rs | 0 src/test/ui/{issues => traits}/issue-99875.stderr | 0 src/test/ui/{issues => typeck}/issue-18937-1.rs | 0 src/test/ui/{issues => typeck}/issue-18937.rs | 0 src/test/ui/{issues => typeck}/issue-18937.stderr | 0 src/test/ui/{issues => typeck}/issue-31173.rs | 0 src/test/ui/{issues => typeck}/issue-31173.stderr | 0 src/tools/tidy/src/ui_tests.rs | 2 +- 25 files changed, 1 insertion(+), 1 deletion(-) rename src/test/ui/{issues => associated-consts}/issue-105330.rs (100%) rename src/test/ui/{issues => associated-consts}/issue-105330.stderr (100%) rename src/test/ui/{issues => associated-types}/issue-25700-1.rs (100%) rename src/test/ui/{issues => associated-types}/issue-25700-2.rs (100%) rename src/test/ui/{issues => associated-types}/issue-25700.rs (100%) rename src/test/ui/{issues => associated-types}/issue-25700.stderr (100%) rename src/test/ui/{issues => codegen}/issue-82859-slice-miscompile.rs (100%) rename src/test/ui/{issues => command}/issue-10626.rs (100%) rename src/test/ui/{issues => drop}/issue-2734.rs (100%) rename src/test/ui/{issues => dropck}/issue-34053.rs (100%) rename src/test/ui/{issues => enum-discriminant}/issue-72554.rs (100%) rename src/test/ui/{issues => enum-discriminant}/issue-72554.stderr (100%) rename src/test/ui/{issues => extern}/issue-13655.rs (100%) rename src/test/ui/{issues => macros}/issue-10536.rs (100%) rename src/test/ui/{issues => macros}/issue-10536.stderr (100%) rename src/test/ui/{issues => nll}/issue-54189.rs (100%) rename src/test/ui/{issues => nll}/issue-54189.stderr (100%) rename src/test/ui/{issues => traits}/issue-99875.rs (100%) rename src/test/ui/{issues => traits}/issue-99875.stderr (100%) rename src/test/ui/{issues => typeck}/issue-18937-1.rs (100%) rename src/test/ui/{issues => typeck}/issue-18937.rs (100%) rename src/test/ui/{issues => typeck}/issue-18937.stderr (100%) rename src/test/ui/{issues => typeck}/issue-31173.rs (100%) rename src/test/ui/{issues => typeck}/issue-31173.stderr (100%) diff --git a/src/test/ui/issues/issue-105330.rs b/src/test/ui/associated-consts/issue-105330.rs similarity index 100% rename from src/test/ui/issues/issue-105330.rs rename to src/test/ui/associated-consts/issue-105330.rs diff --git a/src/test/ui/issues/issue-105330.stderr b/src/test/ui/associated-consts/issue-105330.stderr similarity index 100% rename from src/test/ui/issues/issue-105330.stderr rename to src/test/ui/associated-consts/issue-105330.stderr diff --git a/src/test/ui/issues/issue-25700-1.rs b/src/test/ui/associated-types/issue-25700-1.rs similarity index 100% rename from src/test/ui/issues/issue-25700-1.rs rename to src/test/ui/associated-types/issue-25700-1.rs diff --git a/src/test/ui/issues/issue-25700-2.rs b/src/test/ui/associated-types/issue-25700-2.rs similarity index 100% rename from src/test/ui/issues/issue-25700-2.rs rename to src/test/ui/associated-types/issue-25700-2.rs diff --git a/src/test/ui/issues/issue-25700.rs b/src/test/ui/associated-types/issue-25700.rs similarity index 100% rename from src/test/ui/issues/issue-25700.rs rename to src/test/ui/associated-types/issue-25700.rs diff --git a/src/test/ui/issues/issue-25700.stderr b/src/test/ui/associated-types/issue-25700.stderr similarity index 100% rename from src/test/ui/issues/issue-25700.stderr rename to src/test/ui/associated-types/issue-25700.stderr diff --git a/src/test/ui/issues/issue-82859-slice-miscompile.rs b/src/test/ui/codegen/issue-82859-slice-miscompile.rs similarity index 100% rename from src/test/ui/issues/issue-82859-slice-miscompile.rs rename to src/test/ui/codegen/issue-82859-slice-miscompile.rs diff --git a/src/test/ui/issues/issue-10626.rs b/src/test/ui/command/issue-10626.rs similarity index 100% rename from src/test/ui/issues/issue-10626.rs rename to src/test/ui/command/issue-10626.rs diff --git a/src/test/ui/issues/issue-2734.rs b/src/test/ui/drop/issue-2734.rs similarity index 100% rename from src/test/ui/issues/issue-2734.rs rename to src/test/ui/drop/issue-2734.rs diff --git a/src/test/ui/issues/issue-34053.rs b/src/test/ui/dropck/issue-34053.rs similarity index 100% rename from src/test/ui/issues/issue-34053.rs rename to src/test/ui/dropck/issue-34053.rs diff --git a/src/test/ui/issues/issue-72554.rs b/src/test/ui/enum-discriminant/issue-72554.rs similarity index 100% rename from src/test/ui/issues/issue-72554.rs rename to src/test/ui/enum-discriminant/issue-72554.rs diff --git a/src/test/ui/issues/issue-72554.stderr b/src/test/ui/enum-discriminant/issue-72554.stderr similarity index 100% rename from src/test/ui/issues/issue-72554.stderr rename to src/test/ui/enum-discriminant/issue-72554.stderr diff --git a/src/test/ui/issues/issue-13655.rs b/src/test/ui/extern/issue-13655.rs similarity index 100% rename from src/test/ui/issues/issue-13655.rs rename to src/test/ui/extern/issue-13655.rs diff --git a/src/test/ui/issues/issue-10536.rs b/src/test/ui/macros/issue-10536.rs similarity index 100% rename from src/test/ui/issues/issue-10536.rs rename to src/test/ui/macros/issue-10536.rs diff --git a/src/test/ui/issues/issue-10536.stderr b/src/test/ui/macros/issue-10536.stderr similarity index 100% rename from src/test/ui/issues/issue-10536.stderr rename to src/test/ui/macros/issue-10536.stderr diff --git a/src/test/ui/issues/issue-54189.rs b/src/test/ui/nll/issue-54189.rs similarity index 100% rename from src/test/ui/issues/issue-54189.rs rename to src/test/ui/nll/issue-54189.rs diff --git a/src/test/ui/issues/issue-54189.stderr b/src/test/ui/nll/issue-54189.stderr similarity index 100% rename from src/test/ui/issues/issue-54189.stderr rename to src/test/ui/nll/issue-54189.stderr diff --git a/src/test/ui/issues/issue-99875.rs b/src/test/ui/traits/issue-99875.rs similarity index 100% rename from src/test/ui/issues/issue-99875.rs rename to src/test/ui/traits/issue-99875.rs diff --git a/src/test/ui/issues/issue-99875.stderr b/src/test/ui/traits/issue-99875.stderr similarity index 100% rename from src/test/ui/issues/issue-99875.stderr rename to src/test/ui/traits/issue-99875.stderr diff --git a/src/test/ui/issues/issue-18937-1.rs b/src/test/ui/typeck/issue-18937-1.rs similarity index 100% rename from src/test/ui/issues/issue-18937-1.rs rename to src/test/ui/typeck/issue-18937-1.rs diff --git a/src/test/ui/issues/issue-18937.rs b/src/test/ui/typeck/issue-18937.rs similarity index 100% rename from src/test/ui/issues/issue-18937.rs rename to src/test/ui/typeck/issue-18937.rs diff --git a/src/test/ui/issues/issue-18937.stderr b/src/test/ui/typeck/issue-18937.stderr similarity index 100% rename from src/test/ui/issues/issue-18937.stderr rename to src/test/ui/typeck/issue-18937.stderr diff --git a/src/test/ui/issues/issue-31173.rs b/src/test/ui/typeck/issue-31173.rs similarity index 100% rename from src/test/ui/issues/issue-31173.rs rename to src/test/ui/typeck/issue-31173.rs diff --git a/src/test/ui/issues/issue-31173.stderr b/src/test/ui/typeck/issue-31173.stderr similarity index 100% rename from src/test/ui/issues/issue-31173.stderr rename to src/test/ui/typeck/issue-31173.stderr diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 070e72437be80..166d09fa8b068 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -10,7 +10,7 @@ use std::path::Path; const ENTRY_LIMIT: usize = 1000; // FIXME: The following limits should be reduced eventually. const ROOT_ENTRY_LIMIT: usize = 939; -const ISSUES_ENTRY_LIMIT: usize = 2050; +const ISSUES_ENTRY_LIMIT: usize = 1998; fn check_entries(path: &Path, bad: &mut bool) { for dir in Walk::new(&path.join("test/ui")) { From 854082c2189a2b71b661dbe5ac6917c5190bac57 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Wed, 4 Jan 2023 12:47:24 -0700 Subject: [PATCH 10/11] docs: fix broken link "search bar" --- library/std/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 13dfd41abbf84..6575cc71b0514 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -14,7 +14,7 @@ //! # How to read this documentation //! //! If you already know the name of what you are looking for, the fastest way to -//! find it is to use the search +//! find it is to use the search //! bar at the top of the page. //! //! Otherwise, you may want to jump to one of these useful sections: From c9ebd73416f59f4498f789aa408d8f43b64aa4f3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 4 Jan 2023 21:54:32 +0100 Subject: [PATCH 11/11] Remove unused match pattern for primitive types --- src/librustdoc/json/conversions.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 4a81a9d2d61a5..9a761d4dca8f5 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -252,7 +252,7 @@ pub(crate) fn from_item_id_with_name(item_id: ItemId, tcx: TyCtxt<'_>, name: Opt ItemId::Auto { for_, trait_ } => { Id(format!("a:{}-{}", DisplayDefId(trait_, tcx, None), DisplayDefId(for_, tcx, name))) } - ItemId::Primitive(ty, krate) => Id(format!("p:{}:{}", krate.as_u32(), ty.as_sym())), + ItemId::Primitive(_, _) => unreachable!(), } }