Skip to content

Commit 97ac52f

Browse files
committed
Auto merge of rust-lang#128481 - matthiaskrgr:rollup-efa706r, r=matthiaskrgr
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
2 parents 70591dc + ff1476c commit 97ac52f

File tree

18 files changed

+122
-114
lines changed

18 files changed

+122
-114
lines changed

.git-blame-ignore-revs

+2
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ b2d2184edea578109a48ec3d8decbee5948e8f35
2323
# test directives migration
2424
6e48b96692d63a79a14563f27fe5185f122434f8
2525
ec2cc761bc7067712ecc7734502f703fe3b024c8
26+
# format use declarations
27+
84ac80f1921afc243d71fd0caaa4f2838c294102

compiler/rustc_codegen_ssa/src/back/archive.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,7 @@ impl<'a> ArArchiveBuilder<'a> {
220220
"gnu" => ArchiveKind::Gnu,
221221
"bsd" => ArchiveKind::Bsd,
222222
"darwin" => ArchiveKind::Darwin,
223-
"coff" => {
224-
// FIXME: ar_archive_writer doesn't support COFF archives yet.
225-
// https://github.com/rust-lang/ar_archive_writer/issues/9
226-
ArchiveKind::Gnu
227-
}
223+
"coff" => ArchiveKind::Coff,
228224
"aix_big" => ArchiveKind::AixBig,
229225
kind => {
230226
self.sess.dcx().emit_fatal(UnknownArchiveKind { kind });

compiler/rustc_passes/messages.ftl

+4
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,10 @@ passes_only_has_effect_on =
542542
*[unspecified] (unspecified--this is a compiler bug)
543543
}
544544
545+
passes_optimize_not_fn_or_closure =
546+
attribute should be applied to function or closure
547+
.label = not a function or closure
548+
545549
passes_outer_crate_level_attr =
546550
crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
547551

compiler/rustc_passes/src/check_attr.rs

+22
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
124124
}
125125
[sym::inline] => self.check_inline(hir_id, attr, span, target),
126126
[sym::coverage] => self.check_coverage(attr, span, target),
127+
[sym::optimize] => self.check_optimize(hir_id, attr, target),
127128
[sym::non_exhaustive] => self.check_non_exhaustive(hir_id, attr, span, target),
128129
[sym::marker] => self.check_marker(hir_id, attr, span, target),
129130
[sym::target_feature] => {
@@ -373,6 +374,27 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
373374
}
374375
}
375376

377+
/// Checks that `#[optimize(..)]` is applied to a function/closure/method,
378+
/// or to an impl block or module.
379+
fn check_optimize(&self, hir_id: HirId, attr: &Attribute, target: Target) {
380+
match target {
381+
Target::Fn
382+
| Target::Closure
383+
| Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent)
384+
| Target::Impl
385+
| Target::Mod => {}
386+
387+
_ => {
388+
self.tcx.emit_node_span_lint(
389+
UNUSED_ATTRIBUTES,
390+
hir_id,
391+
attr.span,
392+
errors::OptimizeNotFnOrClosure,
393+
);
394+
}
395+
}
396+
}
397+
376398
fn check_generic_attr(
377399
&self,
378400
hir_id: HirId,

compiler/rustc_passes/src/errors.rs

+4
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ pub struct CoverageNotFnOrClosure {
6868
pub defn_span: Span,
6969
}
7070

71+
#[derive(LintDiagnostic)]
72+
#[diag(passes_optimize_not_fn_or_closure)]
73+
pub struct OptimizeNotFnOrClosure;
74+
7175
#[derive(Diagnostic)]
7276
#[diag(passes_should_be_applied_to_fn)]
7377
pub struct AttrShouldBeAppliedToFn {

library/std/src/f32.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ impl f32 {
574574
#[stable(feature = "rust1", since = "1.0.0")]
575575
#[inline]
576576
pub fn log2(self) -> f32 {
577-
crate::sys::log2f32(self)
577+
unsafe { intrinsics::log2f32(self) }
578578
}
579579

580580
/// Returns the base 10 logarithm of the number.

library/std/src/f64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ impl f64 {
574574
#[stable(feature = "rust1", since = "1.0.0")]
575575
#[inline]
576576
pub fn log2(self) -> f64 {
577-
crate::sys::log2f64(self)
577+
unsafe { intrinsics::log2f64(self) }
578578
}
579579

580580
/// Returns the base 10 logarithm of the number.

library/std/src/sys/pal/mod.rs

-18
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,5 @@ cfg_if::cfg_if! {
7676
}
7777
}
7878

79-
#[cfg(not(test))]
80-
cfg_if::cfg_if! {
81-
if #[cfg(target_os = "android")] {
82-
pub use self::android::log2f32;
83-
pub use self::android::log2f64;
84-
} else {
85-
#[inline]
86-
pub fn log2f32(n: f32) -> f32 {
87-
unsafe { crate::intrinsics::log2f32(n) }
88-
}
89-
90-
#[inline]
91-
pub fn log2f64(n: f64) -> f64 {
92-
unsafe { crate::intrinsics::log2f64(n) }
93-
}
94-
}
95-
}
96-
9779
#[cfg(not(target_os = "uefi"))]
9880
pub type RawOsError = i32;

library/std/src/sys/pal/unix/android.rs

-81
This file was deleted.

library/std/src/sys/pal/unix/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::io::ErrorKind;
88
pub mod weak;
99

1010
pub mod alloc;
11-
pub mod android;
1211
pub mod args;
1312
pub mod env;
1413
pub mod fd;
@@ -237,12 +236,8 @@ pub unsafe fn cleanup() {
237236
}
238237

239238
#[allow(unused_imports)]
240-
#[cfg(not(target_os = "android"))]
241239
pub use libc::signal;
242240

243-
#[cfg(target_os = "android")]
244-
pub use crate::sys::android::signal;
245-
246241
#[inline]
247242
pub(crate) fn is_interrupted(errno: i32) -> bool {
248243
errno == libc::EINTR

src/bootstrap/src/core/build_steps/dist.rs

+34-3
Original file line numberDiff line numberDiff line change
@@ -2122,15 +2122,46 @@ impl Step for LlvmTools {
21222122

21232123
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
21242124
let default = should_build_extended_tool(run.builder, "llvm-tools");
2125-
// FIXME: allow using the names of the tools themselves?
2126-
run.alias("llvm-tools").default_condition(default)
2125+
2126+
let mut run = run.alias("llvm-tools");
2127+
for tool in LLVM_TOOLS {
2128+
run = run.alias(tool);
2129+
}
2130+
2131+
run.default_condition(default)
21272132
}
21282133

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

21332138
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
2139+
fn tools_to_install(paths: &[PathBuf]) -> Vec<&'static str> {
2140+
let mut tools = vec![];
2141+
2142+
for path in paths {
2143+
let path = path.to_str().unwrap();
2144+
2145+
// Include all tools if path is 'llvm-tools'.
2146+
if path == "llvm-tools" {
2147+
return LLVM_TOOLS.to_owned();
2148+
}
2149+
2150+
for tool in LLVM_TOOLS {
2151+
if path == *tool {
2152+
tools.push(*tool);
2153+
}
2154+
}
2155+
}
2156+
2157+
// If no specific tool is requested, include all tools.
2158+
if tools.is_empty() {
2159+
tools = LLVM_TOOLS.to_owned();
2160+
}
2161+
2162+
tools
2163+
}
2164+
21342165
let target = self.target;
21352166

21362167
/* run only if llvm-config isn't used */
@@ -2151,7 +2182,7 @@ impl Step for LlvmTools {
21512182
// Prepare the image directory
21522183
let src_bindir = builder.llvm_out(target).join("bin");
21532184
let dst_bindir = format!("lib/rustlib/{}/bin", target.triple);
2154-
for tool in LLVM_TOOLS {
2185+
for tool in tools_to_install(&builder.paths) {
21552186
let exe = src_bindir.join(exe(tool, target));
21562187
tarball.add_file(&exe, &dst_bindir, 0o755);
21572188
}

tests/coverage/mcdc/condition-limit.coverage

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
LL| |#![feature(coverage_attribute)]
22
LL| |//@ edition: 2021
33
LL| |//@ min-llvm-version: 18
4+
LL| |//@ ignore-llvm-version: 19 - 99
45
LL| |//@ compile-flags: -Zcoverage-options=mcdc
56
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
67
LL| |

tests/coverage/mcdc/if.coverage

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
LL| |#![feature(coverage_attribute)]
22
LL| |//@ edition: 2021
33
LL| |//@ min-llvm-version: 18
4+
LL| |//@ ignore-llvm-version: 19 - 99
45
LL| |//@ compile-flags: -Zcoverage-options=mcdc
56
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
67
LL| |

tests/coverage/mcdc/inlined_expressions.coverage

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
LL| |#![feature(coverage_attribute)]
22
LL| |//@ edition: 2021
33
LL| |//@ min-llvm-version: 18
4+
LL| |//@ ignore-llvm-version: 19 - 99
45
LL| |//@ compile-flags: -Zcoverage-options=mcdc -Copt-level=z -Cllvm-args=--inline-threshold=0
56
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
67
LL| |

tests/coverage/mcdc/nested_if.coverage

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
LL| |#![feature(coverage_attribute)]
22
LL| |//@ edition: 2021
33
LL| |//@ min-llvm-version: 18
4+
LL| |//@ ignore-llvm-version: 19 - 99
45
LL| |//@ compile-flags: -Zcoverage-options=mcdc
56
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
67
LL| |

tests/coverage/mcdc/non_control_flow.coverage

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
LL| |#![feature(coverage_attribute)]
22
LL| |//@ edition: 2021
33
LL| |//@ min-llvm-version: 18
4+
LL| |//@ ignore-llvm-version: 19 - 99
45
LL| |//@ compile-flags: -Zcoverage-options=mcdc
56
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
67
LL| |

tests/ui/attributes/optimize.rs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#![feature(optimize_attribute)]
2+
#![feature(stmt_expr_attributes)]
3+
#![deny(unused_attributes)]
4+
#![allow(dead_code)]
5+
6+
#[optimize(speed)] //~ ERROR attribute should be applied to function or closure
7+
struct F;
8+
9+
fn invalid() {
10+
#[optimize(speed)] //~ ERROR attribute should be applied to function or closure
11+
{
12+
1
13+
};
14+
}
15+
16+
#[optimize(speed)]
17+
fn valid() {}
18+
19+
#[optimize(speed)]
20+
mod valid_module {}
21+
22+
#[optimize(speed)]
23+
impl F {}
24+
25+
fn main() {
26+
let _ = #[optimize(speed)]
27+
(|| 1);
28+
}

tests/ui/attributes/optimize.stderr

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: attribute should be applied to function or closure
2+
--> $DIR/optimize.rs:6:1
3+
|
4+
LL | #[optimize(speed)]
5+
| ^^^^^^^^^^^^^^^^^^
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/optimize.rs:3:9
9+
|
10+
LL | #![deny(unused_attributes)]
11+
| ^^^^^^^^^^^^^^^^^
12+
13+
error: attribute should be applied to function or closure
14+
--> $DIR/optimize.rs:10:5
15+
|
16+
LL | #[optimize(speed)]
17+
| ^^^^^^^^^^^^^^^^^^
18+
19+
error: aborting due to 2 previous errors
20+

0 commit comments

Comments
 (0)