Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 5 pull requests #85518

Merged
merged 11 commits into from
May 20, 2021
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -509,44 +509,23 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
}

AngleBrackets::Available => {
// angle brackets exist, so we insert missing arguments after the existing args

assert!(!self.gen_args.args.is_empty());

if self.num_provided_lifetime_args() > 0 {
let last_lt_arg_span = self.gen_args.args
[self.num_provided_lifetime_args() - 1]
.span()
.shrink_to_hi();
let source_map = self.tcx.sess.source_map();

if let Ok(last_gen_arg) = source_map.span_to_snippet(last_lt_arg_span) {
let sugg = format!("{}, {}", last_gen_arg, suggested_args);

err.span_suggestion_verbose(
last_lt_arg_span,
&msg,
sugg,
Applicability::HasPlaceholders,
);
}
let (sugg_span, is_first) = if self.num_provided_lifetime_args() == 0 {
(self.gen_args.span().unwrap().shrink_to_lo(), true)
} else {
// Non-lifetime arguments included in `gen_args` -> insert missing lifetimes before
// existing arguments
let first_arg_span = self.gen_args.args[0].span().shrink_to_lo();
let source_map = self.tcx.sess.source_map();

if let Ok(first_gen_arg) = source_map.span_to_snippet(first_arg_span) {
let sugg = format!("{}, {}", suggested_args, first_gen_arg);

err.span_suggestion_verbose(
first_arg_span,
&msg,
sugg,
Applicability::HasPlaceholders,
);
}
}
let last_lt = &self.gen_args.args[self.num_provided_lifetime_args() - 1];
(last_lt.span().shrink_to_hi(), false)
};
let has_non_lt_args = self.num_provided_type_or_const_args() != 0;
let has_bindings = !self.gen_args.bindings.is_empty();

let sugg_prefix = if is_first { "" } else { ", " };
let sugg_suffix =
if is_first && (has_non_lt_args || has_bindings) { ", " } else { "" };

let sugg = format!("{}{}{}", sugg_prefix, suggested_args, sugg_suffix);
debug!("sugg: {:?}", sugg);

err.span_suggestion_verbose(sugg_span, &msg, sugg, Applicability::HasPlaceholders);
}
AngleBrackets::Implied => {
// We never encounter missing lifetimes in situations in which lifetimes are elided
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use crate::error::Error;
use crate::fmt::{self, Write};
use crate::io;
use crate::mem;
use crate::memchr;
use crate::num::NonZeroU8;
use crate::ops;
use crate::os::raw::c_char;
Expand All @@ -20,6 +19,7 @@ use crate::slice;
use crate::str::{self, Utf8Error};
use crate::sync::Arc;
use crate::sys;
use crate::sys_common::memchr;

/// A type representing an owned, C-compatible, nul-terminated string with no nul bytes in the
/// middle.
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/io/buffered/linewritershim.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::io::{self, BufWriter, IoSlice, Write};
use crate::memchr;
use crate::sys_common::memchr;

/// Private helper struct for implementing the line-buffered writing logic.
/// This shim temporarily wraps a BufWriter, and uses its internals to
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,12 @@ mod tests;

use crate::cmp;
use crate::fmt;
use crate::memchr;
use crate::ops::{Deref, DerefMut};
use crate::ptr;
use crate::slice;
use crate::str;
use crate::sys;
use crate::sys_common::memchr;

#[stable(feature = "rust1", since = "1.0.0")]
pub use self::buffered::IntoInnerError;
Expand Down
1 change: 0 additions & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,6 @@ mod sys;
pub mod alloc;

// Private support modules
mod memchr;
mod panicking;

// The runtime entry point and a few unstable public functions used by the
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/hermit/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use crate::ffi::{CStr, OsStr, OsString};
use crate::fmt;
use crate::io;
use crate::marker::PhantomData;
use crate::memchr;
use crate::path::{self, PathBuf};
use crate::str;
use crate::sync::Mutex;
use crate::sys::hermit::abi;
use crate::sys::memchr;
use crate::sys::unsupported;
use crate::sys_common::os_str_bytes::*;
use crate::vec;
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ use crate::fmt;
use crate::io;
use crate::iter;
use crate::mem;
use crate::memchr;
use crate::path::{self, PathBuf};
use crate::ptr;
use crate::slice;
use crate::str;
use crate::sys::cvt;
use crate::sys::fd;
use crate::sys::memchr;
use crate::sys::rwlock::{RWLockReadGuard, StaticRWLock};
use crate::sys_common::mutex::{StaticMutex, StaticMutexGuard};
use crate::vec;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Original implementation taken from rust-memchr.
// Copyright 2015 Andrew Gallant, bluss and Nicolas Koch

use crate::sys::memchr as sys;

#[cfg(test)]
mod tests;

Expand All @@ -25,7 +27,7 @@ mod tests;
/// ```
#[inline]
pub fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> {
crate::sys::memchr::memchr(needle, haystack)
sys::memchr(needle, haystack)
}

/// A safe interface to `memrchr`.
Expand All @@ -45,5 +47,5 @@ pub fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> {
/// ```
#[inline]
pub fn memrchr(needle: u8, haystack: &[u8]) -> Option<usize> {
crate::sys::memchr::memrchr(needle, haystack)
sys::memrchr(needle, haystack)
}
1 change: 1 addition & 0 deletions library/std/src/sys_common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub mod bytestring;
pub mod condvar;
pub mod fs;
pub mod io;
pub mod memchr;
pub mod mutex;
// `doc` is required because `sys/mod.rs` imports `unix/ext/mod.rs` on Windows
// when generating documentation.
Expand Down
5 changes: 4 additions & 1 deletion src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ impl Step for ToolBuild {
let is_optional_tool = self.is_optional_tool;

match self.mode {
Mode::ToolRustc => builder.ensure(compile::Rustc { compiler, target }),
Mode::ToolRustc => {
builder.ensure(compile::Std { compiler, target: compiler.host });
builder.ensure(compile::Rustc { compiler, target });
}
Mode::ToolStd => builder.ensure(compile::Std { compiler, target }),
Mode::ToolBootstrap => {} // uses downloaded stage0 compiler libs
_ => panic!("unexpected Mode for tool build"),
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function hideThemeButtonState() {
outputElement: function() {
return document.getElementById("search");
},
title: null,
title: document.title,
titleBeforeSearch: document.title,
timeout: null,
// On the search screen, so you remain on the last tab you opened.
Expand Down
13 changes: 10 additions & 3 deletions src/test/rustdoc-gui/escape-key.goml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ assert: ("#help", "class", "hidden")
assert: ("#search", "class", "content")
assert: ("#main", "class", "content hidden")

// FIXME: Once https://github.com/rust-lang/rust/pull/84462 is merged, add check to ensure
// that Escape hides the search results when a result is focused.
// press-key: "ArrowDown"
// Check that Escape hides the search results when a search result is focused.
focus: ".search-input"
assert: ".search-input:focus"
press-key: "ArrowDown"
assert-false: ".search-input:focus"
assert: "#results a:focus"
press-key: "Escape"
assert: ("#help", "class", "hidden")
assert: ("#search", "class", "content hidden")
assert: ("#main", "class", "content")
10 changes: 10 additions & 0 deletions src/test/ui/suggestions/issue-85347.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#![allow(incomplete_features)]
#![feature(generic_associated_types)]
use std::ops::Deref;
trait Foo {
type Bar<'a>: Deref<Target = <Self>::Bar<Target = Self>>;
//~^ ERROR this associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
//~| HELP add missing
}

fn main() {}
19 changes: 19 additions & 0 deletions src/test/ui/suggestions/issue-85347.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0107]: this associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
--> $DIR/issue-85347.rs:5:42
|
LL | type Bar<'a>: Deref<Target = <Self>::Bar<Target = Self>>;
| ^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-85347.rs:5:10
|
LL | type Bar<'a>: Deref<Target = <Self>::Bar<Target = Self>>;
| ^^^ --
help: add missing lifetime argument
|
LL | type Bar<'a>: Deref<Target = <Self>::Bar<'a, Target = Self>>;
| ^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0107`.