Skip to content

Commit

Permalink
Auto merge of #68201 - JohnTitor:rollup-26e39gu, r=JohnTitor
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Jan 14, 2020
2 parents 30ca215 + b8c0e31 commit c06e4ac
Show file tree
Hide file tree
Showing 17 changed files with 183 additions and 76 deletions.
12 changes: 7 additions & 5 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion src/bootstrap/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
14 changes: 8 additions & 6 deletions src/librustc_ast_lowering/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 6 additions & 4 deletions src/librustc_error_codes/error_codes/E0191.md
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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 {
Expand Down
16 changes: 16 additions & 0 deletions src/librustc_error_codes/error_codes/E0192.md
Original file line number Diff line number Diff line change
@@ -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].

Expand Down
12 changes: 8 additions & 4 deletions src/librustc_lint/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 => [
Expand Down
1 change: 1 addition & 0 deletions src/librustc_span/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
58 changes: 26 additions & 32 deletions src/librustdoc/clean/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 -&gt; usize</code> or \
<code>* -&gt; 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 \
Expand Down
8 changes: 8 additions & 0 deletions src/libstd/sys/unix/ext/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/libterm/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/libterm/terminfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>>,
}
Expand Down Expand Up @@ -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,
}
Expand Down
39 changes: 23 additions & 16 deletions src/libterm/terminfo/parser/compiled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand Down Expand Up @@ -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()
};

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/libterm/win.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
24 changes: 24 additions & 0 deletions src/test/ui/const-generics/const-param-elided-lifetime.rs
Original file line number Diff line number Diff line change
@@ -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() {}
Loading

0 comments on commit c06e4ac

Please sign in to comment.