Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #63112

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fed12fa
Remove mentions of removed `offset_to` method
phil-opp Jun 19, 2019
c9c73f5
Refer to `add` method instead of `offset`
phil-opp Jul 17, 2019
d68f0f6
Remove derives `Encodable`/`Decodable` and unstabilize attribute `#[b…
petrochenkov Jul 27, 2019
dfad725
Recover 'for ( $pat in $expr ) $block'.
Centril Jul 24, 2019
1b11860
Use chaining for diagnosics in parser.
Centril Jul 24, 2019
56b39fb
Add 'span_to_snippet' shortcut.
Centril Jul 24, 2019
18bf9dd
Properly check the defining scope of existential types
Aaron1011 Jul 28, 2019
8811b9c
Fix formatting
Aaron1011 Jul 28, 2019
3e98c3a
Rename test and add comment
Aaron1011 Jul 28, 2019
0cdd693
vxworks: Remove Linux-specific comments.
josephlr Jul 29, 2019
c56d8a8
Add links to None in Option doc
tesuji Jul 29, 2019
624c5da
impl Debug for Chars
max-sixty Jul 26, 2019
3325ff6
comments from @lzutao
max-sixty Jul 29, 2019
8d7fb87
std: Fix a failing `fs` test on Windows
alexcrichton Jul 29, 2019
870efe3
Add very simple edition check to tidy; and add missing edition = 2018s.
crlf0710 Jul 28, 2019
b20abcf
Rollup merge of #61965 - phil-opp:patch-4, r=scottmcm
Centril Jul 29, 2019
600c8f6
Rollup merge of #62507 - petrochenkov:macunstab, r=alexcrichton
Centril Jul 29, 2019
04ec35b
Rollup merge of #62928 - Centril:recover-parens-around-for-head, r=es…
Centril Jul 29, 2019
2575e53
Rollup merge of #63000 - max-sixty:chars-display, r=alexcrichton
Centril Jul 29, 2019
2c0e220
Rollup merge of #63087 - crlf0710:tidy_2018, r=Mark-Simulacrum
Centril Jul 29, 2019
4551dc2
Rollup merge of #63093 - Aaron1011:fix/existential-closure, r=cramertj
Centril Jul 29, 2019
0a0cf6f
Rollup merge of #63099 - josephlr:vxworks, r=alexcrichton
Centril Jul 29, 2019
9845163
Rollup merge of #63108 - lzutao:option-xor-typo, r=jonas-schievink
Centril Jul 29, 2019
2c54921
Rollup merge of #63109 - alexcrichton:disable-windows-fs-test, r=sfac…
Centril Jul 29, 2019
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
10 changes: 10 additions & 0 deletions src/liballoc/tests/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,16 @@ fn test_iterator_last() {
assert_eq!(it.last(), Some('m'));
}

#[test]
fn test_chars_debug() {
let s = "ศไทย中华Việt Nam";
let c = s.chars();
assert_eq!(
format!("{:?}", c),
r#"Chars(['ศ', 'ไ', 'ท', 'ย', '中', '华', 'V', 'i', 'ệ', 't', ' ', 'N', 'a', 'm'])"#
);
}

#[test]
fn test_bytesator() {
let s = "ศไทย中华Việt Nam";
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub fn spin_loop() {
///
/// This function is a no-op, and does not even read from `dummy`.
#[inline]
#[unstable(feature = "test", issue = "27812")]
#[unstable(feature = "test", issue = "50297")]
#[allow(unreachable_code)] // this makes #[cfg] a bit easier below.
pub fn black_box<T>(dummy: T) -> T {
// We need to "use" the argument in some way LLVM can't introspect, and on
Expand Down
27 changes: 2 additions & 25 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,8 @@ pub(crate) mod builtin {
pub macro test($item:item) { /* compiler built-in */ }

/// Attribute macro applied to a function to turn it into a benchmark test.
#[stable(feature = "rust1", since = "1.0.0")]
#[unstable(feature = "test", issue = "50297",
reason = "`bench` is a part of custom test frameworks which are unstable")]
#[allow_internal_unstable(test, rustc_attrs)]
#[rustc_builtin_macro]
#[rustc_macro_transparency = "semitransparent"]
Expand Down Expand Up @@ -1309,37 +1310,13 @@ pub(crate) mod builtin {
#[allow_internal_unstable(core_intrinsics)]
pub macro Debug($item:item) { /* compiler built-in */ }

/// Unstable implementation detail of the `rustc` compiler, do not use.
#[rustc_builtin_macro]
#[rustc_macro_transparency = "semitransparent"]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(
since = "1.0.0",
reason = "derive(Decodable) is deprecated in favor of derive(RustcDecodable)",
suggestion = "RustcDecodable",
)]
#[allow_internal_unstable(core_intrinsics, libstd_sys_internals)]
pub macro Decodable($item:item) { /* compiler built-in */ }

/// Derive macro generating an impl of the trait `Default`.
#[rustc_builtin_macro]
#[rustc_macro_transparency = "semitransparent"]
#[stable(feature = "rust1", since = "1.0.0")]
#[allow_internal_unstable(core_intrinsics)]
pub macro Default($item:item) { /* compiler built-in */ }

/// Unstable implementation detail of the `rustc` compiler, do not use.
#[rustc_builtin_macro]
#[rustc_macro_transparency = "semitransparent"]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(
since = "1.0.0",
reason = "derive(Encodable) is deprecated in favor of derive(RustcEncodable)",
suggestion = "RustcEncodable",
)]
#[allow_internal_unstable(core_intrinsics)]
pub macro Encodable($item:item) { /* compiler built-in */ }

/// Derive macro generating an impl of the trait `Eq`.
#[rustc_builtin_macro]
#[rustc_macro_transparency = "semitransparent"]
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//! * Initial values
//! * Return values for functions that are not defined
//! over their entire input range (partial functions)
//! * Return value for otherwise reporting simple errors, where `None` is
//! * Return value for otherwise reporting simple errors, where [`None`] is
//! returned on error
//! * Optional struct fields
//! * Struct fields that can be loaned or "taken"
Expand Down Expand Up @@ -752,7 +752,7 @@ impl<T> Option<T> {
}
}

/// Returns [`Some`] if exactly one of `self`, `optb` is [`Some`], otherwise returns `None`.
/// Returns [`Some`] if exactly one of `self`, `optb` is [`Some`], otherwise returns [`None`].
///
/// [`Some`]: #variant.Some
/// [`None`]: #variant.None
Expand Down
2 changes: 0 additions & 2 deletions src/libcore/prelude/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ pub use crate::macros::builtin::{
Clone,
Copy,
Debug,
Decodable,
Default,
Encodable,
Eq,
Hash,
Ord,
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ impl<T: ?Sized> *const T {
/// `usize::max_value()`.
///
/// The offset is expressed in number of `T` elements, and not bytes. The value returned can be
/// used with the `offset` or `offset_to` methods.
/// used with the `add` method.
///
/// There are no guarantees whatsover that offsetting the pointer will not overflow or go
/// beyond the allocation that the pointer points into. It is up to the caller to ensure that
Expand Down Expand Up @@ -2410,7 +2410,7 @@ impl<T: ?Sized> *mut T {
/// `usize::max_value()`.
///
/// The offset is expressed in number of `T` elements, and not bytes. The value returned can be
/// used with the `offset` or `offset_to` methods.
/// used with the `add` method.
///
/// There are no guarantees whatsover that offsetting the pointer will not overflow or go
/// beyond the allocation that the pointer points into. It is up to the caller to ensure that
Expand Down
12 changes: 11 additions & 1 deletion src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ Section: Iterators
///
/// [`chars`]: ../../std/primitive.str.html#method.chars
/// [`str`]: ../../std/primitive.str.html
#[derive(Clone, Debug)]
#[derive(Clone)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Chars<'a> {
iter: slice::Iter<'a, u8>
Expand Down Expand Up @@ -600,6 +600,16 @@ impl<'a> Iterator for Chars<'a> {
}
}

#[stable(feature = "chars_debug_impl", since = "1.38.0")]
impl fmt::Debug for Chars<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Chars(")?;
f.debug_list().entries(self.clone()).finish()?;
write!(f, ")")?;
Ok(())
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> DoubleEndedIterator for Chars<'a> {
#[inline]
Expand Down
15 changes: 9 additions & 6 deletions src/librustc/infer/opaque_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1189,11 +1189,7 @@ pub fn may_define_existential_type(
opaque_hir_id: hir::HirId,
) -> bool {
let mut hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
trace!(
"may_define_existential_type(def={:?}, opaque_node={:?})",
tcx.hir().get(hir_id),
tcx.hir().get(opaque_hir_id)
);


// Named existential types can be defined by any siblings or children of siblings.
let scope = tcx.hir().get_defining_scope(opaque_hir_id).expect("could not get defining scope");
Expand All @@ -1202,5 +1198,12 @@ pub fn may_define_existential_type(
hir_id = tcx.hir().get_parent_item(hir_id);
}
// Syntactically, we are allowed to define the concrete type if:
hir_id == scope
let res = hir_id == scope;
trace!(
"may_define_existential_type(def={:?}, opaque_node={:?}) = {}",
tcx.hir().get(hir_id),
tcx.hir().get(opaque_hir_id),
res
);
res
}
2 changes: 1 addition & 1 deletion src/librustc_data_structures/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#![feature(stmt_expr_attributes)]
#![feature(core_intrinsics)]
#![feature(integer_atomics)]
#![feature(test)]

#![cfg_attr(unix, feature(libc))]
#![cfg_attr(test, feature(test))]

#![cfg_attr(not(bootstrap), allow(rustc::default_hash_types))]

Expand Down
23 changes: 20 additions & 3 deletions src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1664,6 +1664,7 @@ fn find_existential_constraints(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
intravisit::NestedVisitorMap::All(&self.tcx.hir())
}
fn visit_item(&mut self, it: &'tcx Item) {
debug!("find_existential_constraints: visiting {:?}", it);
let def_id = self.tcx.hir().local_def_id(it.hir_id);
// The existential type itself or its children are not within its reveal scope.
if def_id != self.def_id {
Expand All @@ -1672,6 +1673,7 @@ fn find_existential_constraints(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
}
}
fn visit_impl_item(&mut self, it: &'tcx ImplItem) {
debug!("find_existential_constraints: visiting {:?}", it);
let def_id = self.tcx.hir().local_def_id(it.hir_id);
// The existential type itself or its children are not within its reveal scope.
if def_id != self.def_id {
Expand All @@ -1680,6 +1682,7 @@ fn find_existential_constraints(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
}
}
fn visit_trait_item(&mut self, it: &'tcx TraitItem) {
debug!("find_existential_constraints: visiting {:?}", it);
let def_id = self.tcx.hir().local_def_id(it.hir_id);
self.check(def_id);
intravisit::walk_trait_item(self, it);
Expand All @@ -1703,9 +1706,23 @@ fn find_existential_constraints(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
} else {
debug!("find_existential_constraints: scope={:?}", tcx.hir().get(scope));
match tcx.hir().get(scope) {
Node::Item(ref it) => intravisit::walk_item(&mut locator, it),
Node::ImplItem(ref it) => intravisit::walk_impl_item(&mut locator, it),
Node::TraitItem(ref it) => intravisit::walk_trait_item(&mut locator, it),
// We explicitly call `visit_*` methods, instead of using `intravisit::walk_*` methods
// This allows our visitor to process the defining item itself, causing
// it to pick up any 'sibling' defining uses.
//
// For example, this code:
// ```
// fn foo() {
// existential type Blah: Debug;
// let my_closure = || -> Blah { true };
// }
// ```
//
// requires us to explicitly process `foo()` in order
// to notice the defining usage of `Blah`.
Node::Item(ref it) => locator.visit_item(it),
Node::ImplItem(ref it) => locator.visit_impl_item(it),
Node::TraitItem(ref it) => locator.visit_trait_item(it),
other => bug!(
"{:?} is not a valid scope for an existential type item",
other
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3316,11 +3316,11 @@ mod tests {
fs::create_dir_all(&d).unwrap();
File::create(&f).unwrap();
if cfg!(not(windows)) {
symlink_dir("../d/e", &c).unwrap();
symlink_file("../d/e", &c).unwrap();
symlink_file("../f", &e).unwrap();
}
if cfg!(windows) {
symlink_dir(r"..\d\e", &c).unwrap();
symlink_file(r"..\d\e", &c).unwrap();
symlink_file(r"..\f", &e).unwrap();
}

Expand Down
3 changes: 2 additions & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
// std may use features in a platform-specific way
#![allow(unused_features)]

#![cfg_attr(test, feature(print_internals, set_stdio, test, update_panic_count))]
#![cfg_attr(test, feature(print_internals, set_stdio, update_panic_count))]
#![cfg_attr(all(target_vendor = "fortanix", target_env = "sgx"),
feature(slice_index_methods, decl_macro, coerce_unsized,
sgx_platform, ptr_wrapping_offset_from))]
Expand Down Expand Up @@ -304,6 +304,7 @@
#![feature(stdsimd)]
#![feature(stmt_expr_attributes)]
#![feature(str_internals)]
#![feature(test)]
#![feature(thread_local)]
#![feature(todo_macro)]
#![feature(toowned_clone_into)]
Expand Down
2 changes: 0 additions & 2 deletions src/libstd/prelude/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ pub use core::prelude::v1::{
Clone,
Copy,
Debug,
Decodable,
Default,
Encodable,
Eq,
Hash,
Ord,
Expand Down
17 changes: 1 addition & 16 deletions src/libstd/sys/vxworks/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,22 +287,7 @@ impl File {
let fd = cvt_r(|| unsafe {
open(path.as_ptr(), flags, opts.mode as c_int)
})?;
let fd = FileDesc::new(fd);
// Currently the standard library supports Linux 2.6.18 which did not
// have the O_CLOEXEC flag (passed above). If we're running on an older
// Linux kernel then the flag is just ignored by the OS. After we open
// the first file, we check whether it has CLOEXEC set. If it doesn't,
// we will explicitly ask for a CLOEXEC fd for every further file we
// open, if it does, we will skip that step.
//
// The CLOEXEC flag, however, is supported on versions of macOS/BSD/etc
// that we support, so we only do this on Linux currently.
fn ensure_cloexec(_: &FileDesc) -> io::Result<()> {
Ok(())
}

ensure_cloexec(&fd)?;
Ok(File(fd))
Ok(File(FileDesc::new(fd)))
}

pub fn file_attr(&self) -> io::Result<FileAttr> {
Expand Down
4 changes: 0 additions & 4 deletions src/libstd/sys/vxworks/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,6 @@ impl Socket {

pub fn accept(&self, storage: *mut sockaddr, len: *mut socklen_t)
-> io::Result<Socket> {
// Unfortunately the only known way right now to accept a socket and
// atomically set the CLOEXEC flag is to use the `accept4` syscall on
// Linux. This was added in 2.6.28, however, and because we support
// 2.6.18 we must detect this support dynamically.
let fd = cvt_r(|| unsafe {
libc::accept(self.0.raw(), storage, len)
})?;
Expand Down
5 changes: 0 additions & 5 deletions src/libstd/sys/vxworks/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
static INVALID: AtomicBool = AtomicBool::new(false);

let mut fds = [0; 2];

// Unfortunately the only known way right now to create atomically set the
// CLOEXEC flag is to use the `pipe2` syscall on Linux. This was added in
// 2.6.27, however, and because we support 2.6.18 we must detect this
// support dynamically.
cvt(unsafe { libc::pipe(fds.as_mut_ptr()) })?;

let fd0 = FileDesc::new(fds[0]);
Expand Down
Loading