Skip to content

Commit fd3da4b

Browse files
committed
Replace some Option<Span> with Span and use DUMMY_SP instead of None
1 parent 81a964c commit fd3da4b

File tree

77 files changed

+250
-250
lines changed

Some content is hidden

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

77 files changed

+250
-250
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
732732
span: Span,
733733
args: Option<&'hir hir::GenericArgs<'hir>>,
734734
) -> &'hir hir::Path<'hir> {
735-
let def_id = self.tcx.require_lang_item(lang_item, Some(span));
735+
let def_id = self.tcx.require_lang_item(lang_item, span);
736736
let def_kind = self.tcx.def_kind(def_id);
737737
let res = Res::Def(def_kind, def_id);
738738
self.arena.alloc(hir::Path {

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
263263
// something that already has `Fn`-like bounds (or is a closure), so we can't
264264
// restrict anyways.
265265
} else {
266-
let copy_did = self.infcx.tcx.require_lang_item(LangItem::Copy, Some(span));
266+
let copy_did = self.infcx.tcx.require_lang_item(LangItem::Copy, span);
267267
self.suggest_adding_bounds(&mut err, ty, copy_did, span);
268268
}
269269

@@ -1915,7 +1915,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
19151915

19161916
let local_ty = self.body.local_decls[place.local].ty;
19171917
let typeck_results = tcx.typeck(self.mir_def_id());
1918-
let clone = tcx.require_lang_item(LangItem::Clone, Some(body.span));
1918+
let clone = tcx.require_lang_item(LangItem::Clone, body.span);
19191919
for expr in expr_finder.clones {
19201920
if let hir::ExprKind::MethodCall(_, rcvr, _, span) = expr.kind
19211921
&& let Some(rcvr_ty) = typeck_results.node_type_opt(rcvr.hir_id)

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
688688
if !self.unsized_feature_enabled() {
689689
let trait_ref = ty::TraitRef::new(
690690
tcx,
691-
tcx.require_lang_item(LangItem::Sized, Some(self.last_span)),
691+
tcx.require_lang_item(LangItem::Sized, self.last_span),
692692
[place_ty],
693693
);
694694
self.prove_trait_ref(
@@ -1010,7 +1010,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
10101010
let ty = place.ty(self.body, tcx).ty;
10111011
let trait_ref = ty::TraitRef::new(
10121012
tcx,
1013-
tcx.require_lang_item(LangItem::Copy, Some(span)),
1013+
tcx.require_lang_item(LangItem::Copy, span),
10141014
[ty],
10151015
);
10161016

@@ -1025,11 +1025,8 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
10251025
}
10261026

10271027
&Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf, ty) => {
1028-
let trait_ref = ty::TraitRef::new(
1029-
tcx,
1030-
tcx.require_lang_item(LangItem::Sized, Some(span)),
1031-
[ty],
1032-
);
1028+
let trait_ref =
1029+
ty::TraitRef::new(tcx, tcx.require_lang_item(LangItem::Sized, span), [ty]);
10331030

10341031
self.prove_trait_ref(
10351032
trait_ref,
@@ -1041,11 +1038,8 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
10411038
&Rvalue::NullaryOp(NullOp::UbChecks, _) => {}
10421039

10431040
Rvalue::ShallowInitBox(_operand, ty) => {
1044-
let trait_ref = ty::TraitRef::new(
1045-
tcx,
1046-
tcx.require_lang_item(LangItem::Sized, Some(span)),
1047-
[*ty],
1048-
);
1041+
let trait_ref =
1042+
ty::TraitRef::new(tcx, tcx.require_lang_item(LangItem::Sized, span), [*ty]);
10491043

10501044
self.prove_trait_ref(
10511045
trait_ref,
@@ -1222,7 +1216,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
12221216
let &ty = ty;
12231217
let trait_ref = ty::TraitRef::new(
12241218
tcx,
1225-
tcx.require_lang_item(LangItem::CoerceUnsized, Some(span)),
1219+
tcx.require_lang_item(LangItem::CoerceUnsized, span),
12261220
[op.ty(self.body, tcx), ty],
12271221
);
12281222

@@ -1811,7 +1805,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
18111805
if let PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) = context {
18121806
let trait_ref = ty::TraitRef::new(
18131807
tcx,
1814-
tcx.require_lang_item(LangItem::Copy, Some(self.last_span)),
1808+
tcx.require_lang_item(LangItem::Copy, self.last_span),
18151809
[place_ty.ty],
18161810
);
18171811

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,10 +544,10 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
544544
// (as it's created inside the body itself, not passed in from outside).
545545
if let DefiningTy::FnDef(def_id, _) = defining_ty {
546546
if self.infcx.tcx.fn_sig(def_id).skip_binder().c_variadic() {
547-
let va_list_did = self.infcx.tcx.require_lang_item(
548-
LangItem::VaList,
549-
Some(self.infcx.tcx.def_span(self.mir_def)),
550-
);
547+
let va_list_did = self
548+
.infcx
549+
.tcx
550+
.require_lang_item(LangItem::VaList, self.infcx.tcx.def_span(self.mir_def));
551551

552552
let reg_vid = self
553553
.infcx

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
380380
rustc_hir::LangItem::PanicBoundsCheck,
381381
&[index, len, location],
382382
*unwind,
383-
Some(source_info.span),
383+
source_info.span,
384384
);
385385
}
386386
AssertKind::MisalignedPointerDereference { ref required, ref found } => {
@@ -393,7 +393,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
393393
rustc_hir::LangItem::PanicMisalignedPointerDereference,
394394
&[required, found, location],
395395
*unwind,
396-
Some(source_info.span),
396+
source_info.span,
397397
);
398398
}
399399
AssertKind::NullPointerDereference => {
@@ -404,7 +404,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
404404
rustc_hir::LangItem::PanicNullPointerDereference,
405405
&[location],
406406
*unwind,
407-
Some(source_info.span),
407+
source_info.span,
408408
)
409409
}
410410
_ => {
@@ -415,7 +415,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
415415
msg.panic_function(),
416416
&[location],
417417
*unwind,
418-
Some(source_info.span),
418+
source_info.span,
419419
);
420420
}
421421
}
@@ -531,7 +531,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
531531
);
532532
}
533533
TerminatorKind::UnwindTerminate(reason) => {
534-
codegen_unwind_terminate(fx, Some(source_info.span), *reason);
534+
codegen_unwind_terminate(fx, source_info.span, *reason);
535535
}
536536
TerminatorKind::UnwindResume => {
537537
// FIXME implement unwinding
@@ -1074,7 +1074,7 @@ pub(crate) fn codegen_operand<'tcx>(
10741074
pub(crate) fn codegen_panic_nounwind<'tcx>(
10751075
fx: &mut FunctionCx<'_, '_, 'tcx>,
10761076
msg_str: &str,
1077-
span: Option<Span>,
1077+
span: Span,
10781078
) {
10791079
let msg_ptr = fx.anonymous_str(msg_str);
10801080
let msg_len = fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(msg_str.len()).unwrap());
@@ -1091,7 +1091,7 @@ pub(crate) fn codegen_panic_nounwind<'tcx>(
10911091

10921092
pub(crate) fn codegen_unwind_terminate<'tcx>(
10931093
fx: &mut FunctionCx<'_, '_, 'tcx>,
1094-
span: Option<Span>,
1094+
span: Span,
10951095
reason: UnwindTerminateReason,
10961096
) {
10971097
codegen_panic_inner(fx, reason.lang_item(), &[], UnwindAction::Unreachable, span);
@@ -1102,7 +1102,7 @@ fn codegen_panic_inner<'tcx>(
11021102
lang_item: rustc_hir::LangItem,
11031103
args: &[Value],
11041104
_unwind: UnwindAction,
1105-
span: Option<Span>,
1105+
span: Span,
11061106
) {
11071107
fx.bcx.set_cold_block(fx.bcx.current_block().unwrap());
11081108

compiler/rustc_codegen_cranelift/src/intrinsics/llvm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>(
7171
See https://github.com/rust-lang/rustc_codegen_cranelift/issues/171\n\
7272
Please open an issue at https://github.com/rust-lang/rustc_codegen_cranelift/issues"
7373
);
74-
crate::base::codegen_panic_nounwind(fx, &msg, None);
74+
crate::base::codegen_panic_nounwind(fx, &msg, span);
7575
return;
7676
}
7777
}

compiler/rustc_codegen_cranelift/src/intrinsics/llvm_aarch64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ pub(super) fn codegen_aarch64_llvm_intrinsic_call<'tcx>(
512512
See https://github.com/rust-lang/rustc_codegen_cranelift/issues/171\n\
513513
Please open an issue at https://github.com/rust-lang/rustc_codegen_cranelift/issues"
514514
);
515-
crate::base::codegen_panic_nounwind(fx, &msg, None);
515+
crate::base::codegen_panic_nounwind(fx, &msg, fx.mir.span);
516516
return;
517517
}
518518
}

compiler/rustc_codegen_cranelift/src/intrinsics/llvm_x86.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ pub(super) fn codegen_x86_llvm_intrinsic_call<'tcx>(
13211321
See https://github.com/rust-lang/rustc_codegen_cranelift/issues/171\n\
13221322
Please open an issue at https://github.com/rust-lang/rustc_codegen_cranelift/issues"
13231323
);
1324-
crate::base::codegen_panic_nounwind(fx, &msg, None);
1324+
crate::base::codegen_panic_nounwind(fx, &msg, span);
13251325
return;
13261326
}
13271327
}

compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
785785
}
786786
})
787787
});
788-
crate::base::codegen_panic_nounwind(fx, &msg_str, Some(source_info.span));
788+
crate::base::codegen_panic_nounwind(fx, &msg_str, source_info.span);
789789
return Ok(());
790790
}
791791
}
@@ -884,7 +884,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
884884
crate::base::codegen_panic_nounwind(
885885
fx,
886886
"128bit atomics not yet supported",
887-
None,
887+
source_info.span,
888888
);
889889
return Ok(());
890890
} else {
@@ -919,7 +919,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
919919
crate::base::codegen_panic_nounwind(
920920
fx,
921921
"128bit atomics not yet supported",
922-
None,
922+
source_info.span,
923923
);
924924
return Ok(());
925925
} else {

compiler/rustc_codegen_cranelift/src/main_shim.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub(crate) fn maybe_create_entry_wrapper(
101101
let call_inst = bcx.ins().call(main_func_ref, &[]);
102102
let call_results = bcx.func.dfg.inst_results(call_inst).to_owned();
103103

104-
let termination_trait = tcx.require_lang_item(LangItem::Termination, None);
104+
let termination_trait = tcx.require_lang_item(LangItem::Termination, DUMMY_SP);
105105
let report = tcx
106106
.associated_items(termination_trait)
107107
.find_by_ident_and_kind(
@@ -136,7 +136,7 @@ pub(crate) fn maybe_create_entry_wrapper(
136136
}
137137
} else {
138138
// Regular main fn invoked via start lang item.
139-
let start_def_id = tcx.require_lang_item(LangItem::Start, None);
139+
let start_def_id = tcx.require_lang_item(LangItem::Start, DUMMY_SP);
140140
let start_instance = Instance::expect_resolve(
141141
tcx,
142142
ty::TypingEnv::fully_monomorphized(),

0 commit comments

Comments
 (0)