Skip to content

Commit

Permalink
Auto merge of #50290 - kennytm:rollup, r=kennytm
Browse files Browse the repository at this point in the history
Rollup of 9 pull requests

Successful merges:

 - #49858 (std: Mark `ptr::Unique` with `#[doc(hidden)]`)
 - #49968 (Stabilize dyn trait)
 - #50192 (Add some utilities to `libsyntax`)
 - #50251 (rustc: Disable threads in LLD for wasm)
 - #50263 (rustc: Emit `uwtable` for allocator shims)
 - #50269 (Update `parking_lot` dependencies)
 - #50273 (Allow #[inline] on closures)
 - #50284 (fix search load page failure)
 - #50257 (Don't ICE on tuple struct ctor with incorrect arg count)

Failed merges:
  • Loading branch information
bors committed Apr 27, 2018
2 parents a997525 + dc6b167 commit 686d0ae
Show file tree
Hide file tree
Showing 69 changed files with 298 additions and 249 deletions.
18 changes: 9 additions & 9 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ impl<T: ?Sized> Box<T> {

#[unstable(feature = "ptr_internals", issue = "0", reason = "use into_raw_non_null instead")]
#[inline]
#[doc(hidden)]
pub fn into_unique(b: Box<T>) -> Unique<T> {
let unique = b.0;
mem::forget(b);
Expand Down
1 change: 1 addition & 0 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2513,6 +2513,7 @@ impl<T: ?Sized> PartialOrd for *mut T {
reason = "use NonNull instead and consider PhantomData<T> \
(if you also use #[may_dangle]), Send, and/or Sync")]
#[allow(deprecated)]
#[doc(hidden)]
pub struct Unique<T: ?Sized> {
pointer: NonZero<*const T>,
// NOTE: this marker has no consequences for variance, but is necessary
Expand Down
2 changes: 1 addition & 1 deletion src/libproc_macro/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl Span {
/// `self` was generated from, if any.
#[unstable(feature = "proc_macro", issue = "38356")]
pub fn parent(&self) -> Option<Span> {
self.0.ctxt().outer().expn_info().map(|i| Span(i.call_site))
self.0.parent().map(Span)
}

/// The span for the origin source code that `self` was generated from. If
Expand Down
15 changes: 10 additions & 5 deletions src/librustc/hir/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum Target {
ForeignMod,
Expression,
Statement,
Closure,
Other,
}

Expand Down Expand Up @@ -103,14 +104,14 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
self.check_repr(item, target);
}

/// Check if an `#[inline]` is applied to a function.
/// Check if an `#[inline]` is applied to a function or a closure.
fn check_inline(&self, attr: &hir::Attribute, span: &Span, target: Target) {
if target != Target::Fn {
if target != Target::Fn && target != Target::Closure {
struct_span_err!(self.tcx.sess,
attr.span,
E0518,
"attribute should be applied to function")
.span_label(*span, "not a function")
"attribute should be applied to function or closure")
.span_label(*span, "not a function or closure")
.emit();
}
}
Expand Down Expand Up @@ -286,9 +287,13 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
}

fn check_expr_attributes(&self, expr: &hir::Expr) {
let target = match expr.node {
hir::ExprClosure(..) => Target::Closure,
_ => Target::Expression,
};
for attr in expr.attrs.iter() {
if attr.check_name("inline") {
self.check_inline(attr, &expr.span, Target::Expression);
self.check_inline(attr, &expr.span, target);
}
if attr.check_name("repr") {
self.emit_repr_error(
Expand Down
16 changes: 7 additions & 9 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4107,15 +4107,13 @@ impl<'a> LoweringContext<'a> {
}

fn maybe_lint_bare_trait(&self, span: Span, id: NodeId, is_global: bool) {
if self.sess.features_untracked().dyn_trait {
self.sess.buffer_lint_with_diagnostic(
builtin::BARE_TRAIT_OBJECT,
id,
span,
"trait objects without an explicit `dyn` are deprecated",
builtin::BuiltinLintDiagnostics::BareTraitObject(span, is_global),
)
}
self.sess.buffer_lint_with_diagnostic(
builtin::BARE_TRAIT_OBJECT,
id,
span,
"trait objects without an explicit `dyn` are deprecated",
builtin::BuiltinLintDiagnostics::BareTraitObject(span, is_global),
)
}

fn wrap_in_try_constructor(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
#![feature(const_fn)]
#![feature(core_intrinsics)]
#![feature(drain_filter)]
#![feature(dyn_trait)]
#![feature(entry_or_default)]
#![cfg_attr(stage0, feature(dyn_trait))]
#![feature(from_ref)]
#![feature(fs_read_write)]
#![cfg_attr(windows, feature(libc))]
Expand Down
6 changes: 6 additions & 0 deletions src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
ArgKind::Arg(format!("{}", field.name), "_".to_string())
}).collect::<Vec<_>>())
}
hir::map::NodeStructCtor(ref variant_data) => {
(self.tcx.sess.codemap().def_span(self.tcx.hir.span(variant_data.id())),
variant_data.fields()
.iter().map(|_| ArgKind::Arg("_".to_owned(), "_".to_owned()))
.collect())
}
_ => panic!("non-FnLike node found: {:?}", node),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![feature(const_fn)]
#![feature(core_intrinsics)]
#![feature(decl_macro)]
#![feature(dyn_trait)]
#![cfg_attr(stage0, feature(dyn_trait))]
#![feature(fs_read_write)]
#![feature(macro_vis_matcher)]
#![feature(exhaustive_patterns)]
Expand Down
4 changes: 4 additions & 0 deletions src/librustc_trans/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use std::ffi::CString;
use std::ptr;

use attributes;
use libc::c_uint;
use rustc::middle::allocator::AllocatorKind;
use rustc::ty::TyCtxt;
Expand Down Expand Up @@ -67,6 +68,9 @@ pub(crate) unsafe fn trans(tcx: TyCtxt, mods: &ModuleLlvm, kind: AllocatorKind)
if tcx.sess.target.target.options.default_hidden_visibility {
llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden);
}
if tcx.sess.target.target.options.requires_uwtable {
attributes::emit_uwtable(llfn, true);
}

let callee = CString::new(kind.fn_name(method.name)).unwrap();
let callee = llvm::LLVMRustGetOrInsertFunction(llmod,
Expand Down
6 changes: 5 additions & 1 deletion src/librustc_trans/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,11 @@ impl Linker for WasmLd {
}

fn finalize(&mut self) -> Command {
self.cmd.arg("--threads");
// There have been reports in the wild (rustwasm/wasm-bindgen#119) of
// using threads causing weird hangs and bugs. Disable it entirely as
// this isn't yet the bottleneck of compilation at all anyway.
self.cmd.arg("--no-threads");

self.cmd.arg("-z").arg("stack-size=1048576");

// FIXME we probably shouldn't pass this but instead pass an explicit
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_typeck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ This API is completely unstable and subject to change.

#![allow(non_camel_case_types)]

#![cfg_attr(stage0, feature(dyn_trait))]

#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(crate_visibility_modifier)]
Expand All @@ -81,7 +83,6 @@ This API is completely unstable and subject to change.
#![feature(rustc_diagnostic_macros)]
#![feature(slice_patterns)]
#![feature(slice_sort_by_cached_key)]
#![feature(dyn_trait)]
#![feature(never_type)]

#[macro_use] extern crate log;
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
window.rootPath = \"{root_path}\";\
window.currentCrate = \"{krate}\";\
</script>\
<script src=\"{root_path}aliases.js\"></script>\
<script src=\"{root_path}main{suffix}.js\"></script>\
<script defer src=\"{root_path}search-index.js\"></script>\
<script defer src=\"{root_path}aliases.js\"></script>\
</body>\
</html>",
css_extension = if css_file_extension {
Expand Down
3 changes: 2 additions & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
html_root_url = "https://doc.rust-lang.org/nightly/",
html_playground_url = "https://play.rust-lang.org/")]

#![cfg_attr(stage0, feature(dyn_trait))]

#![feature(ascii_ctype)]
#![feature(rustc_private)]
#![feature(box_patterns)]
Expand All @@ -23,7 +25,6 @@
#![feature(test)]
#![feature(vec_remove_item)]
#![feature(entry_and_modify)]
#![feature(dyn_trait)]

extern crate arena;
extern crate getopts;
Expand Down
9 changes: 2 additions & 7 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,6 @@ declare_features! (
// Future-proofing enums/structs with #[non_exhaustive] attribute (RFC 2008)
(active, non_exhaustive, "1.22.0", Some(44109), None),

// Trait object syntax with `dyn` prefix
(active, dyn_trait, "1.22.0", Some(44662), Some(Edition::Edition2018)),

// `crate` as visibility modifier, synonymous to `pub(crate)`
(active, crate_visibility_modifier, "1.23.0", Some(45388), Some(Edition::Edition2018)),

Expand Down Expand Up @@ -592,6 +589,8 @@ declare_features! (
(accepted, cfg_target_feature, "1.27.0", Some(29717), None),
// Allows #[target_feature(...)]
(accepted, target_feature, "1.27.0", None, None),
// Trait object syntax with `dyn` prefix
(accepted, dyn_trait, "1.27.0", Some(44662), None),
);

// If you change this, please modify src/doc/unstable-book as well. You must
Expand Down Expand Up @@ -1657,10 +1656,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
gate_feature_post!(&self, never_type, ty.span,
"The `!` type is experimental");
}
ast::TyKind::TraitObject(_, ast::TraitObjectSyntax::Dyn) => {
gate_feature_post!(&self, dyn_trait, ty.span,
"`dyn Trait` syntax is unstable");
}
_ => {}
}
visit::walk_ty(self, ty)
Expand Down
43 changes: 43 additions & 0 deletions src/libsyntax_pos/hygiene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use symbol::{Ident, Symbol};

use serialize::{Encodable, Decodable, Encoder, Decoder};
use std::collections::HashMap;
use rustc_data_structures::fx::FxHashSet;
use std::fmt;

/// A SyntaxContext represents a chain of macro expansions (represented by marks).
Expand Down Expand Up @@ -117,6 +118,32 @@ impl Mark {
true
})
}

/// Computes a mark such that both input marks are descendants of (or equal to) the returned
/// mark. That is, the following holds:
///
/// ```rust
/// let la = least_ancestor(a, b);
/// assert!(a.is_descendant_of(la))
/// assert!(b.is_descendant_of(la))
/// ```
pub fn least_ancestor(mut a: Mark, mut b: Mark) -> Mark {
HygieneData::with(|data| {
// Compute the path from a to the root
let mut a_path = FxHashSet::<Mark>();
while a != Mark::root() {
a_path.insert(a);
a = data.marks[a.0 as usize].parent;
}

// While the path from b to the root hasn't intersected, move up the tree
while !a_path.contains(&b) {
b = data.marks[b.0 as usize].parent;
}

b
})
}
}

pub struct HygieneData {
Expand Down Expand Up @@ -238,6 +265,22 @@ impl SyntaxContext {
})
}

/// Pulls a single mark off of the syntax context. This effectively moves the
/// context up one macro definition level. That is, if we have a nested macro
/// definition as follows:
///
/// ```rust
/// macro_rules! f {
/// macro_rules! g {
/// ...
/// }
/// }
/// ```
///
/// and we have a SyntaxContext that is referring to something declared by an invocation
/// of g (call it g1), calling remove_mark will result in the SyntaxContext for the
/// invocation of f that created g1.
/// Returns the mark that was removed.
pub fn remove_mark(&mut self) -> Mark {
HygieneData::with(|data| {
let outer_mark = data.syntax_contexts[self.0 as usize].outer_mark;
Expand Down
6 changes: 6 additions & 0 deletions src/libsyntax_pos/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@ impl Span {
self.ctxt().outer().expn_info().map(|info| info.call_site.source_callsite()).unwrap_or(self)
}

/// The `Span` for the tokens in the previous macro expansion from which `self` was generated,
/// if any
pub fn parent(self) -> Option<Span> {
self.ctxt().outer().expn_info().map(|i| i.call_site)
}

/// Return the source callee.
///
/// Returns None if the supplied span has no expansion trace,
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/attr-usage-inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#[inline]
fn f() {}

#[inline] //~ ERROR: attribute should be applied to function
#[inline] //~ ERROR: attribute should be applied to function or closure
struct S;

fn main() {}
1 change: 0 additions & 1 deletion src/test/compile-fail/impl-trait/where-allowed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

//! A simple test for testing many permutations of allowedness of
//! impl Trait
#![feature(dyn_trait)]
use std::fmt::Debug;

// Allowed
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-31769.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
// except according to those terms.

fn main() {
#[inline] struct Foo; //~ ERROR attribute should be applied to function
#[inline] struct Foo; //~ ERROR attribute should be applied to function or closure
#[repr(C)] fn foo() {} //~ ERROR attribute should be applied to struct, enum or union
}
Loading

0 comments on commit 686d0ae

Please sign in to comment.