From c5233b7d4bf3c35e5c5809f4b7adbf6220e263ce Mon Sep 17 00:00:00 2001 From: Frank Steffahn Date: Tue, 1 Jun 2021 13:16:52 +0200 Subject: [PATCH 01/11] Fix typo in internal documentation for `TrustedRandomAccess` `next_back` is a method of DoubleEndedIterator, not Iterator. --- library/core/src/iter/adapters/zip.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/iter/adapters/zip.rs b/library/core/src/iter/adapters/zip.rs index 2f8f504d8fcaa..c95324c80ba61 100644 --- a/library/core/src/iter/adapters/zip.rs +++ b/library/core/src/iter/adapters/zip.rs @@ -434,7 +434,7 @@ impl ZipFmt Date: Tue, 1 Jun 2021 18:25:36 +0300 Subject: [PATCH 02/11] updated shlex for jsondocck --- Cargo.lock | 10 ++-------- src/tools/jsondocck/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df7d844194148..6e674d7257f9d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1747,7 +1747,7 @@ dependencies = [ "regex", "serde", "serde_json", - "shlex 0.1.1", + "shlex", ] [[package]] @@ -2128,7 +2128,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "shlex 1.0.0", + "shlex", "tempfile", "toml", ] @@ -4794,12 +4794,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f" -[[package]] -name = "shlex" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" - [[package]] name = "shlex" version = "1.0.0" diff --git a/src/tools/jsondocck/Cargo.toml b/src/tools/jsondocck/Cargo.toml index a6efc4c9a6b5b..eb1c422ef7293 100644 --- a/src/tools/jsondocck/Cargo.toml +++ b/src/tools/jsondocck/Cargo.toml @@ -9,7 +9,7 @@ jsonpath_lib = "0.2" getopts = "0.2" regex = "1.4" lazy_static = "1.4" -shlex = "0.1" +shlex = "1.0" serde = "1.0" serde_json = "1.0" fs-err = "2.5.0" From 5afc594e6294cee451ded335397cade6a9098bd1 Mon Sep 17 00:00:00 2001 From: klensy Date: Tue, 1 Jun 2021 19:44:10 +0300 Subject: [PATCH 03/11] replace lazy_static with once_cell, drop direct dependency on serde --- Cargo.lock | 3 +-- src/tools/jsondocck/Cargo.toml | 3 +-- src/tools/jsondocck/src/main.rs | 12 ++++++------ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6e674d7257f9d..7badb93bce553 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1743,9 +1743,8 @@ dependencies = [ "fs-err", "getopts", "jsonpath_lib", - "lazy_static", + "once_cell", "regex", - "serde", "serde_json", "shlex", ] diff --git a/src/tools/jsondocck/Cargo.toml b/src/tools/jsondocck/Cargo.toml index eb1c422ef7293..b5f1554dbe4df 100644 --- a/src/tools/jsondocck/Cargo.toml +++ b/src/tools/jsondocck/Cargo.toml @@ -8,8 +8,7 @@ edition = "2018" jsonpath_lib = "0.2" getopts = "0.2" regex = "1.4" -lazy_static = "1.4" shlex = "1.0" -serde = "1.0" serde_json = "1.0" fs-err = "2.5.0" +once_cell = "1.0" diff --git a/src/tools/jsondocck/src/main.rs b/src/tools/jsondocck/src/main.rs index 216890d59ad6c..b8ea10f3d2277 100644 --- a/src/tools/jsondocck/src/main.rs +++ b/src/tools/jsondocck/src/main.rs @@ -1,5 +1,5 @@ use jsonpath_lib::select; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use regex::{Regex, RegexBuilder}; use serde_json::Value; use std::borrow::Cow; @@ -94,19 +94,19 @@ impl fmt::Display for CommandKind { } } -lazy_static! { - static ref LINE_PATTERN: Regex = RegexBuilder::new( +static LINE_PATTERN: Lazy = Lazy::new(|| { + RegexBuilder::new( r#" \s(?P!?)@(?P!?) (?P[A-Za-z]+(?:-[A-Za-z]+)*) (?P.*)$ - "# + "#, ) .ignore_whitespace(true) .unicode(true) .build() - .unwrap(); -} + .unwrap() +}); fn print_err(msg: &str, lineno: usize) { eprintln!("Invalid command: {} on line {}", msg, lineno) From 80828f26bb54cbd4508496927be58a5b4b591686 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 2 Jun 2021 18:10:15 +0200 Subject: [PATCH 04/11] Improve check_ref suggestions in macros. --- compiler/rustc_typeck/src/check/demand.rs | 38 +++++++++++------------ 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_typeck/src/check/demand.rs b/compiler/rustc_typeck/src/check/demand.rs index e5fcdcfa74315..9cc435a0dec2e 100644 --- a/compiler/rustc_typeck/src/check/demand.rs +++ b/compiler/rustc_typeck/src/check/demand.rs @@ -8,6 +8,7 @@ use rustc_errors::{Applicability, DiagnosticBuilder}; use rustc_hir as hir; use rustc_hir::lang_items::LangItem; use rustc_hir::{is_range_literal, Node}; +use rustc_middle::lint::in_external_macro; use rustc_middle::ty::adjustment::AllowTwoPhase; use rustc_middle::ty::{self, AssocItem, Ty, TypeAndMut}; use rustc_span::symbol::sym; @@ -412,14 +413,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { checked_ty: Ty<'tcx>, expected: Ty<'tcx>, ) -> Option<(Span, &'static str, String, Applicability)> { - let sm = self.sess().source_map(); + let sess = self.sess(); let sp = expr.span; - if sm.is_imported(sp) { - // Ignore if span is from within a macro #41858, #58298. We previously used the macro - // call span, but that breaks down when the type error comes from multiple calls down. + + // If the span is from an external macro, there's no suggestion we can make. + if in_external_macro(sess, sp) { return None; } + let sm = sess.source_map(); + let replace_prefix = |s: &str, old: &str, new: &str| { s.strip_prefix(old).map(|stripped| new.to_string() + stripped) }; @@ -427,10 +430,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let is_struct_pat_shorthand_field = self.is_hir_id_from_struct_pattern_shorthand_field(expr.hir_id, sp); - // If the span is from a macro, then it's hard to extract the text - // and make a good suggestion, so don't bother. - let is_macro = sp.from_expansion() && sp.desugaring_kind().is_none(); - // `ExprKind::DropTemps` is semantically irrelevant for these suggestions. let expr = expr.peel_drop_temps(); @@ -570,10 +569,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { hir::ExprKind::AddrOf(hir::BorrowKind::Ref, _, ref expr), _, &ty::Ref(_, checked, _), - ) if { - self.infcx.can_sub(self.param_env, checked, &expected).is_ok() && !is_macro - } => - { + ) if self.infcx.can_sub(self.param_env, checked, &expected).is_ok() => { // We have `&T`, check if what was expected was `T`. If so, // we may want to suggest removing a `&`. if sm.is_imported(expr.span) { @@ -589,13 +585,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } return None; } - if let Ok(code) = sm.span_to_snippet(expr.span) { - return Some(( - sp, - "consider removing the borrow", - code, - Applicability::MachineApplicable, - )); + if sp.contains(expr.span) { + if let Ok(code) = sm.span_to_snippet(expr.span) { + return Some(( + sp, + "consider removing the borrow", + code, + Applicability::MachineApplicable, + )); + } } } ( @@ -643,7 +641,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } } - _ if sp == expr.span && !is_macro => { + _ if sp == expr.span => { if let Some(steps) = self.deref_steps(checked_ty, expected) { let expr = expr.peel_blocks(); From e735f6086d4f131ccc6f0205e850860faaea3411 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 2 Jun 2021 18:10:42 +0200 Subject: [PATCH 05/11] Add test for ref suggestions in macros. --- .../auxiliary/proc-macro-type-error.rs | 18 ++++++++++ src/test/ui/suggestions/suggest-ref-macro.rs | 29 ++++++++++++++++ .../ui/suggestions/suggest-ref-macro.stderr | 34 +++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 src/test/ui/suggestions/auxiliary/proc-macro-type-error.rs create mode 100644 src/test/ui/suggestions/suggest-ref-macro.rs create mode 100644 src/test/ui/suggestions/suggest-ref-macro.stderr diff --git a/src/test/ui/suggestions/auxiliary/proc-macro-type-error.rs b/src/test/ui/suggestions/auxiliary/proc-macro-type-error.rs new file mode 100644 index 0000000000000..d71747f9687ef --- /dev/null +++ b/src/test/ui/suggestions/auxiliary/proc-macro-type-error.rs @@ -0,0 +1,18 @@ +// force-host +// no-prefer-dynamic +#![crate_type = "proc-macro"] +#![feature(proc_macro_quote)] + +extern crate proc_macro; + +use proc_macro::{quote, TokenStream}; + +#[proc_macro_attribute] +pub fn hello(_: TokenStream, _: TokenStream) -> TokenStream { + quote!( + fn f(_: &mut i32) {} + fn g() { + f(123); + } + ) +} diff --git a/src/test/ui/suggestions/suggest-ref-macro.rs b/src/test/ui/suggestions/suggest-ref-macro.rs new file mode 100644 index 0000000000000..6f780f32a147b --- /dev/null +++ b/src/test/ui/suggestions/suggest-ref-macro.rs @@ -0,0 +1,29 @@ +// run-check +// aux-build:proc-macro-type-error.rs + +extern crate proc_macro_type_error; + +use proc_macro_type_error::hello; + +#[hello] //~ERROR mismatched types +fn abc() {} + +fn x(_: &mut i32) {} + +macro_rules! bla { + () => { + x(123); + //~^ ERROR mismatched types + //~| SUGGESTION &mut 123 + }; + ($v:expr) => { + x($v) + } +} + +fn main() { + bla!(); + bla!(456); + //~^ ERROR mismatched types + //~| SUGGESTION &mut 456 +} diff --git a/src/test/ui/suggestions/suggest-ref-macro.stderr b/src/test/ui/suggestions/suggest-ref-macro.stderr new file mode 100644 index 0000000000000..147001f0c948b --- /dev/null +++ b/src/test/ui/suggestions/suggest-ref-macro.stderr @@ -0,0 +1,34 @@ +error[E0308]: mismatched types + --> $DIR/suggest-ref-macro.rs:8:1 + | +LL | #[hello] + | ^^^^^^^^ expected `&mut i32`, found integer + | + = note: this error originates in the attribute macro `hello` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0308]: mismatched types + --> $DIR/suggest-ref-macro.rs:15:11 + | +LL | x(123); + | ^^^ + | | + | expected `&mut i32`, found integer + | help: consider mutably borrowing here: `&mut 123` +... +LL | bla!(); + | ------- in this macro invocation + | + = note: this error originates in the macro `bla` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0308]: mismatched types + --> $DIR/suggest-ref-macro.rs:26:10 + | +LL | bla!(456); + | ^^^ + | | + | expected `&mut i32`, found integer + | help: consider mutably borrowing here: `&mut 456` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. From d4ea9fa3fb400e1c5748489a65859fdead3dd132 Mon Sep 17 00:00:00 2001 From: Denis Merigoux Date: Tue, 1 Jun 2021 14:10:14 +0200 Subject: [PATCH 06/11] Restore the num_def_ids_untracked public function giving the total number of exported symbols for each crate Restored underlying num_def_ids_method Update compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs Changed name to fit with naming convention Co-authored-by: bjorn3 Update compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs Replace regular doc with Rustdoc comment Co-authored-by: Joshua Nelson Clarifies third-party use of num_def_ids_untracked --- compiler/rustc_metadata/src/rmeta/decoder.rs | 4 ++++ compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 706f3f6d8542b..59fec58f0a1b3 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1931,6 +1931,10 @@ impl CrateMetadata { self.root.hash } + fn num_def_ids(&self) -> usize { + self.root.tables.def_keys.size() + } + fn local_def_id(&self, index: DefIndex) -> DefId { DefId { krate: self.cnum, index } } diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index 02d1cf9aec79f..c1e12bb7a49cb 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -454,6 +454,13 @@ impl CStore { self.get_crate_data(def_id.krate).module_expansion(def_id.index, sess) } + /// Only public-facing way to traverse all the definitions in a non-local crate. + /// Critically useful for this third-party project: . + /// See for context. + pub fn num_def_ids_untracked(&self, cnum: CrateNum) -> usize { + self.get_crate_data(cnum).num_def_ids() + } + pub fn item_attrs(&self, def_id: DefId, sess: &Session) -> Vec { self.get_crate_data(def_id.krate).get_item_attrs(def_id.index, sess).collect() } From 32ee368c867d2aa977ebaca79b4b5ed8ed689fa3 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Thu, 3 Jun 2021 15:41:48 +0200 Subject: [PATCH 07/11] Show `::{{constructor}}` in std::any::type_name(). --- compiler/rustc_mir/src/interpret/intrinsics/type_name.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/compiler/rustc_mir/src/interpret/intrinsics/type_name.rs b/compiler/rustc_mir/src/interpret/intrinsics/type_name.rs index ae5e78ee33f47..2707d138e6a2c 100644 --- a/compiler/rustc_mir/src/interpret/intrinsics/type_name.rs +++ b/compiler/rustc_mir/src/interpret/intrinsics/type_name.rs @@ -1,5 +1,5 @@ use rustc_hir::def_id::CrateNum; -use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData}; +use rustc_hir::definitions::DisambiguatedDefPathData; use rustc_middle::mir::interpret::Allocation; use rustc_middle::ty::{ self, @@ -127,11 +127,6 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> { ) -> Result { self = print_prefix(self)?; - // Skip `::{{constructor}}` on tuple/unit structs. - if disambiguated_data.data == DefPathData::Ctor { - return Ok(self); - } - write!(self.path, "::{}", disambiguated_data.data).unwrap(); Ok(self) From e3b19e5c25d2de305939a5cc73dcbdf3ae64bd94 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Thu, 3 Jun 2021 15:48:33 +0200 Subject: [PATCH 08/11] Add test for issue 84666. --- library/core/tests/any.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/library/core/tests/any.rs b/library/core/tests/any.rs index b0dc99034644a..b36d6f0d40405 100644 --- a/library/core/tests/any.rs +++ b/library/core/tests/any.rs @@ -114,3 +114,16 @@ fn any_unsized() { fn is_any() {} is_any::<[i32]>(); } + +#[test] +fn distinct_type_names() { + // https://github.com/rust-lang/rust/issues/84666 + + struct Velocity(f32, f32); + + fn type_name_of_val(_: T) -> &'static str { + type_name::() + } + + assert_ne!(type_name_of_val(Velocity), type_name_of_val(Velocity(0.0, -9.8)),); +} From 7f1f90a5a5cd1f254cf9acfc03004f6093946268 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Tue, 30 Mar 2021 10:43:39 -0700 Subject: [PATCH 09/11] Add debug info tests for range, fix-sized array, and cell types --- src/test/debuginfo/fixed-sized-array.rs | 39 +++++++++++++++++++ src/test/debuginfo/mutable-locs.rs | 51 +++++++++++++++++++++++++ src/test/debuginfo/mutex.rs | 38 ++++++++++++++++++ src/test/debuginfo/pretty-std.rs | 12 ++++-- src/test/debuginfo/range-types.rs | 47 +++++++++++++++++++++++ src/test/debuginfo/rc_arc.rs | 27 ++++++++++++- src/test/debuginfo/result-types.rs | 26 +++++++++++++ src/test/debuginfo/rwlock-read.rs | 36 +++++++++++++++++ src/test/debuginfo/rwlock-write.rs | 27 +++++++++++++ src/test/debuginfo/thread.rs | 31 +++++++++++++++ 10 files changed, 329 insertions(+), 5 deletions(-) create mode 100644 src/test/debuginfo/fixed-sized-array.rs create mode 100644 src/test/debuginfo/mutable-locs.rs create mode 100644 src/test/debuginfo/mutex.rs create mode 100644 src/test/debuginfo/range-types.rs create mode 100644 src/test/debuginfo/result-types.rs create mode 100644 src/test/debuginfo/rwlock-read.rs create mode 100644 src/test/debuginfo/rwlock-write.rs create mode 100644 src/test/debuginfo/thread.rs diff --git a/src/test/debuginfo/fixed-sized-array.rs b/src/test/debuginfo/fixed-sized-array.rs new file mode 100644 index 0000000000000..d8899224d2844 --- /dev/null +++ b/src/test/debuginfo/fixed-sized-array.rs @@ -0,0 +1,39 @@ +// Testing the display of fixed sized arrays in cdb. + +// cdb-only +// min-cdb-version: 10.0.18317.1001 +// compile-flags:-g + +// === CDB TESTS ================================================================================== + +// cdb-command: g + +// cdb-command: dx xs,d +// cdb-check:xs,d [Type: int [5]] +// cdb-check: [0] : 1 [Type: int] +// cdb-check: [1] : 2 [Type: int] +// cdb-check: [2] : 3 [Type: int] +// cdb-check: [3] : 4 [Type: int] +// cdb-check: [4] : 5 [Type: int] + +// cdb-command: dx ys,d +// cdb-check:ys,d [Type: int [3]] +// cdb-check: [0] : 0 [Type: int] +// cdb-check: [1] : 0 [Type: int] +// cdb-check: [2] : 0 [Type: int] + +fn main() { + // Fixed-size array (type signature is superfluous) + let xs: [i32; 5] = [1, 2, 3, 4, 5]; + + // All elements can be initialized to the same value + let ys: [i32; 3] = [0; 3]; + + // Indexing starts at 0 + println!("first element of the array: {}", xs[0]); + println!("second element of the array: {}", xs[1]); + + zzz(); // #break +} + +fn zzz() { () } diff --git a/src/test/debuginfo/mutable-locs.rs b/src/test/debuginfo/mutable-locs.rs new file mode 100644 index 0000000000000..6cdc7c00ccaa0 --- /dev/null +++ b/src/test/debuginfo/mutable-locs.rs @@ -0,0 +1,51 @@ +// Testing the display of Cell, RefCell, and RefMut in cdb. + +// cdb-only +// min-cdb-version: 10.0.18317.1001 +// compile-flags:-g + +// === CDB TESTS ================================================================================== + +// cdb-command: g + +// cdb-command:dx static_c,d +// cdb-check:static_c,d [Type: core::cell::Cell] +// cdb-check: [+0x000] value [Type: core::cell::UnsafeCell] + +// cdb-command: dx static_c.value,d +// cdb-check:static_c.value,d [Type: core::cell::UnsafeCell] +// cdb-check: [+0x000] value : 10 [Type: int] + +// cdb-command: dx dynamic_c,d +// cdb-check:dynamic_c,d [Type: core::cell::RefCell] +// cdb-check: [+0x000] borrow [Type: core::cell::Cell] +// cdb-check: [...] value [Type: core::cell::UnsafeCell] + +// cdb-command: dx dynamic_c.value,d +// cdb-check:dynamic_c.value,d [Type: core::cell::UnsafeCell] +// cdb-check: [+0x000] value : 15 [Type: int] + +// cdb-command: dx b,d +// cdb-check:b,d [Type: core::cell::RefMut] +// cdb-check: [+0x000] value : [...] : 42 [Type: int *] +// cdb-check: [...] borrow [Type: core::cell::BorrowRefMut] + +#![allow(unused_variables)] + +use std::cell::{Cell, RefCell}; + +fn main() { + let static_c = Cell::new(5); + static_c.set(10); + + let dynamic_c = RefCell::new(5); + dynamic_c.replace(15); + + let dynamic_c_0 = RefCell::new(15); + let mut b = dynamic_c_0.borrow_mut(); + *b = 42; + + zzz(); // #break +} + +fn zzz() {()} diff --git a/src/test/debuginfo/mutex.rs b/src/test/debuginfo/mutex.rs new file mode 100644 index 0000000000000..ad5f5dee3ff4a --- /dev/null +++ b/src/test/debuginfo/mutex.rs @@ -0,0 +1,38 @@ +// Testing the display of Mutex and MutexGuard in cdb. + +// cdb-only +// min-cdb-version: 10.0.21287.1005 +// compile-flags:-g +// ignore-tidy-linelength + +// === CDB TESTS ================================================================================== +// +// cdb-command:g +// +// cdb-command:dx m,d +// cdb-check:m,d [Type: std::sync::mutex::Mutex] +// cdb-check: [+0x000] inner [Type: std::sys_common::mutex::MovableMutex] +// cdb-check: [+0x008] poison [Type: std::sync::poison::Flag] +// cdb-check: [+0x00c] data [Type: core::cell::UnsafeCell] + +// +// cdb-command:dx m.data,d +// cdb-check:m.data,d [Type: core::cell::UnsafeCell] +// cdb-check: [+0x000] value : 0 [Type: int] + +// +// cdb-command:dx lock,d +// cdb-check:lock,d : Ok({...}) [Type: core::result::Result, std::sync::poison::TryLockError>>] +// cdb-check: [value] [Type: std::sync::mutex::MutexGuard] + +use std::sync::Mutex; + +#[allow(unused_variables)] +fn main() +{ + let m = Mutex::new(0); + let lock = m.try_lock(); + zzz(); // #break +} + +fn zzz() {} diff --git a/src/test/debuginfo/pretty-std.rs b/src/test/debuginfo/pretty-std.rs index 1a99f8412504a..f469c851b8bc1 100644 --- a/src/test/debuginfo/pretty-std.rs +++ b/src/test/debuginfo/pretty-std.rs @@ -4,6 +4,7 @@ // compile-flags:-g // min-gdb-version: 7.7 // min-lldb-version: 310 +// min-cdb-version: 10.0.18317.1001 // === GDB TESTS =================================================================================== @@ -70,8 +71,12 @@ // cdb-command: g // cdb-command: dx slice,d -// cdb-check:slice,d [...] -// NOTE: While slices have a .natvis entry that works in VS & VS Code, it fails in CDB 10.0.18362.1 +// cdb-check:slice,d : { len=4 } [Type: slice] +// cdb-check: [len] : 4 [Type: unsigned __int64] +// cdb-check: [0] : 0 [Type: int] +// cdb-check: [1] : 1 [Type: int] +// cdb-check: [2] : 2 [Type: int] +// cdb-check: [3] : 3 [Type: int] // cdb-command: dx vec,d // cdb-check:vec,d [...] : { len=4 } [Type: [...]::Vec] @@ -83,8 +88,7 @@ // cdb-check: [3] : 7 [Type: unsigned __int64] // cdb-command: dx str_slice -// cdb-check:str_slice [...] -// NOTE: While string slices have a .natvis entry that works in VS & VS Code, it fails in CDB +// cdb-check:str_slice : "IAMA string slice!" [Type: str] // cdb-command: dx string // cdb-check:string : "IAMA string!" [Type: [...]::String] diff --git a/src/test/debuginfo/range-types.rs b/src/test/debuginfo/range-types.rs new file mode 100644 index 0000000000000..526de8ed16602 --- /dev/null +++ b/src/test/debuginfo/range-types.rs @@ -0,0 +1,47 @@ +// Testing the display of range types in cdb. + +// cdb-only +// min-cdb-version: 10.0.18317.1001 +// compile-flags:-g + +// === CDB TESTS ================================================================================== + +// cdb-command: g + +// cdb-command: dx r1,d +// cdb-check:r1,d [Type: core::ops::range::Range] +// cdb-check: [+0x000] start : 3 [Type: int] +// cdb-check: [+0x004] end : 5 [Type: int] + +// cdb-command: dx r2,d +// cdb-check:r2,d [Type: core::ops::range::RangeFrom] +// cdb-check: [+0x000] start : 2 [Type: int] + +// cdb-command: dx r3,d +// cdb-check:r3,d [Type: core::ops::range::RangeInclusive] +// cdb-check: [+0x000] start : 1 [Type: int] +// cdb-check: [+0x004] end : 4 [Type: int] +// cdb-check: [+0x008] exhausted : false [Type: bool] + +// cdb-command: dx r4,d +// cdb-check:r4,d [Type: core::ops::range::RangeToInclusive] +// cdb-check: [+0x000] end : 3 [Type: int] + +// cdb-command: dx r5,d +// cdb-check:r5,d [Type: core::ops::range::RangeFull] + +#[allow(unused_variables)] + +use std::ops::{Range, RangeFrom, RangeFull, RangeInclusive, RangeToInclusive}; + +fn main() +{ + let r1 = Range{start: 3, end: 5}; + let r2 = RangeFrom{start: 2}; + let r3 = RangeInclusive::new(1, 4); + let r4 = RangeToInclusive{end: 3}; + let r5 = RangeFull{}; + zzz(); // #break +} + +fn zzz() { () } diff --git a/src/test/debuginfo/rc_arc.rs b/src/test/debuginfo/rc_arc.rs index 87bc79ea79437..0fc1a617469fb 100644 --- a/src/test/debuginfo/rc_arc.rs +++ b/src/test/debuginfo/rc_arc.rs @@ -1,7 +1,9 @@ -// ignore-windows pretty-printers are not loaded +// pretty-printers are not loaded // compile-flags:-g +// ignore-tidy-linelength // min-gdb-version: 8.1 +// min-cdb-version: 10.0.18317.1001 // === GDB TESTS ================================================================================== @@ -22,6 +24,29 @@ // lldb-command:print a // lldb-check:[...]$1 = strong=2, weak=1 { data = 42 } +// === CDB TESTS ================================================================================== + +// cdb-command:g + +// cdb-command:dx r,d +// cdb-check:r,d : 42 [Type: alloc::rc::Rc] + +// cdb-command:dx r1,d +// cdb-check:r1,d : 42 [Type: alloc::rc::Rc] + +// cdb-command:dx w1,d +// cdb-check:w1,d [Type: alloc::rc::Weak] +// cdb-check: [+0x000] ptr : [...] [Type: core::ptr::non_null::NonNull>] + +// cdb-command:dx a,d +// cdb-check:a,d : 42 [Type: alloc::sync::Arc] + +// cdb-command:dx a1,d +// cdb-check:a1,d : 42 [Type: alloc::sync::Arc] + +// cdb-command:dx w2,d +// cdb-check:w2,d : 42 [Type: alloc::sync::Weak] + use std::rc::Rc; use std::sync::Arc; diff --git a/src/test/debuginfo/result-types.rs b/src/test/debuginfo/result-types.rs new file mode 100644 index 0000000000000..a0d6697932162 --- /dev/null +++ b/src/test/debuginfo/result-types.rs @@ -0,0 +1,26 @@ +// cdb-only +// min-cdb-version: 10.0.18317.1001 +// compile-flags:-g + +// === CDB TESTS ================================================================================== + +// cdb-command: g + +// cdb-command: dx x,d +// cdb-check:x,d : Ok(-3) [Type: core::result::Result] + +// cdb-command: dx y +// cdb-check: [value] [Type: str] + +fn main() +{ + let x: Result = Ok(-3); + assert_eq!(x.is_ok(), true); + + let y: Result = Err("Some error message"); + assert_eq!(y.is_ok(), false); + + zzz(); // #break. +} + +fn zzz() { () } diff --git a/src/test/debuginfo/rwlock-read.rs b/src/test/debuginfo/rwlock-read.rs new file mode 100644 index 0000000000000..9ddbb1681ee2c --- /dev/null +++ b/src/test/debuginfo/rwlock-read.rs @@ -0,0 +1,36 @@ +// Testing the display of RwLock and RwLockReadGuard in cdb. + +// cdb-only +// min-cdb-version: 10.0.18317.1001 +// compile-flags:-g + +// === CDB TESTS ================================================================================== +// +// cdb-command:g +// +// cdb-command:dx l +// cdb-check:l [Type: std::sync::rwlock::RwLock] +// cdb-check: [+0x000] inner : [...] [Type: std::sys_common::rwlock::RWLock *] +// cdb-check: [+0x008] poison [Type: std::sync::poison::Flag] +// cdb-check: [+0x00c] data [Type: core::cell::UnsafeCell] +// +// cdb-command:dx r +// cdb-check:r [Type: std::sync::rwlock::RwLockReadGuard] +// cdb-check: [+0x000] lock : [...] [Type: std::sync::rwlock::RwLock *] +// +// cdb-command:dx r.lock->data,d +// cdb-check:r.lock->data,d [Type: core::cell::UnsafeCell] +// cdb-check: [+0x000] value : 0 [Type: int] + +#[allow(unused_variables)] + +use std::sync::RwLock; + +fn main() +{ + let l = RwLock::new(0); + let r = l.read().unwrap(); + zzz(); // #break +} + +fn zzz() {} diff --git a/src/test/debuginfo/rwlock-write.rs b/src/test/debuginfo/rwlock-write.rs new file mode 100644 index 0000000000000..5a3f903845a0a --- /dev/null +++ b/src/test/debuginfo/rwlock-write.rs @@ -0,0 +1,27 @@ +// Testing the display of RwLockWriteGuard. + +// cdb-only +// min-cdb-version: 10.0.18317.1001 +// compile-flags:-g + +// === CDB TESTS ================================================================================== +// +// cdb-command:g +// +// cdb-command:dx w +// cdb-check:w [Type: std::sync::rwlock::RwLockWriteGuard] +// cdb-check: [+0x000] lock : [...] [Type: std::sync::rwlock::RwLock *] +// cdb-check: [+0x008] poison [Type: std::sync::poison::Guard] + +#[allow(unused_variables)] + +use std::sync::RwLock; + +fn main() +{ + let l = RwLock::new(0); + let w = l.write().unwrap(); + zzz(); // #break +} + +fn zzz() {} diff --git a/src/test/debuginfo/thread.rs b/src/test/debuginfo/thread.rs new file mode 100644 index 0000000000000..b4f60bbe011af --- /dev/null +++ b/src/test/debuginfo/thread.rs @@ -0,0 +1,31 @@ +// Testing the the display of JoinHandle and Thread in cdb. + +// cdb-only +// min-cdb-version: 10.0.18317.1001 +// compile-flags:-g + +// === CDB TESTS ================================================================================== +// +// cdb-command:g +// +// cdb-command:dx join_handle,d +// cdb-check:join_handle,d [Type: std::thread::JoinHandle>] +// cdb-check: [+0x000] __0 [Type: std::thread::JoinInner>] +// +// cdb-command:dx t,d +// cdb-check:t,d : [...] [Type: std::thread::Thread *] +// cdb-check: [+0x000] inner : {...} [Type: alloc::sync::Arc] + +use std::thread; + +#[allow(unused_variables)] +fn main() +{ + let join_handle = thread::spawn(|| { + println!("Initialize a thread"); + }); + let t = join_handle.thread(); + zzz(); // #break +} + +fn zzz() {} From 98c90522a61f434e6e72a292ab639c47db3c2464 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Thu, 3 Jun 2021 13:21:04 -0700 Subject: [PATCH 10/11] Fix linkcheck script from getting out of sync. --- src/tools/linkchecker/linkcheck.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/linkchecker/linkcheck.sh b/src/tools/linkchecker/linkcheck.sh index b68053c76befc..7f226aab7d72d 100755 --- a/src/tools/linkchecker/linkcheck.sh +++ b/src/tools/linkchecker/linkcheck.sh @@ -85,11 +85,11 @@ fi if [ ! -e "linkchecker/main.rs" ] || [ "$iterative" = "0" ] then echo "Downloading linkchecker source..." + nightly_hash=$(rustc +nightly -Vv | grep commit-hash | cut -f2 -d" ") + url="https://raw.githubusercontent.com/rust-lang/rust" mkdir linkchecker - curl -o linkchecker/Cargo.toml \ - https://raw.githubusercontent.com/rust-lang/rust/master/src/tools/linkchecker/Cargo.toml - curl -o linkchecker/main.rs \ - https://raw.githubusercontent.com/rust-lang/rust/master/src/tools/linkchecker/main.rs + curl -o linkchecker/Cargo.toml ${url}/${nightly_hash}/src/tools/linkchecker/Cargo.toml + curl -o linkchecker/main.rs ${url}/${nightly_hash}/src/tools/linkchecker/main.rs fi echo "Building book \"$book_name\"..." From 095f09a5bf1433ca4003728fd95682dd34b19dca Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Thu, 3 Jun 2021 13:21:21 -0700 Subject: [PATCH 11/11] Build linkcheck script as release to run faster. --- src/tools/linkchecker/linkcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/linkchecker/linkcheck.sh b/src/tools/linkchecker/linkcheck.sh index 7f226aab7d72d..9eeebf444a499 100755 --- a/src/tools/linkchecker/linkcheck.sh +++ b/src/tools/linkchecker/linkcheck.sh @@ -106,7 +106,7 @@ else check_path="linkcheck/$book_name" fi echo "Running linkchecker on \"$check_path\"..." -cargo run --manifest-path=linkchecker/Cargo.toml -- "$check_path" +cargo run --release --manifest-path=linkchecker/Cargo.toml -- "$check_path" if [ "$iterative" = "0" ] then