Skip to content

Commit

Permalink
Rollup merge of rust-lang#64907 - alexreg:tidy-up, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
A small amount of tidying-up factored out from PR rust-lang#64648

As requested by @Mark-Simulacrum, I put this in a separate commit to make it easier to review. (As far as I can tell, no violations of the policy here, and they are simply in a separate PR because they're not directly related to the import of that PR.)

r? @Mark-Simulacrum
  • Loading branch information
Centril committed Oct 1, 2019
2 parents b8c5d3a + 33ed03f commit 24a84fa
Show file tree
Hide file tree
Showing 23 changed files with 74 additions and 71 deletions.
6 changes: 3 additions & 3 deletions src/libfmt_macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ impl<'a> Parser<'a> {
&self.input[start..self.input.len()]
}

/// Parses an Argument structure, or what's contained within braces inside the format string
/// Parses an `Argument` structure, or what's contained within braces inside the format string.
fn argument(&mut self) -> Argument<'a> {
let pos = self.position();
let format = self.format();
Expand Down Expand Up @@ -464,7 +464,7 @@ impl<'a> Parser<'a> {
}

/// Parses a format specifier at the current position, returning all of the
/// relevant information in the FormatSpec struct.
/// relevant information in the `FormatSpec` struct.
fn format(&mut self) -> FormatSpec<'a> {
let mut spec = FormatSpec {
fill: None,
Expand Down Expand Up @@ -571,7 +571,7 @@ impl<'a> Parser<'a> {
spec
}

/// Parses a Count parameter at the current position. This does not check
/// Parses a `Count` parameter at the current position. This does not check
/// for 'CountIsNextParam' because that is only used in precision, not
/// width.
fn count(&mut self, start: usize) -> (Count, Option<InnerSpan>) {
Expand Down
16 changes: 8 additions & 8 deletions src/librustc_interface/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ pub fn register_plugins<'a>(
rustc_incremental::prepare_session_directory(sess, &crate_name, disambiguator);

if sess.opts.incremental.is_some() {
time(sess, "garbage collect incremental cache directory", || {
time(sess, "garbage-collect incremental cache directory", || {
if let Err(e) = rustc_incremental::garbage_collect_session_directories(sess) {
warn!(
"Error while trying to garbage collect incremental \
Expand Down Expand Up @@ -318,7 +318,7 @@ fn configure_and_expand_inner<'a>(
crate_loader: &'a mut CrateLoader<'a>,
plugin_info: PluginInfo,
) -> Result<(ast::Crate, Resolver<'a>)> {
time(sess, "pre ast expansion lint checks", || {
time(sess, "pre-AST-expansion lint checks", || {
lint::check_ast_crate(
sess,
&krate,
Expand Down Expand Up @@ -536,8 +536,8 @@ pub fn lower_to_hir(
dep_graph: &DepGraph,
krate: &ast::Crate,
) -> Result<hir::map::Forest> {
// Lower ast -> hir
let hir_forest = time(sess, "lowering ast -> hir", || {
// Lower AST to HIR.
let hir_forest = time(sess, "lowering AST -> HIR", || {
let hir_crate = lower_crate(sess, cstore, &dep_graph, &krate, resolver);

if sess.opts.debugging_opts.hir_stats {
Expand Down Expand Up @@ -757,7 +757,7 @@ pub fn prepare_outputs(
if !only_dep_info {
if let Some(ref dir) = compiler.output_dir {
if fs::create_dir_all(dir).is_err() {
sess.err("failed to find or create the directory specified by --out-dir");
sess.err("failed to find or create the directory specified by `--out-dir`");
return Err(ErrorReported);
}
}
Expand Down Expand Up @@ -830,8 +830,8 @@ pub fn create_global_ctxt(
let global_ctxt: Option<GlobalCtxt<'_>>;
let arenas = AllArenas::new();

// Construct the HIR map
let hir_map = time(sess, "indexing hir", || {
// Construct the HIR map.
let hir_map = time(sess, "indexing HIR", || {
hir::map::map_crate(sess, cstore, &mut hir_forest, &defs)
});

Expand Down Expand Up @@ -942,7 +942,7 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
tcx.par_body_owners(|def_id| tcx.ensure().mir_borrowck(def_id));
});

time(sess, "dumping chalk-like clauses", || {
time(sess, "dumping Chalk-like clauses", || {
rustc_traits::lowering::dump_program_clauses(tcx);
});

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -952,8 +952,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
tcx.sess.span_warn(
span,
"default bound relaxed for a type parameter, but \
this does nothing because the given bound is not \
a default. Only `?Sized` is supported",
this does nothing because the given bound is not \
a default; only `?Sized` is supported",
);
}
}
Expand Down
34 changes: 19 additions & 15 deletions src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,26 +631,30 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

fn suggest_valid_traits(&self,
err: &mut DiagnosticBuilder<'_>,
valid_out_of_scope_traits: Vec<DefId>) -> bool {
fn suggest_valid_traits(
&self,
err: &mut DiagnosticBuilder<'_>,
valid_out_of_scope_traits: Vec<DefId>,
) -> bool {
if !valid_out_of_scope_traits.is_empty() {
let mut candidates = valid_out_of_scope_traits;
candidates.sort();
candidates.dedup();
err.help("items from traits can only be used if the trait is in scope");
let msg = format!("the following {traits_are} implemented but not in scope, \
perhaps add a `use` for {one_of_them}:",
traits_are = if candidates.len() == 1 {
"trait is"
} else {
"traits are"
},
one_of_them = if candidates.len() == 1 {
"it"
} else {
"one of them"
});
let msg = format!(
"the following {traits_are} implemented but not in scope; \
perhaps add a `use` for {one_of_them}:",
traits_are = if candidates.len() == 1 {
"trait is"
} else {
"traits are"
},
one_of_them = if candidates.len() == 1 {
"it"
} else {
"one of them"
},
);

self.suggest_use_candidates(err, msg, candidates);
true
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/parse/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<'a> StringReader<'a> {
source_file: Lrc<syntax_pos::SourceFile>,
override_span: Option<Span>) -> Self {
if source_file.src.is_none() {
sess.span_diagnostic.bug(&format!("Cannot lex source_file without source: {}",
sess.span_diagnostic.bug(&format!("cannot lex `source_file` without source: {}",
source_file.name));
}

Expand Down
31 changes: 15 additions & 16 deletions src/libsyntax_pos/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ pub struct OffsetOverflowError;
/// A single source in the `SourceMap`.
#[derive(Clone)]
pub struct SourceFile {
/// The name of the file that the source came from, source that doesn't
/// The name of the file that the source came from. Source that doesn't
/// originate from files has names between angle brackets by convention
/// (e.g., `<anon>`).
pub name: FileName,
Expand Down Expand Up @@ -922,9 +922,9 @@ impl Encodable for SourceFile {
s.emit_struct_field("name", 0, |s| self.name.encode(s))?;
s.emit_struct_field("name_was_remapped", 1, |s| self.name_was_remapped.encode(s))?;
s.emit_struct_field("src_hash", 2, |s| self.src_hash.encode(s))?;
s.emit_struct_field("start_pos", 4, |s| self.start_pos.encode(s))?;
s.emit_struct_field("end_pos", 5, |s| self.end_pos.encode(s))?;
s.emit_struct_field("lines", 6, |s| {
s.emit_struct_field("start_pos", 3, |s| self.start_pos.encode(s))?;
s.emit_struct_field("end_pos", 4, |s| self.end_pos.encode(s))?;
s.emit_struct_field("lines", 5, |s| {
let lines = &self.lines[..];
// Store the length.
s.emit_u32(lines.len() as u32)?;
Expand Down Expand Up @@ -970,13 +970,13 @@ impl Encodable for SourceFile {

Ok(())
})?;
s.emit_struct_field("multibyte_chars", 7, |s| {
s.emit_struct_field("multibyte_chars", 6, |s| {
self.multibyte_chars.encode(s)
})?;
s.emit_struct_field("non_narrow_chars", 8, |s| {
s.emit_struct_field("non_narrow_chars", 7, |s| {
self.non_narrow_chars.encode(s)
})?;
s.emit_struct_field("name_hash", 9, |s| {
s.emit_struct_field("name_hash", 8, |s| {
self.name_hash.encode(s)
})
})
Expand All @@ -985,17 +985,16 @@ impl Encodable for SourceFile {

impl Decodable for SourceFile {
fn decode<D: Decoder>(d: &mut D) -> Result<SourceFile, D::Error> {

d.read_struct("SourceFile", 8, |d| {
let name: FileName = d.read_struct_field("name", 0, |d| Decodable::decode(d))?;
let name_was_remapped: bool =
d.read_struct_field("name_was_remapped", 1, |d| Decodable::decode(d))?;
let src_hash: u128 =
d.read_struct_field("src_hash", 2, |d| Decodable::decode(d))?;
let start_pos: BytePos =
d.read_struct_field("start_pos", 4, |d| Decodable::decode(d))?;
let end_pos: BytePos = d.read_struct_field("end_pos", 5, |d| Decodable::decode(d))?;
let lines: Vec<BytePos> = d.read_struct_field("lines", 6, |d| {
d.read_struct_field("start_pos", 3, |d| Decodable::decode(d))?;
let end_pos: BytePos = d.read_struct_field("end_pos", 4, |d| Decodable::decode(d))?;
let lines: Vec<BytePos> = d.read_struct_field("lines", 5, |d| {
let num_lines: u32 = Decodable::decode(d)?;
let mut lines = Vec::with_capacity(num_lines as usize);

Expand Down Expand Up @@ -1024,18 +1023,18 @@ impl Decodable for SourceFile {
Ok(lines)
})?;
let multibyte_chars: Vec<MultiByteChar> =
d.read_struct_field("multibyte_chars", 7, |d| Decodable::decode(d))?;
d.read_struct_field("multibyte_chars", 6, |d| Decodable::decode(d))?;
let non_narrow_chars: Vec<NonNarrowChar> =
d.read_struct_field("non_narrow_chars", 8, |d| Decodable::decode(d))?;
d.read_struct_field("non_narrow_chars", 7, |d| Decodable::decode(d))?;
let name_hash: u128 =
d.read_struct_field("name_hash", 9, |d| Decodable::decode(d))?;
d.read_struct_field("name_hash", 8, |d| Decodable::decode(d))?;
Ok(SourceFile {
name,
name_was_remapped,
unmapped_path: None,
// `crate_of_origin` has to be set by the importer.
// This value matches up with rustc::hir::def_id::INVALID_CRATE.
// That constant is not available here unfortunately :(
// This value matches up with `rustc::hir::def_id::INVALID_CRATE`.
// That constant is not available here, unfortunately.
crate_of_origin: std::u32::MAX - 1,
start_pos,
end_pos,
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/coherence/coherence_inherent.old.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | s.the_fn();
| ^^^^^^ method not found in `&Lib::TheStruct`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
`use Lib::TheTrait;`

error: aborting due to previous error
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/coherence/coherence_inherent.re.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | s.the_fn();
| ^^^^^^ method not found in `&Lib::TheStruct`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
`use Lib::TheTrait;`

error: aborting due to previous error
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/coherence/coherence_inherent_cc.old.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | s.the_fn();
| ^^^^^^ method not found in `&coherence_inherent_cc_lib::TheStruct`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
`use coherence_inherent_cc_lib::TheTrait;`

error: aborting due to previous error
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/coherence/coherence_inherent_cc.re.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | s.the_fn();
| ^^^^^^ method not found in `&coherence_inherent_cc_lib::TheStruct`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
`use coherence_inherent_cc_lib::TheTrait;`

error: aborting due to previous error
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/hygiene/no_implicit_prelude.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ LL | ().clone()
| ^^^^^ method not found in `()`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
`use std::clone::Clone;`

error: aborting due to 3 previous errors
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/hygiene/trait_items.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LL | pub macro m() { ().f() }
| ^ method not found in `()`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
`use foo::T;`

error: aborting due to previous error
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/impl-trait/no-method-suggested-traits.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | 1u32.method();
| ^^^^^^ method not found in `u32`
|
= help: items from traits can only be used if the trait is in scope
help: the following traits are implemented but not in scope, perhaps add a `use` for one of them:
help: the following traits are implemented but not in scope; perhaps add a `use` for one of them:
|
LL | use foo::Bar;
|
Expand All @@ -23,7 +23,7 @@ LL | std::rc::Rc::new(&mut Box::new(&1u32)).method();
| ^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&u32>>`
|
= help: items from traits can only be used if the trait is in scope
help: the following traits are implemented but not in scope, perhaps add a `use` for one of them:
help: the following traits are implemented but not in scope; perhaps add a `use` for one of them:
|
LL | use foo::Bar;
|
Expand All @@ -41,7 +41,7 @@ LL | 'a'.method();
| ^^^^^^ method not found in `char`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use foo::Bar;
|
Expand All @@ -61,7 +61,7 @@ LL | std::rc::Rc::new(&mut Box::new(&'a')).method();
| ^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&char>>`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use foo::Bar;
|
Expand All @@ -73,7 +73,7 @@ LL | 1i32.method();
| ^^^^^^ method not found in `i32`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use no_method_suggested_traits::foo::PubPub;
|
Expand All @@ -85,7 +85,7 @@ LL | std::rc::Rc::new(&mut Box::new(&1i32)).method();
| ^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&i32>>`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use no_method_suggested_traits::foo::PubPub;
|
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-10465.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | b.foo();
| ^^^ method not found in `&b::B`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
`use a::A;`

error: aborting due to previous error
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-37534.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ help: possible better candidate is found in another module, you can import it in
LL | use std::hash::Hash;
|

warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default. Only `?Sized` is supported
warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default; only `?Sized` is supported
--> $DIR/issue-37534.rs:1:12
|
LL | struct Foo<T: ?Hash> { }
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-39175.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | Command::new("echo").arg("hello").exec();
| ^^^^ method not found in `&mut std::process::Command`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use std::os::unix::process::CommandExt;
|
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-43189.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | ().a();
| ^ method not found in `()`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use xcrate_issue_43189_b::xcrate_issue_43189_a::A;
|
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/maybe-bounds-where.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ error[E0203]: type parameter has more than one relaxed default bound, only one i
LL | struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized;
| ^

warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default. Only `?Sized` is supported
warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default; only `?Sized` is supported
--> $DIR/maybe-bounds-where.rs:15:11
|
LL | struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized;
Expand Down
Loading

0 comments on commit 24a84fa

Please sign in to comment.