Skip to content

Commit 24a84fa

Browse files
authored
Rollup merge of rust-lang#64907 - alexreg:tidy-up, r=Mark-Simulacrum
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
2 parents b8c5d3a + 33ed03f commit 24a84fa

23 files changed

+74
-71
lines changed

src/libfmt_macros/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ impl<'a> Parser<'a> {
410410
&self.input[start..self.input.len()]
411411
}
412412

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

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

574-
/// Parses a Count parameter at the current position. This does not check
574+
/// Parses a `Count` parameter at the current position. This does not check
575575
/// for 'CountIsNextParam' because that is only used in precision, not
576576
/// width.
577577
fn count(&mut self, start: usize) -> (Count, Option<InnerSpan>) {

src/librustc_interface/passes.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ pub fn register_plugins<'a>(
247247
rustc_incremental::prepare_session_directory(sess, &crate_name, disambiguator);
248248

249249
if sess.opts.incremental.is_some() {
250-
time(sess, "garbage collect incremental cache directory", || {
250+
time(sess, "garbage-collect incremental cache directory", || {
251251
if let Err(e) = rustc_incremental::garbage_collect_session_directories(sess) {
252252
warn!(
253253
"Error while trying to garbage collect incremental \
@@ -318,7 +318,7 @@ fn configure_and_expand_inner<'a>(
318318
crate_loader: &'a mut CrateLoader<'a>,
319319
plugin_info: PluginInfo,
320320
) -> Result<(ast::Crate, Resolver<'a>)> {
321-
time(sess, "pre ast expansion lint checks", || {
321+
time(sess, "pre-AST-expansion lint checks", || {
322322
lint::check_ast_crate(
323323
sess,
324324
&krate,
@@ -536,8 +536,8 @@ pub fn lower_to_hir(
536536
dep_graph: &DepGraph,
537537
krate: &ast::Crate,
538538
) -> Result<hir::map::Forest> {
539-
// Lower ast -> hir
540-
let hir_forest = time(sess, "lowering ast -> hir", || {
539+
// Lower AST to HIR.
540+
let hir_forest = time(sess, "lowering AST -> HIR", || {
541541
let hir_crate = lower_crate(sess, cstore, &dep_graph, &krate, resolver);
542542

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

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

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

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

src/librustc_typeck/astconv.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -952,8 +952,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
952952
tcx.sess.span_warn(
953953
span,
954954
"default bound relaxed for a type parameter, but \
955-
this does nothing because the given bound is not \
956-
a default. Only `?Sized` is supported",
955+
this does nothing because the given bound is not \
956+
a default; only `?Sized` is supported",
957957
);
958958
}
959959
}

src/librustc_typeck/check/method/suggest.rs

+19-15
Original file line numberDiff line numberDiff line change
@@ -631,26 +631,30 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
631631
}
632632
}
633633

634-
fn suggest_valid_traits(&self,
635-
err: &mut DiagnosticBuilder<'_>,
636-
valid_out_of_scope_traits: Vec<DefId>) -> bool {
634+
fn suggest_valid_traits(
635+
&self,
636+
err: &mut DiagnosticBuilder<'_>,
637+
valid_out_of_scope_traits: Vec<DefId>,
638+
) -> bool {
637639
if !valid_out_of_scope_traits.is_empty() {
638640
let mut candidates = valid_out_of_scope_traits;
639641
candidates.sort();
640642
candidates.dedup();
641643
err.help("items from traits can only be used if the trait is in scope");
642-
let msg = format!("the following {traits_are} implemented but not in scope, \
643-
perhaps add a `use` for {one_of_them}:",
644-
traits_are = if candidates.len() == 1 {
645-
"trait is"
646-
} else {
647-
"traits are"
648-
},
649-
one_of_them = if candidates.len() == 1 {
650-
"it"
651-
} else {
652-
"one of them"
653-
});
644+
let msg = format!(
645+
"the following {traits_are} implemented but not in scope; \
646+
perhaps add a `use` for {one_of_them}:",
647+
traits_are = if candidates.len() == 1 {
648+
"trait is"
649+
} else {
650+
"traits are"
651+
},
652+
one_of_them = if candidates.len() == 1 {
653+
"it"
654+
} else {
655+
"one of them"
656+
},
657+
);
654658

655659
self.suggest_use_candidates(err, msg, candidates);
656660
true

src/libsyntax/parse/lexer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'a> StringReader<'a> {
4747
source_file: Lrc<syntax_pos::SourceFile>,
4848
override_span: Option<Span>) -> Self {
4949
if source_file.src.is_none() {
50-
sess.span_diagnostic.bug(&format!("Cannot lex source_file without source: {}",
50+
sess.span_diagnostic.bug(&format!("cannot lex `source_file` without source: {}",
5151
source_file.name));
5252
}
5353

src/libsyntax_pos/lib.rs

+15-16
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ pub struct OffsetOverflowError;
884884
/// A single source in the `SourceMap`.
885885
#[derive(Clone)]
886886
pub struct SourceFile {
887-
/// The name of the file that the source came from, source that doesn't
887+
/// The name of the file that the source came from. Source that doesn't
888888
/// originate from files has names between angle brackets by convention
889889
/// (e.g., `<anon>`).
890890
pub name: FileName,
@@ -922,9 +922,9 @@ impl Encodable for SourceFile {
922922
s.emit_struct_field("name", 0, |s| self.name.encode(s))?;
923923
s.emit_struct_field("name_was_remapped", 1, |s| self.name_was_remapped.encode(s))?;
924924
s.emit_struct_field("src_hash", 2, |s| self.src_hash.encode(s))?;
925-
s.emit_struct_field("start_pos", 4, |s| self.start_pos.encode(s))?;
926-
s.emit_struct_field("end_pos", 5, |s| self.end_pos.encode(s))?;
927-
s.emit_struct_field("lines", 6, |s| {
925+
s.emit_struct_field("start_pos", 3, |s| self.start_pos.encode(s))?;
926+
s.emit_struct_field("end_pos", 4, |s| self.end_pos.encode(s))?;
927+
s.emit_struct_field("lines", 5, |s| {
928928
let lines = &self.lines[..];
929929
// Store the length.
930930
s.emit_u32(lines.len() as u32)?;
@@ -970,13 +970,13 @@ impl Encodable for SourceFile {
970970

971971
Ok(())
972972
})?;
973-
s.emit_struct_field("multibyte_chars", 7, |s| {
973+
s.emit_struct_field("multibyte_chars", 6, |s| {
974974
self.multibyte_chars.encode(s)
975975
})?;
976-
s.emit_struct_field("non_narrow_chars", 8, |s| {
976+
s.emit_struct_field("non_narrow_chars", 7, |s| {
977977
self.non_narrow_chars.encode(s)
978978
})?;
979-
s.emit_struct_field("name_hash", 9, |s| {
979+
s.emit_struct_field("name_hash", 8, |s| {
980980
self.name_hash.encode(s)
981981
})
982982
})
@@ -985,17 +985,16 @@ impl Encodable for SourceFile {
985985

986986
impl Decodable for SourceFile {
987987
fn decode<D: Decoder>(d: &mut D) -> Result<SourceFile, D::Error> {
988-
989988
d.read_struct("SourceFile", 8, |d| {
990989
let name: FileName = d.read_struct_field("name", 0, |d| Decodable::decode(d))?;
991990
let name_was_remapped: bool =
992991
d.read_struct_field("name_was_remapped", 1, |d| Decodable::decode(d))?;
993992
let src_hash: u128 =
994993
d.read_struct_field("src_hash", 2, |d| Decodable::decode(d))?;
995994
let start_pos: BytePos =
996-
d.read_struct_field("start_pos", 4, |d| Decodable::decode(d))?;
997-
let end_pos: BytePos = d.read_struct_field("end_pos", 5, |d| Decodable::decode(d))?;
998-
let lines: Vec<BytePos> = d.read_struct_field("lines", 6, |d| {
995+
d.read_struct_field("start_pos", 3, |d| Decodable::decode(d))?;
996+
let end_pos: BytePos = d.read_struct_field("end_pos", 4, |d| Decodable::decode(d))?;
997+
let lines: Vec<BytePos> = d.read_struct_field("lines", 5, |d| {
999998
let num_lines: u32 = Decodable::decode(d)?;
1000999
let mut lines = Vec::with_capacity(num_lines as usize);
10011000

@@ -1024,18 +1023,18 @@ impl Decodable for SourceFile {
10241023
Ok(lines)
10251024
})?;
10261025
let multibyte_chars: Vec<MultiByteChar> =
1027-
d.read_struct_field("multibyte_chars", 7, |d| Decodable::decode(d))?;
1026+
d.read_struct_field("multibyte_chars", 6, |d| Decodable::decode(d))?;
10281027
let non_narrow_chars: Vec<NonNarrowChar> =
1029-
d.read_struct_field("non_narrow_chars", 8, |d| Decodable::decode(d))?;
1028+
d.read_struct_field("non_narrow_chars", 7, |d| Decodable::decode(d))?;
10301029
let name_hash: u128 =
1031-
d.read_struct_field("name_hash", 9, |d| Decodable::decode(d))?;
1030+
d.read_struct_field("name_hash", 8, |d| Decodable::decode(d))?;
10321031
Ok(SourceFile {
10331032
name,
10341033
name_was_remapped,
10351034
unmapped_path: None,
10361035
// `crate_of_origin` has to be set by the importer.
1037-
// This value matches up with rustc::hir::def_id::INVALID_CRATE.
1038-
// That constant is not available here unfortunately :(
1036+
// This value matches up with `rustc::hir::def_id::INVALID_CRATE`.
1037+
// That constant is not available here, unfortunately.
10391038
crate_of_origin: std::u32::MAX - 1,
10401039
start_pos,
10411040
end_pos,

src/test/ui/coherence/coherence_inherent.old.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | s.the_fn();
55
| ^^^^^^ method not found in `&Lib::TheStruct`
66
|
77
= help: items from traits can only be used if the trait is in scope
8-
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
8+
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
99
`use Lib::TheTrait;`
1010

1111
error: aborting due to previous error

src/test/ui/coherence/coherence_inherent.re.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | s.the_fn();
55
| ^^^^^^ method not found in `&Lib::TheStruct`
66
|
77
= help: items from traits can only be used if the trait is in scope
8-
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
8+
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
99
`use Lib::TheTrait;`
1010

1111
error: aborting due to previous error

src/test/ui/coherence/coherence_inherent_cc.old.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | s.the_fn();
55
| ^^^^^^ method not found in `&coherence_inherent_cc_lib::TheStruct`
66
|
77
= help: items from traits can only be used if the trait is in scope
8-
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
8+
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
99
`use coherence_inherent_cc_lib::TheTrait;`
1010

1111
error: aborting due to previous error

src/test/ui/coherence/coherence_inherent_cc.re.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | s.the_fn();
55
| ^^^^^^ method not found in `&coherence_inherent_cc_lib::TheStruct`
66
|
77
= help: items from traits can only be used if the trait is in scope
8-
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
8+
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
99
`use coherence_inherent_cc_lib::TheTrait;`
1010

1111
error: aborting due to previous error

src/test/ui/hygiene/no_implicit_prelude.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ LL | ().clone()
2525
| ^^^^^ method not found in `()`
2626
|
2727
= help: items from traits can only be used if the trait is in scope
28-
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
28+
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
2929
`use std::clone::Clone;`
3030

3131
error: aborting due to 3 previous errors

src/test/ui/hygiene/trait_items.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | pub macro m() { ().f() }
88
| ^ method not found in `()`
99
|
1010
= help: items from traits can only be used if the trait is in scope
11-
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
11+
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
1212
`use foo::T;`
1313

1414
error: aborting due to previous error

src/test/ui/impl-trait/no-method-suggested-traits.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | 1u32.method();
55
| ^^^^^^ method not found in `u32`
66
|
77
= help: items from traits can only be used if the trait is in scope
8-
help: the following traits are implemented but not in scope, perhaps add a `use` for one of them:
8+
help: the following traits are implemented but not in scope; perhaps add a `use` for one of them:
99
|
1010
LL | use foo::Bar;
1111
|
@@ -23,7 +23,7 @@ LL | std::rc::Rc::new(&mut Box::new(&1u32)).method();
2323
| ^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&u32>>`
2424
|
2525
= help: items from traits can only be used if the trait is in scope
26-
help: the following traits are implemented but not in scope, perhaps add a `use` for one of them:
26+
help: the following traits are implemented but not in scope; perhaps add a `use` for one of them:
2727
|
2828
LL | use foo::Bar;
2929
|
@@ -41,7 +41,7 @@ LL | 'a'.method();
4141
| ^^^^^^ method not found in `char`
4242
|
4343
= help: items from traits can only be used if the trait is in scope
44-
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
44+
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
4545
|
4646
LL | use foo::Bar;
4747
|
@@ -61,7 +61,7 @@ LL | std::rc::Rc::new(&mut Box::new(&'a')).method();
6161
| ^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&char>>`
6262
|
6363
= help: items from traits can only be used if the trait is in scope
64-
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
64+
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
6565
|
6666
LL | use foo::Bar;
6767
|
@@ -73,7 +73,7 @@ LL | 1i32.method();
7373
| ^^^^^^ method not found in `i32`
7474
|
7575
= help: items from traits can only be used if the trait is in scope
76-
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
76+
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
7777
|
7878
LL | use no_method_suggested_traits::foo::PubPub;
7979
|
@@ -85,7 +85,7 @@ LL | std::rc::Rc::new(&mut Box::new(&1i32)).method();
8585
| ^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&i32>>`
8686
|
8787
= help: items from traits can only be used if the trait is in scope
88-
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
88+
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
8989
|
9090
LL | use no_method_suggested_traits::foo::PubPub;
9191
|

src/test/ui/issues/issue-10465.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | b.foo();
55
| ^^^ method not found in `&b::B`
66
|
77
= help: items from traits can only be used if the trait is in scope
8-
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
8+
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
99
`use a::A;`
1010

1111
error: aborting due to previous error

src/test/ui/issues/issue-37534.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ help: possible better candidate is found in another module, you can import it in
88
LL | use std::hash::Hash;
99
|
1010

11-
warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default. Only `?Sized` is supported
11+
warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default; only `?Sized` is supported
1212
--> $DIR/issue-37534.rs:1:12
1313
|
1414
LL | struct Foo<T: ?Hash> { }

src/test/ui/issues/issue-39175.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | Command::new("echo").arg("hello").exec();
55
| ^^^^ method not found in `&mut std::process::Command`
66
|
77
= help: items from traits can only be used if the trait is in scope
8-
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
8+
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
99
|
1010
LL | use std::os::unix::process::CommandExt;
1111
|

src/test/ui/issues/issue-43189.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | ().a();
55
| ^ method not found in `()`
66
|
77
= help: items from traits can only be used if the trait is in scope
8-
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
8+
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
99
|
1010
LL | use xcrate_issue_43189_b::xcrate_issue_43189_a::A;
1111
|

src/test/ui/maybe-bounds-where.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ error[E0203]: type parameter has more than one relaxed default bound, only one i
3434
LL | struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized;
3535
| ^
3636

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

0 commit comments

Comments
 (0)