Skip to content

Commit 4884061

Browse files
committed
Auto merge of #68286 - Dylan-DPC:rollup-x7ssgov, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #68033 (Don't use f64 shims for f32 cmath functions on non 32-bit x86 MSVC) - #68244 (Enable leak sanitizer test case) - #68255 (Remove unused auxiliary file that was replaced with rust_test_helpers) - #68263 (rustdoc: HTML escape codeblocks which fail syntax highlighting) - #68274 (remove dead code) Failed merges: r? @ghost
2 parents 117ceeb + a529e70 commit 4884061

File tree

8 files changed

+38
-80
lines changed

8 files changed

+38
-80
lines changed

src/librustc/traits/select.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -3767,16 +3767,12 @@ impl<'tcx> TraitObligation<'tcx> {
37673767
// NOTE(flaper87): As of now, it keeps track of the whole error
37683768
// chain. Ideally, we should have a way to configure this either
37693769
// by using -Z verbose or just a CLI argument.
3770-
if obligation.recursion_depth >= 0 {
3771-
let derived_cause = DerivedObligationCause {
3772-
parent_trait_ref: obligation.predicate.to_poly_trait_ref(),
3773-
parent_code: Rc::new(obligation.cause.code.clone()),
3774-
};
3775-
let derived_code = variant(derived_cause);
3776-
ObligationCause::new(obligation.cause.span, obligation.cause.body_id, derived_code)
3777-
} else {
3778-
obligation.cause.clone()
3779-
}
3770+
let derived_cause = DerivedObligationCause {
3771+
parent_trait_ref: obligation.predicate.to_poly_trait_ref(),
3772+
parent_code: Rc::new(obligation.cause.code.clone()),
3773+
};
3774+
let derived_code = variant(derived_cause);
3775+
ObligationCause::new(obligation.cause.span, obligation.cause.body_id, derived_code)
37803776
}
37813777
}
37823778

src/librustdoc/html/highlight.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub fn render_with_highlighting(
6565
Err(()) => {
6666
// If errors are encountered while trying to highlight, just emit
6767
// the unhighlighted source.
68-
write!(out, "<pre><code>{}</code></pre>", src).unwrap();
68+
write!(out, "<pre><code>{}</code></pre>", Escape(src)).unwrap();
6969
}
7070
}
7171

src/libstd/f32.rs

+8-52
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,7 @@ impl f32 {
4444
#[stable(feature = "rust1", since = "1.0.0")]
4545
#[inline]
4646
pub fn floor(self) -> f32 {
47-
// On MSVC LLVM will lower many math intrinsics to a call to the
48-
// corresponding function. On MSVC, however, many of these functions
49-
// aren't actually available as symbols to call, but rather they are all
50-
// `static inline` functions in header files. This means that from a C
51-
// perspective it's "compatible", but not so much from an ABI
52-
// perspective (which we're worried about).
53-
//
54-
// The inline header functions always just cast to a f64 and do their
55-
// operation, so we do that here as well, but only for MSVC targets.
56-
//
57-
// Note that there are many MSVC-specific float operations which
58-
// redirect to this comment, so `floorf` is just one case of a missing
59-
// function on MSVC, but there are many others elsewhere.
60-
#[cfg(target_env = "msvc")]
61-
return (self as f64).floor() as f32;
62-
#[cfg(not(target_env = "msvc"))]
63-
return unsafe { intrinsics::floorf32(self) };
47+
unsafe { intrinsics::floorf32(self) }
6448
}
6549

6650
/// Returns the smallest integer greater than or equal to a number.
@@ -78,11 +62,7 @@ impl f32 {
7862
#[stable(feature = "rust1", since = "1.0.0")]
7963
#[inline]
8064
pub fn ceil(self) -> f32 {
81-
// see notes above in `floor`
82-
#[cfg(target_env = "msvc")]
83-
return (self as f64).ceil() as f32;
84-
#[cfg(not(target_env = "msvc"))]
85-
return unsafe { intrinsics::ceilf32(self) };
65+
unsafe { intrinsics::ceilf32(self) }
8666
}
8767

8868
/// Returns the nearest integer to a number. Round half-way cases away from
@@ -348,11 +328,7 @@ impl f32 {
348328
#[stable(feature = "rust1", since = "1.0.0")]
349329
#[inline]
350330
pub fn powf(self, n: f32) -> f32 {
351-
// see notes above in `floor`
352-
#[cfg(target_env = "msvc")]
353-
return (self as f64).powf(n as f64) as f32;
354-
#[cfg(not(target_env = "msvc"))]
355-
return unsafe { intrinsics::powf32(self, n) };
331+
unsafe { intrinsics::powf32(self, n) }
356332
}
357333

358334
/// Returns the square root of a number.
@@ -399,11 +375,7 @@ impl f32 {
399375
#[stable(feature = "rust1", since = "1.0.0")]
400376
#[inline]
401377
pub fn exp(self) -> f32 {
402-
// see notes above in `floor`
403-
#[cfg(target_env = "msvc")]
404-
return (self as f64).exp() as f32;
405-
#[cfg(not(target_env = "msvc"))]
406-
return unsafe { intrinsics::expf32(self) };
378+
unsafe { intrinsics::expf32(self) }
407379
}
408380

409381
/// Returns `2^(self)`.
@@ -447,11 +419,7 @@ impl f32 {
447419
#[stable(feature = "rust1", since = "1.0.0")]
448420
#[inline]
449421
pub fn ln(self) -> f32 {
450-
// see notes above in `floor`
451-
#[cfg(target_env = "msvc")]
452-
return (self as f64).ln() as f32;
453-
#[cfg(not(target_env = "msvc"))]
454-
return unsafe { intrinsics::logf32(self) };
422+
unsafe { intrinsics::logf32(self) }
455423
}
456424

457425
/// Returns the logarithm of the number with respect to an arbitrary base.
@@ -521,11 +489,7 @@ impl f32 {
521489
#[stable(feature = "rust1", since = "1.0.0")]
522490
#[inline]
523491
pub fn log10(self) -> f32 {
524-
// see notes above in `floor`
525-
#[cfg(target_env = "msvc")]
526-
return (self as f64).log10() as f32;
527-
#[cfg(not(target_env = "msvc"))]
528-
return unsafe { intrinsics::log10f32(self) };
492+
unsafe { intrinsics::log10f32(self) }
529493
}
530494

531495
/// The positive difference of two numbers.
@@ -625,11 +589,7 @@ impl f32 {
625589
#[stable(feature = "rust1", since = "1.0.0")]
626590
#[inline]
627591
pub fn sin(self) -> f32 {
628-
// see notes in `core::f32::Float::floor`
629-
#[cfg(target_env = "msvc")]
630-
return (self as f64).sin() as f32;
631-
#[cfg(not(target_env = "msvc"))]
632-
return unsafe { intrinsics::sinf32(self) };
592+
unsafe { intrinsics::sinf32(self) }
633593
}
634594

635595
/// Computes the cosine of a number (in radians).
@@ -649,11 +609,7 @@ impl f32 {
649609
#[stable(feature = "rust1", since = "1.0.0")]
650610
#[inline]
651611
pub fn cos(self) -> f32 {
652-
// see notes in `core::f32::Float::floor`
653-
#[cfg(target_env = "msvc")]
654-
return (self as f64).cos() as f32;
655-
#[cfg(not(target_env = "msvc"))]
656-
return unsafe { intrinsics::cosf32(self) };
612+
unsafe { intrinsics::cosf32(self) }
657613
}
658614

659615
/// Computes the tangent of a number (in radians).

src/libstd/sys/windows/cmath.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" {
2727

2828
pub use self::shims::*;
2929

30-
#[cfg(not(target_env = "msvc"))]
30+
#[cfg(not(all(target_env = "msvc", target_arch = "x86")))]
3131
mod shims {
3232
use libc::c_float;
3333

@@ -43,10 +43,10 @@ mod shims {
4343
}
4444
}
4545

46-
// On MSVC these functions aren't defined, so we just define shims which promote
47-
// everything fo f64, perform the calculation, and then demote back to f32.
48-
// While not precisely correct should be "correct enough" for now.
49-
#[cfg(target_env = "msvc")]
46+
// On 32-bit x86 MSVC these functions aren't defined, so we just define shims
47+
// which promote everything fo f64, perform the calculation, and then demote
48+
// back to f32. While not precisely correct should be "correct enough" for now.
49+
#[cfg(all(target_env = "msvc", target_arch = "x86"))]
5050
mod shims {
5151
use libc::c_float;
5252

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
-include ../tools.mk
22

33
# needs-sanitizer-support
4-
# only-linux
5-
# only-x86_64
6-
# ignore-test
7-
# FIXME(#46126) ThinLTO for libstd broke this test
84

95
all:
10-
$(RUSTC) -C opt-level=1 -g -Z sanitizer=leak -Z print-link-args leak.rs | $(CGREP) rustc_rt.lsan
6+
$(RUSTC) -O -Z sanitizer=leak -Z print-link-args leak.rs | $(CGREP) rustc_rt.lsan
117
$(TMPDIR)/leak 2>&1 | $(CGREP) 'detected memory leaks'
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
#![feature(test)]
2+
3+
use std::hint::black_box;
14
use std::mem;
25

36
fn main() {
4-
let xs = vec![1, 2, 3, 4];
5-
mem::forget(xs);
7+
for _ in 0..10 {
8+
let xs = vec![1, 2, 3];
9+
// Prevent compiler from removing the memory allocation.
10+
let xs = black_box(xs);
11+
mem::forget(xs);
12+
}
613
}

src/test/rustdoc/bad-codeblock-syntax.rs

+8
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,11 @@ pub fn quux() {}
2525
/// \_
2626
/// ```
2727
pub fn ok() {}
28+
29+
// @has bad_codeblock_syntax/fn.escape.html
30+
// @has - '//*[@class="docblock"]/pre/code' '\_ <script>alert("not valid Rust");</script>'
31+
/// ```
32+
/// \_
33+
/// <script>alert("not valid Rust");</script>
34+
/// ```
35+
pub fn escape() {}

src/test/ui/rfcs/rfc1717/auxiliary/clibrary.rs

-5
This file was deleted.

0 commit comments

Comments
 (0)