diff options
| author | bors <bors@rust-lang.org> | 2020-01-14 07:13:31 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-01-14 07:13:31 +0000 |
| commit | c06e4aca19046b07d952b16e9f002bfab38fde6b (patch) | |
| tree | 8fe9c20096ddf75571b4e9ff94a929858a4da40e | |
| parent | 30ca215b4e38b32aa7abdd635c5e2d56f5724494 (diff) | |
| parent | b8c0e3129c0db858226f48406f6f8cb6f2a2b066 (diff) | |
| download | rust-c06e4aca19046b07d952b16e9f002bfab38fde6b.tar.gz rust-c06e4aca19046b07d952b16e9f002bfab38fde6b.zip | |
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
| -rw-r--r-- | config.toml.example | 12 | ||||
| -rw-r--r-- | src/bootstrap/format.rs | 10 | ||||
| -rw-r--r-- | src/librustc_ast_lowering/lib.rs | 14 | ||||
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0191.md | 10 | ||||
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0192.md | 16 | ||||
| -rw-r--r-- | src/librustc_lint/internal.rs | 12 | ||||
| -rw-r--r-- | src/librustc_span/symbol.rs | 1 | ||||
| -rw-r--r-- | src/librustdoc/clean/auto_trait.rs | 58 | ||||
| -rw-r--r-- | src/librustdoc/core.rs | 3 | ||||
| -rw-r--r-- | src/librustdoc/html/static/main.js | 4 | ||||
| -rw-r--r-- | src/libstd/sys/unix/ext/net.rs | 8 | ||||
| -rw-r--r-- | src/libterm/lib.rs | 2 | ||||
| -rw-r--r-- | src/libterm/terminfo/mod.rs | 4 | ||||
| -rw-r--r-- | src/libterm/terminfo/parser/compiled.rs | 39 | ||||
| -rw-r--r-- | src/libterm/win.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/const-generics/const-param-elided-lifetime.rs | 24 | ||||
| -rw-r--r-- | src/test/ui/const-generics/const-param-elided-lifetime.stderr | 40 |
17 files changed, 183 insertions, 76 deletions
diff --git a/config.toml.example b/config.toml.example index bfd9e18cdd4..c9e17337ee2 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 65b654fb519..6e5e3fe07e7 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 d30d0bd8345..76a0889c376 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 b79196f6cec..46b773bdc50 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 33308868cb2..5fd951b2e86 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 2f8393bd906..5a5aedc2e97 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 a8b2db300a4..889f6099070 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 c8b63ed5c80..56013ee3a81 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 '<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 - } + 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>' + 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 61a7bc765bc..4c8b8112fa8 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 8ccb74d6f15..809d38a7ead 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -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 \ diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index e0e6e02a443..4c3cb67c9ee 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 d2e3b07ab85..2116b433fce 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -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; diff --git a/src/libterm/terminfo/mod.rs b/src/libterm/terminfo/mod.rs index f1adc536a3d..918875e792a 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<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, } diff --git a/src/libterm/terminfo/parser/compiled.rs b/src/libterm/terminfo/parser/compiled.rs index d36adb72c8e..fbc5aebdb2c 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<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 diff --git a/src/libterm/win.rs b/src/libterm/win.rs index b6c607a3081..c24cf9518aa 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<T: Write + Send + 'static> WinConsole<T> { 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 00000000000..5679dd35c30 --- /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<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() {} 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 00000000000..93133c507fe --- /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<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 + |
