diff --git a/config.toml.example b/config.toml.example index bfd9e18cdd41a..c9e17337ee23f 100644 --- a/config.toml.example +++ b/config.toml.example @@ -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 diff --git a/src/bootstrap/format.rs b/src/bootstrap/format.rs index 65b654fb51929..6e5e3fe07e746 100644 --- a/src/bootstrap/format.rs +++ b/src/bootstrap/format.rs @@ -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)] diff --git a/src/librustc_ast_lowering/lib.rs b/src/librustc_ast_lowering/lib.rs index d30d0bd8345ff..76a0889c376a2 100644 --- a/src/librustc_ast_lowering/lib.rs +++ b/src/librustc_ast_lowering/lib.rs @@ -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 { diff --git a/src/librustc_error_codes/error_codes/E0191.md b/src/librustc_error_codes/error_codes/E0191.md index b79196f6cec7a..46b773bdc50d6 100644 --- a/src/librustc_error_codes/error_codes/E0191.md +++ b/src/librustc_error_codes/error_codes/E0191.md @@ -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 { diff --git a/src/librustc_error_codes/error_codes/E0192.md b/src/librustc_error_codes/error_codes/E0192.md index 33308868cb235..5fd951b2e86cb 100644 --- a/src/librustc_error_codes/error_codes/E0192.md +++ b/src/librustc_error_codes/error_codes/E0192.md @@ -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]. diff --git a/src/librustc_lint/internal.rs b/src/librustc_lint/internal.rs index 2f8393bd906c0..5a5aedc2e9715 100644 --- a/src/librustc_lint/internal.rs +++ b/src/librustc_lint/internal.rs @@ -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 => [ diff --git a/src/librustc_span/symbol.rs b/src/librustc_span/symbol.rs index a8b2db300a478..889f6099070ae 100644 --- a/src/librustc_span/symbol.rs +++ b/src/librustc_span/symbol.rs @@ -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; diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index c8b63ed5c8096..56013ee3a816f 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -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; - - match args { - // Convert somethiung like ' = u8' - // to 'T: Iterator' - &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 - } + let args = &mut new_trait_path + .segments + .last_mut() + .expect("segments were empty") + .args; + + match args { + // Convert somethiung like ' = u8' + // to 'T: Iterator' + 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 } } diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 61a7bc765bcf2..4c8b8112fa85a 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -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, diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 8ccb74d6f15d3..809d38a7ead8f 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -2663,8 +2663,8 @@ function getSearchElement() { "Accepted types are: fn, mod, struct, \ enum, trait, type, macro, \ and const.", - "Search functions by type signature (e.g., vec -> usize or \ - * -> vec)", + "Search functions by type signature (e.g., vec -> usize or \ + * -> vec)", "Search multiple things at once by splitting your query with comma (e.g., \ str,u8 or String,struct:Vec,test)", "You can look for items with an exact name by putting double quotes around \ diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index e0e6e02a443e1..4c3cb67c9ee0f 100644 --- a/src/libstd/sys/unix/ext/net.rs +++ b/src/libstd/sys/unix/ext/net.rs @@ -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) diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs index d2e3b07ab855d..2116b433fce3f 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -91,7 +91,7 @@ pub fn stderr() -> Option> { #[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; diff --git a/src/libterm/terminfo/mod.rs b/src/libterm/terminfo/mod.rs index f1adc536a3dc4..918875e792a66 100644 --- a/src/libterm/terminfo/mod.rs +++ b/src/libterm/terminfo/mod.rs @@ -24,7 +24,7 @@ pub struct TermInfo { /// Map of capability name to boolean value pub bools: HashMap, /// Map of capability name to numeric value - pub numbers: HashMap, + pub numbers: HashMap, /// Map of capability name to raw (unexpanded) string pub strings: HashMap>, } @@ -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 { - num_colors: u16, + num_colors: u32, out: T, ti: TermInfo, } diff --git a/src/libterm/terminfo/parser/compiled.rs b/src/libterm/terminfo/parser/compiled.rs index d36adb72c8eef..fbc5aebdb2c6c 100644 --- a/src/libterm/terminfo/parser/compiled.rs +++ b/src/libterm/terminfo/parser/compiled.rs @@ -159,16 +159,16 @@ pub static stringnames: &[&str] = &[ "cbt", "_", "cr", "csr", "tbc", "clear", fn read_le_u16(r: &mut dyn io::Read) -> io::Result { 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 { + 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 { match r.bytes().next() { Some(s) => s, @@ -194,9 +194,12 @@ pub fn parse(file: &mut dyn io::Read, longnames: bool) -> Result 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 = 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 = 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 diff --git a/src/libterm/win.rs b/src/libterm/win.rs index b6c607a30816c..c24cf9518aa25 100644 --- a/src/libterm/win.rs +++ b/src/libterm/win.rs @@ -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 WinConsole { diff --git a/src/test/ui/const-generics/const-param-elided-lifetime.rs b/src/test/ui/const-generics/const-param-elided-lifetime.rs new file mode 100644 index 0000000000000..5679dd35c307a --- /dev/null +++ b/src/test/ui/const-generics/const-param-elided-lifetime.rs @@ -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>() {}` 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; +//~^ ERROR `&` without an explicit lifetime name cannot be used here +trait B {} + +impl A { //~ ERROR `&` without an explicit lifetime name cannot be used here + fn foo(&self) {} + //~^ ERROR `&` without an explicit lifetime name cannot be used here +} + +impl B for A {} +//~^ ERROR `&` without an explicit lifetime name cannot be used here + +fn bar() {} +//~^ ERROR `&` without an explicit lifetime name cannot be used here + +fn main() {} diff --git a/src/test/ui/const-generics/const-param-elided-lifetime.stderr b/src/test/ui/const-generics/const-param-elided-lifetime.stderr new file mode 100644 index 0000000000000..93133c507fe40 --- /dev/null +++ b/src/test/ui/const-generics/const-param-elided-lifetime.stderr @@ -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; + | ^ 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 A { + | ^ 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(&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 B for A {} + | ^ 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() {} + | ^ 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 +