From bcf57d8f20830683d0b66e231010903146a298e7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 28 May 2020 14:51:12 +0200 Subject: [PATCH 1/7] Fix escape key handling --- src/librustdoc/html/static/main.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 9869c50fbb0cf..c349b59e562a9 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -81,6 +81,7 @@ function getSearchElement() { var disableShortcuts = getCurrentValue("rustdoc-disable-shortcuts") === "true"; var search_input = getSearchInput(); + var searchTimeout = null; // On the search screen, so you remain on the last tab you opened. // @@ -344,6 +345,10 @@ function getSearchElement() { if (hasClass(help, "hidden") === false) { displayHelp(false, ev, help); } else if (hasClass(search, "hidden") === false) { + if (searchTimeout !== null) { + clearTimeout(searchTimeout); + searchTimeout = null; + } ev.preventDefault(); hideSearchResults(search); document.title = titleBeforeSearch; @@ -1799,7 +1804,6 @@ function getSearchElement() { } function startSearch() { - var searchTimeout; var callback = function() { clearTimeout(searchTimeout); if (search_input.value.length === 0) { @@ -1815,7 +1819,10 @@ function getSearchElement() { search_input.oninput = callback; document.getElementsByClassName("search-form")[0].onsubmit = function(e) { e.preventDefault(); - clearTimeout(searchTimeout); + if (searchTimeout !== null) { + clearTimeout(searchTimeout); + searchTimeout = null; + } search(); }; search_input.onchange = function(e) { @@ -1824,7 +1831,10 @@ function getSearchElement() { return; } // Do NOT e.preventDefault() here. It will prevent pasting. - clearTimeout(searchTimeout); + if (searchTimeout !== null) { + clearTimeout(searchTimeout); + searchTimeout = null; + } // zero-timeout necessary here because at the time of event handler execution the // pasted content is not in the input field yet. Shouldn’t make any difference for // change, though. From 3bf9eb0f7a1f2da9df2983aa8cf95a420130cada Mon Sep 17 00:00:00 2001 From: XIAO Tian Date: Sat, 30 May 2020 11:28:33 +0800 Subject: [PATCH 2/7] Add a test for wrong assoc type diagnostics --- src/test/ui/associated-types/issue-72806.rs | 20 +++++++++++++++++++ .../ui/associated-types/issue-72806.stderr | 9 +++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/test/ui/associated-types/issue-72806.rs create mode 100644 src/test/ui/associated-types/issue-72806.stderr diff --git a/src/test/ui/associated-types/issue-72806.rs b/src/test/ui/associated-types/issue-72806.rs new file mode 100644 index 0000000000000..ae63781d568a1 --- /dev/null +++ b/src/test/ui/associated-types/issue-72806.rs @@ -0,0 +1,20 @@ +trait Bar { + type Ok; + type Sibling: Bar2; +} +trait Bar2 { + type Ok; +} + +struct Foo; +struct Foo2; + +impl Bar for Foo { //~ ERROR type mismatch resolving `::Ok == char` + type Ok = (); + type Sibling = Foo2; +} +impl Bar2 for Foo2 { + type Ok = u32; +} + +fn main() {} diff --git a/src/test/ui/associated-types/issue-72806.stderr b/src/test/ui/associated-types/issue-72806.stderr new file mode 100644 index 0000000000000..03a6565848dc3 --- /dev/null +++ b/src/test/ui/associated-types/issue-72806.stderr @@ -0,0 +1,9 @@ +error[E0271]: type mismatch resolving `::Ok == char` + --> $DIR/issue-72806.rs:12:6 + | +LL | impl Bar for Foo { + | ^^^ expected `u32`, found `char` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0271`. From 1a68c8e8d957e8df19e5adced776879bbe3d5344 Mon Sep 17 00:00:00 2001 From: XIAO Tian Date: Sat, 30 May 2020 11:26:46 +0800 Subject: [PATCH 3/7] Fix associate type diagnostics --- src/librustc_trait_selection/traits/wf.rs | 31 +++++++++-------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/librustc_trait_selection/traits/wf.rs b/src/librustc_trait_selection/traits/wf.rs index 714ca7a30cff6..39c7528a63240 100644 --- a/src/librustc_trait_selection/traits/wf.rs +++ b/src/librustc_trait_selection/traits/wf.rs @@ -172,25 +172,18 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>( }; match pred.kind() { ty::PredicateKind::Projection(proj) => { - // The obligation comes not from the current `impl` nor the `trait` being - // implemented, but rather from a "second order" obligation, like in - // `src/test/ui/associated-types/point-at-type-on-obligation-failure.rs`. - let trait_assoc_item = tcx.associated_item(proj.projection_def_id()); - if let Some(impl_item_span) = - items.iter().find(|item| item.ident == trait_assoc_item.ident).map(fix_span) - { - cause.span = impl_item_span; - } else { - let kind = &proj.ty().skip_binder().kind; - if let ty::Projection(projection_ty) = kind { - // This happens when an associated type has a projection coming from another - // associated type. See `traits-assoc-type-in-supertrait-bad.rs`. - let trait_assoc_item = tcx.associated_item(projection_ty.item_def_id); - if let Some(impl_item_span) = - items.iter().find(|item| item.ident == trait_assoc_item.ident).map(fix_span) - { - cause.span = impl_item_span; - } + // The obligation comes not from the current `impl` nor the `trait` being implemented, + // but rather from a "second order" obligation, where an associated type has a + // projection coming from another associated type. See + // `src/test/ui/associated-types/point-at-type-on-obligation-failure.rs` and + // `traits-assoc-type-in-supertrait-bad.rs`. + let kind = &proj.ty().skip_binder().kind; + if let ty::Projection(projection_ty) = kind { + let trait_assoc_item = tcx.associated_item(projection_ty.item_def_id); + if let Some(impl_item_span) = + items.iter().find(|item| item.ident == trait_assoc_item.ident).map(fix_span) + { + cause.span = impl_item_span; } } } From 532dabdb8ef9536abc68c6adcdd9ca557c0e445a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 31 May 2020 11:58:15 +0200 Subject: [PATCH 4/7] Miri tests: skip parts of test_char_range --- src/libcore/tests/iter.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index ab4f4aa7c73c8..3b854b56c320d 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -1959,8 +1959,11 @@ fn test_range() { #[test] fn test_char_range() { use std::char; - assert!(('\0'..=char::MAX).eq((0..=char::MAX as u32).filter_map(char::from_u32))); - assert!(('\0'..=char::MAX).rev().eq((0..=char::MAX as u32).filter_map(char::from_u32).rev())); + // Miri is too slow + let from = if cfg!(miri) { char::from_u32(0xD800 - 10).unwrap() } else { '\0' }; + let to = if cfg!(miri) { char::from_u32(0xDFFF + 10).unwrap() } else { char::MAX }; + assert!((from..=to).eq((from as u32..=to as u32).filter_map(char::from_u32))); + assert!((from..=to).rev().eq((from as u32..=to as u32).filter_map(char::from_u32).rev())); assert_eq!(('\u{D7FF}'..='\u{E000}').count(), 2); assert_eq!(('\u{D7FF}'..='\u{E000}').size_hint(), (2, Some(2))); From 7a2efa3a106389e9cd5c8bf3ab8f809398e77053 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 31 May 2020 14:27:33 +0200 Subject: [PATCH 5/7] Put input timeout clearance inside a function --- src/librustdoc/html/static/main.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index c349b59e562a9..6169d5ce8e85c 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -92,6 +92,13 @@ function getSearchElement() { var titleBeforeSearch = document.title; + function clearInputTimeout() { + if (searchTimeout !== null) { + clearTimeout(searchTimeout); + searchTimeout = null; + } + } + function getPageId() { var id = document.location.href.split("#")[1]; if (id) { @@ -345,10 +352,7 @@ function getSearchElement() { if (hasClass(help, "hidden") === false) { displayHelp(false, ev, help); } else if (hasClass(search, "hidden") === false) { - if (searchTimeout !== null) { - clearTimeout(searchTimeout); - searchTimeout = null; - } + clearInputTimeout(); ev.preventDefault(); hideSearchResults(search); document.title = titleBeforeSearch; @@ -1805,7 +1809,7 @@ function getSearchElement() { function startSearch() { var callback = function() { - clearTimeout(searchTimeout); + clearInputTimeout(); if (search_input.value.length === 0) { if (browserSupportsHistoryApi()) { history.replaceState("", window.currentCrate + " - Rust", "?search="); @@ -1819,10 +1823,7 @@ function getSearchElement() { search_input.oninput = callback; document.getElementsByClassName("search-form")[0].onsubmit = function(e) { e.preventDefault(); - if (searchTimeout !== null) { - clearTimeout(searchTimeout); - searchTimeout = null; - } + clearInputTimeout(); search(); }; search_input.onchange = function(e) { @@ -1831,10 +1832,7 @@ function getSearchElement() { return; } // Do NOT e.preventDefault() here. It will prevent pasting. - if (searchTimeout !== null) { - clearTimeout(searchTimeout); - searchTimeout = null; - } + clearInputTimeout(); // zero-timeout necessary here because at the time of event handler execution the // pasted content is not in the input field yet. Shouldn’t make any difference for // change, though. From dd0338fbac143cb0c3844575f5ae4406854b56c5 Mon Sep 17 00:00:00 2001 From: JOE1994 Date: Sun, 31 May 2020 14:37:26 -0400 Subject: [PATCH 6/7] Clarify terms in doc comments Doc comments of 'copy_from_slice' say that people should use 'clone_from_slice' when 'src' doesn't implement 'Copy'. However, 'src' is a reference and it always implements 'Copy'. The term 'src' should be fixed to 'T' in the doc comments. Thank you for reviewing this PR :) --- src/libcore/slice/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 2361749f16645..ff333f77334f7 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -2173,7 +2173,7 @@ impl [T] { /// /// The length of `src` must be the same as `self`. /// - /// If `src` implements `Copy`, it can be more performant to use + /// If `T` implements `Copy`, it can be more performant to use /// [`copy_from_slice`]. /// /// # Panics @@ -2244,7 +2244,7 @@ impl [T] { /// /// The length of `src` must be the same as `self`. /// - /// If `src` does not implement `Copy`, use [`clone_from_slice`]. + /// If `T` does not implement `Copy`, use [`clone_from_slice`]. /// /// # Panics /// From 0a71ba22430c5ca9ca19db1ee03c378e8b1da73c Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sun, 31 May 2020 14:51:08 -0400 Subject: [PATCH 7/7] Fix release notes for niche initialization change MaybeUninit is not affected by the linked PR. --- RELEASES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 7cba27e134a78..100993bb75cec 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -100,8 +100,8 @@ Compatibility Notes source file rather than the previous format of ``.][70969] **Note:** this may not point a file that actually exists on the user's system. - [The minimum required external LLVM version has been bumped to LLVM 8.][71147] -- [`mem::{zeroed, uninitialised, MaybeUninit}` will now panic when used with types - that do not allow zero initialization such as `NonZeroU8`.][66059] This was +- [`mem::{zeroed, uninitialised}` will now panic when used with types that do + not allow zero initialization such as `NonZeroU8`.][66059] This was previously a warning. - [In 1.45.0 (the next release) converting a `f64` to `u32` using the `as` operator has been defined as a saturating operation.][71269] This was previously