Skip to content

Commit cc08b55

Browse files
committed
Auto merge of #150563 - JonathanBrouwer:rollup-9ncjbou, r=JonathanBrouwer
Rollup of 2 pull requests Successful merges: - #150454 (cleanup: move c-variadic arguments handling into compute_inputs_and_output) - #150529 (Update books) r? `@ghost` `@rustbot` modify labels: rollup
2 parents b49c7d7 + cef03a7 commit cc08b55

File tree

6 files changed

+59
-39
lines changed

6 files changed

+59
-39
lines changed

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -543,38 +543,9 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
543543
&indices,
544544
);
545545

546-
let (unnormalized_output_ty, mut unnormalized_input_tys) =
546+
let (unnormalized_output_ty, unnormalized_input_tys) =
547547
inputs_and_output.split_last().unwrap();
548548

549-
// C-variadic fns also have a `VaList` input that's not listed in the signature
550-
// (as it's created inside the body itself, not passed in from outside).
551-
if let DefiningTy::FnDef(def_id, _) = defining_ty {
552-
if self.infcx.tcx.fn_sig(def_id).skip_binder().c_variadic() {
553-
let va_list_did = self
554-
.infcx
555-
.tcx
556-
.require_lang_item(LangItem::VaList, self.infcx.tcx.def_span(self.mir_def));
557-
558-
let reg_vid = self
559-
.infcx
560-
.next_nll_region_var(NllRegionVariableOrigin::FreeRegion, || {
561-
RegionCtxt::Free(sym::c_dash_variadic)
562-
})
563-
.as_var();
564-
565-
let region = ty::Region::new_var(self.infcx.tcx, reg_vid);
566-
let va_list_ty = self
567-
.infcx
568-
.tcx
569-
.type_of(va_list_did)
570-
.instantiate(self.infcx.tcx, &[region.into()]);
571-
572-
unnormalized_input_tys = self.infcx.tcx.mk_type_list_from_iter(
573-
unnormalized_input_tys.iter().copied().chain(iter::once(va_list_ty)),
574-
);
575-
}
576-
}
577-
578549
let fr_fn_body = self
579550
.infcx
580551
.next_nll_region_var(NllRegionVariableOrigin::FreeRegion, || {
@@ -816,7 +787,40 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
816787
DefiningTy::FnDef(def_id, _) => {
817788
let sig = tcx.fn_sig(def_id).instantiate_identity();
818789
let sig = indices.fold_to_region_vids(tcx, sig);
819-
sig.inputs_and_output()
790+
let inputs_and_output = sig.inputs_and_output();
791+
792+
// C-variadic fns also have a `VaList` input that's not listed in the signature
793+
// (as it's created inside the body itself, not passed in from outside).
794+
if self.infcx.tcx.fn_sig(def_id).skip_binder().c_variadic() {
795+
let va_list_did = self
796+
.infcx
797+
.tcx
798+
.require_lang_item(LangItem::VaList, self.infcx.tcx.def_span(self.mir_def));
799+
800+
let reg_vid = self
801+
.infcx
802+
.next_nll_region_var(NllRegionVariableOrigin::FreeRegion, || {
803+
RegionCtxt::Free(sym::c_dash_variadic)
804+
})
805+
.as_var();
806+
807+
let region = ty::Region::new_var(self.infcx.tcx, reg_vid);
808+
let va_list_ty = self
809+
.infcx
810+
.tcx
811+
.type_of(va_list_did)
812+
.instantiate(self.infcx.tcx, &[region.into()]);
813+
814+
// The signature needs to follow the order [input_tys, va_list_ty, output_ty]
815+
return inputs_and_output.map_bound(|tys| {
816+
let (output_ty, input_tys) = tys.split_last().unwrap();
817+
tcx.mk_type_list_from_iter(
818+
input_tys.iter().copied().chain([va_list_ty, *output_ty]),
819+
)
820+
});
821+
}
822+
823+
inputs_and_output
820824
}
821825

822826
DefiningTy::Const(def_id, _) => {

src/doc/reference

Submodule reference updated 70 files

src/tools/rustbook/Cargo.lock

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,10 @@ dependencies = [
320320
"syn",
321321
]
322322

323+
[[package]]
324+
name = "diagnostics"
325+
version = "0.0.0"
326+
323327
[[package]]
324328
name = "digest"
325329
version = "0.10.7"
@@ -464,6 +468,16 @@ dependencies = [
464468
"wasip2",
465469
]
466470

471+
[[package]]
472+
name = "grammar"
473+
version = "0.0.0"
474+
dependencies = [
475+
"diagnostics",
476+
"pathdiff",
477+
"regex",
478+
"walkdir",
479+
]
480+
467481
[[package]]
468482
name = "handlebars"
469483
version = "6.3.2"
@@ -774,9 +788,11 @@ dependencies = [
774788

775789
[[package]]
776790
name = "mdbook-spec"
777-
version = "0.1.2"
791+
version = "0.0.0"
778792
dependencies = [
779793
"anyhow",
794+
"diagnostics",
795+
"grammar",
780796
"mdbook-markdown",
781797
"mdbook-preprocessor",
782798
"once_cell",

src/tools/rustbook/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ edition = "2021"
1111
clap = { version = "4.0.32", features = ["cargo"] }
1212
mdbook-driver = { version = "0.5.2", features = ["search"] }
1313
mdbook-i18n-helpers = "0.4.0"
14-
mdbook-spec = { path = "../../doc/reference/mdbook-spec" }
14+
mdbook-spec = { path = "../../doc/reference/tools/mdbook-spec" }
1515
mdbook-trpl = { path = "../../doc/book/packages/mdbook-trpl" }
1616
tracing-subscriber = { version = "0.3.20", features = ["env-filter"] }

tests/ui/c-variadic/variadic-ffi-4.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ error: lifetime may not live long enough
3030
--> $DIR/variadic-ffi-4.rs:22:5
3131
|
3232
LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaList, mut ap1: ...) {
33-
| ------- ------- has type `VaList<'2>`
33+
| ------- ------- has type `VaList<'1>`
3434
| |
35-
| has type `&mut VaList<'1>`
35+
| has type `&mut VaList<'2>`
3636
LL | ap0 = &mut ap1;
3737
| ^^^^^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
3838
|
@@ -44,9 +44,9 @@ error: lifetime may not live long enough
4444
--> $DIR/variadic-ffi-4.rs:22:5
4545
|
4646
LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaList, mut ap1: ...) {
47-
| ------- ------- has type `VaList<'2>`
47+
| ------- ------- has type `VaList<'1>`
4848
| |
49-
| has type `&mut VaList<'1>`
49+
| has type `&mut VaList<'2>`
5050
LL | ap0 = &mut ap1;
5151
| ^^^^^^^^^^^^^^ assignment requires that `'2` must outlive `'1`
5252
|

0 commit comments

Comments
 (0)