Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,11 @@ Nathaniel Hamovitz <18648574+nhamovitz@users.noreply.github.com>
Nathaniel Herman <nherman@post.harvard.edu> Nathaniel Herman <nherman@college.harvard.edu>
Neil Pankey <npankey@gmail.com> <neil@wire.im>
Ngo Iok Ui (Wu Yu Wei) <wusyong9104@gmail.com>
Nia Deckers <me@nia.gay>
Nia Deckers <me@nia.gay> <nia-e@haecceity.cc>
Nia Deckers <me@nia.gay> <nia@zed.dev>
Nia Deckers <me@nia.gay> <nia@hexcat.nl>
Nia Deckers <me@nia.gay> <a5b6@riseup.net>
Nicholas Baron <nicholas.baron.ten@gmail.com>
Nicholas Bishop <nbishop@nbishop.net> <nicholasbishop@gmail.com>
Nicholas Bishop <nbishop@nbishop.net> <nicholasbishop@google.com>
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_ast_lowering/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ pub fn extern_abi_stability(abi: ExternAbi) -> Result<(), UnstableAbi> {
ExternAbi::Rust
| ExternAbi::C { .. }
| ExternAbi::Cdecl { .. }
| ExternAbi::Custom
| ExternAbi::Stdcall { .. }
| ExternAbi::Fastcall { .. }
| ExternAbi::Thiscall { .. }
Expand Down Expand Up @@ -144,9 +145,6 @@ pub fn extern_abi_stability(abi: ExternAbi) -> Result<(), UnstableAbi> {
feature: sym::cmse_nonsecure_entry,
explain: GateReason::Experimental,
}),
ExternAbi::Custom => {
Err(UnstableAbi { abi, feature: sym::abi_custom, explain: GateReason::Experimental })
}
ExternAbi::Swift => {
Err(UnstableAbi { abi, feature: sym::abi_swift, explain: GateReason::Experimental })
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ declare_features! (

/// Allows `#[target_feature(...)]` on aarch64 platforms
(accepted, aarch64_target_feature, "1.61.0", Some(44839)),
/// Allows `extern "custom" fn()`.
(accepted, abi_custom, "CURRENT_RUSTC_VERSION", Some(140829)),
/// Allows using the `efiapi` ABI.
(accepted, abi_efiapi, "1.68.0", Some(65815)),
/// Allows the sysV64 ABI to be specified on all platforms
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,6 @@ declare_features! (
(unstable, abi_avr_interrupt, "1.45.0", Some(69664)),
/// Allows `extern "cmse-nonsecure-call" fn()`.
(unstable, abi_cmse_nonsecure_call, "1.90.0", Some(81391)),
/// Allows `extern "custom" fn()`.
(unstable, abi_custom, "1.89.0", Some(140829)),
/// Allows `extern "gpu-kernel" fn()`.
(unstable, abi_gpu_kernel, "1.86.0", Some(135467)),
/// Allows `extern "msp430-interrupt" fn()`.
Expand Down
1 change: 0 additions & 1 deletion library/compiler-builtins/compiler-builtins/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![cfg_attr(feature = "compiler-builtins", compiler_builtins)]
#![cfg_attr(all(target_family = "wasm"), feature(wasm_numeric_instr))]
#![feature(abi_custom)]
#![feature(abi_unadjusted)]
#![feature(asm_experimental_arch)]
#![feature(cfg_target_has_atomic)]
Expand Down
3 changes: 2 additions & 1 deletion src/ci/scripts/verify-channel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ IFS=$'\n\t'

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

if isCiBranch try-perf || isCiBranch automation/bors/try || isCiBranch automation/bors/auto; then
if isCiBranch try-perf || isCiBranch automation/bors/try-perf || \
isCiBranch automation/bors/try || isCiBranch automation/bors/auto; then
echo "channel verification is only executed on PR builds"
exit
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ The following example can be compiled with `-Zinstrument-mcount=yes` or `-Zinstr

```rust
#![feature(instrument_fn)]
#![feature(abi_custom)]

fn main() {
// Ensure all the early startup occurs before attempting to call this trivial, single-threaded
Expand Down
118 changes: 81 additions & 37 deletions src/librustdoc/clean/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,22 @@ impl Cfg {
}

fn should_append_only_to_description(&self) -> bool {
match self.0 {
CfgEntry::Any(..)
| CfgEntry::All(..)
| CfgEntry::NameValue { .. }
| CfgEntry::Version(..)
| CfgEntry::Not(CfgEntry::NameValue { .. }, _) => true,
CfgEntry::Not(..) | CfgEntry::Bool(..) => false,
fn should_append_only_to_description(cfg: &CfgEntry) -> bool {
match cfg {
CfgEntry::NameValue { .. }
| CfgEntry::Version(..)
| CfgEntry::Not(CfgEntry::NameValue { .. }, _) => true,
CfgEntry::Any(a, _) | CfgEntry::All(a, _) => {
if a.is_empty() {
false
} else {
a.iter().any(|sub| should_append_only_to_description(sub))
}
}
CfgEntry::Not(..) | CfgEntry::Bool(..) => false,
}
}
should_append_only_to_description(&self.0)
}

fn should_use_with_in_description(&self) -> bool {
Expand Down Expand Up @@ -309,7 +317,19 @@ impl Cfg {
}

fn omit_preposition(&self) -> bool {
matches!(self.0, CfgEntry::Bool(..))
fn omit_preposition(cfg: &CfgEntry) -> bool {
match cfg {
CfgEntry::NameValue { .. }
| CfgEntry::Version(..)
| CfgEntry::Not(CfgEntry::NameValue { .. }, _) => false,
CfgEntry::Any(a, _) | CfgEntry::All(a, _) => {
a.is_empty() || matches!(a.as_slice(), [a] if omit_preposition(&a))
}
CfgEntry::Not(a, _) => omit_preposition(a),
CfgEntry::Bool(..) => true,
}
}
omit_preposition(&self.0)
}

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

let short_longhand = self.1.is_long() && {
let all_crate_features = sub_cfgs.iter().all(|sub_cfg| {
matches!(sub_cfg, CfgEntry::NameValue { name: sym::feature, value: Some(_), .. })
});
let all_target_features = sub_cfgs.iter().all(|sub_cfg| {
matches!(
sub_cfg,
CfgEntry::NameValue { name: sym::target_feature, value: Some(_), .. }
)
});
let all_crate_features = !sub_cfgs.is_empty()
&& sub_cfgs.iter().all(|sub_cfg| {
matches!(
sub_cfg,
CfgEntry::NameValue { name: sym::feature, value: Some(_), .. }
)
});
let all_target_features = !sub_cfgs.is_empty()
&& sub_cfgs.iter().all(|sub_cfg| {
matches!(
sub_cfg,
CfgEntry::NameValue { name: sym::target_feature, value: Some(_), .. }
)
});

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

impl fmt::Display for Display<'_> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fn display_bool(fmt: &mut fmt::Formatter<'_>, value: bool) -> fmt::Result {
if value { fmt.write_str("everywhere") } else { fmt.write_str("nowhere") }
}

match &self.0 {
CfgEntry::Not(CfgEntry::Any(sub_cfgs, _), _) => {
let separator = if sub_cfgs.iter().all(is_simple_cfg) { " nor " } else { ", nor " };
fmt.write_str("neither ")?;

sub_cfgs
.iter()
.map(|sub_cfg| {
Wrapped::with_parens()
.when(is_any_cfg(sub_cfg))
.wrap(Display(sub_cfg, self.1))
})
.joined(separator, fmt)
}
CfgEntry::Not(CfgEntry::Not(sub_cfg, _), _) => Display(sub_cfg, self.1).fmt(fmt),
CfgEntry::Not(CfgEntry::Any(sub_cfgs, _), _) => match sub_cfgs.as_slice() {
// `not(any())` is `true` because `any()` is `false`.
[] => display_bool(fmt, true),
[CfgEntry::Bool(value, _)] => display_bool(fmt, !*value),
sub_cfgs => {
let separator =
if sub_cfgs.iter().all(is_simple_cfg) { " nor " } else { ", nor " };
if sub_cfgs.len() > 1 {
fmt.write_str("neither ")?;
} else {
fmt.write_str("not(")?;
}

sub_cfgs
.iter()
.map(|sub_cfg| {
Wrapped::with_parens()
.when(is_any_cfg(sub_cfg))
.wrap(Display(sub_cfg, self.1))
})
.joined(separator, fmt)?;
if sub_cfgs.len() == 1 {
fmt.write_str(")")?;
}
Ok(())
}
},
CfgEntry::Not(s @ CfgEntry::All(sub_cfgs, _), _) => match sub_cfgs.as_slice() {
// `not(all())` is `false` because `all()` is `true`.
[] => display_bool(fmt, false),
[CfgEntry::Bool(value, _)] => display_bool(fmt, !*value),
_ => write!(fmt, "not ({})", Display(s, self.1)),
},
CfgEntry::Not(simple @ CfgEntry::NameValue { .. }, _) => {
write!(fmt, "non-{}", Display(simple, self.1))
}
Expand All @@ -531,13 +581,7 @@ impl fmt::Display for Display<'_> {
}
CfgEntry::All(sub_cfgs, _) => self.display_sub_cfgs(fmt, sub_cfgs.as_slice(), " and "),

CfgEntry::Bool(v, _) => {
if *v {
fmt.write_str("everywhere")
} else {
fmt.write_str("nowhere")
}
}
CfgEntry::Bool(v, _) => display_bool(fmt, *v),

&CfgEntry::NameValue { name, value, .. } => {
let human_readable = match (*name, value) {
Expand Down
38 changes: 36 additions & 2 deletions src/librustdoc/clean/cfg/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,19 @@ fn cfg_any_e(v: ThinVec<CfgEntry>) -> CfgEntry {
}

fn cfg_not(v: CfgEntry) -> Cfg {
Cfg(CfgEntry::Not(Box::new(v), DUMMY_SP))
Cfg(cfg_not_e(v))
}

fn cfg_not_e(v: CfgEntry) -> CfgEntry {
CfgEntry::Not(Box::new(v), DUMMY_SP)
}

fn cfg_true() -> Cfg {
Cfg(CfgEntry::Bool(true, DUMMY_SP))
Cfg(cfg_true_e())
}

fn cfg_true_e() -> CfgEntry {
CfgEntry::Bool(true, DUMMY_SP)
}

fn cfg_false() -> Cfg {
Expand Down Expand Up @@ -377,6 +385,32 @@ fn test_render_long_html() {
.render_long_html(),
"Available on <strong>x86-64 and target feature <code>sse2</code></strong> only."
);
// `any(true)`
assert_eq!(
cfg_any(thin_vec![cfg_true_e()]).render_long_html(),
"Available <strong>everywhere</strong>.",
);
// `not(any(true))`
assert_eq!(
cfg_not(cfg_any_e(thin_vec![cfg_true_e()])).render_long_html(),
"Available <strong>nowhere</strong>.",
);
// `any(all(true))`
assert_eq!(
cfg_any(thin_vec![cfg_all_e(thin_vec![cfg_true_e()])]).render_long_html(),
"Available <strong>everywhere</strong>."
);
// `not(any(all(true)))`
assert_eq!(
cfg_not(cfg_any_e(thin_vec![cfg_all_e(thin_vec![cfg_true_e()])])).render_long_html(),
"Available <strong>not(everywhere)</strong>.",
);
// `not(not(any(all(true))))`
assert_eq!(
cfg_not(cfg_not_e(cfg_any_e(thin_vec![cfg_all_e(thin_vec![cfg_true_e()])])))
.render_long_html(),
"Available <strong>everywhere</strong>.",
);
})
}

Expand Down
20 changes: 20 additions & 0 deletions tests/rustdoc-html/doc-cfg/always-true.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Some generated "cfg text" check.
// Regression test for <https://github.com/rust-lang/rust/issues/145075>.

#![feature(doc_cfg)]
#![crate_name = "foo"]

// This one doesn't display any cfg label.
//@ has 'foo/fn.f.html'
//@ count - '//*[@class="stab portability"]' 0
#[cfg(any(all()))]
pub fn f() {}

//@ has 'foo/fn.f2.html'
// If you change the selector in this one, don't forget to update the one of the `f`
// function as well!
//@ count - '//*[@class="stab portability"]' 1
//@ has - '//*[@class="stab portability"]' 'Available everywhere.'
// This one display a cfg label.
#[cfg(any(true))]
pub fn f2() {}
1 change: 0 additions & 1 deletion tests/ui/abi/bad-custom.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@ edition: 2021
//@ check-fail
//@ needs-asm-support
#![feature(abi_custom)]

#[unsafe(naked)]
unsafe extern "custom" fn return_explicit_unit() -> () {
Expand Down
Loading
Loading