Skip to content

Rollup of 5 pull requests #61716

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

Merged
merged 15 commits into from
Jun 10, 2019
Merged
Changes from all commits
Commits
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
43 changes: 16 additions & 27 deletions src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
@@ -1326,30 +1326,10 @@ extern "rust-intrinsic" {
pub fn nontemporal_store<T>(ptr: *mut T, val: T);
}

mod real_intrinsics {
extern "rust-intrinsic" {
/// Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source
/// and destination must *not* overlap.
/// For the full docs, see the stabilized wrapper [`copy_nonoverlapping`].
///
/// [`copy_nonoverlapping`]: ../../std/ptr/fn.copy_nonoverlapping.html
pub fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);

/// Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source
/// and destination may overlap.
/// For the full docs, see the stabilized wrapper [`copy`].
///
/// [`copy`]: ../../std/ptr/fn.copy.html
pub fn copy<T>(src: *const T, dst: *mut T, count: usize);

/// Sets `count * size_of::<T>()` bytes of memory starting at `dst` to
/// `val`.
/// For the full docs, see the stabilized wrapper [`write_bytes`].
///
/// [`write_bytes`]: ../../std/ptr/fn.write_bytes.html
pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
}
}
// Some functions are defined here because they accidentally got made
// available in this module on stable. See <https://github.com/rust-lang/rust/issues/15702>.
// (`transmute` also falls into this category, but it cannot be wrapped due to the
// check that `T` and `U` have the same size.)

/// Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source
/// and destination must *not* overlap.
@@ -1437,7 +1417,10 @@ mod real_intrinsics {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
real_intrinsics::copy_nonoverlapping(src, dst, count);
extern "rust-intrinsic" {
fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
}
copy_nonoverlapping(src, dst, count);
}

/// Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source
@@ -1494,7 +1477,10 @@ pub unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
real_intrinsics::copy(src, dst, count)
extern "rust-intrinsic" {
fn copy<T>(src: *const T, dst: *mut T, count: usize);
}
copy(src, dst, count)
}

/// Sets `count * size_of::<T>()` bytes of memory starting at `dst` to
@@ -1572,7 +1558,10 @@ pub unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
real_intrinsics::write_bytes(dst, val, count)
extern "rust-intrinsic" {
fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
}
write_bytes(dst, val, count)
}

// Simple bootstrap implementations of minnum/maxnum for stage0 compilation.
21 changes: 11 additions & 10 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
@@ -2168,7 +2168,7 @@ impl<'a> LoweringContext<'a> {
itctx: ImplTraitContext<'_>,
explicit_owner: Option<NodeId>,
) -> hir::PathSegment {
let (mut generic_args, infer_types) = if let Some(ref generic_args) = segment.args {
let (mut generic_args, infer_args) = if let Some(ref generic_args) = segment.args {
let msg = "parenthesized type parameters may only be used with a `Fn` trait";
match **generic_args {
GenericArgs::AngleBracketed(ref data) => {
@@ -2230,17 +2230,17 @@ impl<'a> LoweringContext<'a> {
.collect();
if expected_lifetimes > 0 && param_mode == ParamMode::Explicit {
let anon_lt_suggestion = vec!["'_"; expected_lifetimes].join(", ");
let no_ty_args = generic_args.args.len() == expected_lifetimes;
let no_non_lt_args = generic_args.args.len() == expected_lifetimes;
let no_bindings = generic_args.bindings.is_empty();
let (incl_angl_brckt, insertion_span, suggestion) = if no_ty_args && no_bindings {
let (incl_angl_brckt, insertion_sp, suggestion) = if no_non_lt_args && no_bindings {
// If there are no (non-implicit) generic args or associated type
// bindings, our suggestion includes the angle brackets.
(true, path_span.shrink_to_hi(), format!("<{}>", anon_lt_suggestion))
} else {
// Otherwise (sorry, this is kind of gross) we need to infer the
// place to splice in the `'_, ` from the generics that do exist.
let first_generic_span = first_generic_span
.expect("already checked that type args or bindings exist");
.expect("already checked that non-lifetime args or bindings exist");
(false, first_generic_span.shrink_to_lo(), format!("{}, ", anon_lt_suggestion))
};
match self.anonymous_lifetime_mode {
@@ -2263,7 +2263,7 @@ impl<'a> LoweringContext<'a> {
expected_lifetimes,
path_span,
incl_angl_brckt,
insertion_span,
insertion_sp,
suggestion,
);
err.emit();
@@ -2280,7 +2280,7 @@ impl<'a> LoweringContext<'a> {
expected_lifetimes,
path_span,
incl_angl_brckt,
insertion_span,
insertion_sp,
suggestion,
)
);
@@ -2305,7 +2305,7 @@ impl<'a> LoweringContext<'a> {
Some(id),
Some(self.lower_res(res)),
generic_args,
infer_types,
infer_args,
)
}

@@ -2316,9 +2316,10 @@ impl<'a> LoweringContext<'a> {
mut itctx: ImplTraitContext<'_>,
) -> (hir::GenericArgs, bool) {
let &AngleBracketedArgs { ref args, ref constraints, .. } = data;
let has_types = args.iter().any(|arg| match arg {
let has_non_lt_args = args.iter().any(|arg| match arg {
ast::GenericArg::Lifetime(_) => false,
ast::GenericArg::Type(_) => true,
_ => false,
ast::GenericArg::Const(_) => true,
});
(
hir::GenericArgs {
@@ -2328,7 +2329,7 @@ impl<'a> LoweringContext<'a> {
.collect(),
parenthesized: false,
},
!has_types && param_mode == ParamMode::Optional
!has_non_lt_args && param_mode == ParamMode::Optional
)
}

12 changes: 10 additions & 2 deletions src/librustc/hir/map/definitions.rs
Original file line number Diff line number Diff line change
@@ -582,9 +582,17 @@ impl DefPathData {
}
}

/// Evaluates to the number of tokens passed to it.
///
/// Logarithmic counting: every one or two recursive expansions, the number of
/// tokens to count is divided by two, instead of being reduced by one.
/// Therefore, the recursion depth is the binary logarithm of the number of
/// tokens to count, and the expanded tree is likewise very small.
macro_rules! count {
() => (0usize);
( $x:tt $($xs:tt)* ) => (1usize + count!($($xs)*));
() => (0usize);
($one:tt) => (1usize);
($($pairs:tt $_p:tt)*) => (count!($($pairs)*) << 1usize);
($odd:tt $($rest:tt)*) => (count!($($rest)*) | 1usize);
}

// We define the GlobalMetaDataKind enum with this macro because we want to
8 changes: 4 additions & 4 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
@@ -348,7 +348,7 @@ pub struct PathSegment {
/// This only applies to expression and pattern paths, and
/// out of those only the segments with no type parameters
/// to begin with, e.g., `Vec::new` is `<Vec<..>>::new::<..>`.
pub infer_types: bool,
pub infer_args: bool,
}

impl PathSegment {
@@ -358,7 +358,7 @@ impl PathSegment {
ident,
hir_id: None,
res: None,
infer_types: true,
infer_args: true,
args: None,
}
}
@@ -368,13 +368,13 @@ impl PathSegment {
hir_id: Option<HirId>,
res: Option<Res>,
args: GenericArgs,
infer_types: bool,
infer_args: bool,
) -> Self {
PathSegment {
ident,
hir_id,
res,
infer_types,
infer_args,
args: if args.is_empty() {
None
} else {
16 changes: 8 additions & 8 deletions src/librustc/hir/print.rs
Original file line number Diff line number Diff line change
@@ -1196,7 +1196,7 @@ impl<'a> State<'a> {

segment.with_generic_args(|generic_args| {
if !generic_args.args.is_empty() || !generic_args.bindings.is_empty() {
return self.print_generic_args(&generic_args, segment.infer_types, true);
return self.print_generic_args(&generic_args, segment.infer_args, true);
}
Ok(())
})?;
@@ -1561,7 +1561,7 @@ impl<'a> State<'a> {
if segment.ident.name != kw::PathRoot {
self.print_ident(segment.ident)?;
segment.with_generic_args(|generic_args| {
self.print_generic_args(generic_args, segment.infer_types,
self.print_generic_args(generic_args, segment.infer_args,
colons_before_params)
})?;
}
@@ -1574,7 +1574,7 @@ impl<'a> State<'a> {
if segment.ident.name != kw::PathRoot {
self.print_ident(segment.ident)?;
segment.with_generic_args(|generic_args| {
self.print_generic_args(generic_args, segment.infer_types, false)
self.print_generic_args(generic_args, segment.infer_args, false)
})?;
}
Ok(())
@@ -1602,7 +1602,7 @@ impl<'a> State<'a> {
self.print_ident(segment.ident)?;
segment.with_generic_args(|generic_args| {
self.print_generic_args(generic_args,
segment.infer_types,
segment.infer_args,
colons_before_params)
})?;
}
@@ -1614,7 +1614,7 @@ impl<'a> State<'a> {
self.print_ident(item_segment.ident)?;
item_segment.with_generic_args(|generic_args| {
self.print_generic_args(generic_args,
item_segment.infer_types,
item_segment.infer_args,
colons_before_params)
})
}
@@ -1626,7 +1626,7 @@ impl<'a> State<'a> {
self.print_ident(item_segment.ident)?;
item_segment.with_generic_args(|generic_args| {
self.print_generic_args(generic_args,
item_segment.infer_types,
item_segment.infer_args,
colons_before_params)
})
}
@@ -1635,7 +1635,7 @@ impl<'a> State<'a> {

fn print_generic_args(&mut self,
generic_args: &hir::GenericArgs,
infer_types: bool,
infer_args: bool,
colons_before_params: bool)
-> io::Result<()> {
if generic_args.parenthesized {
@@ -1681,7 +1681,7 @@ impl<'a> State<'a> {

// FIXME(eddyb): this would leak into error messages (e.g.,
// "non-exhaustive patterns: `Some::<..>(_)` not covered").
if infer_types && false {
if infer_args && false {
start_or_comma(self)?;
self.s.word("..")?;
}
8 changes: 6 additions & 2 deletions src/librustc_interface/util.rs
Original file line number Diff line number Diff line change
@@ -121,9 +121,13 @@ pub fn create_session(
}

// Temporarily have stack size set to 32MB to deal with various crates with long method
// chains or deep syntax trees.
// chains or deep syntax trees, except when on Haiku.
// FIXME(oli-obk): get https://github.com/rust-lang/rust/pull/55617 the finish line
const STACK_SIZE: usize = 32 * 1024 * 1024; // 32MB
#[cfg(not(target_os = "haiku"))]
const STACK_SIZE: usize = 32 * 1024 * 1024;

#[cfg(target_os = "haiku")]
const STACK_SIZE: usize = 16 * 1024 * 1024;

fn get_stack_size() -> Option<usize> {
// FIXME: Hacks on hacks. If the env is trying to override the stack size
Loading