Skip to content

Commit 75ab3e3

Browse files
committed
Auto merge of #161122 - JonathanBrouwer:rollup-hr85oTB, r=JonathanBrouwer
Rollup of 4 pull requests Successful merges: - #161111 (Take bors try-perf branch into account in verify-channel.sh) - #158504 (Stabilize `extern "custom"`) - #161030 (mailmap: fix nia's gazillion emails) - #161105 (rustdoc: Small `doc_cfg` messages improvements)
2 parents 0844f35 + 1c7f9b3 commit 75ab3e3

26 files changed

Lines changed: 437 additions & 508 deletions

.mailmap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,11 @@ Nathaniel Hamovitz <18648574+nhamovitz@users.noreply.github.com>
505505
Nathaniel Herman <nherman@post.harvard.edu> Nathaniel Herman <nherman@college.harvard.edu>
506506
Neil Pankey <npankey@gmail.com> <neil@wire.im>
507507
Ngo Iok Ui (Wu Yu Wei) <wusyong9104@gmail.com>
508+
Nia Deckers <me@nia.gay>
509+
Nia Deckers <me@nia.gay> <nia-e@haecceity.cc>
510+
Nia Deckers <me@nia.gay> <nia@zed.dev>
511+
Nia Deckers <me@nia.gay> <nia@hexcat.nl>
512+
Nia Deckers <me@nia.gay> <a5b6@riseup.net>
508513
Nicholas Baron <nicholas.baron.ten@gmail.com>
509514
Nicholas Bishop <nbishop@nbishop.net> <nicholasbishop@gmail.com>
510515
Nicholas Bishop <nbishop@nbishop.net> <nicholasbishop@google.com>

compiler/rustc_ast_lowering/src/stability.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ pub fn extern_abi_stability(abi: ExternAbi) -> Result<(), UnstableAbi> {
7070
ExternAbi::Rust
7171
| ExternAbi::C { .. }
7272
| ExternAbi::Cdecl { .. }
73+
| ExternAbi::Custom
7374
| ExternAbi::Stdcall { .. }
7475
| ExternAbi::Fastcall { .. }
7576
| ExternAbi::Thiscall { .. }
@@ -144,9 +145,6 @@ pub fn extern_abi_stability(abi: ExternAbi) -> Result<(), UnstableAbi> {
144145
feature: sym::cmse_nonsecure_entry,
145146
explain: GateReason::Experimental,
146147
}),
147-
ExternAbi::Custom => {
148-
Err(UnstableAbi { abi, feature: sym::abi_custom, explain: GateReason::Experimental })
149-
}
150148
ExternAbi::Swift => {
151149
Err(UnstableAbi { abi, feature: sym::abi_swift, explain: GateReason::Experimental })
152150
}

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ declare_features! (
4646

4747
/// Allows `#[target_feature(...)]` on aarch64 platforms
4848
(accepted, aarch64_target_feature, "1.61.0", Some(44839)),
49+
/// Allows `extern "custom" fn()`.
50+
(accepted, abi_custom, "CURRENT_RUSTC_VERSION", Some(140829)),
4951
/// Allows using the `efiapi` ABI.
5052
(accepted, abi_efiapi, "1.68.0", Some(65815)),
5153
/// Allows the sysV64 ABI to be specified on all platforms

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,6 @@ declare_features! (
372372
(unstable, abi_avr_interrupt, "1.45.0", Some(69664)),
373373
/// Allows `extern "cmse-nonsecure-call" fn()`.
374374
(unstable, abi_cmse_nonsecure_call, "1.90.0", Some(81391)),
375-
/// Allows `extern "custom" fn()`.
376-
(unstable, abi_custom, "1.89.0", Some(140829)),
377375
/// Allows `extern "gpu-kernel" fn()`.
378376
(unstable, abi_gpu_kernel, "1.86.0", Some(135467)),
379377
/// Allows `extern "msp430-interrupt" fn()`.

library/compiler-builtins/compiler-builtins/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![cfg_attr(feature = "compiler-builtins", compiler_builtins)]
22
#![cfg_attr(all(target_family = "wasm"), feature(wasm_numeric_instr))]
3-
#![feature(abi_custom)]
43
#![feature(abi_unadjusted)]
54
#![feature(asm_experimental_arch)]
65
#![feature(cfg_target_has_atomic)]

src/ci/scripts/verify-channel.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ IFS=$'\n\t'
88

99
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
1010

11-
if isCiBranch try-perf || isCiBranch automation/bors/try || isCiBranch automation/bors/auto; then
11+
if isCiBranch try-perf || isCiBranch automation/bors/try-perf || \
12+
isCiBranch automation/bors/try || isCiBranch automation/bors/auto; then
1213
echo "channel verification is only executed on PR builds"
1314
exit
1415
fi

src/doc/unstable-book/src/compiler-flags/instrument-mcount.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ The following example can be compiled with `-Zinstrument-mcount=yes` or `-Zinstr
4040

4141
```rust
4242
#![feature(instrument_fn)]
43-
#![feature(abi_custom)]
4443

4544
fn main() {
4645
// Ensure all the early startup occurs before attempting to call this trivial, single-threaded

src/librustdoc/clean/cfg.rs

Lines changed: 81 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,22 @@ impl Cfg {
227227
}
228228

229229
fn should_append_only_to_description(&self) -> bool {
230-
match self.0 {
231-
CfgEntry::Any(..)
232-
| CfgEntry::All(..)
233-
| CfgEntry::NameValue { .. }
234-
| CfgEntry::Version(..)
235-
| CfgEntry::Not(CfgEntry::NameValue { .. }, _) => true,
236-
CfgEntry::Not(..) | CfgEntry::Bool(..) => false,
230+
fn should_append_only_to_description(cfg: &CfgEntry) -> bool {
231+
match cfg {
232+
CfgEntry::NameValue { .. }
233+
| CfgEntry::Version(..)
234+
| CfgEntry::Not(CfgEntry::NameValue { .. }, _) => true,
235+
CfgEntry::Any(a, _) | CfgEntry::All(a, _) => {
236+
if a.is_empty() {
237+
false
238+
} else {
239+
a.iter().any(|sub| should_append_only_to_description(sub))
240+
}
241+
}
242+
CfgEntry::Not(..) | CfgEntry::Bool(..) => false,
243+
}
237244
}
245+
should_append_only_to_description(&self.0)
238246
}
239247

240248
fn should_use_with_in_description(&self) -> bool {
@@ -309,7 +317,19 @@ impl Cfg {
309317
}
310318

311319
fn omit_preposition(&self) -> bool {
312-
matches!(self.0, CfgEntry::Bool(..))
320+
fn omit_preposition(cfg: &CfgEntry) -> bool {
321+
match cfg {
322+
CfgEntry::NameValue { .. }
323+
| CfgEntry::Version(..)
324+
| CfgEntry::Not(CfgEntry::NameValue { .. }, _) => false,
325+
CfgEntry::Any(a, _) | CfgEntry::All(a, _) => {
326+
a.is_empty() || matches!(a.as_slice(), [a] if omit_preposition(&a))
327+
}
328+
CfgEntry::Not(a, _) => omit_preposition(a),
329+
CfgEntry::Bool(..) => true,
330+
}
331+
}
332+
omit_preposition(&self.0)
313333
}
314334

315335
pub(crate) fn inner(&self) -> &CfgEntry {
@@ -459,15 +479,20 @@ impl Display<'_> {
459479
use fmt::Display as _;
460480

461481
let short_longhand = self.1.is_long() && {
462-
let all_crate_features = sub_cfgs.iter().all(|sub_cfg| {
463-
matches!(sub_cfg, CfgEntry::NameValue { name: sym::feature, value: Some(_), .. })
464-
});
465-
let all_target_features = sub_cfgs.iter().all(|sub_cfg| {
466-
matches!(
467-
sub_cfg,
468-
CfgEntry::NameValue { name: sym::target_feature, value: Some(_), .. }
469-
)
470-
});
482+
let all_crate_features = !sub_cfgs.is_empty()
483+
&& sub_cfgs.iter().all(|sub_cfg| {
484+
matches!(
485+
sub_cfg,
486+
CfgEntry::NameValue { name: sym::feature, value: Some(_), .. }
487+
)
488+
});
489+
let all_target_features = !sub_cfgs.is_empty()
490+
&& sub_cfgs.iter().all(|sub_cfg| {
491+
matches!(
492+
sub_cfg,
493+
CfgEntry::NameValue { name: sym::target_feature, value: Some(_), .. }
494+
)
495+
});
471496

472497
if all_crate_features {
473498
fmt.write_str("crate features ")?;
@@ -506,20 +531,45 @@ impl Display<'_> {
506531

507532
impl fmt::Display for Display<'_> {
508533
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
534+
fn display_bool(fmt: &mut fmt::Formatter<'_>, value: bool) -> fmt::Result {
535+
if value { fmt.write_str("everywhere") } else { fmt.write_str("nowhere") }
536+
}
537+
509538
match &self.0 {
510-
CfgEntry::Not(CfgEntry::Any(sub_cfgs, _), _) => {
511-
let separator = if sub_cfgs.iter().all(is_simple_cfg) { " nor " } else { ", nor " };
512-
fmt.write_str("neither ")?;
513-
514-
sub_cfgs
515-
.iter()
516-
.map(|sub_cfg| {
517-
Wrapped::with_parens()
518-
.when(is_any_cfg(sub_cfg))
519-
.wrap(Display(sub_cfg, self.1))
520-
})
521-
.joined(separator, fmt)
522-
}
539+
CfgEntry::Not(CfgEntry::Not(sub_cfg, _), _) => Display(sub_cfg, self.1).fmt(fmt),
540+
CfgEntry::Not(CfgEntry::Any(sub_cfgs, _), _) => match sub_cfgs.as_slice() {
541+
// `not(any())` is `true` because `any()` is `false`.
542+
[] => display_bool(fmt, true),
543+
[CfgEntry::Bool(value, _)] => display_bool(fmt, !*value),
544+
sub_cfgs => {
545+
let separator =
546+
if sub_cfgs.iter().all(is_simple_cfg) { " nor " } else { ", nor " };
547+
if sub_cfgs.len() > 1 {
548+
fmt.write_str("neither ")?;
549+
} else {
550+
fmt.write_str("not(")?;
551+
}
552+
553+
sub_cfgs
554+
.iter()
555+
.map(|sub_cfg| {
556+
Wrapped::with_parens()
557+
.when(is_any_cfg(sub_cfg))
558+
.wrap(Display(sub_cfg, self.1))
559+
})
560+
.joined(separator, fmt)?;
561+
if sub_cfgs.len() == 1 {
562+
fmt.write_str(")")?;
563+
}
564+
Ok(())
565+
}
566+
},
567+
CfgEntry::Not(s @ CfgEntry::All(sub_cfgs, _), _) => match sub_cfgs.as_slice() {
568+
// `not(all())` is `false` because `all()` is `true`.
569+
[] => display_bool(fmt, false),
570+
[CfgEntry::Bool(value, _)] => display_bool(fmt, !*value),
571+
_ => write!(fmt, "not ({})", Display(s, self.1)),
572+
},
523573
CfgEntry::Not(simple @ CfgEntry::NameValue { .. }, _) => {
524574
write!(fmt, "non-{}", Display(simple, self.1))
525575
}
@@ -531,13 +581,7 @@ impl fmt::Display for Display<'_> {
531581
}
532582
CfgEntry::All(sub_cfgs, _) => self.display_sub_cfgs(fmt, sub_cfgs.as_slice(), " and "),
533583

534-
CfgEntry::Bool(v, _) => {
535-
if *v {
536-
fmt.write_str("everywhere")
537-
} else {
538-
fmt.write_str("nowhere")
539-
}
540-
}
584+
CfgEntry::Bool(v, _) => display_bool(fmt, *v),
541585

542586
&CfgEntry::NameValue { name, value, .. } => {
543587
let human_readable = match (*name, value) {

src/librustdoc/clean/cfg/tests.rs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,19 @@ fn cfg_any_e(v: ThinVec<CfgEntry>) -> CfgEntry {
4242
}
4343

4444
fn cfg_not(v: CfgEntry) -> Cfg {
45-
Cfg(CfgEntry::Not(Box::new(v), DUMMY_SP))
45+
Cfg(cfg_not_e(v))
46+
}
47+
48+
fn cfg_not_e(v: CfgEntry) -> CfgEntry {
49+
CfgEntry::Not(Box::new(v), DUMMY_SP)
4650
}
4751

4852
fn cfg_true() -> Cfg {
49-
Cfg(CfgEntry::Bool(true, DUMMY_SP))
53+
Cfg(cfg_true_e())
54+
}
55+
56+
fn cfg_true_e() -> CfgEntry {
57+
CfgEntry::Bool(true, DUMMY_SP)
5058
}
5159

5260
fn cfg_false() -> Cfg {
@@ -377,6 +385,32 @@ fn test_render_long_html() {
377385
.render_long_html(),
378386
"Available on <strong>x86-64 and target feature <code>sse2</code></strong> only."
379387
);
388+
// `any(true)`
389+
assert_eq!(
390+
cfg_any(thin_vec![cfg_true_e()]).render_long_html(),
391+
"Available <strong>everywhere</strong>.",
392+
);
393+
// `not(any(true))`
394+
assert_eq!(
395+
cfg_not(cfg_any_e(thin_vec![cfg_true_e()])).render_long_html(),
396+
"Available <strong>nowhere</strong>.",
397+
);
398+
// `any(all(true))`
399+
assert_eq!(
400+
cfg_any(thin_vec![cfg_all_e(thin_vec![cfg_true_e()])]).render_long_html(),
401+
"Available <strong>everywhere</strong>."
402+
);
403+
// `not(any(all(true)))`
404+
assert_eq!(
405+
cfg_not(cfg_any_e(thin_vec![cfg_all_e(thin_vec![cfg_true_e()])])).render_long_html(),
406+
"Available <strong>not(everywhere)</strong>.",
407+
);
408+
// `not(not(any(all(true))))`
409+
assert_eq!(
410+
cfg_not(cfg_not_e(cfg_any_e(thin_vec![cfg_all_e(thin_vec![cfg_true_e()])])))
411+
.render_long_html(),
412+
"Available <strong>everywhere</strong>.",
413+
);
380414
})
381415
}
382416

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Some generated "cfg text" check.
2+
// Regression test for <https://github.com/rust-lang/rust/issues/145075>.
3+
4+
#![feature(doc_cfg)]
5+
#![crate_name = "foo"]
6+
7+
// This one doesn't display any cfg label.
8+
//@ has 'foo/fn.f.html'
9+
//@ count - '//*[@class="stab portability"]' 0
10+
#[cfg(any(all()))]
11+
pub fn f() {}
12+
13+
//@ has 'foo/fn.f2.html'
14+
// If you change the selector in this one, don't forget to update the one of the `f`
15+
// function as well!
16+
//@ count - '//*[@class="stab portability"]' 1
17+
//@ has - '//*[@class="stab portability"]' 'Available everywhere.'
18+
// This one display a cfg label.
19+
#[cfg(any(true))]
20+
pub fn f2() {}

0 commit comments

Comments
 (0)