Auto merge of #68201 - JohnTitor:rollup-26e39gu, r=JohnTitor
Rollup of 10 pull requests Successful merges: - #67854 (Use `report_in_external_macro` for internal lints) - #67989 (rustdoc: Don't allow `#![feature(...)]` on stable or beta) - #68036 (libterm: parse extended terminfo format) - #68127 (Clarify the relationship between `extended` and `tools` in `config.toml`) - #68143 (Forbid elided lifetimes within const generic parameter types) - #68150 (Document behavior of set_nonblocking on UnixListener) - #68166 (rustdoc: HTML escape arrows on help popup) - #68176 (Clean up err codes) - #68179 (Remove unneeded scope) - #68188 (Tweak assertion note in format check) Failed merges: r? @ghost
This commit is contained in:
commit
c06e4aca19
17 changed files with 182 additions and 75 deletions
|
|
@ -181,21 +181,23 @@
|
|||
# Indicate whether the vendored sources are used for Rust dependencies or not
|
||||
#vendor = false
|
||||
|
||||
# Typically the build system will build the rust compiler twice. The second
|
||||
# Typically the build system will build the Rust compiler twice. The second
|
||||
# compiler, however, will simply use its own libraries to link against. If you
|
||||
# would rather to perform a full bootstrap, compiling the compiler three times,
|
||||
# then you can set this option to true. You shouldn't ever need to set this
|
||||
# option to true.
|
||||
#full-bootstrap = false
|
||||
|
||||
# Enable a build of the extended rust tool set which is not only the compiler
|
||||
# Enable a build of the extended Rust tool set which is not only the compiler
|
||||
# but also tools such as Cargo. This will also produce "combined installers"
|
||||
# which are used to install Rust and Cargo together. This is disabled by
|
||||
# default.
|
||||
# default. The `tools` option (immediately below) specifies which tools should
|
||||
# be built if `extended = true`.
|
||||
#extended = false
|
||||
|
||||
# Installs chosen set of extended tools if enabled. By default builds all.
|
||||
# If chosen tool failed to build the installation fails.
|
||||
# Installs chosen set of extended tools if `extended = true`. By default builds all.
|
||||
# If chosen tool failed to build the installation fails. If `extended = false`, this
|
||||
# option is ignored.
|
||||
#tools = ["cargo", "rls", "clippy", "rustfmt", "analysis", "src"]
|
||||
|
||||
# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose
|
||||
|
|
|
|||
|
|
@ -20,7 +20,15 @@ fn rustfmt(src: &Path, rustfmt: &Path, path: &Path, check: bool) {
|
|||
cmd.arg(&path);
|
||||
let cmd_debug = format!("{:?}", cmd);
|
||||
let status = cmd.status().expect("executing rustfmt");
|
||||
assert!(status.success(), "running {} successful", cmd_debug);
|
||||
if !status.success() {
|
||||
eprintln!(
|
||||
"Running `{}` failed.\nIf you're running `tidy`, \
|
||||
try again with `--bless` flag. Or, you just want to format \
|
||||
code, run `./x.py fmt` instead.",
|
||||
cmd_debug,
|
||||
);
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
|
|
|
|||
|
|
@ -2120,12 +2120,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
|
||||
(hir::ParamName::Plain(param.ident), kind)
|
||||
}
|
||||
GenericParamKind::Const { ref ty } => (
|
||||
hir::ParamName::Plain(param.ident),
|
||||
hir::GenericParamKind::Const {
|
||||
ty: self.lower_ty(&ty, ImplTraitContext::disallowed()),
|
||||
},
|
||||
),
|
||||
GenericParamKind::Const { ref ty } => {
|
||||
let ty = self
|
||||
.with_anonymous_lifetime_mode(AnonymousLifetimeMode::ReportError, |this| {
|
||||
this.lower_ty(&ty, ImplTraitContext::disallowed())
|
||||
});
|
||||
|
||||
(hir::ParamName::Plain(param.ident), hir::GenericParamKind::Const { ty })
|
||||
}
|
||||
};
|
||||
|
||||
hir::GenericParam {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
Trait objects need to have all associated types specified. Erroneous code
|
||||
example:
|
||||
An associated type wasn't specified for a trait object.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0191
|
||||
trait Trait {
|
||||
|
|
@ -10,8 +11,9 @@ type Foo = Trait; // error: the value of the associated type `Bar` (from
|
|||
// the trait `Trait`) must be specified
|
||||
```
|
||||
|
||||
Please verify you specified all associated types of the trait and that you
|
||||
used the right trait. Example:
|
||||
Trait objects need to have all associated types specified. Please verify that
|
||||
all associated types of the trait were specified and the correct trait was used.
|
||||
Example:
|
||||
|
||||
```
|
||||
trait Trait {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,19 @@
|
|||
A negative impl was added on a trait implementation.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0192
|
||||
trait Trait {
|
||||
type Bar;
|
||||
}
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl !Trait for Foo { } //~ ERROR E0192
|
||||
|
||||
fn main() {}
|
||||
```
|
||||
|
||||
Negative impls are only allowed for auto traits. For more
|
||||
information see the [opt-in builtin traits RFC][RFC 19].
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ use syntax::ast::{Ident, Item, ItemKind};
|
|||
declare_tool_lint! {
|
||||
pub rustc::DEFAULT_HASH_TYPES,
|
||||
Allow,
|
||||
"forbid HashMap and HashSet and suggest the FxHash* variants"
|
||||
"forbid HashMap and HashSet and suggest the FxHash* variants",
|
||||
report_in_external_macro: true
|
||||
}
|
||||
|
||||
pub struct DefaultHashTypes {
|
||||
|
|
@ -52,19 +53,22 @@ impl EarlyLintPass for DefaultHashTypes {
|
|||
declare_tool_lint! {
|
||||
pub rustc::USAGE_OF_TY_TYKIND,
|
||||
Allow,
|
||||
"usage of `ty::TyKind` outside of the `ty::sty` module"
|
||||
"usage of `ty::TyKind` outside of the `ty::sty` module",
|
||||
report_in_external_macro: true
|
||||
}
|
||||
|
||||
declare_tool_lint! {
|
||||
pub rustc::TY_PASS_BY_REFERENCE,
|
||||
Allow,
|
||||
"passing `Ty` or `TyCtxt` by reference"
|
||||
"passing `Ty` or `TyCtxt` by reference",
|
||||
report_in_external_macro: true
|
||||
}
|
||||
|
||||
declare_tool_lint! {
|
||||
pub rustc::USAGE_OF_QUALIFIED_TY,
|
||||
Allow,
|
||||
"using `ty::{Ty,TyCtxt}` instead of importing it"
|
||||
"using `ty::{Ty,TyCtxt}` instead of importing it",
|
||||
report_in_external_macro: true
|
||||
}
|
||||
|
||||
declare_lint_pass!(TyTyKind => [
|
||||
|
|
|
|||
|
|
@ -1049,6 +1049,7 @@ pub mod kw {
|
|||
}
|
||||
|
||||
// This module has a very short name because it's used a lot.
|
||||
#[allow(rustc::default_hash_types)]
|
||||
pub mod sym {
|
||||
use super::Symbol;
|
||||
use std::convert::TryInto;
|
||||
|
|
|
|||
|
|
@ -560,8 +560,8 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
|
|||
lifetime_to_bounds.entry(lifetime).or_default().extend(bounds);
|
||||
}
|
||||
WherePredicate::EqPredicate { lhs, rhs } => {
|
||||
match &lhs {
|
||||
&Type::QPath { name: ref left_name, ref self_type, ref trait_ } => {
|
||||
match lhs {
|
||||
Type::QPath { name: ref left_name, ref self_type, ref trait_ } => {
|
||||
let ty = &*self_type;
|
||||
match **trait_ {
|
||||
Type::ResolvedPath {
|
||||
|
|
@ -580,36 +580,30 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
|
|||
continue;
|
||||
}
|
||||
|
||||
// FIXME: Remove this scope when NLL lands
|
||||
{
|
||||
let args = &mut new_trait_path
|
||||
.segments
|
||||
.last_mut()
|
||||
.expect("segments were empty")
|
||||
.args;
|
||||
let args = &mut new_trait_path
|
||||
.segments
|
||||
.last_mut()
|
||||
.expect("segments were empty")
|
||||
.args;
|
||||
|
||||
match args {
|
||||
// Convert somethiung like '<T as Iterator::Item> = u8'
|
||||
// to 'T: Iterator<Item=u8>'
|
||||
&mut GenericArgs::AngleBracketed {
|
||||
ref mut bindings,
|
||||
..
|
||||
} => {
|
||||
bindings.push(TypeBinding {
|
||||
name: left_name.clone(),
|
||||
kind: TypeBindingKind::Equality { ty: rhs },
|
||||
});
|
||||
}
|
||||
&mut GenericArgs::Parenthesized { .. } => {
|
||||
existing_predicates.push(
|
||||
WherePredicate::EqPredicate {
|
||||
lhs: lhs.clone(),
|
||||
rhs,
|
||||
},
|
||||
);
|
||||
continue; // If something other than a Fn ends up
|
||||
// with parenthesis, leave it alone
|
||||
}
|
||||
match args {
|
||||
// Convert somethiung like '<T as Iterator::Item> = u8'
|
||||
// to 'T: Iterator<Item=u8>'
|
||||
GenericArgs::AngleBracketed {
|
||||
ref mut bindings, ..
|
||||
} => {
|
||||
bindings.push(TypeBinding {
|
||||
name: left_name.clone(),
|
||||
kind: TypeBindingKind::Equality { ty: rhs },
|
||||
});
|
||||
}
|
||||
GenericArgs::Parenthesized { .. } => {
|
||||
existing_predicates.push(WherePredicate::EqPredicate {
|
||||
lhs: lhs.clone(),
|
||||
rhs,
|
||||
});
|
||||
continue; // If something other than a Fn ends up
|
||||
// with parenthesis, leave it alone
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -307,8 +307,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
|||
cg: codegen_options,
|
||||
externs,
|
||||
target_triple: target,
|
||||
// Ensure that rustdoc works even if rustc is feature-staged
|
||||
unstable_features: UnstableFeatures::Allow,
|
||||
unstable_features: UnstableFeatures::from_environment(),
|
||||
actually_rustdoc: true,
|
||||
debugging_opts: debugging_options,
|
||||
error_format,
|
||||
|
|
|
|||
|
|
@ -2663,8 +2663,8 @@ function getSearchElement() {
|
|||
"Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, \
|
||||
<code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, \
|
||||
and <code>const</code>.",
|
||||
"Search functions by type signature (e.g., <code>vec -> usize</code> or \
|
||||
<code>* -> vec</code>)",
|
||||
"Search functions by type signature (e.g., <code>vec -> usize</code> or \
|
||||
<code>* -> vec</code>)",
|
||||
"Search multiple things at once by splitting your query with comma (e.g., \
|
||||
<code>str,u8</code> or <code>String,struct:Vec,test</code>)",
|
||||
"You can look for items with an exact name by putting double quotes around \
|
||||
|
|
|
|||
|
|
@ -902,6 +902,12 @@ impl UnixListener {
|
|||
|
||||
/// Moves the socket into or out of nonblocking mode.
|
||||
///
|
||||
/// This will result in the `accept` operation becoming nonblocking,
|
||||
/// i.e., immediately returning from their calls. If the IO operation is
|
||||
/// successful, `Ok` is returned and no further action is required. If the
|
||||
/// IO operation could not be completed and needs to be retried, an error
|
||||
/// with kind [`io::ErrorKind::WouldBlock`] is returned.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```no_run
|
||||
|
|
@ -913,6 +919,8 @@ impl UnixListener {
|
|||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// [`io::ErrorKind::WouldBlock`]: ../../../io/enum.ErrorKind.html#variant.WouldBlock
|
||||
#[stable(feature = "unix_socket", since = "1.10.0")]
|
||||
pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
|
||||
self.0.set_nonblocking(nonblocking)
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ pub fn stderr() -> Option<Box<StderrTerminal>> {
|
|||
#[allow(missing_docs)]
|
||||
pub mod color {
|
||||
/// Number for a terminal color
|
||||
pub type Color = u16;
|
||||
pub type Color = u32;
|
||||
|
||||
pub const BLACK: Color = 0;
|
||||
pub const RED: Color = 1;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ pub struct TermInfo {
|
|||
/// Map of capability name to boolean value
|
||||
pub bools: HashMap<String, bool>,
|
||||
/// Map of capability name to numeric value
|
||||
pub numbers: HashMap<String, u16>,
|
||||
pub numbers: HashMap<String, u32>,
|
||||
/// Map of capability name to raw (unexpanded) string
|
||||
pub strings: HashMap<String, Vec<u8>>,
|
||||
}
|
||||
|
|
@ -129,7 +129,7 @@ fn cap_for_attr(attr: Attr) -> &'static str {
|
|||
/// A Terminal that knows how many colors it supports, with a reference to its
|
||||
/// parsed Terminfo database record.
|
||||
pub struct TerminfoTerminal<T> {
|
||||
num_colors: u16,
|
||||
num_colors: u32,
|
||||
out: T,
|
||||
ti: TermInfo,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,16 +159,16 @@ pub static stringnames: &[&str] = &[ "cbt", "_", "cr", "csr", "tbc", "clear",
|
|||
|
||||
fn read_le_u16(r: &mut dyn io::Read) -> io::Result<u16> {
|
||||
let mut b = [0; 2];
|
||||
let mut amt = 0;
|
||||
while amt < b.len() {
|
||||
match r.read(&mut b[amt..])? {
|
||||
0 => return Err(io::Error::new(io::ErrorKind::Other, "end of file")),
|
||||
n => amt += n,
|
||||
}
|
||||
}
|
||||
r.read_exact(&mut b)?;
|
||||
Ok((b[0] as u16) | ((b[1] as u16) << 8))
|
||||
}
|
||||
|
||||
fn read_le_u32(r: &mut dyn io::Read) -> io::Result<u32> {
|
||||
let mut b = [0; 4];
|
||||
r.read_exact(&mut b)?;
|
||||
Ok((b[0] as u32) | ((b[1] as u32) << 8) | ((b[2] as u32) << 16) | ((b[3] as u32) << 24))
|
||||
}
|
||||
|
||||
fn read_byte(r: &mut dyn io::Read) -> io::Result<u8> {
|
||||
match r.bytes().next() {
|
||||
Some(s) => s,
|
||||
|
|
@ -194,9 +194,12 @@ pub fn parse(file: &mut dyn io::Read, longnames: bool) -> Result<TermInfo, Strin
|
|||
|
||||
// Check magic number
|
||||
let magic = t!(read_le_u16(file));
|
||||
if magic != 0x011A {
|
||||
return Err(format!("invalid magic number: expected {:x}, found {:x}", 0x011A, magic));
|
||||
}
|
||||
|
||||
let extended = match magic {
|
||||
0o0432 => false,
|
||||
0o01036 => true,
|
||||
_ => return Err(format!("invalid magic number, found {:o}", magic)),
|
||||
};
|
||||
|
||||
// According to the spec, these fields must be >= -1 where -1 means that the feature is not
|
||||
// supported. Using 0 instead of -1 works because we skip sections with length 0.
|
||||
|
|
@ -258,11 +261,15 @@ pub fn parse(file: &mut dyn io::Read, longnames: bool) -> Result<TermInfo, Strin
|
|||
t!(read_byte(file)); // compensate for padding
|
||||
}
|
||||
|
||||
let numbers_map: HashMap<String, u16> = t! {
|
||||
(0..numbers_count).filter_map(|i| match read_le_u16(file) {
|
||||
Ok(0xFFFF) => None,
|
||||
Ok(n) => Some(Ok((nnames[i].to_string(), n))),
|
||||
Err(e) => Some(Err(e))
|
||||
let numbers_map: HashMap<String, u32> = t! {
|
||||
(0..numbers_count).filter_map(|i| {
|
||||
let number = if extended { read_le_u32(file) } else { read_le_u16(file).map(Into::into) };
|
||||
|
||||
match number {
|
||||
Ok(0xFFFF) => None,
|
||||
Ok(n) => Some(Ok((nnames[i].to_string(), n))),
|
||||
Err(e) => Some(Err(e))
|
||||
}
|
||||
}).collect()
|
||||
};
|
||||
|
||||
|
|
@ -318,7 +325,7 @@ pub fn msys_terminfo() -> TermInfo {
|
|||
strings.insert("setab".to_string(), b"\x1B[4%p1%dm".to_vec());
|
||||
|
||||
let mut numbers = HashMap::new();
|
||||
numbers.insert("colors".to_string(), 8u16);
|
||||
numbers.insert("colors".to_string(), 8);
|
||||
|
||||
TermInfo {
|
||||
names: vec!["cygwin".to_string()], // msys is a fork of an older cygwin version
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ fn bits_to_color(bits: u16) -> color::Color {
|
|||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
color | (bits & 0x8) // copy the hi-intensity bit
|
||||
color | (u32::from(bits) & 0x8) // copy the hi-intensity bit
|
||||
}
|
||||
|
||||
impl<T: Write + Send + 'static> WinConsole<T> {
|
||||
|
|
|
|||
24
src/test/ui/const-generics/const-param-elided-lifetime.rs
Normal file
24
src/test/ui/const-generics/const-param-elided-lifetime.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// Elided lifetimes within the type of a const generic parameters is disallowed. This matches the
|
||||
// behaviour of trait bounds where `fn foo<T: Ord<&u8>>() {}` is illegal. Though we could change
|
||||
// elided lifetimes within the type of a const generic parameters to be 'static, like elided
|
||||
// lifetimes within const/static items.
|
||||
|
||||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
|
||||
|
||||
struct A<const N: &u8>;
|
||||
//~^ ERROR `&` without an explicit lifetime name cannot be used here
|
||||
trait B {}
|
||||
|
||||
impl<const N: &u8> A<N> { //~ ERROR `&` without an explicit lifetime name cannot be used here
|
||||
fn foo<const M: &u8>(&self) {}
|
||||
//~^ ERROR `&` without an explicit lifetime name cannot be used here
|
||||
}
|
||||
|
||||
impl<const N: &u8> B for A<N> {}
|
||||
//~^ ERROR `&` without an explicit lifetime name cannot be used here
|
||||
|
||||
fn bar<const N: &u8>() {}
|
||||
//~^ ERROR `&` without an explicit lifetime name cannot be used here
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||
--> $DIR/const-param-elided-lifetime.rs:9:19
|
||||
|
|
||||
LL | struct A<const N: &u8>;
|
||||
| ^ explicit lifetime name needed here
|
||||
|
||||
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||
--> $DIR/const-param-elided-lifetime.rs:13:15
|
||||
|
|
||||
LL | impl<const N: &u8> A<N> {
|
||||
| ^ explicit lifetime name needed here
|
||||
|
||||
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||
--> $DIR/const-param-elided-lifetime.rs:14:21
|
||||
|
|
||||
LL | fn foo<const M: &u8>(&self) {}
|
||||
| ^ explicit lifetime name needed here
|
||||
|
||||
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||
--> $DIR/const-param-elided-lifetime.rs:18:15
|
||||
|
|
||||
LL | impl<const N: &u8> B for A<N> {}
|
||||
| ^ explicit lifetime name needed here
|
||||
|
||||
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||
--> $DIR/const-param-elided-lifetime.rs:21:17
|
||||
|
|
||||
LL | fn bar<const N: &u8>() {}
|
||||
| ^ explicit lifetime name needed here
|
||||
|
||||
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
|
||||
--> $DIR/const-param-elided-lifetime.rs:6:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue