Skip to content

Commit

Permalink
Auto merge of rust-lang#128481 - matthiaskrgr:rollup-efa706r, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#128416 (android: Remove libstd hacks for unsupported Android APIs)
 - rust-lang#128437 (improve bootstrap to allow selecting llvm tools individually)
 - rust-lang#128450 (Create COFF archives for non-LLVM backends)
 - rust-lang#128458 (Emit an error if `#[optimize]` is applied to an incompatible item)
 - rust-lang#128477 (Finish blessing `coverage/mcdc` tests after LLVM 19 upgrade)
 - rust-lang#128478 (Ignore `use` declaration reformatting in `.git-blame-ignore-revs`.)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Aug 1, 2024
2 parents 70591dc + ff1476c commit 97ac52f
Show file tree
Hide file tree
Showing 18 changed files with 122 additions and 114 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ b2d2184edea578109a48ec3d8decbee5948e8f35
# test directives migration
6e48b96692d63a79a14563f27fe5185f122434f8
ec2cc761bc7067712ecc7734502f703fe3b024c8
# format use declarations
84ac80f1921afc243d71fd0caaa4f2838c294102
6 changes: 1 addition & 5 deletions compiler/rustc_codegen_ssa/src/back/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,7 @@ impl<'a> ArArchiveBuilder<'a> {
"gnu" => ArchiveKind::Gnu,
"bsd" => ArchiveKind::Bsd,
"darwin" => ArchiveKind::Darwin,
"coff" => {
// FIXME: ar_archive_writer doesn't support COFF archives yet.
// https://github.com/rust-lang/ar_archive_writer/issues/9
ArchiveKind::Gnu
}
"coff" => ArchiveKind::Coff,
"aix_big" => ArchiveKind::AixBig,
kind => {
self.sess.dcx().emit_fatal(UnknownArchiveKind { kind });
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_passes/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,10 @@ passes_only_has_effect_on =
*[unspecified] (unspecified--this is a compiler bug)
}
passes_optimize_not_fn_or_closure =
attribute should be applied to function or closure
.label = not a function or closure
passes_outer_crate_level_attr =
crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
Expand Down
22 changes: 22 additions & 0 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
}
[sym::inline] => self.check_inline(hir_id, attr, span, target),
[sym::coverage] => self.check_coverage(attr, span, target),
[sym::optimize] => self.check_optimize(hir_id, attr, target),
[sym::non_exhaustive] => self.check_non_exhaustive(hir_id, attr, span, target),
[sym::marker] => self.check_marker(hir_id, attr, span, target),
[sym::target_feature] => {
Expand Down Expand Up @@ -373,6 +374,27 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
}
}

/// Checks that `#[optimize(..)]` is applied to a function/closure/method,
/// or to an impl block or module.
fn check_optimize(&self, hir_id: HirId, attr: &Attribute, target: Target) {
match target {
Target::Fn
| Target::Closure
| Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent)
| Target::Impl
| Target::Mod => {}

_ => {
self.tcx.emit_node_span_lint(
UNUSED_ATTRIBUTES,
hir_id,
attr.span,
errors::OptimizeNotFnOrClosure,
);
}
}
}

fn check_generic_attr(
&self,
hir_id: HirId,
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ pub struct CoverageNotFnOrClosure {
pub defn_span: Span,
}

#[derive(LintDiagnostic)]
#[diag(passes_optimize_not_fn_or_closure)]
pub struct OptimizeNotFnOrClosure;

#[derive(Diagnostic)]
#[diag(passes_should_be_applied_to_fn)]
pub struct AttrShouldBeAppliedToFn {
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ impl f32 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn log2(self) -> f32 {
crate::sys::log2f32(self)
unsafe { intrinsics::log2f32(self) }
}

/// Returns the base 10 logarithm of the number.
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ impl f64 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn log2(self) -> f64 {
crate::sys::log2f64(self)
unsafe { intrinsics::log2f64(self) }
}

/// Returns the base 10 logarithm of the number.
Expand Down
18 changes: 0 additions & 18 deletions library/std/src/sys/pal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,5 @@ cfg_if::cfg_if! {
}
}

#[cfg(not(test))]
cfg_if::cfg_if! {
if #[cfg(target_os = "android")] {
pub use self::android::log2f32;
pub use self::android::log2f64;
} else {
#[inline]
pub fn log2f32(n: f32) -> f32 {
unsafe { crate::intrinsics::log2f32(n) }
}

#[inline]
pub fn log2f64(n: f64) -> f64 {
unsafe { crate::intrinsics::log2f64(n) }
}
}
}

#[cfg(not(target_os = "uefi"))]
pub type RawOsError = i32;
81 changes: 0 additions & 81 deletions library/std/src/sys/pal/unix/android.rs

This file was deleted.

5 changes: 0 additions & 5 deletions library/std/src/sys/pal/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::io::ErrorKind;
pub mod weak;

pub mod alloc;
pub mod android;
pub mod args;
pub mod env;
pub mod fd;
Expand Down Expand Up @@ -237,12 +236,8 @@ pub unsafe fn cleanup() {
}

#[allow(unused_imports)]
#[cfg(not(target_os = "android"))]
pub use libc::signal;

#[cfg(target_os = "android")]
pub use crate::sys::android::signal;

#[inline]
pub(crate) fn is_interrupted(errno: i32) -> bool {
errno == libc::EINTR
Expand Down
37 changes: 34 additions & 3 deletions src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2122,15 +2122,46 @@ impl Step for LlvmTools {

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
let default = should_build_extended_tool(run.builder, "llvm-tools");
// FIXME: allow using the names of the tools themselves?
run.alias("llvm-tools").default_condition(default)

let mut run = run.alias("llvm-tools");
for tool in LLVM_TOOLS {
run = run.alias(tool);
}

run.default_condition(default)
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(LlvmTools { target: run.target });
}

fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
fn tools_to_install(paths: &[PathBuf]) -> Vec<&'static str> {
let mut tools = vec![];

for path in paths {
let path = path.to_str().unwrap();

// Include all tools if path is 'llvm-tools'.
if path == "llvm-tools" {
return LLVM_TOOLS.to_owned();
}

for tool in LLVM_TOOLS {
if path == *tool {
tools.push(*tool);
}
}
}

// If no specific tool is requested, include all tools.
if tools.is_empty() {
tools = LLVM_TOOLS.to_owned();
}

tools
}

let target = self.target;

/* run only if llvm-config isn't used */
Expand All @@ -2151,7 +2182,7 @@ impl Step for LlvmTools {
// Prepare the image directory
let src_bindir = builder.llvm_out(target).join("bin");
let dst_bindir = format!("lib/rustlib/{}/bin", target.triple);
for tool in LLVM_TOOLS {
for tool in tools_to_install(&builder.paths) {
let exe = src_bindir.join(exe(tool, target));
tarball.add_file(&exe, &dst_bindir, 0o755);
}
Expand Down
1 change: 1 addition & 0 deletions tests/coverage/mcdc/condition-limit.coverage
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
LL| |#![feature(coverage_attribute)]
LL| |//@ edition: 2021
LL| |//@ min-llvm-version: 18
LL| |//@ ignore-llvm-version: 19 - 99
LL| |//@ compile-flags: -Zcoverage-options=mcdc
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
LL| |
Expand Down
1 change: 1 addition & 0 deletions tests/coverage/mcdc/if.coverage
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
LL| |#![feature(coverage_attribute)]
LL| |//@ edition: 2021
LL| |//@ min-llvm-version: 18
LL| |//@ ignore-llvm-version: 19 - 99
LL| |//@ compile-flags: -Zcoverage-options=mcdc
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
LL| |
Expand Down
1 change: 1 addition & 0 deletions tests/coverage/mcdc/inlined_expressions.coverage
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
LL| |#![feature(coverage_attribute)]
LL| |//@ edition: 2021
LL| |//@ min-llvm-version: 18
LL| |//@ ignore-llvm-version: 19 - 99
LL| |//@ compile-flags: -Zcoverage-options=mcdc -Copt-level=z -Cllvm-args=--inline-threshold=0
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
LL| |
Expand Down
1 change: 1 addition & 0 deletions tests/coverage/mcdc/nested_if.coverage
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
LL| |#![feature(coverage_attribute)]
LL| |//@ edition: 2021
LL| |//@ min-llvm-version: 18
LL| |//@ ignore-llvm-version: 19 - 99
LL| |//@ compile-flags: -Zcoverage-options=mcdc
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
LL| |
Expand Down
1 change: 1 addition & 0 deletions tests/coverage/mcdc/non_control_flow.coverage
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
LL| |#![feature(coverage_attribute)]
LL| |//@ edition: 2021
LL| |//@ min-llvm-version: 18
LL| |//@ ignore-llvm-version: 19 - 99
LL| |//@ compile-flags: -Zcoverage-options=mcdc
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
LL| |
Expand Down
28 changes: 28 additions & 0 deletions tests/ui/attributes/optimize.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#![feature(optimize_attribute)]
#![feature(stmt_expr_attributes)]
#![deny(unused_attributes)]
#![allow(dead_code)]

#[optimize(speed)] //~ ERROR attribute should be applied to function or closure
struct F;

fn invalid() {
#[optimize(speed)] //~ ERROR attribute should be applied to function or closure
{
1
};
}

#[optimize(speed)]
fn valid() {}

#[optimize(speed)]
mod valid_module {}

#[optimize(speed)]
impl F {}

fn main() {
let _ = #[optimize(speed)]
(|| 1);
}
20 changes: 20 additions & 0 deletions tests/ui/attributes/optimize.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
error: attribute should be applied to function or closure
--> $DIR/optimize.rs:6:1
|
LL | #[optimize(speed)]
| ^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/optimize.rs:3:9
|
LL | #![deny(unused_attributes)]
| ^^^^^^^^^^^^^^^^^

error: attribute should be applied to function or closure
--> $DIR/optimize.rs:10:5
|
LL | #[optimize(speed)]
| ^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

0 comments on commit 97ac52f

Please sign in to comment.