From 89986a39a8236a3e4bfbb74b4d3a0a03667e8b56 Mon Sep 17 00:00:00 2001 From: Luro02 <24826124+Luro02@users.noreply.github.com> Date: Wed, 11 Dec 2019 17:59:32 +0100 Subject: [PATCH 01/14] add partialeq and eq to cursor --- src/libstd/io/cursor.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index a94176e710005..1cdedd859d338 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -72,7 +72,7 @@ use core::convert::TryInto; /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, Eq, PartialEq)] pub struct Cursor { inner: T, pos: u64, @@ -902,4 +902,16 @@ mod tests { c.set_position(::max_value() as u64 + 1); assert!(c.write_all(&[1, 2, 3]).is_err()); } + + #[test] + fn test_partial_eq() { + assert_eq!(Cursor::new(Vec::::new()), Cursor::new(Vec::::new())); + } + + #[test] + fn test_eq() { + struct AssertEq(pub T); + + let _: AssertEq>> = AssertEq(Cursor::new(Vec::new())); + } } From 4ce2384501833127fa3c9e995240d78b07f0ab2f Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 22 Dec 2019 14:14:37 +0100 Subject: [PATCH 02/14] Improve JS code a bit by avoid erasing all event handlers --- src/librustdoc/html/static/main.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 1459e8f37cd32..ad988557f9bcc 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -324,6 +324,7 @@ function getSearchElement() { } function handleEscape(ev) { + debugger; var help = getHelpElement(); var search = getSearchElement(); hideModal(); @@ -390,8 +391,8 @@ function getSearchElement() { return null; } - document.onkeypress = handleShortcut; - document.onkeydown = handleShortcut; + document.addEventListener("keypress", handleShortcut); + document.addEventListener("keydown", handleShortcut); var handleSourceHighlight = (function() { var prev_line_id = 0; @@ -430,7 +431,7 @@ function getSearchElement() { } })(); - document.onclick = function(ev) { + document.addEventListener("click", function(ev) { if (hasClass(ev.target, "collapse-toggle")) { collapseDocs(ev.target, "toggle"); } else if (hasClass(ev.target.parentNode, "collapse-toggle")) { @@ -452,7 +453,7 @@ function getSearchElement() { expandSection(a.hash.replace(/^#/, "")); } } - }; + }); var x = document.getElementsByClassName("version-selector"); if (x.length > 0) { From b67701347abd3469a92577cfe748206ecfc25694 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 22 Dec 2019 15:42:10 +0100 Subject: [PATCH 03/14] Improve code readability --- src/librustdoc/html/static/main.js | 80 ++++++++++++++---------------- 1 file changed, 37 insertions(+), 43 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index ad988557f9bcc..d0c44cd40b21a 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -138,6 +138,22 @@ function getSearchElement() { } } + function showSearchResults(search) { + if (search === null || typeof search === 'undefined') { + search = getSearchElement(); + } + addClass(main, "hidden"); + removeClass(search, "hidden"); + } + + function hideSearchResults(search) { + if (search === null || typeof search === 'undefined') { + search = getSearchElement(); + } + addClass(search, "hidden"); + removeClass(main, "hidden"); + } + // used for special search precedence var TY_PRIMITIVE = itemTypes.indexOf("primitive"); var TY_KEYWORD = itemTypes.indexOf("keyword"); @@ -169,8 +185,7 @@ function getSearchElement() { if (ev !== null && search && !hasClass(search, "hidden") && ev.newURL) { // This block occurs when clicking on an element in the navbar while // in a search. - addClass(search, "hidden"); - removeClass(main, "hidden"); + hideSearchResults(search); var hash = ev.newURL.slice(ev.newURL.indexOf("#") + 1); if (browserSupportsHistoryApi()) { history.replaceState(hash, "", "?search=#" + hash); @@ -324,7 +339,6 @@ function getSearchElement() { } function handleEscape(ev) { - debugger; var help = getHelpElement(); var search = getSearchElement(); hideModal(); @@ -332,8 +346,7 @@ function getSearchElement() { displayHelp(false, ev, help); } else if (hasClass(search, "hidden") === false) { ev.preventDefault(); - addClass(search, "hidden"); - removeClass(main, "hidden"); + hideSearchResults(search); document.title = titleBeforeSearch; } defocusSearchBar(); @@ -1265,8 +1278,7 @@ function getSearchElement() { } dst = dst[0]; if (window.location.pathname === dst.pathname) { - addClass(getSearchElement(), "hidden"); - removeClass(main, "hidden"); + hideSearchResults(); document.location.href = dst.href; } }; @@ -1341,8 +1353,6 @@ function getSearchElement() { e.preventDefault(); } else if (e.which === 16) { // shift // Does nothing, it's just to avoid losing "focus" on the highlighted element. - } else if (e.which === 27) { // escape - handleEscape(e); } else if (actives[currentTab].length > 0) { removeClass(actives[currentTab][0], "highlighted"); } @@ -1492,10 +1502,9 @@ function getSearchElement() { "
" + ret_others[0] + ret_in_args[0] + ret_returned[0] + "
"; - addClass(main, "hidden"); var search = getSearchElement(); - removeClass(search, "hidden"); search.innerHTML = output; + showSearchResults(search); var tds = search.getElementsByTagName("td"); var td_width = 0; if (tds.length > 0) { @@ -1700,13 +1709,7 @@ function getSearchElement() { if (browserSupportsHistoryApi()) { history.replaceState("", window.currentCrate + " - Rust", "?search="); } - if (hasClass(main, "content")) { - removeClass(main, "hidden"); - } - var search_c = getSearchElement(); - if (hasClass(search_c, "content")) { - addClass(search_c, "hidden"); - } + hideSearchResults(); } else { searchTimeout = setTimeout(search, 500); } @@ -1742,19 +1745,8 @@ function getSearchElement() { // Store the previous so we can revert back to it later. var previousTitle = document.title; - window.onpopstate = function(e) { + window.addEventListener("popstate", function(e) { var params = getQueryStringParams(); - // When browsing back from search results the main page - // visibility must be reset. - if (!params.search) { - if (hasClass(main, "content")) { - removeClass(main, "hidden"); - } - var search_c = getSearchElement(); - if (hasClass(search_c, "content")) { - addClass(search_c, "hidden"); - } - } // Revert to the previous title manually since the History // API ignores the title parameter. document.title = previousTitle; @@ -1766,18 +1758,21 @@ function getSearchElement() { // perform the search. This will empty the bar if there's // nothing there, which lets you really go back to a // previous state with nothing in the bar. - if (params.search) { + if (params.search && params.search.length > 0) { search_input.value = params.search; + // Some browsers fire "onpopstate" for every page load + // (Chrome), while others fire the event only when actually + // popping a state (Firefox), which is why search() is + // called both here and at the end of the startSearch() + // function. + search(e); } else { search_input.value = ""; + // When browsing back from search results the main page + // visibility must be reset. + hideSearchResults(); } - // Some browsers fire "onpopstate" for every page load - // (Chrome), while others fire the event only when actually - // popping a state (Firefox), which is why search() is - // called both here and at the end of the startSearch() - // function. - search(); - }; + }); } search(); } @@ -2523,9 +2518,9 @@ function getSearchElement() { } function putBackSearch(search_input) { - if (search_input.value !== "") { - addClass(main, "hidden"); - removeClass(getSearchElement(), "hidden"); + var search = getSearchElement(); + if (search_input.value !== "" && hasClass(search, "hidden")) { + showSearchResults(search); if (browserSupportsHistoryApi()) { history.replaceState(search_input.value, "", @@ -2542,10 +2537,9 @@ function getSearchElement() { var params = getQueryStringParams(); if (params && params.search) { - addClass(main, "hidden"); var search = getSearchElement(); - removeClass(search, "hidden"); search.innerHTML = "<h3 style=\"text-align: center;\">Loading search results...</h3>"; + showSearchResults(search); } var sidebar_menu = document.getElementsByClassName("sidebar-menu")[0]; From 71ff18fb8965712cc0a35a9d968cdc41c6561386 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez <guillaume1.gomez@gmail.com> Date: Sun, 22 Dec 2019 15:42:29 +0100 Subject: [PATCH 04/14] Fix invalid results showing back --- src/librustdoc/html/static/main.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index d0c44cd40b21a..8ccb74d6f15d3 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1722,6 +1722,10 @@ function getSearchElement() { search(); }; search_input.onchange = function(e) { + if (e.target !== document.activeElement) { + // To prevent doing anything when it's from a blur event. + return; + } // Do NOT e.preventDefault() here. It will prevent pasting. clearTimeout(searchTimeout); // zero-timeout necessary here because at the time of event handler execution the From 101dd7bad9432730fa2f625ae43afcc2929457d4 Mon Sep 17 00:00:00 2001 From: Yuki Okushi <huyuumi.dev@gmail.com> Date: Mon, 23 Dec 2019 05:13:46 +0900 Subject: [PATCH 05/14] Use `is_none` instead of `if let` --- src/librustc/traits/error_reporting.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index b299fd6117e41..aabf1d625a8a8 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -2289,7 +2289,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { let span = self.tcx.def_span(generator_did); // Do not ICE on closure typeck (#66868). - if let None = self.tcx.hir().as_local_hir_id(generator_did) { + if self.tcx.hir().as_local_hir_id(generator_did).is_none() { return false; } From 7c485ccfad968ba6fe226a59f9337adbc158dd6b Mon Sep 17 00:00:00 2001 From: Yuki Okushi <huyuumi.dev@gmail.com> Date: Mon, 23 Dec 2019 07:35:18 +0900 Subject: [PATCH 06/14] Add test for issue-61747 --- src/test/ui/const-generics/issues/issue-61747.rs | 16 ++++++++++++++++ .../ui/const-generics/issues/issue-61747.stderr | 8 ++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/test/ui/const-generics/issues/issue-61747.rs create mode 100644 src/test/ui/const-generics/issues/issue-61747.stderr diff --git a/src/test/ui/const-generics/issues/issue-61747.rs b/src/test/ui/const-generics/issues/issue-61747.rs new file mode 100644 index 0000000000000..cab87200b5022 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-61747.rs @@ -0,0 +1,16 @@ +// check-pass + +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +struct Const<const N: usize>; + +impl<const C: usize> Const<{C}> { + fn successor() -> Const<{C + 1}> { + Const + } +} + +fn main() { + Const::<1>::successor(); +} diff --git a/src/test/ui/const-generics/issues/issue-61747.stderr b/src/test/ui/const-generics/issues/issue-61747.stderr new file mode 100644 index 0000000000000..ccf36a7f805ec --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-61747.stderr @@ -0,0 +1,8 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/issue-61747.rs:3:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + From 96253c2d15d5f9ed1e6e63a97ac5f705c8fc4421 Mon Sep 17 00:00:00 2001 From: Yuki Okushi <huyuumi.dev@gmail.com> Date: Mon, 23 Dec 2019 07:36:02 +0900 Subject: [PATCH 07/14] Add test for issue-66205 --- src/test/ui/const-generics/issues/issue-66205.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/test/ui/const-generics/issues/issue-66205.rs diff --git a/src/test/ui/const-generics/issues/issue-66205.rs b/src/test/ui/const-generics/issues/issue-66205.rs new file mode 100644 index 0000000000000..2e47b4d1882f2 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-66205.rs @@ -0,0 +1,10 @@ +// check-pass + +#![allow(incomplete_features, dead_code, unconditional_recursion)] +#![feature(const_generics)] + +fn fact<const N: usize>() { + fact::<{ N - 1 }>(); +} + +fn main() {} From 6ec3a63bb287d11849b2fc3546793437bbbbd865 Mon Sep 17 00:00:00 2001 From: Yuki Okushi <huyuumi.dev@gmail.com> Date: Mon, 23 Dec 2019 07:36:30 +0900 Subject: [PATCH 08/14] Add test for issue-66270 --- .../issue-66270-pat-struct-parser-recovery.rs | 14 ++++++++++++++ .../issue-66270-pat-struct-parser-recovery.stderr | 8 ++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/test/ui/pattern/issue-66270-pat-struct-parser-recovery.rs create mode 100644 src/test/ui/pattern/issue-66270-pat-struct-parser-recovery.stderr diff --git a/src/test/ui/pattern/issue-66270-pat-struct-parser-recovery.rs b/src/test/ui/pattern/issue-66270-pat-struct-parser-recovery.rs new file mode 100644 index 0000000000000..48a8e04829a0a --- /dev/null +++ b/src/test/ui/pattern/issue-66270-pat-struct-parser-recovery.rs @@ -0,0 +1,14 @@ +// Regression test for #66270, fixed by #66246 + +struct Bug { + incorrect_field: 0, + //~^ ERROR expected type +} + +struct Empty {} + +fn main() { + let Bug { + any_field: Empty {}, + } = Bug {}; +} diff --git a/src/test/ui/pattern/issue-66270-pat-struct-parser-recovery.stderr b/src/test/ui/pattern/issue-66270-pat-struct-parser-recovery.stderr new file mode 100644 index 0000000000000..fef0f3c0e06ef --- /dev/null +++ b/src/test/ui/pattern/issue-66270-pat-struct-parser-recovery.stderr @@ -0,0 +1,8 @@ +error: expected type, found `0` + --> $DIR/issue-66270-pat-struct-parser-recovery.rs:4:22 + | +LL | incorrect_field: 0, + | ^ expected type + +error: aborting due to previous error + From 3265dc7c29dbcfe7f2dbff26842fd4b8d9fd04d0 Mon Sep 17 00:00:00 2001 From: Yuki Okushi <huyuumi.dev@gmail.com> Date: Mon, 23 Dec 2019 07:36:59 +0900 Subject: [PATCH 09/14] Add test for issue-66868 --- .../auxiliary/issue_66868_closure_typeck.rs | 25 +++++++++++++++++++ .../ui/typeck/issue-66868-closure-typeck.rs | 15 +++++++++++ .../typeck/issue-66868-closure-typeck.stderr | 22 ++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 src/test/ui/typeck/auxiliary/issue_66868_closure_typeck.rs create mode 100644 src/test/ui/typeck/issue-66868-closure-typeck.rs create mode 100644 src/test/ui/typeck/issue-66868-closure-typeck.stderr diff --git a/src/test/ui/typeck/auxiliary/issue_66868_closure_typeck.rs b/src/test/ui/typeck/auxiliary/issue_66868_closure_typeck.rs new file mode 100644 index 0000000000000..bbeb7d431f6d6 --- /dev/null +++ b/src/test/ui/typeck/auxiliary/issue_66868_closure_typeck.rs @@ -0,0 +1,25 @@ +// edition:2018 + +#![crate_type = "lib"] + +use std::{ + future::Future, + pin::Pin, + sync::RwLock, + task::{Context, Poll}, +}; + +struct S {} + +impl Future for S { + type Output = (); + fn poll(self: Pin<&mut Self>, _: &mut Context) -> Poll<Self::Output> { + Poll::Pending + } +} + +pub async fn f() { + let fo = RwLock::new(S {}); + + (&mut *fo.write().unwrap()).await; +} diff --git a/src/test/ui/typeck/issue-66868-closure-typeck.rs b/src/test/ui/typeck/issue-66868-closure-typeck.rs new file mode 100644 index 0000000000000..322b5c82ec07d --- /dev/null +++ b/src/test/ui/typeck/issue-66868-closure-typeck.rs @@ -0,0 +1,15 @@ +// Fixed by #67071 +// aux-build: issue_66868_closure_typeck.rs +// edition:2018 + +extern crate issue_66868_closure_typeck; + +pub fn g<T>(task: T) +where + T: Send, +{ +} + +fn main() { + g(issue_66868_closure_typeck::f()); //~ ERROR: cannot be sent between threads safely +} diff --git a/src/test/ui/typeck/issue-66868-closure-typeck.stderr b/src/test/ui/typeck/issue-66868-closure-typeck.stderr new file mode 100644 index 0000000000000..d9f4b6511d51b --- /dev/null +++ b/src/test/ui/typeck/issue-66868-closure-typeck.stderr @@ -0,0 +1,22 @@ +error[E0277]: `std::sync::RwLockWriteGuard<'_, issue_66868_closure_typeck::S>` cannot be sent between threads safely + --> $DIR/issue-66868-closure-typeck.rs:14:5 + | +LL | pub fn g<T>(task: T) + | - +LL | where +LL | T: Send, + | ---- required by this bound in `g` +... +LL | g(issue_66868_closure_typeck::f()); + | ^ `std::sync::RwLockWriteGuard<'_, issue_66868_closure_typeck::S>` cannot be sent between threads safely + | + = help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::sync::RwLockWriteGuard<'_, issue_66868_closure_typeck::S>` + = note: required because it appears within the type `for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5> {std::sync::RwLock<issue_66868_closure_typeck::S>, &'r std::sync::RwLock<issue_66868_closure_typeck::S>, std::sync::RwLock<issue_66868_closure_typeck::S>, std::result::Result<std::sync::RwLockWriteGuard<'s, issue_66868_closure_typeck::S>, std::sync::PoisonError<std::sync::RwLockWriteGuard<'t0, issue_66868_closure_typeck::S>>>, &'t1 mut std::sync::RwLockWriteGuard<'t2, issue_66868_closure_typeck::S>, std::sync::RwLockWriteGuard<'t3, issue_66868_closure_typeck::S>, issue_66868_closure_typeck::S, &'t4 mut issue_66868_closure_typeck::S, &'t5 mut issue_66868_closure_typeck::S, ()}` + = note: required because it appears within the type `[static generator@DefId(14:16 ~ issue_66868_closure_typeck[8787]::f[0]::{{closure}}[0]) for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5> {std::sync::RwLock<issue_66868_closure_typeck::S>, &'r std::sync::RwLock<issue_66868_closure_typeck::S>, std::sync::RwLock<issue_66868_closure_typeck::S>, std::result::Result<std::sync::RwLockWriteGuard<'s, issue_66868_closure_typeck::S>, std::sync::PoisonError<std::sync::RwLockWriteGuard<'t0, issue_66868_closure_typeck::S>>>, &'t1 mut std::sync::RwLockWriteGuard<'t2, issue_66868_closure_typeck::S>, std::sync::RwLockWriteGuard<'t3, issue_66868_closure_typeck::S>, issue_66868_closure_typeck::S, &'t4 mut issue_66868_closure_typeck::S, &'t5 mut issue_66868_closure_typeck::S, ()}]` + = note: required because it appears within the type `std::future::GenFuture<[static generator@DefId(14:16 ~ issue_66868_closure_typeck[8787]::f[0]::{{closure}}[0]) for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5> {std::sync::RwLock<issue_66868_closure_typeck::S>, &'r std::sync::RwLock<issue_66868_closure_typeck::S>, std::sync::RwLock<issue_66868_closure_typeck::S>, std::result::Result<std::sync::RwLockWriteGuard<'s, issue_66868_closure_typeck::S>, std::sync::PoisonError<std::sync::RwLockWriteGuard<'t0, issue_66868_closure_typeck::S>>>, &'t1 mut std::sync::RwLockWriteGuard<'t2, issue_66868_closure_typeck::S>, std::sync::RwLockWriteGuard<'t3, issue_66868_closure_typeck::S>, issue_66868_closure_typeck::S, &'t4 mut issue_66868_closure_typeck::S, &'t5 mut issue_66868_closure_typeck::S, ()}]>` + = note: required because it appears within the type `impl std::future::Future` + = note: required because it appears within the type `impl std::future::Future` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. From 40bec994122df5e020525abda543f5476e035b8f Mon Sep 17 00:00:00 2001 From: Yuki Okushi <huyuumi.dev@gmail.com> Date: Mon, 23 Dec 2019 07:37:16 +0900 Subject: [PATCH 10/14] Add test for issue-67424 --- .../generic-associated-types/issue-67424.rs | 13 ++++++++++++ .../issue-67424.stderr | 20 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/test/ui/generic-associated-types/issue-67424.rs create mode 100644 src/test/ui/generic-associated-types/issue-67424.stderr diff --git a/src/test/ui/generic-associated-types/issue-67424.rs b/src/test/ui/generic-associated-types/issue-67424.rs new file mode 100644 index 0000000000000..9b616b8abc2ee --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-67424.rs @@ -0,0 +1,13 @@ +// Fixed by #67160 + +trait Trait1 { + type A; +} + +trait Trait2 { + type Type1<B>: Trait1<A=B>; + //~^ ERROR: generic associated types are unstable + //~| ERROR: type-generic associated types are not yet implemented +} + +fn main() {} diff --git a/src/test/ui/generic-associated-types/issue-67424.stderr b/src/test/ui/generic-associated-types/issue-67424.stderr new file mode 100644 index 0000000000000..59ff8ac0a3a70 --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-67424.stderr @@ -0,0 +1,20 @@ +error[E0658]: generic associated types are unstable + --> $DIR/issue-67424.rs:8:5 + | +LL | type Type1<B>: Trait1<A=B>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/44265 + = help: add `#![feature(generic_associated_types)]` to the crate attributes to enable + +error: type-generic associated types are not yet implemented + --> $DIR/issue-67424.rs:8:5 + | +LL | type Type1<B>: Trait1<A=B>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/44265 + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. From e55ed792f134f45b5b9d6f445ad817715f336c96 Mon Sep 17 00:00:00 2001 From: Yuki Okushi <huyuumi.dev@gmail.com> Date: Mon, 23 Dec 2019 08:24:11 +0900 Subject: [PATCH 11/14] Apply suggestion from Centril Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com> --- src/test/ui/const-generics/issues/issue-61747.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/ui/const-generics/issues/issue-61747.rs b/src/test/ui/const-generics/issues/issue-61747.rs index cab87200b5022..64674bb894e1f 100644 --- a/src/test/ui/const-generics/issues/issue-61747.rs +++ b/src/test/ui/const-generics/issues/issue-61747.rs @@ -12,5 +12,5 @@ impl<const C: usize> Const<{C}> { } fn main() { - Const::<1>::successor(); + let _x: Const::<2> = Const::<1>::successor(); } From 056dff5748270249d81a03b355bc7ddd8da7f900 Mon Sep 17 00:00:00 2001 From: Oliver Scherer <github35764891676564198441@oli-obk.de> Date: Mon, 23 Dec 2019 01:24:11 +0100 Subject: [PATCH 12/14] Fix ICE in mir interpretation --- src/librustc_mir/interpret/place.rs | 3 ++- src/test/ui/consts/const_prop_slice_pat_ice.rs | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/consts/const_prop_slice_pat_ice.rs diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index 8923b167fdee8..6e7fa302abcbb 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -530,11 +530,12 @@ where // This can only be reached in ConstProp and non-rustc-MIR. throw_ub!(BoundsCheckFailed { len: min_length as u64, index: n as u64 }); } - assert!(offset < min_length); let index = if from_end { + assert!(offset - 1 < min_length); n - u64::from(offset) } else { + assert!(offset < min_length); u64::from(offset) }; diff --git a/src/test/ui/consts/const_prop_slice_pat_ice.rs b/src/test/ui/consts/const_prop_slice_pat_ice.rs new file mode 100644 index 0000000000000..5fec36e44bd8c --- /dev/null +++ b/src/test/ui/consts/const_prop_slice_pat_ice.rs @@ -0,0 +1,9 @@ +// check-pass +#![feature(slice_patterns)] + +fn main() { + match &[0, 1] as &[i32] { + [a @ .., x] => {} + &[] => {} + } +} From ac05c84ad705ec7983c4eae72ba0817bc48699d8 Mon Sep 17 00:00:00 2001 From: Yuki Okushi <huyuumi.dev@gmail.com> Date: Mon, 23 Dec 2019 10:18:18 +0900 Subject: [PATCH 13/14] Bless test --- src/test/ui/typeck/issue-66868-closure-typeck.stderr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/ui/typeck/issue-66868-closure-typeck.stderr b/src/test/ui/typeck/issue-66868-closure-typeck.stderr index d9f4b6511d51b..42322df2eafa8 100644 --- a/src/test/ui/typeck/issue-66868-closure-typeck.stderr +++ b/src/test/ui/typeck/issue-66868-closure-typeck.stderr @@ -12,8 +12,8 @@ LL | g(issue_66868_closure_typeck::f()); | = help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::sync::RwLockWriteGuard<'_, issue_66868_closure_typeck::S>` = note: required because it appears within the type `for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5> {std::sync::RwLock<issue_66868_closure_typeck::S>, &'r std::sync::RwLock<issue_66868_closure_typeck::S>, std::sync::RwLock<issue_66868_closure_typeck::S>, std::result::Result<std::sync::RwLockWriteGuard<'s, issue_66868_closure_typeck::S>, std::sync::PoisonError<std::sync::RwLockWriteGuard<'t0, issue_66868_closure_typeck::S>>>, &'t1 mut std::sync::RwLockWriteGuard<'t2, issue_66868_closure_typeck::S>, std::sync::RwLockWriteGuard<'t3, issue_66868_closure_typeck::S>, issue_66868_closure_typeck::S, &'t4 mut issue_66868_closure_typeck::S, &'t5 mut issue_66868_closure_typeck::S, ()}` - = note: required because it appears within the type `[static generator@DefId(14:16 ~ issue_66868_closure_typeck[8787]::f[0]::{{closure}}[0]) for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5> {std::sync::RwLock<issue_66868_closure_typeck::S>, &'r std::sync::RwLock<issue_66868_closure_typeck::S>, std::sync::RwLock<issue_66868_closure_typeck::S>, std::result::Result<std::sync::RwLockWriteGuard<'s, issue_66868_closure_typeck::S>, std::sync::PoisonError<std::sync::RwLockWriteGuard<'t0, issue_66868_closure_typeck::S>>>, &'t1 mut std::sync::RwLockWriteGuard<'t2, issue_66868_closure_typeck::S>, std::sync::RwLockWriteGuard<'t3, issue_66868_closure_typeck::S>, issue_66868_closure_typeck::S, &'t4 mut issue_66868_closure_typeck::S, &'t5 mut issue_66868_closure_typeck::S, ()}]` - = note: required because it appears within the type `std::future::GenFuture<[static generator@DefId(14:16 ~ issue_66868_closure_typeck[8787]::f[0]::{{closure}}[0]) for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5> {std::sync::RwLock<issue_66868_closure_typeck::S>, &'r std::sync::RwLock<issue_66868_closure_typeck::S>, std::sync::RwLock<issue_66868_closure_typeck::S>, std::result::Result<std::sync::RwLockWriteGuard<'s, issue_66868_closure_typeck::S>, std::sync::PoisonError<std::sync::RwLockWriteGuard<'t0, issue_66868_closure_typeck::S>>>, &'t1 mut std::sync::RwLockWriteGuard<'t2, issue_66868_closure_typeck::S>, std::sync::RwLockWriteGuard<'t3, issue_66868_closure_typeck::S>, issue_66868_closure_typeck::S, &'t4 mut issue_66868_closure_typeck::S, &'t5 mut issue_66868_closure_typeck::S, ()}]>` + = note: required because it appears within the type `[static generator@DefId(15:16 ~ issue_66868_closure_typeck[8787]::f[0]::{{closure}}[0]) for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5> {std::sync::RwLock<issue_66868_closure_typeck::S>, &'r std::sync::RwLock<issue_66868_closure_typeck::S>, std::sync::RwLock<issue_66868_closure_typeck::S>, std::result::Result<std::sync::RwLockWriteGuard<'s, issue_66868_closure_typeck::S>, std::sync::PoisonError<std::sync::RwLockWriteGuard<'t0, issue_66868_closure_typeck::S>>>, &'t1 mut std::sync::RwLockWriteGuard<'t2, issue_66868_closure_typeck::S>, std::sync::RwLockWriteGuard<'t3, issue_66868_closure_typeck::S>, issue_66868_closure_typeck::S, &'t4 mut issue_66868_closure_typeck::S, &'t5 mut issue_66868_closure_typeck::S, ()}]` + = note: required because it appears within the type `std::future::GenFuture<[static generator@DefId(15:16 ~ issue_66868_closure_typeck[8787]::f[0]::{{closure}}[0]) for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5> {std::sync::RwLock<issue_66868_closure_typeck::S>, &'r std::sync::RwLock<issue_66868_closure_typeck::S>, std::sync::RwLock<issue_66868_closure_typeck::S>, std::result::Result<std::sync::RwLockWriteGuard<'s, issue_66868_closure_typeck::S>, std::sync::PoisonError<std::sync::RwLockWriteGuard<'t0, issue_66868_closure_typeck::S>>>, &'t1 mut std::sync::RwLockWriteGuard<'t2, issue_66868_closure_typeck::S>, std::sync::RwLockWriteGuard<'t3, issue_66868_closure_typeck::S>, issue_66868_closure_typeck::S, &'t4 mut issue_66868_closure_typeck::S, &'t5 mut issue_66868_closure_typeck::S, ()}]>` = note: required because it appears within the type `impl std::future::Future` = note: required because it appears within the type `impl std::future::Future` From 5b8df34203d1d6f308da7413c9f27b0b0887b438 Mon Sep 17 00:00:00 2001 From: Oliver Scherer <github35764891676564198441@oli-obk.de> Date: Mon, 23 Dec 2019 11:27:34 +0100 Subject: [PATCH 14/14] Update src/librustc_mir/interpret/place.rs Co-Authored-By: Ralf Jung <post@ralfj.de> --- src/librustc_mir/interpret/place.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index 6e7fa302abcbb..37540d8a3ccb1 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -532,7 +532,7 @@ where } let index = if from_end { - assert!(offset - 1 < min_length); + assert!(0 < offset && offset - 1 < min_length); n - u64::from(offset) } else { assert!(offset < min_length);