Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c27f756

Browse files
committedOct 13, 2019
Auto merge of #65388 - Centril:rollup-rhg0dvs, r=Centril
Rollup of 10 pull requests Successful merges: - #65214 (Split non-CAS atomic support off into target_has_atomic_load_store) - #65246 (vxWorks: implement get_path() and get_mode() for File fmt::Debug) - #65312 (improve performance of signed saturating_mul) - #65336 (Fix typo in task::Waker) - #65346 (nounwind tests and cleanup) - #65347 (Fix #[unwind(abort)] with Rust ABI) - #65366 (Implement Error::source on IntoStringError + Remove superfluous cause impls) - #65369 (Don't discard value names when using address or memory sanitizer) - #65370 (Add `dyn` to `Any` documentation) - #65373 (Fix typo in docs for `Rc`) Failed merges: r? @ghost
2 parents aa2ae56 + 92b36ce commit c27f756

File tree

24 files changed

+269
-199
lines changed

24 files changed

+269
-199
lines changed
 

‎src/liballoc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ mod boxed {
153153
#[cfg(test)]
154154
mod tests;
155155
pub mod collections;
156-
#[cfg(all(target_has_atomic = "ptr", target_has_atomic = "cas"))]
156+
#[cfg(target_has_atomic = "ptr")]
157157
pub mod sync;
158158
pub mod rc;
159159
pub mod raw_vec;

‎src/liballoc/rc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ impl<T: Clone> Rc<T> {
773773
/// referred to as clone-on-write.
774774
///
775775
/// If there are no other `Rc` pointers to this value, then [`Weak`]
776-
/// pointers to this value will be dissassociated.
776+
/// pointers to this value will be disassociated.
777777
///
778778
/// See also [`get_mut`], which will fail rather than cloning.
779779
///
@@ -799,7 +799,7 @@ impl<T: Clone> Rc<T> {
799799
/// assert_eq!(*other_data, 12);
800800
/// ```
801801
///
802-
/// [`Weak`] pointers will be dissassociated:
802+
/// [`Weak`] pointers will be disassociated:
803803
///
804804
/// ```
805805
/// use std::rc::Rc;

‎src/libcore/any.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
//! of any `'static` type through runtime reflection.
33
//!
44
//! `Any` itself can be used to get a `TypeId`, and has more features when used
5-
//! as a trait object. As `&Any` (a borrowed trait object), it has the `is` and
6-
//! `downcast_ref` methods, to test if the contained value is of a given type,
7-
//! and to get a reference to the inner value as a type. As `&mut Any`, there
5+
//! as a trait object. As `&dyn Any` (a borrowed trait object), it has the `is`
6+
//! and `downcast_ref` methods, to test if the contained value is of a given type,
7+
//! and to get a reference to the inner value as a type. As `&mut dyn Any`, there
88
//! is also the `downcast_mut` method, for getting a mutable reference to the
9-
//! inner value. `Box<Any>` adds the `downcast` method, which attempts to
9+
//! inner value. `Box<dyn Any>` adds the `downcast` method, which attempts to
1010
//! convert to a `Box<T>`. See the [`Box`] documentation for the full details.
1111
//!
12-
//! Note that &Any is limited to testing whether a value is of a specified
12+
//! Note that `&dyn Any` is limited to testing whether a value is of a specified
1313
//! concrete type, and cannot be used to test whether a type implements a trait.
1414
//!
1515
//! [`Box`]: ../../std/boxed/struct.Box.html

‎src/libcore/num/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ $EndFeature, "
10581058
#[inline]
10591059
pub fn saturating_mul(self, rhs: Self) -> Self {
10601060
self.checked_mul(rhs).unwrap_or_else(|| {
1061-
if (self < 0 && rhs < 0) || (self > 0 && rhs > 0) {
1061+
if (self < 0) == (rhs < 0) {
10621062
Self::max_value()
10631063
} else {
10641064
Self::min_value()

‎src/libcore/sync/atomic.rs

Lines changed: 92 additions & 70 deletions
Large diffs are not rendered by default.

‎src/libcore/task/wake.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl fmt::Debug for Context<'_> {
217217
/// This handle encapsulates a [`RawWaker`] instance, which defines the
218218
/// executor-specific wakeup behavior.
219219
///
220-
/// Implements [`Clone`], [`trait@Send`], and [`trait@Sync`].
220+
/// Implements [`Clone`], [`Send`], and [`Sync`].
221221
///
222222
/// [`RawWaker`]: struct.RawWaker.html
223223
#[repr(transparent)]

‎src/librustc/session/config.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,22 +1513,25 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
15131513
}
15141514
for &i in &[8, 16, 32, 64, 128] {
15151515
if i >= min_atomic_width && i <= max_atomic_width {
1516-
let s = i.to_string();
1517-
ret.insert((
1518-
sym::target_has_atomic,
1519-
Some(Symbol::intern(&s)),
1520-
));
1521-
if &s == wordsz {
1516+
let mut insert_atomic = |s| {
15221517
ret.insert((
1523-
sym::target_has_atomic,
1524-
Some(Symbol::intern("ptr")),
1518+
sym::target_has_atomic_load_store,
1519+
Some(Symbol::intern(s)),
15251520
));
1521+
if atomic_cas {
1522+
ret.insert((
1523+
sym::target_has_atomic,
1524+
Some(Symbol::intern(s))
1525+
));
1526+
}
1527+
};
1528+
let s = i.to_string();
1529+
insert_atomic(&s);
1530+
if &s == wordsz {
1531+
insert_atomic("ptr");
15261532
}
15271533
}
15281534
}
1529-
if atomic_cas {
1530-
ret.insert((sym::target_has_atomic, Some(Symbol::intern("cas"))));
1531-
}
15321535
if sess.opts.debug_assertions {
15331536
ret.insert((Symbol::intern("debug_assertions"), None));
15341537
}

‎src/librustc/session/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_data_structures::fingerprint::Fingerprint;
77

88
use crate::lint;
99
use crate::lint::builtin::BuiltinLintDiagnostics;
10-
use crate::session::config::{OutputType, PrintRequest, SwitchWithOptPath};
10+
use crate::session::config::{OutputType, PrintRequest, Sanitizer, SwitchWithOptPath};
1111
use crate::session::search_paths::{PathKind, SearchPath};
1212
use crate::util::nodemap::{FxHashMap, FxHashSet};
1313
use crate::util::common::{duration_to_secs_str, ErrorReported};
@@ -626,6 +626,14 @@ impl Session {
626626
.output_types
627627
.contains_key(&OutputType::LlvmAssembly)
628628
|| self.opts.output_types.contains_key(&OutputType::Bitcode);
629+
630+
// Address sanitizer and memory sanitizer use alloca name when reporting an issue.
631+
let more_names = match self.opts.debugging_opts.sanitizer {
632+
Some(Sanitizer::Address) => true,
633+
Some(Sanitizer::Memory) => true,
634+
_ => more_names,
635+
};
636+
629637
self.opts.debugging_opts.fewer_names || !more_names
630638
}
631639

‎src/librustc_codegen_llvm/attributes.rs

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -270,23 +270,12 @@ pub fn from_fn_attrs(
270270
// optimize based on this!
271271
false
272272
} else if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::UNWIND) {
273-
// If a specific #[unwind] attribute is present, use that
273+
// If a specific #[unwind] attribute is present, use that.
274274
true
275275
} else if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_ALLOCATOR_NOUNWIND) {
276-
// Special attribute for allocator functions, which can't unwind
276+
// Special attribute for allocator functions, which can't unwind.
277277
false
278-
} else if let Some(_) = id {
279-
// rust-lang/rust#64655, rust-lang/rust#63909: to minimize
280-
// risk associated with changing cases where nounwind
281-
// attribute is attached, this code is deliberately mimicking
282-
// old control flow based on whether `id` is `Some` or `None`.
283-
//
284-
// However, in the long term we should either:
285-
// - fold this into final else (i.e. stop inspecting `id`)
286-
// - or, adopt Rust PR #63909.
287-
//
288-
// see also Rust RFC 2753.
289-
278+
} else {
290279
let sig = cx.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
291280
if sig.abi == Abi::Rust || sig.abi == Abi::RustCall {
292281
// Any Rust method (or `extern "Rust" fn` or `extern
@@ -312,15 +301,6 @@ pub fn from_fn_attrs(
312301
// In either case, we mark item as explicitly nounwind.
313302
false
314303
}
315-
} else {
316-
// assume this can possibly unwind, avoiding the application of a
317-
// `nounwind` attribute below.
318-
//
319-
// (But: See comments in previous branch. Specifically, it is
320-
// unclear whether there is real value in the assumption this
321-
// can unwind. The conservatism here may just be papering over
322-
// a real problem by making some UB a bit harder to hit.)
323-
true
324304
});
325305

326306
// Always annotate functions with the target-cpu they are compiled for.

‎src/librustc_mir/build/mod.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -502,24 +502,21 @@ macro_rules! unpack {
502502
};
503503
}
504504

505-
fn should_abort_on_panic(tcx: TyCtxt<'_>, fn_def_id: DefId, abi: Abi) -> bool {
506-
// Not callable from C, so we can safely unwind through these
507-
if abi == Abi::Rust || abi == Abi::RustCall { return false; }
508-
509-
// Validate `#[unwind]` syntax regardless of platform-specific panic strategy
505+
fn should_abort_on_panic(tcx: TyCtxt<'_>, fn_def_id: DefId, _abi: Abi) -> bool {
506+
// Validate `#[unwind]` syntax regardless of platform-specific panic strategy.
510507
let attrs = &tcx.get_attrs(fn_def_id);
511508
let unwind_attr = attr::find_unwind_attr(Some(tcx.sess.diagnostic()), attrs);
512509

513-
// We never unwind, so it's not relevant to stop an unwind
510+
// We never unwind, so it's not relevant to stop an unwind.
514511
if tcx.sess.panic_strategy() != PanicStrategy::Unwind { return false; }
515512

516-
// We cannot add landing pads, so don't add one
513+
// We cannot add landing pads, so don't add one.
517514
if tcx.sess.no_landing_pads() { return false; }
518515

519516
// This is a special case: some functions have a C abi but are meant to
520517
// unwind anyway. Don't stop them.
521518
match unwind_attr {
522-
None => false, // FIXME(#58794)
519+
None => false, // FIXME(#58794); should be `!(abi == Abi::Rust || abi == Abi::RustCall)`
523520
Some(UnwindAttr::Allowed) => false,
524521
Some(UnwindAttr::Aborts) => true,
525522
}

‎src/libstd/error.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ impl<'a, E: Error + 'a> From<E> for Box<dyn Error + 'a> {
269269

270270
#[stable(feature = "rust1", since = "1.0.0")]
271271
impl<'a, E: Error + Send + Sync + 'a> From<E> for Box<dyn Error + Send + Sync + 'a> {
272-
/// Converts a type of [`Error`] + [`trait@Send`] + [`trait@Sync`] into a box of
273-
/// dyn [`Error`] + [`trait@Send`] + [`trait@Sync`].
272+
/// Converts a type of [`Error`] + [`Send`] + [`Sync`] into a box of
273+
/// dyn [`Error`] + [`Send`] + [`Sync`].
274274
///
275275
/// [`Error`]: ../error/trait.Error.html
276276
///
@@ -313,7 +313,7 @@ impl<'a, E: Error + Send + Sync + 'a> From<E> for Box<dyn Error + Send + Sync +
313313

314314
#[stable(feature = "rust1", since = "1.0.0")]
315315
impl From<String> for Box<dyn Error + Send + Sync> {
316-
/// Converts a [`String`] into a box of dyn [`Error`] + [`trait@Send`] + [`trait@Sync`].
316+
/// Converts a [`String`] into a box of dyn [`Error`] + [`Send`] + [`Sync`].
317317
///
318318
/// [`Error`]: ../error/trait.Error.html
319319
///
@@ -377,7 +377,7 @@ impl From<String> for Box<dyn Error> {
377377

378378
#[stable(feature = "rust1", since = "1.0.0")]
379379
impl<'a> From<&str> for Box<dyn Error + Send + Sync + 'a> {
380-
/// Converts a [`str`] into a box of dyn [`Error`] + [`trait@Send`] + [`trait@Sync`].
380+
/// Converts a [`str`] into a box of dyn [`Error`] + [`Send`] + [`Sync`].
381381
///
382382
/// [`Error`]: ../error/trait.Error.html
383383
///
@@ -420,7 +420,7 @@ impl From<&str> for Box<dyn Error> {
420420

421421
#[stable(feature = "cow_box_error", since = "1.22.0")]
422422
impl<'a, 'b> From<Cow<'b, str>> for Box<dyn Error + Send + Sync + 'a> {
423-
/// Converts a [`Cow`] into a box of dyn [`Error`] + [`trait@Send`] + [`trait@Sync`].
423+
/// Converts a [`Cow`] into a box of dyn [`Error`] + [`Send`] + [`Sync`].
424424
///
425425
/// [`Cow`]: ../borrow/enum.Cow.html
426426
/// [`Error`]: ../error/trait.Error.html

‎src/libstd/ffi/c_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ impl Error for IntoStringError {
919919
"C string contained non-utf8 bytes"
920920
}
921921

922-
fn cause(&self) -> Option<&dyn Error> {
922+
fn source(&self) -> Option<&(dyn Error + 'static)> {
923923
Some(&self.error)
924924
}
925925
}

‎src/libstd/panic.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ use crate::ops::{Deref, DerefMut};
1212
use crate::panicking;
1313
use crate::ptr::{Unique, NonNull};
1414
use crate::rc::Rc;
15-
use crate::sync::{Arc, Mutex, RwLock, atomic};
15+
use crate::sync::{Arc, Mutex, RwLock};
16+
#[cfg(not(bootstrap))]
17+
use crate::sync::atomic;
1618
use crate::task::{Context, Poll};
1719
use crate::thread::Result;
1820

@@ -240,49 +242,49 @@ impl<T: ?Sized> RefUnwindSafe for Mutex<T> {}
240242
#[stable(feature = "unwind_safe_lock_refs", since = "1.12.0")]
241243
impl<T: ?Sized> RefUnwindSafe for RwLock<T> {}
242244

243-
#[cfg(target_has_atomic = "ptr")]
245+
#[cfg(target_has_atomic_load_store = "ptr")]
244246
#[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")]
245247
impl RefUnwindSafe for atomic::AtomicIsize {}
246-
#[cfg(target_has_atomic = "8")]
248+
#[cfg(target_has_atomic_load_store = "8")]
247249
#[unstable(feature = "integer_atomics", issue = "32976")]
248250
impl RefUnwindSafe for atomic::AtomicI8 {}
249-
#[cfg(target_has_atomic = "16")]
251+
#[cfg(target_has_atomic_load_store = "16")]
250252
#[unstable(feature = "integer_atomics", issue = "32976")]
251253
impl RefUnwindSafe for atomic::AtomicI16 {}
252-
#[cfg(target_has_atomic = "32")]
254+
#[cfg(target_has_atomic_load_store = "32")]
253255
#[unstable(feature = "integer_atomics", issue = "32976")]
254256
impl RefUnwindSafe for atomic::AtomicI32 {}
255-
#[cfg(target_has_atomic = "64")]
257+
#[cfg(target_has_atomic_load_store = "64")]
256258
#[unstable(feature = "integer_atomics", issue = "32976")]
257259
impl RefUnwindSafe for atomic::AtomicI64 {}
258-
#[cfg(target_has_atomic = "128")]
260+
#[cfg(target_has_atomic_load_store = "128")]
259261
#[unstable(feature = "integer_atomics", issue = "32976")]
260262
impl RefUnwindSafe for atomic::AtomicI128 {}
261263

262-
#[cfg(target_has_atomic = "ptr")]
264+
#[cfg(target_has_atomic_load_store = "ptr")]
263265
#[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")]
264266
impl RefUnwindSafe for atomic::AtomicUsize {}
265-
#[cfg(target_has_atomic = "8")]
267+
#[cfg(target_hastarget_has_atomic_load_store_atomic = "8")]
266268
#[unstable(feature = "integer_atomics", issue = "32976")]
267269
impl RefUnwindSafe for atomic::AtomicU8 {}
268-
#[cfg(target_has_atomic = "16")]
270+
#[cfg(target_has_atomic_load_store = "16")]
269271
#[unstable(feature = "integer_atomics", issue = "32976")]
270272
impl RefUnwindSafe for atomic::AtomicU16 {}
271-
#[cfg(target_has_atomic = "32")]
273+
#[cfg(target_has_atomic_load_store = "32")]
272274
#[unstable(feature = "integer_atomics", issue = "32976")]
273275
impl RefUnwindSafe for atomic::AtomicU32 {}
274-
#[cfg(target_has_atomic = "64")]
276+
#[cfg(target_has_atomic_load_store = "64")]
275277
#[unstable(feature = "integer_atomics", issue = "32976")]
276278
impl RefUnwindSafe for atomic::AtomicU64 {}
277-
#[cfg(target_has_atomic = "128")]
279+
#[cfg(target_has_atomic_load_store = "128")]
278280
#[unstable(feature = "integer_atomics", issue = "32976")]
279281
impl RefUnwindSafe for atomic::AtomicU128 {}
280282

281-
#[cfg(target_has_atomic = "8")]
283+
#[cfg(target_has_atomic_load_store = "8")]
282284
#[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")]
283285
impl RefUnwindSafe for atomic::AtomicBool {}
284286

285-
#[cfg(target_has_atomic = "ptr")]
287+
#[cfg(target_has_atomic_load_store = "ptr")]
286288
#[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")]
287289
impl<T> RefUnwindSafe for atomic::AtomicPtr<T> {}
288290

‎src/libstd/sync/mpsc/mod.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,10 +1581,6 @@ impl<T: Send> error::Error for SendError<T> {
15811581
fn description(&self) -> &str {
15821582
"sending on a closed channel"
15831583
}
1584-
1585-
fn cause(&self) -> Option<&dyn error::Error> {
1586-
None
1587-
}
15881584
}
15891585

15901586
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1624,10 +1620,6 @@ impl<T: Send> error::Error for TrySendError<T> {
16241620
}
16251621
}
16261622
}
1627-
1628-
fn cause(&self) -> Option<&dyn error::Error> {
1629-
None
1630-
}
16311623
}
16321624

16331625
#[stable(feature = "mpsc_error_conversions", since = "1.24.0")]
@@ -1652,10 +1644,6 @@ impl error::Error for RecvError {
16521644
fn description(&self) -> &str {
16531645
"receiving on a closed channel"
16541646
}
1655-
1656-
fn cause(&self) -> Option<&dyn error::Error> {
1657-
None
1658-
}
16591647
}
16601648

16611649
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1685,10 +1673,6 @@ impl error::Error for TryRecvError {
16851673
}
16861674
}
16871675
}
1688-
1689-
fn cause(&self) -> Option<&dyn error::Error> {
1690-
None
1691-
}
16921676
}
16931677

16941678
#[stable(feature = "mpsc_error_conversions", since = "1.24.0")]
@@ -1726,10 +1710,6 @@ impl error::Error for RecvTimeoutError {
17261710
}
17271711
}
17281712
}
1729-
1730-
fn cause(&self) -> Option<&dyn error::Error> {
1731-
None
1732-
}
17331713
}
17341714

17351715
#[stable(feature = "mpsc_error_conversions", since = "1.24.0")]

‎src/libstd/sys/vxworks/fs.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -400,13 +400,27 @@ impl FromInner<c_int> for File {
400400

401401
impl fmt::Debug for File {
402402
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
403-
fn get_path(_fd: c_int) -> Option<PathBuf> {
404-
// FIXME(#:(): implement this for VxWorks
405-
None
403+
fn get_path(fd: c_int) -> Option<PathBuf> {
404+
let mut buf = vec![0;libc::PATH_MAX as usize];
405+
let n = unsafe { libc::ioctl(fd, libc::FIOGETNAME, buf.as_ptr()) };
406+
if n == -1 {
407+
return None;
408+
}
409+
let l = buf.iter().position(|&c| c == 0).unwrap();
410+
buf.truncate(l as usize);
411+
Some(PathBuf::from(OsString::from_vec(buf)))
406412
}
407-
fn get_mode(_fd: c_int) -> Option<(bool, bool)> {
408-
// FIXME(#:(): implement this for VxWorks
409-
None
413+
fn get_mode(fd: c_int) -> Option<(bool, bool)> {
414+
let mode = unsafe { libc::fcntl(fd, libc::F_GETFL) };
415+
if mode == -1 {
416+
return None;
417+
}
418+
match mode & libc::O_ACCMODE {
419+
libc::O_RDONLY => Some((true, false)),
420+
libc::O_RDWR => Some((true, true)),
421+
libc::O_WRONLY => Some((false, true)),
422+
_ => None
423+
}
410424
}
411425

412426
let fd = self.0.raw();

‎src/libsyntax/feature_gate/builtin_attrs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const GATED_CFGS: &[(Symbol, Symbol, GateFn)] = &[
2929
// (name in cfg, feature, function to check if the feature is enabled)
3030
(sym::target_thread_local, sym::cfg_target_thread_local, cfg_fn!(cfg_target_thread_local)),
3131
(sym::target_has_atomic, sym::cfg_target_has_atomic, cfg_fn!(cfg_target_has_atomic)),
32+
(sym::target_has_atomic_load_store, sym::cfg_target_has_atomic, cfg_fn!(cfg_target_has_atomic)),
3233
(sym::rustdoc, sym::doc_cfg, cfg_fn!(doc_cfg)),
3334
(sym::doctest, sym::cfg_doctest, cfg_fn!(cfg_doctest)),
3435
];

‎src/libsyntax_pos/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@ symbols! {
658658
suggestion,
659659
target_feature,
660660
target_has_atomic,
661+
target_has_atomic_load_store,
661662
target_thread_local,
662663
task,
663664
tbm_target_feature,

‎src/test/codegen/extern-functions.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎src/test/codegen/nounwind-extern.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// compile-flags: -C opt-level=0
2+
3+
#![crate_type = "lib"]
4+
#![feature(unwind_attributes)]
5+
6+
// Make sure these all do *not* get the attribute.
7+
// We disable optimizations to prevent LLVM from infering the attribute.
8+
// CHECK-NOT: nounwind
9+
10+
// "C" ABI
11+
// pub extern fn foo() {} // FIXME right now we don't abort-on-panic but add `nounwind` nevertheless
12+
#[unwind(allowed)]
13+
pub extern fn foo_allowed() {}
14+
15+
// "Rust"
16+
// (`extern "Rust"` could be removed as all `fn` get it implicitly; we leave it in for clarity.)
17+
pub extern "Rust" fn bar() {}
18+
#[unwind(allowed)]
19+
pub extern "Rust" fn bar_allowed() {}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// compile-flags: -C no-prepopulate-passes
2+
3+
#![crate_type = "lib"]
4+
#![feature(unwind_attributes)]
5+
6+
extern {
7+
// CHECK: Function Attrs:{{.*}}nounwind
8+
// CHECK-NEXT: declare void @extern_fn
9+
fn extern_fn();
10+
// CHECK-NOT: Function Attrs:{{.*}}nounwind
11+
// CHECK: declare void @unwinding_extern_fn
12+
#[unwind(allowed)]
13+
fn unwinding_extern_fn();
14+
// CHECK-NOT: nounwind
15+
// CHECK: declare void @aborting_extern_fn
16+
#[unwind(aborts)]
17+
fn aborting_extern_fn(); // FIXME: we want to have the attribute here
18+
}
19+
20+
extern "Rust" {
21+
// CHECK-NOT: nounwind
22+
// CHECK: declare void @rust_extern_fn
23+
fn rust_extern_fn();
24+
// CHECK-NOT: nounwind
25+
// CHECK: declare void @rust_unwinding_extern_fn
26+
#[unwind(allowed)]
27+
fn rust_unwinding_extern_fn();
28+
// CHECK-NOT: nounwind
29+
// CHECK: declare void @rust_aborting_extern_fn
30+
#[unwind(aborts)]
31+
fn rust_aborting_extern_fn(); // FIXME: we want to have the attribute here
32+
}
33+
34+
pub unsafe fn force_declare() {
35+
extern_fn();
36+
unwinding_extern_fn();
37+
aborting_extern_fn();
38+
rust_extern_fn();
39+
rust_unwinding_extern_fn();
40+
rust_aborting_extern_fn();
41+
}

‎src/test/run-make-fulldeps/sanitizer-address/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ endif
2424

2525
all:
2626
$(RUSTC) -g -Z sanitizer=address -Z print-link-args $(EXTRA_RUSTFLAG) overflow.rs | $(CGREP) librustc_asan
27+
# Verify that stack buffer overflow is detected:
2728
$(TMPDIR)/overflow 2>&1 | $(CGREP) stack-buffer-overflow
29+
# Verify that variable name is included in address sanitizer report:
30+
$(TMPDIR)/overflow 2>&1 | $(CGREP) "'xs'"

‎src/test/run-make-fulldeps/target-without-atomic-cas/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
# The target used below doesn't support atomic CAS operations. Verify that's the case
44
all:
5-
$(RUSTC) --print cfg --target thumbv6m-none-eabi | $(CGREP) -v 'target_has_atomic="cas"'
5+
$(RUSTC) --print cfg --target thumbv6m-none-eabi | $(CGREP) -v 'target_has_atomic="ptr"'

‎src/test/ui/abi/abort-on-c-abi.rs renamed to ‎src/test/ui/panics/abort-on-panic.rs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,51 @@ use std::io::prelude::*;
1414
use std::io;
1515
use std::process::{Command, Stdio};
1616

17-
#[unwind(aborts)] // FIXME(#58794)
17+
#[unwind(aborts)] // FIXME(#58794) should work even without the attribute
1818
extern "C" fn panic_in_ffi() {
1919
panic!("Test");
2020
}
2121

22+
#[unwind(aborts)]
23+
extern "Rust" fn panic_in_rust_abi() {
24+
panic!("TestRust");
25+
}
26+
2227
fn test() {
2328
let _ = panic::catch_unwind(|| { panic_in_ffi(); });
2429
// The process should have aborted by now.
2530
io::stdout().write(b"This should never be printed.\n");
2631
let _ = io::stdout().flush();
2732
}
2833

34+
fn testrust() {
35+
let _ = panic::catch_unwind(|| { panic_in_rust_abi(); });
36+
// The process should have aborted by now.
37+
io::stdout().write(b"This should never be printed.\n");
38+
let _ = io::stdout().flush();
39+
}
40+
2941
fn main() {
3042
let args: Vec<String> = env::args().collect();
31-
if args.len() > 1 && args[1] == "test" {
32-
return test();
43+
if args.len() > 1 {
44+
// This is inside the self-executed command.
45+
match &*args[1] {
46+
"test" => return test(),
47+
"testrust" => return testrust(),
48+
_ => panic!("bad test"),
49+
}
3350
}
3451

52+
// These end up calling the self-execution branches above.
3553
let mut p = Command::new(&args[0])
3654
.stdout(Stdio::piped())
3755
.stdin(Stdio::piped())
3856
.arg("test").spawn().unwrap();
3957
assert!(!p.wait().unwrap().success());
58+
59+
let mut p = Command::new(&args[0])
60+
.stdout(Stdio::piped())
61+
.stdin(Stdio::piped())
62+
.arg("testrust").spawn().unwrap();
63+
assert!(!p.wait().unwrap().success());
4064
}

0 commit comments

Comments
 (0)
Please sign in to comment.