Skip to content

Commit c06e4ac

Browse files
committed
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
2 parents 30ca215 + b8c0e31 commit c06e4ac

File tree

17 files changed

+183
-76
lines changed

17 files changed

+183
-76
lines changed

config.toml.example

+7-5
Original file line numberDiff line numberDiff line change
@@ -181,21 +181,23 @@
181181
# Indicate whether the vendored sources are used for Rust dependencies or not
182182
#vendor = false
183183

184-
# Typically the build system will build the rust compiler twice. The second
184+
# Typically the build system will build the Rust compiler twice. The second
185185
# compiler, however, will simply use its own libraries to link against. If you
186186
# would rather to perform a full bootstrap, compiling the compiler three times,
187187
# then you can set this option to true. You shouldn't ever need to set this
188188
# option to true.
189189
#full-bootstrap = false
190190

191-
# Enable a build of the extended rust tool set which is not only the compiler
191+
# Enable a build of the extended Rust tool set which is not only the compiler
192192
# but also tools such as Cargo. This will also produce "combined installers"
193193
# which are used to install Rust and Cargo together. This is disabled by
194-
# default.
194+
# default. The `tools` option (immediately below) specifies which tools should
195+
# be built if `extended = true`.
195196
#extended = false
196197

197-
# Installs chosen set of extended tools if enabled. By default builds all.
198-
# If chosen tool failed to build the installation fails.
198+
# Installs chosen set of extended tools if `extended = true`. By default builds all.
199+
# If chosen tool failed to build the installation fails. If `extended = false`, this
200+
# option is ignored.
199201
#tools = ["cargo", "rls", "clippy", "rustfmt", "analysis", "src"]
200202

201203
# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose

src/bootstrap/format.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ fn rustfmt(src: &Path, rustfmt: &Path, path: &Path, check: bool) {
2020
cmd.arg(&path);
2121
let cmd_debug = format!("{:?}", cmd);
2222
let status = cmd.status().expect("executing rustfmt");
23-
assert!(status.success(), "running {} successful", cmd_debug);
23+
if !status.success() {
24+
eprintln!(
25+
"Running `{}` failed.\nIf you're running `tidy`, \
26+
try again with `--bless` flag. Or, you just want to format \
27+
code, run `./x.py fmt` instead.",
28+
cmd_debug,
29+
);
30+
std::process::exit(1);
31+
}
2432
}
2533

2634
#[derive(serde::Deserialize)]

src/librustc_ast_lowering/lib.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -2120,12 +2120,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21202120

21212121
(hir::ParamName::Plain(param.ident), kind)
21222122
}
2123-
GenericParamKind::Const { ref ty } => (
2124-
hir::ParamName::Plain(param.ident),
2125-
hir::GenericParamKind::Const {
2126-
ty: self.lower_ty(&ty, ImplTraitContext::disallowed()),
2127-
},
2128-
),
2123+
GenericParamKind::Const { ref ty } => {
2124+
let ty = self
2125+
.with_anonymous_lifetime_mode(AnonymousLifetimeMode::ReportError, |this| {
2126+
this.lower_ty(&ty, ImplTraitContext::disallowed())
2127+
});
2128+
2129+
(hir::ParamName::Plain(param.ident), hir::GenericParamKind::Const { ty })
2130+
}
21292131
};
21302132

21312133
hir::GenericParam {

src/librustc_error_codes/error_codes/E0191.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
Trait objects need to have all associated types specified. Erroneous code
2-
example:
1+
An associated type wasn't specified for a trait object.
2+
3+
Erroneous code example:
34

45
```compile_fail,E0191
56
trait Trait {
@@ -10,8 +11,9 @@ type Foo = Trait; // error: the value of the associated type `Bar` (from
1011
// the trait `Trait`) must be specified
1112
```
1213

13-
Please verify you specified all associated types of the trait and that you
14-
used the right trait. Example:
14+
Trait objects need to have all associated types specified. Please verify that
15+
all associated types of the trait were specified and the correct trait was used.
16+
Example:
1517

1618
```
1719
trait Trait {

src/librustc_error_codes/error_codes/E0192.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
A negative impl was added on a trait implementation.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0192
6+
trait Trait {
7+
type Bar;
8+
}
9+
10+
struct Foo;
11+
12+
impl !Trait for Foo { } //~ ERROR E0192
13+
14+
fn main() {}
15+
```
16+
117
Negative impls are only allowed for auto traits. For more
218
information see the [opt-in builtin traits RFC][RFC 19].
319

src/librustc_lint/internal.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use syntax::ast::{Ident, Item, ItemKind};
1212
declare_tool_lint! {
1313
pub rustc::DEFAULT_HASH_TYPES,
1414
Allow,
15-
"forbid HashMap and HashSet and suggest the FxHash* variants"
15+
"forbid HashMap and HashSet and suggest the FxHash* variants",
16+
report_in_external_macro: true
1617
}
1718

1819
pub struct DefaultHashTypes {
@@ -52,19 +53,22 @@ impl EarlyLintPass for DefaultHashTypes {
5253
declare_tool_lint! {
5354
pub rustc::USAGE_OF_TY_TYKIND,
5455
Allow,
55-
"usage of `ty::TyKind` outside of the `ty::sty` module"
56+
"usage of `ty::TyKind` outside of the `ty::sty` module",
57+
report_in_external_macro: true
5658
}
5759

5860
declare_tool_lint! {
5961
pub rustc::TY_PASS_BY_REFERENCE,
6062
Allow,
61-
"passing `Ty` or `TyCtxt` by reference"
63+
"passing `Ty` or `TyCtxt` by reference",
64+
report_in_external_macro: true
6265
}
6366

6467
declare_tool_lint! {
6568
pub rustc::USAGE_OF_QUALIFIED_TY,
6669
Allow,
67-
"using `ty::{Ty,TyCtxt}` instead of importing it"
70+
"using `ty::{Ty,TyCtxt}` instead of importing it",
71+
report_in_external_macro: true
6872
}
6973

7074
declare_lint_pass!(TyTyKind => [

src/librustc_span/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,7 @@ pub mod kw {
10491049
}
10501050

10511051
// This module has a very short name because it's used a lot.
1052+
#[allow(rustc::default_hash_types)]
10521053
pub mod sym {
10531054
use super::Symbol;
10541055
use std::convert::TryInto;

src/librustdoc/clean/auto_trait.rs

+26-32
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,8 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
560560
lifetime_to_bounds.entry(lifetime).or_default().extend(bounds);
561561
}
562562
WherePredicate::EqPredicate { lhs, rhs } => {
563-
match &lhs {
564-
&Type::QPath { name: ref left_name, ref self_type, ref trait_ } => {
563+
match lhs {
564+
Type::QPath { name: ref left_name, ref self_type, ref trait_ } => {
565565
let ty = &*self_type;
566566
match **trait_ {
567567
Type::ResolvedPath {
@@ -580,36 +580,30 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
580580
continue;
581581
}
582582

583-
// FIXME: Remove this scope when NLL lands
584-
{
585-
let args = &mut new_trait_path
586-
.segments
587-
.last_mut()
588-
.expect("segments were empty")
589-
.args;
590-
591-
match args {
592-
// Convert somethiung like '<T as Iterator::Item> = u8'
593-
// to 'T: Iterator<Item=u8>'
594-
&mut GenericArgs::AngleBracketed {
595-
ref mut bindings,
596-
..
597-
} => {
598-
bindings.push(TypeBinding {
599-
name: left_name.clone(),
600-
kind: TypeBindingKind::Equality { ty: rhs },
601-
});
602-
}
603-
&mut GenericArgs::Parenthesized { .. } => {
604-
existing_predicates.push(
605-
WherePredicate::EqPredicate {
606-
lhs: lhs.clone(),
607-
rhs,
608-
},
609-
);
610-
continue; // If something other than a Fn ends up
611-
// with parenthesis, leave it alone
612-
}
583+
let args = &mut new_trait_path
584+
.segments
585+
.last_mut()
586+
.expect("segments were empty")
587+
.args;
588+
589+
match args {
590+
// Convert somethiung like '<T as Iterator::Item> = u8'
591+
// to 'T: Iterator<Item=u8>'
592+
GenericArgs::AngleBracketed {
593+
ref mut bindings, ..
594+
} => {
595+
bindings.push(TypeBinding {
596+
name: left_name.clone(),
597+
kind: TypeBindingKind::Equality { ty: rhs },
598+
});
599+
}
600+
GenericArgs::Parenthesized { .. } => {
601+
existing_predicates.push(WherePredicate::EqPredicate {
602+
lhs: lhs.clone(),
603+
rhs,
604+
});
605+
continue; // If something other than a Fn ends up
606+
// with parenthesis, leave it alone
613607
}
614608
}
615609

src/librustdoc/core.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
307307
cg: codegen_options,
308308
externs,
309309
target_triple: target,
310-
// Ensure that rustdoc works even if rustc is feature-staged
311-
unstable_features: UnstableFeatures::Allow,
310+
unstable_features: UnstableFeatures::from_environment(),
312311
actually_rustdoc: true,
313312
debugging_opts: debugging_options,
314313
error_format,

src/librustdoc/html/static/main.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2663,8 +2663,8 @@ function getSearchElement() {
26632663
"Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, \
26642664
<code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, \
26652665
and <code>const</code>.",
2666-
"Search functions by type signature (e.g., <code>vec -> usize</code> or \
2667-
<code>* -> vec</code>)",
2666+
"Search functions by type signature (e.g., <code>vec -&gt; usize</code> or \
2667+
<code>* -&gt; vec</code>)",
26682668
"Search multiple things at once by splitting your query with comma (e.g., \
26692669
<code>str,u8</code> or <code>String,struct:Vec,test</code>)",
26702670
"You can look for items with an exact name by putting double quotes around \

src/libstd/sys/unix/ext/net.rs

+8
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,12 @@ impl UnixListener {
902902

903903
/// Moves the socket into or out of nonblocking mode.
904904
///
905+
/// This will result in the `accept` operation becoming nonblocking,
906+
/// i.e., immediately returning from their calls. If the IO operation is
907+
/// successful, `Ok` is returned and no further action is required. If the
908+
/// IO operation could not be completed and needs to be retried, an error
909+
/// with kind [`io::ErrorKind::WouldBlock`] is returned.
910+
///
905911
/// # Examples
906912
///
907913
/// ```no_run
@@ -913,6 +919,8 @@ impl UnixListener {
913919
/// Ok(())
914920
/// }
915921
/// ```
922+
///
923+
/// [`io::ErrorKind::WouldBlock`]: ../../../io/enum.ErrorKind.html#variant.WouldBlock
916924
#[stable(feature = "unix_socket", since = "1.10.0")]
917925
pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
918926
self.0.set_nonblocking(nonblocking)

src/libterm/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub fn stderr() -> Option<Box<StderrTerminal>> {
9191
#[allow(missing_docs)]
9292
pub mod color {
9393
/// Number for a terminal color
94-
pub type Color = u16;
94+
pub type Color = u32;
9595

9696
pub const BLACK: Color = 0;
9797
pub const RED: Color = 1;

src/libterm/terminfo/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub struct TermInfo {
2424
/// Map of capability name to boolean value
2525
pub bools: HashMap<String, bool>,
2626
/// Map of capability name to numeric value
27-
pub numbers: HashMap<String, u16>,
27+
pub numbers: HashMap<String, u32>,
2828
/// Map of capability name to raw (unexpanded) string
2929
pub strings: HashMap<String, Vec<u8>>,
3030
}
@@ -129,7 +129,7 @@ fn cap_for_attr(attr: Attr) -> &'static str {
129129
/// A Terminal that knows how many colors it supports, with a reference to its
130130
/// parsed Terminfo database record.
131131
pub struct TerminfoTerminal<T> {
132-
num_colors: u16,
132+
num_colors: u32,
133133
out: T,
134134
ti: TermInfo,
135135
}

src/libterm/terminfo/parser/compiled.rs

+23-16
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,16 @@ pub static stringnames: &[&str] = &[ "cbt", "_", "cr", "csr", "tbc", "clear",
159159

160160
fn read_le_u16(r: &mut dyn io::Read) -> io::Result<u16> {
161161
let mut b = [0; 2];
162-
let mut amt = 0;
163-
while amt < b.len() {
164-
match r.read(&mut b[amt..])? {
165-
0 => return Err(io::Error::new(io::ErrorKind::Other, "end of file")),
166-
n => amt += n,
167-
}
168-
}
162+
r.read_exact(&mut b)?;
169163
Ok((b[0] as u16) | ((b[1] as u16) << 8))
170164
}
171165

166+
fn read_le_u32(r: &mut dyn io::Read) -> io::Result<u32> {
167+
let mut b = [0; 4];
168+
r.read_exact(&mut b)?;
169+
Ok((b[0] as u32) | ((b[1] as u32) << 8) | ((b[2] as u32) << 16) | ((b[3] as u32) << 24))
170+
}
171+
172172
fn read_byte(r: &mut dyn io::Read) -> io::Result<u8> {
173173
match r.bytes().next() {
174174
Some(s) => s,
@@ -194,9 +194,12 @@ pub fn parse(file: &mut dyn io::Read, longnames: bool) -> Result<TermInfo, Strin
194194

195195
// Check magic number
196196
let magic = t!(read_le_u16(file));
197-
if magic != 0x011A {
198-
return Err(format!("invalid magic number: expected {:x}, found {:x}", 0x011A, magic));
199-
}
197+
198+
let extended = match magic {
199+
0o0432 => false,
200+
0o01036 => true,
201+
_ => return Err(format!("invalid magic number, found {:o}", magic)),
202+
};
200203

201204
// According to the spec, these fields must be >= -1 where -1 means that the feature is not
202205
// 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
258261
t!(read_byte(file)); // compensate for padding
259262
}
260263

261-
let numbers_map: HashMap<String, u16> = t! {
262-
(0..numbers_count).filter_map(|i| match read_le_u16(file) {
263-
Ok(0xFFFF) => None,
264-
Ok(n) => Some(Ok((nnames[i].to_string(), n))),
265-
Err(e) => Some(Err(e))
264+
let numbers_map: HashMap<String, u32> = t! {
265+
(0..numbers_count).filter_map(|i| {
266+
let number = if extended { read_le_u32(file) } else { read_le_u16(file).map(Into::into) };
267+
268+
match number {
269+
Ok(0xFFFF) => None,
270+
Ok(n) => Some(Ok((nnames[i].to_string(), n))),
271+
Err(e) => Some(Err(e))
272+
}
266273
}).collect()
267274
};
268275

@@ -318,7 +325,7 @@ pub fn msys_terminfo() -> TermInfo {
318325
strings.insert("setab".to_string(), b"\x1B[4%p1%dm".to_vec());
319326

320327
let mut numbers = HashMap::new();
321-
numbers.insert("colors".to_string(), 8u16);
328+
numbers.insert("colors".to_string(), 8);
322329

323330
TermInfo {
324331
names: vec!["cygwin".to_string()], // msys is a fork of an older cygwin version

src/libterm/win.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fn bits_to_color(bits: u16) -> color::Color {
8989
_ => unreachable!(),
9090
};
9191

92-
color | (bits & 0x8) // copy the hi-intensity bit
92+
color | (u32::from(bits) & 0x8) // copy the hi-intensity bit
9393
}
9494

9595
impl<T: Write + Send + 'static> WinConsole<T> {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Elided lifetimes within the type of a const generic parameters is disallowed. This matches the
2+
// behaviour of trait bounds where `fn foo<T: Ord<&u8>>() {}` is illegal. Though we could change
3+
// elided lifetimes within the type of a const generic parameters to be 'static, like elided
4+
// lifetimes within const/static items.
5+
6+
#![feature(const_generics)]
7+
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
8+
9+
struct A<const N: &u8>;
10+
//~^ ERROR `&` without an explicit lifetime name cannot be used here
11+
trait B {}
12+
13+
impl<const N: &u8> A<N> { //~ ERROR `&` without an explicit lifetime name cannot be used here
14+
fn foo<const M: &u8>(&self) {}
15+
//~^ ERROR `&` without an explicit lifetime name cannot be used here
16+
}
17+
18+
impl<const N: &u8> B for A<N> {}
19+
//~^ ERROR `&` without an explicit lifetime name cannot be used here
20+
21+
fn bar<const N: &u8>() {}
22+
//~^ ERROR `&` without an explicit lifetime name cannot be used here
23+
24+
fn main() {}

0 commit comments

Comments
 (0)