Skip to content

Commit 507bff9

Browse files
committed
Auto merge of #80510 - JohnTitor:rollup-gow7y0l, r=JohnTitor
Rollup of 7 pull requests Successful merges: - #80185 (Fix ICE when pointing at multi bytes character) - #80260 (slightly more typed interface to panic implementation) - #80311 (Improvements to NatVis support) - #80337 (Use `desc` as a doc-comment for queries if there are no doc comments) - #80381 (Revert "Cleanup markdown span handling") - #80492 (remove empty wraps, don't return Results from from infallible functions) - #80509 (where possible, pass slices instead of &Vec or &String (clippy::ptr_arg)) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents bbcaed0 + 41fa0db commit 507bff9

File tree

45 files changed

+387
-279
lines changed

Some content is hidden

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

45 files changed

+387
-279
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ pub(crate) unsafe fn optimize(
485485
diag_handler: &Handler,
486486
module: &ModuleCodegen<ModuleLlvm>,
487487
config: &ModuleConfig,
488-
) -> Result<(), FatalError> {
488+
) {
489489
let _timer = cgcx.prof.generic_activity_with_arg("LLVM_module_optimize", &module.name[..]);
490490

491491
let llmod = module.module_llvm.llmod();
@@ -511,7 +511,7 @@ pub(crate) unsafe fn optimize(
511511
_ => llvm::OptStage::PreLinkNoLTO,
512512
};
513513
optimize_with_new_llvm_pass_manager(cgcx, module, config, opt_level, opt_stage);
514-
return Ok(());
514+
return;
515515
}
516516

517517
if cgcx.prof.llvm_recording_enabled() {
@@ -634,7 +634,6 @@ pub(crate) unsafe fn optimize(
634634
llvm::LLVMDisposePassManager(fpm);
635635
llvm::LLVMDisposePassManager(mpm);
636636
}
637-
Ok(())
638637
}
639638

640639
unsafe fn add_sanitizer_passes(config: &ModuleConfig, passes: &mut Vec<&'static mut llvm::Pass>) {

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,13 +2322,13 @@ fn set_members_of_composite_type(
23222322
DIB(cx),
23232323
composite_type_metadata,
23242324
Some(type_array),
2325-
type_params,
2325+
Some(type_params),
23262326
);
23272327
}
23282328
}
23292329

23302330
/// Computes the type parameters for a type, if any, for the given metadata.
2331-
fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> Option<&'ll DIArray> {
2331+
fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> &'ll DIArray {
23322332
if let ty::Adt(def, substs) = *ty.kind() {
23332333
if substs.types().next().is_some() {
23342334
let generics = cx.tcx.generics_of(def.did);
@@ -2358,10 +2358,10 @@ fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> Option<&'
23582358
})
23592359
.collect();
23602360

2361-
return Some(create_DIArray(DIB(cx), &template_params[..]));
2361+
return create_DIArray(DIB(cx), &template_params[..]);
23622362
}
23632363
}
2364-
return Some(create_DIArray(DIB(cx), &[]));
2364+
return create_DIArray(DIB(cx), &[]);
23652365

23662366
fn get_parameter_names(cx: &CodegenCx<'_, '_>, generics: &ty::Generics) -> Vec<Symbol> {
23672367
let mut names = generics

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl WriteBackendMethods for LlvmCodegenBackend {
160160
module: &ModuleCodegen<Self::Module>,
161161
config: &ModuleConfig,
162162
) -> Result<(), FatalError> {
163-
back::write::optimize(cgcx, diag_handler, module, config)
163+
Ok(back::write::optimize(cgcx, diag_handler, module, config))
164164
}
165165
unsafe fn optimize_thin(
166166
cgcx: &CodegenContext<Self>,

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
522522
mut bx: Bx,
523523
terminator: &mir::Terminator<'tcx>,
524524
func: &mir::Operand<'tcx>,
525-
args: &Vec<mir::Operand<'tcx>>,
525+
args: &[mir::Operand<'tcx>],
526526
destination: &Option<(mir::Place<'tcx>, mir::BasicBlock)>,
527527
cleanup: Option<mir::BasicBlock>,
528528
fn_span: Span,

compiler/rustc_driver/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ fn handle_explain(registry: Registry, code: &str, output: ErrorOutputType) {
603603
}
604604
}
605605

606-
fn show_content_with_pager(content: &String) {
606+
fn show_content_with_pager(content: &str) {
607607
let pager_name = env::var_os("PAGER").unwrap_or_else(|| {
608608
if cfg!(windows) { OsString::from("more.com") } else { OsString::from("less") }
609609
});

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
417417
// obviously it never weeds out ALL errors.
418418
fn process_errors(
419419
&self,
420-
errors: &Vec<RegionResolutionError<'tcx>>,
420+
errors: &[RegionResolutionError<'tcx>],
421421
) -> Vec<RegionResolutionError<'tcx>> {
422422
debug!("process_errors()");
423423

@@ -442,7 +442,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
442442
};
443443

444444
let mut errors = if errors.iter().all(|e| is_bound_failure(e)) {
445-
errors.clone()
445+
errors.to_owned()
446446
} else {
447447
errors.iter().filter(|&e| !is_bound_failure(e)).cloned().collect()
448448
};

compiler/rustc_macros/src/query.rs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use syn::parse::{Parse, ParseStream, Result};
55
use syn::punctuated::Punctuated;
66
use syn::spanned::Spanned;
77
use syn::{
8-
braced, parenthesized, parse_macro_input, AttrStyle, Attribute, Block, Error, Expr, Ident,
9-
ReturnType, Token, Type,
8+
braced, parenthesized, parse_macro_input, parse_quote, AttrStyle, Attribute, Block, Error,
9+
Expr, Ident, ReturnType, Token, Type,
1010
};
1111

1212
mod kw {
@@ -272,6 +272,40 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
272272
if desc.is_some() {
273273
panic!("duplicate modifier `desc` for query `{}`", query.name);
274274
}
275+
// If there are no doc-comments, give at least some idea of what
276+
// it does by showing the query description.
277+
if query.doc_comments.is_empty() {
278+
use ::syn::*;
279+
let mut list = list.iter();
280+
let format_str: String = match list.next() {
281+
Some(&Expr::Lit(ExprLit { lit: Lit::Str(ref lit_str), .. })) => {
282+
lit_str.value().replace("`{}`", "{}") // We add them later anyways for consistency
283+
}
284+
_ => panic!("Expected a string literal"),
285+
};
286+
let mut fmt_fragments = format_str.split("{}");
287+
let mut doc_string = fmt_fragments.next().unwrap().to_string();
288+
list.map(::quote::ToTokens::to_token_stream).zip(fmt_fragments).for_each(
289+
|(tts, next_fmt_fragment)| {
290+
use ::core::fmt::Write;
291+
write!(
292+
&mut doc_string,
293+
" `{}` {}",
294+
tts.to_string().replace(" . ", "."),
295+
next_fmt_fragment,
296+
)
297+
.unwrap();
298+
},
299+
);
300+
let doc_string = format!(
301+
"[query description - consider adding a doc-comment!] {}",
302+
doc_string
303+
);
304+
let comment = parse_quote! {
305+
#[doc = #doc_string]
306+
};
307+
query.doc_comments.push(comment);
308+
}
275309
desc = Some((tcx, list));
276310
}
277311
QueryModifier::FatalCycle => {

compiler/rustc_macros/src/session_diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
574574
/// format!("Expected a point greater than ({x}, {y})", x = self.x, y = self.y)
575575
/// ```
576576
/// This function builds the entire call to format!.
577-
fn build_format(&self, input: &String, span: proc_macro2::Span) -> proc_macro2::TokenStream {
577+
fn build_format(&self, input: &str, span: proc_macro2::Span) -> proc_macro2::TokenStream {
578578
// This set is used later to generate the final format string. To keep builds reproducible,
579579
// the iteration order needs to be deterministic, hence why we use a BTreeSet here instead
580580
// of a HashSet.

compiler/rustc_mir/src/borrow_check/diagnostics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
954954
&self,
955955
def_id: DefId,
956956
target_place: PlaceRef<'tcx>,
957-
places: &Vec<Operand<'tcx>>,
957+
places: &[Operand<'tcx>],
958958
) -> Option<(Span, Option<GeneratorKind>, Span)> {
959959
debug!(
960960
"closure_span: def_id={:?} target_place={:?} places={:?}",

compiler/rustc_mir/src/borrow_check/type_check/liveness/local_use_map.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ impl vll::LinkElem for Appearance {
5858
}
5959

6060
impl LocalUseMap {
61-
crate fn build(
62-
live_locals: &Vec<Local>,
63-
elements: &RegionValueElements,
64-
body: &Body<'_>,
65-
) -> Self {
61+
crate fn build(live_locals: &[Local], elements: &RegionValueElements, body: &Body<'_>) -> Self {
6662
let nones = IndexVec::from_elem_n(None, body.local_decls.len());
6763
let mut local_use_map = LocalUseMap {
6864
first_def_at: nones.clone(),

0 commit comments

Comments
 (0)