Skip to content

Commit f0448f4

Browse files
committed
Auto merge of rust-lang#91760 - matthiaskrgr:rollup-zcemh6j, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - rust-lang#90407 (Document all public items in `rustc_incremental`) - rust-lang#90897 (Fix incorrect stability attributes) - rust-lang#91105 (Fix method name reference in stream documentation) - rust-lang#91325 (adjust const_eval_select documentation) - rust-lang#91470 (code-cov: generate dead functions with private/default linkage) - rust-lang#91482 (Update documentation to use `from()` to initialize `HashMap`s and `BTreeMap`s) - rust-lang#91524 (Fix Vec::extend_from_slice docs) - rust-lang#91575 (Fix ICE on format string of macro with secondary-label) - rust-lang#91625 (Remove redundant [..]s) - rust-lang#91646 (Fix documentation for `core::ready::Ready`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0b42dea + 1fca934 commit f0448f4

File tree

67 files changed

+424
-224
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+424
-224
lines changed

compiler/rustc_ast/src/util/literal.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl LitKind {
5757
// string in the token.
5858
let s = symbol.as_str();
5959
let symbol =
60-
if s.contains(&['\\', '\r'][..]) {
60+
if s.contains(&['\\', '\r']) {
6161
let mut buf = String::with_capacity(s.len());
6262
let mut error = Ok(());
6363
unescape_literal(&s, Mode::Str, &mut |_, unescaped_char| {

compiler/rustc_ast_passes/src/feature_gate.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
347347

348348
if let Some(modifiers) = nested_meta.value_str() {
349349
for modifier in modifiers.as_str().split(',') {
350-
if let Some(modifier) = modifier.strip_prefix(&['+', '-'][..]) {
350+
if let Some(modifier) = modifier.strip_prefix(&['+', '-']) {
351351
macro_rules! gate_modifier { ($($name:literal => $feature:ident)*) => {
352352
$(if modifier == $name {
353353
let msg = concat!("`#[link(modifiers=\"", $name, "\")]` is unstable");
@@ -383,7 +383,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
383383
}
384384

385385
ast::ItemKind::Fn(..) => {
386-
if self.sess.contains_name(&i.attrs[..], sym::start) {
386+
if self.sess.contains_name(&i.attrs, sym::start) {
387387
gate_feature_post!(
388388
&self,
389389
start,
@@ -396,7 +396,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
396396
}
397397

398398
ast::ItemKind::Struct(..) => {
399-
for attr in self.sess.filter_by_name(&i.attrs[..], sym::repr) {
399+
for attr in self.sess.filter_by_name(&i.attrs, sym::repr) {
400400
for item in attr.meta_item_list().unwrap_or_else(Vec::new) {
401401
if item.has_name(sym::simd) {
402402
gate_feature_post!(

compiler/rustc_ast_pretty/src/pprust/state.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
499499
ast::MetaItemKind::List(ref items) => {
500500
self.print_path(&item.path, false, 0);
501501
self.popen();
502-
self.commasep(Consistent, &items[..], |s, i| s.print_meta_list_item(i));
502+
self.commasep(Consistent, &items, |s, i| s.print_meta_list_item(i));
503503
self.pclose();
504504
}
505505
}
@@ -997,7 +997,7 @@ impl<'a> State<'a> {
997997
}
998998
ast::TyKind::Tup(ref elts) => {
999999
self.popen();
1000-
self.commasep(Inconsistent, &elts[..], |s, ty| s.print_type(ty));
1000+
self.commasep(Inconsistent, &elts, |s, ty| s.print_type(ty));
10011001
if elts.len() == 1 {
10021002
self.word(",");
10031003
}
@@ -1017,10 +1017,10 @@ impl<'a> State<'a> {
10171017
ast::TyKind::Path(Some(ref qself), ref path) => self.print_qpath(path, qself, false),
10181018
ast::TyKind::TraitObject(ref bounds, syntax) => {
10191019
let prefix = if syntax == ast::TraitObjectSyntax::Dyn { "dyn" } else { "" };
1020-
self.print_type_bounds(prefix, &bounds[..]);
1020+
self.print_type_bounds(prefix, &bounds);
10211021
}
10221022
ast::TyKind::ImplTrait(_, ref bounds) => {
1023-
self.print_type_bounds("impl", &bounds[..]);
1023+
self.print_type_bounds("impl", &bounds);
10241024
}
10251025
ast::TyKind::Array(ref ty, ref length) => {
10261026
self.word("[");
@@ -1339,7 +1339,7 @@ impl<'a> State<'a> {
13391339
real_bounds.push(b.clone());
13401340
}
13411341
}
1342-
self.print_type_bounds(":", &real_bounds[..]);
1342+
self.print_type_bounds(":", &real_bounds);
13431343
self.print_where_clause(&generics.where_clause);
13441344
self.word(" ");
13451345
self.bopen();
@@ -1368,7 +1368,7 @@ impl<'a> State<'a> {
13681368
}
13691369
}
13701370
self.nbsp();
1371-
self.print_type_bounds("=", &real_bounds[..]);
1371+
self.print_type_bounds("=", &real_bounds);
13721372
self.print_where_clause(&generics.where_clause);
13731373
self.word(";");
13741374
}
@@ -1960,10 +1960,10 @@ impl<'a> State<'a> {
19601960
self.print_expr_tup(exprs);
19611961
}
19621962
ast::ExprKind::Call(ref func, ref args) => {
1963-
self.print_expr_call(func, &args[..]);
1963+
self.print_expr_call(func, &args);
19641964
}
19651965
ast::ExprKind::MethodCall(ref segment, ref args, _) => {
1966-
self.print_expr_method_call(segment, &args[..]);
1966+
self.print_expr_method_call(segment, &args);
19671967
}
19681968
ast::ExprKind::Binary(op, ref lhs, ref rhs) => {
19691969
self.print_expr_binary(op, lhs, rhs);
@@ -2440,11 +2440,11 @@ impl<'a> State<'a> {
24402440
self.print_path(path, true, 0);
24412441
}
24422442
self.popen();
2443-
self.commasep(Inconsistent, &elts[..], |s, p| s.print_pat(p));
2443+
self.commasep(Inconsistent, &elts, |s, p| s.print_pat(p));
24442444
self.pclose();
24452445
}
24462446
PatKind::Or(ref pats) => {
2447-
self.strsep("|", true, Inconsistent, &pats[..], |s, p| s.print_pat(p));
2447+
self.strsep("|", true, Inconsistent, &pats, |s, p| s.print_pat(p));
24482448
}
24492449
PatKind::Path(None, ref path) => {
24502450
self.print_path(path, true, 0);
@@ -2462,7 +2462,7 @@ impl<'a> State<'a> {
24622462
self.word_space("{");
24632463
self.commasep_cmnt(
24642464
Consistent,
2465-
&fields[..],
2465+
&fields,
24662466
|s, f| {
24672467
s.cbox(INDENT_UNIT);
24682468
if !f.is_shorthand {
@@ -2485,7 +2485,7 @@ impl<'a> State<'a> {
24852485
}
24862486
PatKind::Tuple(ref elts) => {
24872487
self.popen();
2488-
self.commasep(Inconsistent, &elts[..], |s, p| s.print_pat(p));
2488+
self.commasep(Inconsistent, &elts, |s, p| s.print_pat(p));
24892489
if elts.len() == 1 {
24902490
self.word(",");
24912491
}
@@ -2527,7 +2527,7 @@ impl<'a> State<'a> {
25272527
}
25282528
PatKind::Slice(ref elts) => {
25292529
self.word("[");
2530-
self.commasep(Inconsistent, &elts[..], |s, p| s.print_pat(p));
2530+
self.commasep(Inconsistent, &elts, |s, p| s.print_pat(p));
25312531
self.word("]");
25322532
}
25332533
PatKind::Rest => self.word(".."),
@@ -2836,7 +2836,7 @@ impl<'a> State<'a> {
28362836
self.print_path(&tree.prefix, false, 0);
28372837
self.word("::{");
28382838
}
2839-
self.commasep(Inconsistent, &items[..], |this, &(ref tree, _)| {
2839+
self.commasep(Inconsistent, &items, |this, &(ref tree, _)| {
28402840
this.print_use_tree(tree)
28412841
});
28422842
self.word("}");

compiler/rustc_builtin_macros/src/asm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option<ast::Inl
712712
Some(&idx) => Some(idx),
713713
None => {
714714
let msg = format!("there is no argument named `{}`", name);
715-
ecx.struct_span_err(span, &msg[..]).emit();
715+
ecx.struct_span_err(span, &msg).emit();
716716
None
717717
}
718718
},

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -766,17 +766,17 @@ impl<'a> TraitDef<'a> {
766766
self,
767767
struct_def,
768768
type_ident,
769-
&self_args[..],
770-
&nonself_args[..],
769+
&self_args,
770+
&nonself_args,
771771
)
772772
} else {
773773
method_def.expand_struct_method_body(
774774
cx,
775775
self,
776776
struct_def,
777777
type_ident,
778-
&self_args[..],
779-
&nonself_args[..],
778+
&self_args,
779+
&nonself_args,
780780
use_temporaries,
781781
)
782782
};
@@ -815,8 +815,8 @@ impl<'a> TraitDef<'a> {
815815
self,
816816
enum_def,
817817
type_ident,
818-
&self_args[..],
819-
&nonself_args[..],
818+
&self_args,
819+
&nonself_args,
820820
)
821821
} else {
822822
method_def.expand_enum_method_body(
@@ -825,7 +825,7 @@ impl<'a> TraitDef<'a> {
825825
enum_def,
826826
type_ident,
827827
self_args,
828-
&nonself_args[..],
828+
&nonself_args,
829829
)
830830
};
831831

@@ -1217,7 +1217,7 @@ impl<'a> MethodDef<'a> {
12171217
let vi_idents = self_arg_names
12181218
.iter()
12191219
.map(|name| {
1220-
let vi_suffix = format!("{}_vi", &name[..]);
1220+
let vi_suffix = format!("{}_vi", name);
12211221
Ident::from_str_and_span(&vi_suffix, span)
12221222
})
12231223
.collect::<Vec<Ident>>();
@@ -1226,7 +1226,7 @@ impl<'a> MethodDef<'a> {
12261226
// delegated expression that handles the catch-all case,
12271227
// using `__variants_tuple` to drive logic if necessary.
12281228
let catch_all_substructure =
1229-
EnumNonMatchingCollapsed(self_arg_idents, &variants[..], &vi_idents[..]);
1229+
EnumNonMatchingCollapsed(self_arg_idents, &variants, &vi_idents);
12301230

12311231
let first_fieldless = variants.iter().find(|v| v.data.fields().is_empty());
12321232

@@ -1261,7 +1261,7 @@ impl<'a> MethodDef<'a> {
12611261
idents
12621262
};
12631263
for self_arg_name in &self_arg_names[1..] {
1264-
let (p, idents) = mk_self_pat(cx, &self_arg_name[..]);
1264+
let (p, idents) = mk_self_pat(cx, &self_arg_name);
12651265
subpats.push(p);
12661266
self_pats_idents.push(idents);
12671267
}

compiler/rustc_builtin_macros/src/format.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ impl<'a, 'b> Context<'a, 'b> {
549549
} else {
550550
self.fmtsp
551551
};
552-
let mut err = self.ecx.struct_span_err(sp, &msg[..]);
552+
let mut err = self.ecx.struct_span_err(sp, &msg);
553553

554554
err.note(&format!(
555555
"did you intend to capture a variable `{}` from \
@@ -995,8 +995,9 @@ pub fn expand_preparsed_format_args(
995995
e.note(&note);
996996
}
997997
if let Some((label, span)) = err.secondary_label {
998-
let sp = fmt_span.from_inner(span);
999-
e.span_label(sp, label);
998+
if efmt_kind_is_lit {
999+
e.span_label(fmt_span.from_inner(span), label);
1000+
}
10001001
}
10011002
e.emit();
10021003
return DummyResult::raw_expr(sp, true);

compiler/rustc_codegen_gcc/src/back/write.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub(crate) unsafe fn codegen(cgcx: &CodegenContext<GccCodegenBackend>, _diag_han
3232
if config.emit_asm {
3333
let _timer = cgcx
3434
.prof
35-
.generic_activity_with_arg("LLVM_module_codegen_emit_asm", &module.name[..]);
35+
.generic_activity_with_arg("LLVM_module_codegen_emit_asm", &*module.name);
3636
let path = cgcx.output_filenames.temp_path(OutputType::Assembly, module_name);
3737
context.compile_to_file(OutputKind::Assembler, path.to_str().expect("path to str"));
3838
}
@@ -41,7 +41,7 @@ pub(crate) unsafe fn codegen(cgcx: &CodegenContext<GccCodegenBackend>, _diag_han
4141
EmitObj::ObjectCode(_) => {
4242
let _timer = cgcx
4343
.prof
44-
.generic_activity_with_arg("LLVM_module_codegen_emit_obj", &module.name[..]);
44+
.generic_activity_with_arg("LLVM_module_codegen_emit_obj", &*module.name);
4545
match &*module.name {
4646
"std_example.7rcbfp3g-cgu.15" => {
4747
println!("Dumping reproducer {}", module.name);

compiler/rustc_codegen_llvm/src/asm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ pub(crate) fn inline_asm_call(
477477
.collect::<Vec<_>>();
478478

479479
debug!("Asm Output Type: {:?}", output);
480-
let fty = bx.cx.type_func(&argtys[..], output);
480+
let fty = bx.cx.type_func(&argtys, output);
481481
unsafe {
482482
// Ask LLVM to verify that the constraints are well-formed.
483483
let constraints_ok = llvm::LLVMRustInlineAsmVerify(fty, cons.as_ptr().cast(), cons.len());

compiler/rustc_codegen_llvm/src/back/lto.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ pub(crate) fn run_pass_manager(
587587
config: &ModuleConfig,
588588
thin: bool,
589589
) -> Result<(), FatalError> {
590-
let _timer = cgcx.prof.extra_verbose_generic_activity("LLVM_lto_optimize", &module.name[..]);
590+
let _timer = cgcx.prof.extra_verbose_generic_activity("LLVM_lto_optimize", &*module.name);
591591

592592
// Now we have one massive module inside of llmod. Time to run the
593593
// LTO-specific optimization passes that LLVM provides.

compiler/rustc_codegen_llvm/src/back/write.rs

+16-20
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ pub(crate) unsafe fn optimize(
510510
module: &ModuleCodegen<ModuleLlvm>,
511511
config: &ModuleConfig,
512512
) -> Result<(), FatalError> {
513-
let _timer = cgcx.prof.generic_activity_with_arg("LLVM_module_optimize", &module.name[..]);
513+
let _timer = cgcx.prof.generic_activity_with_arg("LLVM_module_optimize", &*module.name);
514514

515515
let llmod = module.module_llvm.llmod();
516516
let llcx = &*module.module_llvm.llcx;
@@ -663,14 +663,14 @@ pub(crate) unsafe fn optimize(
663663
{
664664
let _timer = cgcx.prof.extra_verbose_generic_activity(
665665
"LLVM_module_optimize_function_passes",
666-
&module.name[..],
666+
&*module.name,
667667
);
668668
llvm::LLVMRustRunFunctionPassManager(fpm, llmod);
669669
}
670670
{
671671
let _timer = cgcx.prof.extra_verbose_generic_activity(
672672
"LLVM_module_optimize_module_passes",
673-
&module.name[..],
673+
&*module.name,
674674
);
675675
llvm::LLVMRunPassManager(mpm, llmod);
676676
}
@@ -733,7 +733,7 @@ pub(crate) unsafe fn codegen(
733733
module: ModuleCodegen<ModuleLlvm>,
734734
config: &ModuleConfig,
735735
) -> Result<CompiledModule, FatalError> {
736-
let _timer = cgcx.prof.generic_activity_with_arg("LLVM_module_codegen", &module.name[..]);
736+
let _timer = cgcx.prof.generic_activity_with_arg("LLVM_module_codegen", &*module.name);
737737
{
738738
let llmod = module.module_llvm.llmod();
739739
let llcx = &*module.module_llvm.llcx;
@@ -782,7 +782,7 @@ pub(crate) unsafe fn codegen(
782782
if config.bitcode_needed() {
783783
let _timer = cgcx
784784
.prof
785-
.generic_activity_with_arg("LLVM_module_codegen_make_bitcode", &module.name[..]);
785+
.generic_activity_with_arg("LLVM_module_codegen_make_bitcode", &*module.name);
786786
let thin = ThinBuffer::new(llmod);
787787
let data = thin.data();
788788

@@ -795,29 +795,26 @@ pub(crate) unsafe fn codegen(
795795
}
796796

797797
if config.emit_bc || config.emit_obj == EmitObj::Bitcode {
798-
let _timer = cgcx.prof.generic_activity_with_arg(
799-
"LLVM_module_codegen_emit_bitcode",
800-
&module.name[..],
801-
);
798+
let _timer = cgcx
799+
.prof
800+
.generic_activity_with_arg("LLVM_module_codegen_emit_bitcode", &*module.name);
802801
if let Err(e) = fs::write(&bc_out, data) {
803802
let msg = format!("failed to write bytecode to {}: {}", bc_out.display(), e);
804803
diag_handler.err(&msg);
805804
}
806805
}
807806

808807
if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) {
809-
let _timer = cgcx.prof.generic_activity_with_arg(
810-
"LLVM_module_codegen_embed_bitcode",
811-
&module.name[..],
812-
);
808+
let _timer = cgcx
809+
.prof
810+
.generic_activity_with_arg("LLVM_module_codegen_embed_bitcode", &*module.name);
813811
embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data);
814812
}
815813
}
816814

817815
if config.emit_ir {
818-
let _timer = cgcx
819-
.prof
820-
.generic_activity_with_arg("LLVM_module_codegen_emit_ir", &module.name[..]);
816+
let _timer =
817+
cgcx.prof.generic_activity_with_arg("LLVM_module_codegen_emit_ir", &*module.name);
821818
let out = cgcx.output_filenames.temp_path(OutputType::LlvmAssembly, module_name);
822819
let out_c = path_to_c_string(&out);
823820

@@ -866,9 +863,8 @@ pub(crate) unsafe fn codegen(
866863
}
867864

868865
if config.emit_asm {
869-
let _timer = cgcx
870-
.prof
871-
.generic_activity_with_arg("LLVM_module_codegen_emit_asm", &module.name[..]);
866+
let _timer =
867+
cgcx.prof.generic_activity_with_arg("LLVM_module_codegen_emit_asm", &*module.name);
872868
let path = cgcx.output_filenames.temp_path(OutputType::Assembly, module_name);
873869

874870
// We can't use the same module for asm and object code output,
@@ -898,7 +894,7 @@ pub(crate) unsafe fn codegen(
898894
EmitObj::ObjectCode(_) => {
899895
let _timer = cgcx
900896
.prof
901-
.generic_activity_with_arg("LLVM_module_codegen_emit_obj", &module.name[..]);
897+
.generic_activity_with_arg("LLVM_module_codegen_emit_obj", &*module.name);
902898

903899
let dwo_out = cgcx.output_filenames.temp_path_dwo(module_name);
904900
let dwo_out = match cgcx.split_debuginfo {

compiler/rustc_codegen_llvm/src/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl CodegenCx<'ll, 'tcx> {
120120
!null_terminated as Bool,
121121
);
122122
let sym = self.generate_local_symbol_name("str");
123-
let g = self.define_global(&sym[..], self.val_ty(sc)).unwrap_or_else(|| {
123+
let g = self.define_global(&sym, self.val_ty(sc)).unwrap_or_else(|| {
124124
bug!("symbol `{}` is already defined", sym);
125125
});
126126
llvm::LLVMSetInitializer(g, sc);

0 commit comments

Comments
 (0)