From 86562b4fdb39e2810e84c2107297a682cdec8042 Mon Sep 17 00:00:00 2001 From: LingMan Date: Tue, 1 Jun 2021 20:50:08 +0200 Subject: [PATCH 01/16] Use `Iterator::find` instead of open-coding it --- compiler/rustc_lint/src/types.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 9c94bab04e98f..e0f19ad5ec841 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -680,16 +680,11 @@ pub fn transparent_newtype_field<'a, 'tcx>( variant: &'a ty::VariantDef, ) -> Option<&'a ty::FieldDef> { let param_env = tcx.param_env(variant.def_id); - for field in &variant.fields { + variant.fields.iter().find(|field| { let field_ty = tcx.type_of(field.did); let is_zst = tcx.layout_of(param_env.and(field_ty)).map_or(false, |layout| layout.is_zst()); - - if !is_zst { - return Some(field); - } - } - - None + !is_zst + }) } /// Is type known to be non-null? From 51d98e3d4eb91041d86c05ddf32fd838a0de7988 Mon Sep 17 00:00:00 2001 From: hyd-dev Date: Thu, 3 Jun 2021 11:46:53 +0800 Subject: [PATCH 02/16] Update the documentation of `-C force-unwind-tables` --- src/doc/rustc/src/codegen-options/index.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md index 077c322bd7736..2921e365d7a7c 100644 --- a/src/doc/rustc/src/codegen-options/index.md +++ b/src/doc/rustc/src/codegen-options/index.md @@ -149,8 +149,7 @@ values: * `y`, `yes`, `on`, or no value: Unwind tables are forced to be generated. * `n`, `no`, or `off`: Unwind tables are not forced to be generated. If unwind - tables are required by the target or `-C panic=unwind`, an error will be - emitted. + tables are required by the target an error will be emitted. The default if not specified depends on the target. From c176e04e94fe357242aeb1001116203bbd738c54 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Tue, 30 Mar 2021 10:43:39 -0700 Subject: [PATCH 03/16] 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 | 28 ++++++++++++++ src/test/debuginfo/rwlock-read.rs | 36 +++++++++++++++++ src/test/debuginfo/rwlock-write.rs | 27 +++++++++++++ src/test/debuginfo/thread.rs | 31 +++++++++++++++ 10 files changed, 331 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 68e73b5f38da9..367d53e69367d 100644 --- a/src/test/debuginfo/pretty-std.rs +++ b/src/test/debuginfo/pretty-std.rs @@ -5,6 +5,7 @@ // compile-flags:-g // min-gdb-version: 7.7 // min-lldb-version: 310 +// min-cdb-version: 10.0.18317.1001 // === GDB TESTS =================================================================================== @@ -71,8 +72,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] @@ -84,8 +89,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..18eae7f301fbb --- /dev/null +++ b/src/test/debuginfo/result-types.rs @@ -0,0 +1,28 @@ +// 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 [Type: enum$>] +// cdb-check: [...] __0 : -3 [Type: int] + +// cdb-command: dx y +// cdb-check:y : Err [Type: enum$>] +// cdb-check: [...] __0 : "Some error message" [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 eb3fd6d208da80147430fea4be740acea687d8aa Mon Sep 17 00:00:00 2001 From: Reagan McFarland Date: Sun, 6 Jun 2021 16:21:47 -0400 Subject: [PATCH 04/16] Default panic message should print Box Prior to this patch, the default panic message (resulting from calling `panic_any(42);` for example), would print the following error message: ``` thread 'main' panicked at 'Box', ... ``` However, this should be `Box` instead. --- library/std/src/panicking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index 02957e75a7409..e591e073e7bbb 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -193,7 +193,7 @@ fn default_hook(info: &PanicInfo<'_>) { Some(s) => *s, None => match info.payload().downcast_ref::() { Some(s) => &s[..], - None => "Box", + None => "Box", }, }; let thread = thread_info::current_thread(); From 570ba09cbe3922036db07f5862ebe6cc2a4b456e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 6 Jun 2021 23:06:01 +0200 Subject: [PATCH 05/16] Fix invalid weight for type pages --- src/librustdoc/html/static/rustdoc.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index d3f8a7aa67dd7..35b2785fac004 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -138,7 +138,7 @@ h2, h3, h4 { border-bottom: 1px solid; } .impl, .method, -.type, .associatedconstant, +.type:not(.container-rustdoc), .associatedconstant, .associatedtype { flex-basis: 100%; font-weight: 600; From 45973621bcc57adb4d97d23d20ae915041db5534 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 6 Jun 2021 23:06:49 +0200 Subject: [PATCH 06/16] Add test to check that font-weight is correctly set on type page --- src/test/rustdoc-gui/sidebar.goml | 3 ++- src/test/rustdoc-gui/src/lib.rs | 3 +++ src/test/rustdoc-gui/type-weight.rs | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 src/test/rustdoc-gui/type-weight.rs diff --git a/src/test/rustdoc-gui/sidebar.goml b/src/test/rustdoc-gui/sidebar.goml index 388ca120d770e..7703677154ef9 100644 --- a/src/test/rustdoc-gui/sidebar.goml +++ b/src/test/rustdoc-gui/sidebar.goml @@ -11,7 +11,8 @@ assert: (".sidebar-elems > .items > ul > li:nth-child(2)", "Structs") assert: (".sidebar-elems > .items > ul > li:nth-child(3)", "Enums") assert: (".sidebar-elems > .items > ul > li:nth-child(4)", "Traits") assert: (".sidebar-elems > .items > ul > li:nth-child(5)", "Functions") -assert: (".sidebar-elems > .items > ul > li:nth-child(6)", "Keywords") +assert: (".sidebar-elems > .items > ul > li:nth-child(6)", "Type Definitions") +assert: (".sidebar-elems > .items > ul > li:nth-child(7)", "Keywords") assert: ("#structs + table td > a", "Foo") click: "#structs + table td > a" diff --git a/src/test/rustdoc-gui/src/lib.rs b/src/test/rustdoc-gui/src/lib.rs index 272b1d05452e3..5141b6d1920ea 100644 --- a/src/test/rustdoc-gui/src/lib.rs +++ b/src/test/rustdoc-gui/src/lib.rs @@ -96,3 +96,6 @@ pub enum AnEnum { #[doc(keyword = "CookieMonster")] pub mod keyword {} + +/// Just some type alias. +pub type SomeType = u32; diff --git a/src/test/rustdoc-gui/type-weight.rs b/src/test/rustdoc-gui/type-weight.rs new file mode 100644 index 0000000000000..8b6518e7f317a --- /dev/null +++ b/src/test/rustdoc-gui/type-weight.rs @@ -0,0 +1,2 @@ +goto: file://|DOC_PATH|/test_docs/type.SomeType.html +assert-all: (".top-block .docblock p", {"font-weight": "400"}) From 8330233ba751778f8571c8879f85612fd2d9fb9a Mon Sep 17 00:00:00 2001 From: Reagan McFarland Date: Sun, 6 Jun 2021 19:38:53 -0400 Subject: [PATCH 07/16] Update testsuite to match new panic msg This patch fixes tests from failing that were matching on `Box`, which was the old panic message. Since the new panic message is `Box`, the tests have been updated to match against this instead. --- src/test/ui/panics/panic-macro-any-wrapped.rs | 2 +- src/test/ui/panics/panic-macro-any.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/ui/panics/panic-macro-any-wrapped.rs b/src/test/ui/panics/panic-macro-any-wrapped.rs index 95ae6ffe8be02..100ac10c76717 100644 --- a/src/test/ui/panics/panic-macro-any-wrapped.rs +++ b/src/test/ui/panics/panic-macro-any-wrapped.rs @@ -1,5 +1,5 @@ // run-fail -// error-pattern:panicked at 'Box' +// error-pattern:panicked at 'Box' // ignore-emscripten no processes #![allow(non_fmt_panic)] diff --git a/src/test/ui/panics/panic-macro-any.rs b/src/test/ui/panics/panic-macro-any.rs index d2a7ba3713a51..a5ba30220e89a 100644 --- a/src/test/ui/panics/panic-macro-any.rs +++ b/src/test/ui/panics/panic-macro-any.rs @@ -1,5 +1,5 @@ // run-fail -// error-pattern:panicked at 'Box' +// error-pattern:panicked at 'Box' // ignore-emscripten no processes #![feature(box_syntax)] From a0aabf7aed06b5fa49e16dad74986c677e146eb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 7 Jun 2021 08:15:15 +0300 Subject: [PATCH 08/16] :arrow_up: rust-analyzer --- src/tools/rust-analyzer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer b/src/tools/rust-analyzer index f4383981249d3..13da28cc2bc1b 160000 --- a/src/tools/rust-analyzer +++ b/src/tools/rust-analyzer @@ -1 +1 @@ -Subproject commit f4383981249d3f2964f2c667f3349f8ff15b77c4 +Subproject commit 13da28cc2bc1b59f7af817eca36927a71edb023c From 4ca7a1119e77afa2528b28282e91a5226367733a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 7 Jun 2021 11:12:27 +0200 Subject: [PATCH 09/16] Fix integration of codeblocks in search result description --- src/librustdoc/html/static/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/search.js b/src/librustdoc/html/static/search.js index b3242bf4df923..35be246b5bf2e 100644 --- a/src/librustdoc/html/static/search.js +++ b/src/librustdoc/html/static/search.js @@ -1024,7 +1024,7 @@ window.initSearch = function(rawSearchIndex) { var description = document.createElement("div"); description.className = "desc"; var spanDesc = document.createElement("span"); - spanDesc.innerText = item.desc + "\u00A0"; + spanDesc.insertAdjacentHTML("beforeend", item.desc); description.appendChild(spanDesc); wrapper.appendChild(description); From 314ef592e284b16d4cb1764cec79cd5f0e0d0171 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 7 Jun 2021 11:19:29 +0200 Subject: [PATCH 10/16] Add test to ensure the result descripton is correctly handling codeblocks --- src/test/rustdoc-gui/search-result-description.goml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/test/rustdoc-gui/search-result-description.goml diff --git a/src/test/rustdoc-gui/search-result-description.goml b/src/test/rustdoc-gui/search-result-description.goml new file mode 100644 index 0000000000000..a50d03cf48912 --- /dev/null +++ b/src/test/rustdoc-gui/search-result-description.goml @@ -0,0 +1,5 @@ +// This test is to ensure that the codeblocks are correctly rendered in the search results. +goto: file://|DOC_PATH|/test_docs/index.html?search=some_more_function +// Waiting for the search results to appear... +wait-for: "#titles" +assert: (".search-results .desc code", "format!") From a20870bdb9ecce8af7acb2db13177fc52f890f92 Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Mon, 7 Jun 2021 13:01:04 +0200 Subject: [PATCH 11/16] Comment out unused error codes in error_codes.rs --- compiler/rustc_error_codes/src/error_codes.rs | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index c343809179b0a..f82c03a4f8894 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -553,8 +553,8 @@ E0783: include_str!("./error_codes/E0783.md"), E0311, // thing may not live long enough E0313, // lifetime of borrowed pointer outlives lifetime of captured // variable - E0314, // closure outlives stack frame - E0315, // cannot invoke closure outside of its lifetime +// E0314, // closure outlives stack frame +// E0315, // cannot invoke closure outside of its lifetime E0316, // nested quantification of lifetimes // E0319, // trait impls for defaulted traits allowed just for structs/enums E0320, // recursive overflow during dropck @@ -584,21 +584,21 @@ E0783: include_str!("./error_codes/E0783.md"), // E0470, removed // E0471, // constant evaluation error (in pattern) E0472, // llvm_asm! is unsupported on this target - E0473, // dereference of reference outside its lifetime - E0474, // captured variable `..` does not outlive the enclosing closure - E0475, // index of slice outside its lifetime +// E0473, // dereference of reference outside its lifetime +// E0474, // captured variable `..` does not outlive the enclosing closure +// E0475, // index of slice outside its lifetime E0476, // lifetime of the source pointer does not outlive lifetime bound... - E0479, // the type `..` (provided as the value of a type parameter) is... - E0480, // lifetime of method receiver does not outlive the method call - E0481, // lifetime of function argument does not outlive the function call +// E0479, // the type `..` (provided as the value of a type parameter) is... +// E0480, // lifetime of method receiver does not outlive the method call +// E0481, // lifetime of function argument does not outlive the function call E0482, // lifetime of return value does not outlive the function call - E0483, // lifetime of operand does not outlive the operation - E0484, // reference is not valid at the time of borrow - E0485, // automatically reference is not valid at the time of borrow - E0486, // type of expression contains references that are not valid during.. - E0487, // unsafe use of destructor: destructor might be called while... - E0488, // lifetime of variable does not enclose its declaration - E0489, // type/lifetime parameter not in scope here +// E0483, // lifetime of operand does not outlive the operation +// E0484, // reference is not valid at the time of borrow +// E0485, // automatically reference is not valid at the time of borrow +// E0486, // type of expression contains references that are not valid during.. +// E0487, // unsafe use of destructor: destructor might be called while... +// E0488, // lifetime of variable does not enclose its declaration +// E0489, // type/lifetime parameter not in scope here E0490, // a value of type `..` is borrowed for too long E0498, // malformed plugin attribute E0514, // metadata version mismatch From c01d63ab767084eba25bfc317d5aa1f21820836d Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Mon, 7 Jun 2021 13:05:17 +0200 Subject: [PATCH 12/16] Add E0316.md --- compiler/rustc_error_codes/src/error_codes.rs | 2 +- .../src/error_codes/E0316.md | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 compiler/rustc_error_codes/src/error_codes/E0316.md diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index f82c03a4f8894..f10efd832361c 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -157,6 +157,7 @@ E0308: include_str!("./error_codes/E0308.md"), E0309: include_str!("./error_codes/E0309.md"), E0310: include_str!("./error_codes/E0310.md"), E0312: include_str!("./error_codes/E0312.md"), +E0316: include_str!("./error_codes/E0316.md"), E0317: include_str!("./error_codes/E0317.md"), E0321: include_str!("./error_codes/E0321.md"), E0322: include_str!("./error_codes/E0322.md"), @@ -555,7 +556,6 @@ E0783: include_str!("./error_codes/E0783.md"), // variable // E0314, // closure outlives stack frame // E0315, // cannot invoke closure outside of its lifetime - E0316, // nested quantification of lifetimes // E0319, // trait impls for defaulted traits allowed just for structs/enums E0320, // recursive overflow during dropck // E0372, // coherence not object safe diff --git a/compiler/rustc_error_codes/src/error_codes/E0316.md b/compiler/rustc_error_codes/src/error_codes/E0316.md new file mode 100644 index 0000000000000..4368c321737b2 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0316.md @@ -0,0 +1,32 @@ +A `where` clause contains a nested quantification over lifetimes. + +Erroneous code example: + +```compile_fail,E0316 +trait Tr<'a, 'b> {} + +fn foo(t: T) +where + for<'a> &'a T: for<'b> Tr<'a, 'b>, // error: nested quantification +{ +} +``` + +Rust syntax allows lifetime quantifications in two places within +`where` clauses: Quantifying over the trait bound only (as in +`Ty: for<'l> Trait<'l>`) and quantifying over the whole clause +(as in `for<'l> &'l Ty: Trait<'l>`). Using both in the same clause +leads to a nested lifetime quantification, which is not supported. + +The following example compiles, because the clause with the nested +quantification has been rewritten to use only one `for<>`: + +``` +trait Tr<'a, 'b> {} + +fn foo(t: T) +where + for<'a, 'b> &'a T: Tr<'a, 'b>, // ok +{ +} +``` From 09307a3e0db0154ac0c37443463a73c32bfe9b5d Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Mon, 7 Jun 2021 15:00:47 +0200 Subject: [PATCH 13/16] Bless ui/where-clauses/where-for-self.rs test --- src/test/ui/where-clauses/where-for-self.stderr | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/ui/where-clauses/where-for-self.stderr b/src/test/ui/where-clauses/where-for-self.stderr index 84430ffcf887f..d06afc1e42376 100644 --- a/src/test/ui/where-clauses/where-for-self.stderr +++ b/src/test/ui/where-clauses/where-for-self.stderr @@ -6,3 +6,4 @@ LL | where for<'a> &'a T: for<'b> Bar<'b> error: aborting due to previous error +For more information about this error, try `rustc --explain E0316`. From fb92c92a7211c45f8361f2e865512dce244f3c96 Mon Sep 17 00:00:00 2001 From: Cameron Steffen Date: Mon, 7 Jun 2021 09:50:07 -0500 Subject: [PATCH 14/16] Remove lifetime hack --- compiler/rustc_resolve/src/late/lifetimes.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/compiler/rustc_resolve/src/late/lifetimes.rs b/compiler/rustc_resolve/src/late/lifetimes.rs index efa5d7e7b1139..ca7cdc4caf505 100644 --- a/compiler/rustc_resolve/src/late/lifetimes.rs +++ b/compiler/rustc_resolve/src/late/lifetimes.rs @@ -1841,14 +1841,6 @@ fn object_lifetime_defaults_for_item( } impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { - // FIXME(#37666) this works around a limitation in the region inferencer - fn hack(&mut self, f: F) - where - F: for<'b> FnOnce(&mut LifetimeContext<'b, 'tcx>), - { - f(self) - } - fn with(&mut self, wrap_scope: Scope<'_>, f: F) where F: for<'b> FnOnce(ScopeRef<'_>, &mut LifetimeContext<'b, 'tcx>), @@ -2252,7 +2244,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { }; self.with(scope, move |old_scope, this| { this.check_lifetime_params(old_scope, &generics.params); - this.hack(walk); // FIXME(#37666) workaround in place of `walk(this)` + walk(this); }); } From 5aa188ac5d20c6f7f1ed131a6e4f932f22b0d312 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Mon, 7 Jun 2021 10:55:31 -0400 Subject: [PATCH 15/16] Correct type signature in doc for Bound::as_mut --- library/core/src/ops/range.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/ops/range.rs b/library/core/src/ops/range.rs index 684e6bb4a0fba..bb948376bc7c7 100644 --- a/library/core/src/ops/range.rs +++ b/library/core/src/ops/range.rs @@ -686,7 +686,7 @@ impl Bound { } } - /// Converts from `&mut Bound` to `Bound<&T>`. + /// Converts from `&mut Bound` to `Bound<&mut T>`. #[inline] #[unstable(feature = "bound_as_ref", issue = "80996")] pub fn as_mut(&mut self) -> Bound<&mut T> { From fddf012177671110caa96c4d9036199a0b91b8e7 Mon Sep 17 00:00:00 2001 From: Lionel Foxcroft Date: Fri, 4 Jun 2021 01:27:19 -0400 Subject: [PATCH 16/16] Clarify documentation of slice sorting methods --- library/core/src/slice/mod.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 3bcea4e6d25ed..0e5c5ee726e54 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -2100,9 +2100,11 @@ impl [T] { /// /// If the value is found then [`Result::Ok`] is returned, containing the /// index of the matching element. If there are multiple matches, then any - /// one of the matches could be returned. If the value is not found then - /// [`Result::Err`] is returned, containing the index where a matching - /// element could be inserted while maintaining sorted order. + /// one of the matches could be returned. The index is chosen + /// deterministically, but is subject to change in future versions of Rust. + /// If the value is not found then [`Result::Err`] is returned, containing + /// the index where a matching element could be inserted while maintaining + /// sorted order. /// /// See also [`binary_search_by`], [`binary_search_by_key`], and [`partition_point`]. /// @@ -2153,9 +2155,11 @@ impl [T] { /// /// If the value is found then [`Result::Ok`] is returned, containing the /// index of the matching element. If there are multiple matches, then any - /// one of the matches could be returned. If the value is not found then - /// [`Result::Err`] is returned, containing the index where a matching - /// element could be inserted while maintaining sorted order. + /// one of the matches could be returned. The index is chosen + /// deterministically, but is subject to change in future versions of Rust. + /// If the value is not found then [`Result::Err`] is returned, containing + /// the index where a matching element could be inserted while maintaining + /// sorted order. /// /// See also [`binary_search`], [`binary_search_by_key`], and [`partition_point`]. /// @@ -2224,9 +2228,11 @@ impl [T] { /// /// If the value is found then [`Result::Ok`] is returned, containing the /// index of the matching element. If there are multiple matches, then any - /// one of the matches could be returned. If the value is not found then - /// [`Result::Err`] is returned, containing the index where a matching - /// element could be inserted while maintaining sorted order. + /// one of the matches could be returned. The index is chosen + /// deterministically, but is subject to change in future versions of Rust. + /// If the value is not found then [`Result::Err`] is returned, containing + /// the index where a matching element could be inserted while maintaining + /// sorted order. /// /// See also [`binary_search`], [`binary_search_by`], and [`partition_point`]. ///