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 8 pull requests #65482

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
23d3ff1
Fix zero-size uninitialized boxes
SimonSapin Oct 6, 2019
715ffab
InterpCx: make memory field public
RalfJung Oct 11, 2019
c50664d
Prefer statx on linux if available
oxalica Oct 4, 2019
55cddb8
Fix missing guard
oxalica Oct 10, 2019
e3b7f3d
Fix cfgs for current libc
oxalica Oct 13, 2019
247df6e
Don't recommend ONCE_INIT in std::sync::Once
Kampfkarren Oct 16, 2019
9dba03f
move parse::attr -> parse::parser::attr
Centril Oct 8, 2019
7d7969d
syntax: extract parse_derive_paths
Centril Oct 8, 2019
41bfe94
syntax: extract parse_cfg_attr
Centril Oct 8, 2019
98017ca
move diagnostics.rs into parser/
Centril Oct 8, 2019
c189565
syntax: reduce visibilities
Centril Oct 8, 2019
55f3c2d
ast: use more direct imports
Centril Oct 8, 2019
7ec38a9
attr: remove dep on ExtCtxt
Centril Oct 8, 2019
d160a4e
syntax::parse: don't depend on syntax::ext
Centril Oct 8, 2019
d420d71
move syntax::ext to new crate syntax_expand
Centril Oct 16, 2019
bf02d49
move SeqSep to parser.rs
Centril Oct 8, 2019
9dc07b0
parser: leave a FIXME for later
Centril Oct 8, 2019
904168f
mbe: leave a FIXME
Centril Oct 8, 2019
be40bbd
make tidy happy
Centril Oct 12, 2019
2245910
Fix types
oxalica Oct 16, 2019
f7804ef
Fix typo
oxalica Oct 16, 2019
ddbc0de
Add long error explanation for E0575
GuillaumeGomez Oct 12, 2019
367cda4
Update ui tests
GuillaumeGomez Oct 12, 2019
1a26fdf
ui-fulldeps: make them pass again?
Centril Oct 16, 2019
940d48e
add example for type_name
tesuji Oct 16, 2019
ca1cfda
Uninitialized boxes: check for zero-size allocation based on Layout::…
SimonSapin Oct 16, 2019
352b026
Uninitialized boxes: add test for zero-size allocations
SimonSapin Oct 16, 2019
8ca16dd
panictry!(..) -> .unwrap()
Centril Oct 16, 2019
e490aae
fmt::Write is about string slices, not byte slices
RalfJung Oct 16, 2019
1089caf
Rollup merge of #65094 - oxalica:linux-statx, r=alexcrichton
Centril Oct 16, 2019
bd9795c
Rollup merge of #65174 - SimonSapin:zero-box, r=alexcrichton
Centril Oct 16, 2019
c03e516
Rollup merge of #65319 - RalfJung:memory, r=Centril
Centril Oct 16, 2019
28aa2d9
Rollup merge of #65334 - GuillaumeGomez:long-err-explanation-E0575, r…
Centril Oct 16, 2019
b0868d2
Rollup merge of #65461 - Kampfkarren:patch-1, r=Centril
Centril Oct 16, 2019
028c586
Rollup merge of #65465 - Centril:split-syntax-1, r=petrochenkov
Centril Oct 16, 2019
8ecdc84
Rollup merge of #65475 - lzutao:eg_type_name, r=Centril
Centril Oct 16, 2019
940ae78
Rollup merge of #65478 - RalfJung:write, r=jonas-schievink
Centril Oct 16, 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
27 changes: 27 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3112,6 +3112,7 @@ dependencies = [
"serialize",
"smallvec",
"syntax",
"syntax_expand",
"syntax_pos",
]

Expand Down Expand Up @@ -3427,6 +3428,7 @@ dependencies = [
"rustc_target",
"serialize",
"syntax",
"syntax_expand",
"syntax_pos",
"tempfile",
]
Expand Down Expand Up @@ -3559,6 +3561,7 @@ dependencies = [
"serialize",
"smallvec",
"syntax",
"syntax_expand",
"syntax_ext",
"syntax_pos",
"tempfile",
Expand Down Expand Up @@ -3630,6 +3633,7 @@ dependencies = [
"smallvec",
"stable_deref_trait",
"syntax",
"syntax_expand",
"syntax_pos",
]

Expand Down Expand Up @@ -3678,6 +3682,7 @@ dependencies = [
"rustc_index",
"rustc_target",
"syntax",
"syntax_expand",
"syntax_pos",
]

Expand All @@ -3695,6 +3700,7 @@ dependencies = [
"rustc",
"rustc_metadata",
"syntax",
"syntax_expand",
"syntax_pos",
]

Expand Down Expand Up @@ -3723,6 +3729,7 @@ dependencies = [
"rustc_metadata",
"smallvec",
"syntax",
"syntax_expand",
"syntax_pos",
]

Expand Down Expand Up @@ -4336,6 +4343,25 @@ dependencies = [
"syntax_pos",
]

[[package]]
name = "syntax_expand"
version = "0.0.0"
dependencies = [
"bitflags",
"lazy_static 1.3.0",
"log",
"rustc_data_structures",
"rustc_errors",
"rustc_index",
"rustc_lexer",
"rustc_target",
"scoped-tls",
"serialize",
"smallvec",
"syntax",
"syntax_pos",
]

[[package]]
name = "syntax_ext"
version = "0.0.0"
Expand All @@ -4347,6 +4373,7 @@ dependencies = [
"rustc_target",
"smallvec",
"syntax",
"syntax_expand",
"syntax_pos",
]

Expand Down
16 changes: 13 additions & 3 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ impl<T> Box<T> {
#[unstable(feature = "new_uninit", issue = "63291")]
pub fn new_uninit() -> Box<mem::MaybeUninit<T>> {
let layout = alloc::Layout::new::<mem::MaybeUninit<T>>();
if layout.size() == 0 {
return Box(NonNull::dangling().into())
}
let ptr = unsafe {
Global.alloc(layout)
.unwrap_or_else(|_| alloc::handle_alloc_error(layout))
Expand Down Expand Up @@ -182,9 +185,16 @@ impl<T> Box<[T]> {
#[unstable(feature = "new_uninit", issue = "63291")]
pub fn new_uninit_slice(len: usize) -> Box<[mem::MaybeUninit<T>]> {
let layout = alloc::Layout::array::<mem::MaybeUninit<T>>(len).unwrap();
let ptr = unsafe { alloc::alloc(layout) };
let unique = Unique::new(ptr).unwrap_or_else(|| alloc::handle_alloc_error(layout));
let slice = unsafe { slice::from_raw_parts_mut(unique.cast().as_ptr(), len) };
let ptr = if layout.size() == 0 {
NonNull::dangling()
} else {
unsafe {
Global.alloc(layout)
.unwrap_or_else(|_| alloc::handle_alloc_error(layout))
.cast()
}
};
let slice = unsafe { slice::from_raw_parts_mut(ptr.as_ptr(), len) };
Box(Unique::from(slice))
}
}
Expand Down
19 changes: 19 additions & 0 deletions src/liballoc/tests/boxed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use std::ptr::NonNull;
use std::mem::MaybeUninit;

#[test]
fn unitialized_zero_size_box() {
assert_eq!(
&*Box::<()>::new_uninit() as *const _,
NonNull::<MaybeUninit<()>>::dangling().as_ptr(),
);
assert_eq!(
Box::<[()]>::new_uninit_slice(4).as_ptr(),
NonNull::<MaybeUninit<()>>::dangling().as_ptr(),
);
assert_eq!(
Box::<[String]>::new_uninit_slice(0).as_ptr(),
NonNull::<MaybeUninit<String>>::dangling().as_ptr(),
);
}

2 changes: 2 additions & 0 deletions src/liballoc/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![feature(box_syntax)]
#![feature(drain_filter)]
#![feature(exact_size_is_empty)]
#![feature(new_uninit)]
#![feature(option_flattening)]
#![feature(pattern)]
#![feature(trusted_len)]
Expand All @@ -14,6 +15,7 @@ use std::collections::hash_map::DefaultHasher;

mod arc;
mod binary_heap;
mod boxed;
mod btree;
mod cow_str;
mod fmt;
Expand Down
9 changes: 9 additions & 0 deletions src/libcore/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,15 @@ impl TypeId {
///
/// The current implementation uses the same infrastructure as compiler
/// diagnostics and debuginfo, but this is not guaranteed.
///
/// # Example
///
/// ```rust
/// assert_eq!(
/// std::any::type_name::<Option<String>>(),
/// "core::option::Option<alloc::string::String>",
/// );
/// ```
#[stable(feature = "type_name", since = "1.38.0")]
#[rustc_const_unstable(feature = "const_type_name")]
pub const fn type_name<T: ?Sized>() -> &'static str {
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ pub struct Error;
/// [`io::Write`]: ../../std/io/trait.Write.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Write {
/// Writes a slice of bytes into this writer, returning whether the write
/// Writes a string slice into this writer, returning whether the write
/// succeeded.
///
/// This method can only succeed if the entire byte slice was successfully
/// This method can only succeed if the entire string slice was successfully
/// written, and this method will not return until all data has been
/// written or an error occurs.
///
Expand Down
1 change: 1 addition & 0 deletions src/librustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ rustc_index = { path = "../librustc_index" }
errors = { path = "../librustc_errors", package = "rustc_errors" }
rustc_serialize = { path = "../libserialize", package = "serialize" }
syntax = { path = "../libsyntax" }
syntax_expand = { path = "../libsyntax_expand" }
syntax_pos = { path = "../libsyntax_pos" }
backtrace = "0.3.3"
parking_lot = "0.9"
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::ty;
use crate::util::nodemap::DefIdMap;

use syntax::ast;
use syntax::ext::base::MacroKind;
use syntax_expand::base::MacroKind;
use syntax::ast::NodeId;
use syntax_pos::Span;
use rustc_macros::HashStable;
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ use syntax::ast;
use syntax::ptr::P as AstP;
use syntax::ast::*;
use syntax::errors;
use syntax::ext::base::SpecialDerives;
use syntax::ext::hygiene::ExpnId;
use syntax_expand::base::SpecialDerives;
use syntax::print::pprust;
use syntax::tokenstream::{TokenStream, TokenTree};
use syntax::parse::token::{self, Nonterminal, Token};
use syntax::tokenstream::{TokenStream, TokenTree};
use syntax::sess::ParseSess;
use syntax::source_map::{respan, ExpnData, ExpnKind, DesugaringKind, Spanned};
use syntax::symbol::{kw, sym, Symbol};
use syntax::visit::{self, Visitor};
use syntax_pos::hygiene::ExpnId;
use syntax_pos::Span;

const HIR_ID_COUNTER_LOCKED: u32 = 0xFFFFFFFF;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/lowering/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use smallvec::SmallVec;
use syntax::attr;
use syntax::ast::*;
use syntax::visit::{self, Visitor};
use syntax::ext::base::SpecialDerives;
use syntax_expand::base::SpecialDerives;
use syntax::source_map::{respan, DesugaringKind, Spanned};
use syntax::symbol::{kw, sym};
use syntax_pos::Span;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/def_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::hir::map::definitions::*;
use crate::hir::def_id::DefIndex;

use syntax::ast::*;
use syntax::ext::hygiene::ExpnId;
use syntax_expand::hygiene::ExpnId;
use syntax::visit;
use syntax::symbol::{kw, sym};
use syntax::parse::token::{self, Token};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::borrow::Borrow;
use std::fmt::Write;
use std::hash::Hash;
use syntax::ast;
use syntax::ext::hygiene::ExpnId;
use syntax_expand::hygiene::ExpnId;
use syntax::symbol::{Symbol, sym, InternedString};
use syntax_pos::{Span, DUMMY_SP};

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use rustc_data_structures::svh::Svh;
use rustc_index::vec::IndexVec;
use syntax::ast::{self, Name, NodeId};
use syntax::source_map::Spanned;
use syntax::ext::base::MacroKind;
use syntax_expand::base::MacroKind;
use syntax_pos::{Span, DUMMY_SP};

pub mod blocks;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ich/hcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::cell::RefCell;

use syntax::ast;
use syntax::source_map::SourceMap;
use syntax::ext::hygiene::SyntaxContext;
use syntax_expand::hygiene::SyntaxContext;
use syntax::symbol::Symbol;
use syntax::tokenstream::DelimSpan;
use syntax_pos::{Span, DUMMY_SP};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ich/impls_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl_stable_hash_for!(enum ::syntax::ast::AsmDialect {
Intel
});

impl_stable_hash_for!(enum ::syntax::ext::base::MacroKind {
impl_stable_hash_for!(enum ::syntax_expand::base::MacroKind {
Bang,
Attr,
Derive,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use syntax::ast;
use syntax::source_map::{MultiSpan, ExpnKind, DesugaringKind};
use syntax::early_buffered_lints::BufferedEarlyLintId;
use syntax::edition::Edition;
use syntax::ext::base::MacroKind;
use syntax_expand::base::MacroKind;
use syntax::symbol::{Symbol, sym};
use syntax_pos::Span;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use errors::emitter::HumanReadableErrorType;
use errors::annotate_snippet_emitter_writer::{AnnotateSnippetEmitterWriter};
use syntax::ast::{self, NodeId};
use syntax::edition::Edition;
use syntax::ext::allocator::AllocatorKind;
use syntax_expand::allocator::AllocatorKind;
use syntax::feature_gate::{self, AttributeType};
use syntax::json::JsonEmitter;
use syntax::source_map;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use std::{mem, ptr};
use std::ops::Range;
use syntax::ast::{self, Name, Ident, NodeId};
use syntax::attr;
use syntax::ext::hygiene::ExpnId;
use syntax_expand::hygiene::ExpnId;
use syntax::symbol::{kw, sym, Symbol, InternedString};
use syntax_pos::Span;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::ffi::CString;
use crate::attributes;
use libc::c_uint;
use rustc::ty::TyCtxt;
use syntax::ext::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};
use syntax_expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};

use crate::ModuleLlvm;
use crate::llvm::{self, False, True};
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_codegen_llvm/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ extern crate rustc_driver as _;

#[macro_use] extern crate log;
extern crate syntax;
extern crate syntax_expand;
extern crate syntax_pos;
extern crate rustc_errors as errors;

Expand All @@ -48,7 +49,7 @@ use rustc_codegen_ssa::back::lto::{SerializedModule, LtoModuleCodegen, ThinModul
use rustc_codegen_ssa::CompiledModule;
use errors::{FatalError, Handler};
use rustc::dep_graph::WorkProduct;
use syntax::ext::allocator::AllocatorKind;
use syntax_expand::allocator::AllocatorKind;
use syntax_pos::symbol::InternedString;
pub use llvm_util::target_features;
use std::any::Any;
Expand Down
1 change: 1 addition & 0 deletions src/librustc_codegen_ssa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ tempfile = "3.1"

rustc_serialize = { path = "../libserialize", package = "serialize" }
syntax = { path = "../libsyntax" }
syntax_expand = { path = "../libsyntax_expand" }
syntax_pos = { path = "../libsyntax_pos" }
rustc = { path = "../librustc" }
rustc_apfloat = { path = "../librustc_apfloat" }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use rustc::ty::query::Providers;
use rustc::ty::subst::SubstsRef;
use rustc::util::nodemap::{FxHashMap, DefIdMap};
use rustc_index::vec::IndexVec;
use syntax::ext::allocator::ALLOCATOR_METHODS;
use syntax_expand::allocator::ALLOCATOR_METHODS;

pub type ExportedSymbols = FxHashMap<
CrateNum,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use rustc_errors::{Handler, Level, FatalError, DiagnosticId, SourceMapperDyn};
use rustc_errors::emitter::{Emitter};
use rustc_target::spec::MergeFunctions;
use syntax::attr;
use syntax::ext::hygiene::ExpnId;
use syntax_expand::hygiene::ExpnId;
use syntax_pos::symbol::{Symbol, sym};
use jobserver::{Client, Acquired};

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/traits/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc::ty::TyCtxt;
use rustc_codegen_utils::codegen_backend::CodegenBackend;
use std::sync::Arc;
use std::sync::mpsc;
use syntax::ext::allocator::AllocatorKind;
use syntax_expand::allocator::AllocatorKind;
use syntax_pos::symbol::InternedString;

pub trait BackendTypes {
Expand Down
1 change: 1 addition & 0 deletions src/librustc_interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ rayon = { version = "0.3.0", package = "rustc-rayon" }
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
syntax = { path = "../libsyntax" }
syntax_ext = { path = "../libsyntax_ext" }
syntax_expand = { path = "../libsyntax_expand" }
syntax_pos = { path = "../libsyntax_pos" }
rustc_serialize = { path = "../libserialize", package = "serialize" }
rustc = { path = "../librustc" }
Expand Down
Loading