Skip to content

Commit

Permalink
Auto merge of #72831 - Dylan-DPC:rollup-6rxjwt9, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Rollup of 5 pull requests

Successful merges:

 - #72691 (Fix escape key handling)
 - #72807 (Avoid setting wrong obligation cause span of associated type mismatch)
 - #72812 (Miri tests: skip parts of test_char_range)
 - #72829 (Clarify terms in doc comments)
 - #72830 (Fix release notes for niche initialization change)

Failed merges:

r? @ghost
  • Loading branch information
bors committed May 31, 2020
2 parents 5fd2f06 + 76e0ecc commit 0d93d3f
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 29 deletions.
4 changes: 2 additions & 2 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ Compatibility Notes
source file rather than the previous format of `<NAME macros>`.][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
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2173,7 +2173,7 @@ impl<T> [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
Expand Down Expand Up @@ -2244,7 +2244,7 @@ impl<T> [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
///
Expand Down
7 changes: 5 additions & 2 deletions src/libcore/tests/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down
31 changes: 12 additions & 19 deletions src/librustc_trait_selection/traits/wf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down
16 changes: 12 additions & 4 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ function defocusSearchBar() {

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.
//
Expand All @@ -101,6 +102,13 @@ function defocusSearchBar() {

var titleBeforeSearch = document.title;

function clearInputTimeout() {
if (searchTimeout !== null) {
clearTimeout(searchTimeout);
searchTimeout = null;
}
}

function getPageId() {
var id = document.location.href.split("#")[1];
if (id) {
Expand Down Expand Up @@ -355,6 +363,7 @@ function defocusSearchBar() {
if (hasClass(help, "hidden") === false) {
displayHelp(false, ev, help);
} else if (hasClass(search, "hidden") === false) {
clearInputTimeout();
ev.preventDefault();
hideSearchResults(search);
document.title = titleBeforeSearch;
Expand Down Expand Up @@ -1810,9 +1819,8 @@ function defocusSearchBar() {
}

function startSearch() {
var searchTimeout;
var callback = function() {
clearTimeout(searchTimeout);
clearInputTimeout();
if (search_input.value.length === 0) {
if (browserSupportsHistoryApi()) {
history.replaceState("", window.currentCrate + " - Rust", "?search=");
Expand All @@ -1826,7 +1834,7 @@ function defocusSearchBar() {
search_input.oninput = callback;
document.getElementsByClassName("search-form")[0].onsubmit = function(e) {
e.preventDefault();
clearTimeout(searchTimeout);
clearInputTimeout();
search();
};
search_input.onchange = function(e) {
Expand All @@ -1835,7 +1843,7 @@ function defocusSearchBar() {
return;
}
// Do NOT e.preventDefault() here. It will prevent pasting.
clearTimeout(searchTimeout);
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.
Expand Down
20 changes: 20 additions & 0 deletions src/test/ui/associated-types/issue-72806.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
trait Bar {
type Ok;
type Sibling: Bar2<Ok=char>;
}
trait Bar2 {
type Ok;
}

struct Foo;
struct Foo2;

impl Bar for Foo { //~ ERROR type mismatch resolving `<Foo2 as Bar2>::Ok == char`
type Ok = ();
type Sibling = Foo2;
}
impl Bar2 for Foo2 {
type Ok = u32;
}

fn main() {}
9 changes: 9 additions & 0 deletions src/test/ui/associated-types/issue-72806.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0271]: type mismatch resolving `<Foo2 as Bar2>::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`.

0 comments on commit 0d93d3f

Please sign in to comment.