Skip to content

Commit 686d0ae

Browse files
committed
Auto merge of #50290 - kennytm:rollup, r=kennytm
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:
2 parents a997525 + dc6b167 commit 686d0ae

File tree

69 files changed

+298
-249
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+298
-249
lines changed

src/Cargo.lock

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/liballoc/boxed.rs

+1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ impl<T: ?Sized> Box<T> {
184184

185185
#[unstable(feature = "ptr_internals", issue = "0", reason = "use into_raw_non_null instead")]
186186
#[inline]
187+
#[doc(hidden)]
187188
pub fn into_unique(b: Box<T>) -> Unique<T> {
188189
let unique = b.0;
189190
mem::forget(b);

src/libcore/ptr.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2513,6 +2513,7 @@ impl<T: ?Sized> PartialOrd for *mut T {
25132513
reason = "use NonNull instead and consider PhantomData<T> \
25142514
(if you also use #[may_dangle]), Send, and/or Sync")]
25152515
#[allow(deprecated)]
2516+
#[doc(hidden)]
25162517
pub struct Unique<T: ?Sized> {
25172518
pointer: NonZero<*const T>,
25182519
// NOTE: this marker has no consequences for variance, but is necessary

src/libproc_macro/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl Span {
270270
/// `self` was generated from, if any.
271271
#[unstable(feature = "proc_macro", issue = "38356")]
272272
pub fn parent(&self) -> Option<Span> {
273-
self.0.ctxt().outer().expn_info().map(|i| Span(i.call_site))
273+
self.0.parent().map(Span)
274274
}
275275

276276
/// The span for the origin source code that `self` was generated from. If

src/librustc/hir/check_attr.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ enum Target {
3030
ForeignMod,
3131
Expression,
3232
Statement,
33+
Closure,
3334
Other,
3435
}
3536

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

106-
/// Check if an `#[inline]` is applied to a function.
107+
/// Check if an `#[inline]` is applied to a function or a closure.
107108
fn check_inline(&self, attr: &hir::Attribute, span: &Span, target: Target) {
108-
if target != Target::Fn {
109+
if target != Target::Fn && target != Target::Closure {
109110
struct_span_err!(self.tcx.sess,
110111
attr.span,
111112
E0518,
112-
"attribute should be applied to function")
113-
.span_label(*span, "not a function")
113+
"attribute should be applied to function or closure")
114+
.span_label(*span, "not a function or closure")
114115
.emit();
115116
}
116117
}
@@ -286,9 +287,13 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
286287
}
287288

288289
fn check_expr_attributes(&self, expr: &hir::Expr) {
290+
let target = match expr.node {
291+
hir::ExprClosure(..) => Target::Closure,
292+
_ => Target::Expression,
293+
};
289294
for attr in expr.attrs.iter() {
290295
if attr.check_name("inline") {
291-
self.check_inline(attr, &expr.span, Target::Expression);
296+
self.check_inline(attr, &expr.span, target);
292297
}
293298
if attr.check_name("repr") {
294299
self.emit_repr_error(

src/librustc/hir/lowering.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -4107,15 +4107,13 @@ impl<'a> LoweringContext<'a> {
41074107
}
41084108

41094109
fn maybe_lint_bare_trait(&self, span: Span, id: NodeId, is_global: bool) {
4110-
if self.sess.features_untracked().dyn_trait {
4111-
self.sess.buffer_lint_with_diagnostic(
4112-
builtin::BARE_TRAIT_OBJECT,
4113-
id,
4114-
span,
4115-
"trait objects without an explicit `dyn` are deprecated",
4116-
builtin::BuiltinLintDiagnostics::BareTraitObject(span, is_global),
4117-
)
4118-
}
4110+
self.sess.buffer_lint_with_diagnostic(
4111+
builtin::BARE_TRAIT_OBJECT,
4112+
id,
4113+
span,
4114+
"trait objects without an explicit `dyn` are deprecated",
4115+
builtin::BuiltinLintDiagnostics::BareTraitObject(span, is_global),
4116+
)
41194117
}
41204118

41214119
fn wrap_in_try_constructor(

src/librustc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
#![feature(const_fn)]
4646
#![feature(core_intrinsics)]
4747
#![feature(drain_filter)]
48-
#![feature(dyn_trait)]
4948
#![feature(entry_or_default)]
49+
#![cfg_attr(stage0, feature(dyn_trait))]
5050
#![feature(from_ref)]
5151
#![feature(fs_read_write)]
5252
#![cfg_attr(windows, feature(libc))]

src/librustc/traits/error_reporting.rs

+6
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
979979
ArgKind::Arg(format!("{}", field.name), "_".to_string())
980980
}).collect::<Vec<_>>())
981981
}
982+
hir::map::NodeStructCtor(ref variant_data) => {
983+
(self.tcx.sess.codemap().def_span(self.tcx.hir.span(variant_data.id())),
984+
variant_data.fields()
985+
.iter().map(|_| ArgKind::Arg("_".to_owned(), "_".to_owned()))
986+
.collect())
987+
}
982988
_ => panic!("non-FnLike node found: {:?}", node),
983989
}
984990
}

src/librustc_mir/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
2424
#![feature(const_fn)]
2525
#![feature(core_intrinsics)]
2626
#![feature(decl_macro)]
27-
#![feature(dyn_trait)]
27+
#![cfg_attr(stage0, feature(dyn_trait))]
2828
#![feature(fs_read_write)]
2929
#![feature(macro_vis_matcher)]
3030
#![feature(exhaustive_patterns)]

src/librustc_trans/allocator.rs

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use std::ffi::CString;
1212
use std::ptr;
1313

14+
use attributes;
1415
use libc::c_uint;
1516
use rustc::middle::allocator::AllocatorKind;
1617
use rustc::ty::TyCtxt;
@@ -67,6 +68,9 @@ pub(crate) unsafe fn trans(tcx: TyCtxt, mods: &ModuleLlvm, kind: AllocatorKind)
6768
if tcx.sess.target.target.options.default_hidden_visibility {
6869
llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden);
6970
}
71+
if tcx.sess.target.target.options.requires_uwtable {
72+
attributes::emit_uwtable(llfn, true);
73+
}
7074

7175
let callee = CString::new(kind.fn_name(method.name)).unwrap();
7276
let callee = llvm::LLVMRustGetOrInsertFunction(llmod,

src/librustc_trans/back/linker.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,11 @@ impl Linker for WasmLd {
959959
}
960960

961961
fn finalize(&mut self) -> Command {
962-
self.cmd.arg("--threads");
962+
// There have been reports in the wild (rustwasm/wasm-bindgen#119) of
963+
// using threads causing weird hangs and bugs. Disable it entirely as
964+
// this isn't yet the bottleneck of compilation at all anyway.
965+
self.cmd.arg("--no-threads");
966+
963967
self.cmd.arg("-z").arg("stack-size=1048576");
964968

965969
// FIXME we probably shouldn't pass this but instead pass an explicit

src/librustc_typeck/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ This API is completely unstable and subject to change.
7171

7272
#![allow(non_camel_case_types)]
7373

74+
#![cfg_attr(stage0, feature(dyn_trait))]
75+
7476
#![feature(box_patterns)]
7577
#![feature(box_syntax)]
7678
#![feature(crate_visibility_modifier)]
@@ -81,7 +83,6 @@ This API is completely unstable and subject to change.
8183
#![feature(rustc_diagnostic_macros)]
8284
#![feature(slice_patterns)]
8385
#![feature(slice_sort_by_cached_key)]
84-
#![feature(dyn_trait)]
8586
#![feature(never_type)]
8687

8788
#[macro_use] extern crate log;

src/librustdoc/html/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
146146
window.rootPath = \"{root_path}\";\
147147
window.currentCrate = \"{krate}\";\
148148
</script>\
149+
<script src=\"{root_path}aliases.js\"></script>\
149150
<script src=\"{root_path}main{suffix}.js\"></script>\
150151
<script defer src=\"{root_path}search-index.js\"></script>\
151-
<script defer src=\"{root_path}aliases.js\"></script>\
152152
</body>\
153153
</html>",
154154
css_extension = if css_file_extension {

src/librustdoc/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
html_root_url = "https://doc.rust-lang.org/nightly/",
1414
html_playground_url = "https://play.rust-lang.org/")]
1515

16+
#![cfg_attr(stage0, feature(dyn_trait))]
17+
1618
#![feature(ascii_ctype)]
1719
#![feature(rustc_private)]
1820
#![feature(box_patterns)]
@@ -23,7 +25,6 @@
2325
#![feature(test)]
2426
#![feature(vec_remove_item)]
2527
#![feature(entry_and_modify)]
26-
#![feature(dyn_trait)]
2728

2829
extern crate arena;
2930
extern crate getopts;

src/libsyntax/feature_gate.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,6 @@ declare_features! (
375375
// Future-proofing enums/structs with #[non_exhaustive] attribute (RFC 2008)
376376
(active, non_exhaustive, "1.22.0", Some(44109), None),
377377

378-
// Trait object syntax with `dyn` prefix
379-
(active, dyn_trait, "1.22.0", Some(44662), Some(Edition::Edition2018)),
380-
381378
// `crate` as visibility modifier, synonymous to `pub(crate)`
382379
(active, crate_visibility_modifier, "1.23.0", Some(45388), Some(Edition::Edition2018)),
383380

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

597596
// If you change this, please modify src/doc/unstable-book as well. You must
@@ -1657,10 +1656,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
16571656
gate_feature_post!(&self, never_type, ty.span,
16581657
"The `!` type is experimental");
16591658
}
1660-
ast::TyKind::TraitObject(_, ast::TraitObjectSyntax::Dyn) => {
1661-
gate_feature_post!(&self, dyn_trait, ty.span,
1662-
"`dyn Trait` syntax is unstable");
1663-
}
16641659
_ => {}
16651660
}
16661661
visit::walk_ty(self, ty)

src/libsyntax_pos/hygiene.rs

+43
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use symbol::{Ident, Symbol};
2121

2222
use serialize::{Encodable, Decodable, Encoder, Decoder};
2323
use std::collections::HashMap;
24+
use rustc_data_structures::fx::FxHashSet;
2425
use std::fmt;
2526

2627
/// A SyntaxContext represents a chain of macro expansions (represented by marks).
@@ -117,6 +118,32 @@ impl Mark {
117118
true
118119
})
119120
}
121+
122+
/// Computes a mark such that both input marks are descendants of (or equal to) the returned
123+
/// mark. That is, the following holds:
124+
///
125+
/// ```rust
126+
/// let la = least_ancestor(a, b);
127+
/// assert!(a.is_descendant_of(la))
128+
/// assert!(b.is_descendant_of(la))
129+
/// ```
130+
pub fn least_ancestor(mut a: Mark, mut b: Mark) -> Mark {
131+
HygieneData::with(|data| {
132+
// Compute the path from a to the root
133+
let mut a_path = FxHashSet::<Mark>();
134+
while a != Mark::root() {
135+
a_path.insert(a);
136+
a = data.marks[a.0 as usize].parent;
137+
}
138+
139+
// While the path from b to the root hasn't intersected, move up the tree
140+
while !a_path.contains(&b) {
141+
b = data.marks[b.0 as usize].parent;
142+
}
143+
144+
b
145+
})
146+
}
120147
}
121148

122149
pub struct HygieneData {
@@ -238,6 +265,22 @@ impl SyntaxContext {
238265
})
239266
}
240267

268+
/// Pulls a single mark off of the syntax context. This effectively moves the
269+
/// context up one macro definition level. That is, if we have a nested macro
270+
/// definition as follows:
271+
///
272+
/// ```rust
273+
/// macro_rules! f {
274+
/// macro_rules! g {
275+
/// ...
276+
/// }
277+
/// }
278+
/// ```
279+
///
280+
/// and we have a SyntaxContext that is referring to something declared by an invocation
281+
/// of g (call it g1), calling remove_mark will result in the SyntaxContext for the
282+
/// invocation of f that created g1.
283+
/// Returns the mark that was removed.
241284
pub fn remove_mark(&mut self) -> Mark {
242285
HygieneData::with(|data| {
243286
let outer_mark = data.syntax_contexts[self.0 as usize].outer_mark;

src/libsyntax_pos/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,12 @@ impl Span {
291291
self.ctxt().outer().expn_info().map(|info| info.call_site.source_callsite()).unwrap_or(self)
292292
}
293293

294+
/// The `Span` for the tokens in the previous macro expansion from which `self` was generated,
295+
/// if any
296+
pub fn parent(self) -> Option<Span> {
297+
self.ctxt().outer().expn_info().map(|i| i.call_site)
298+
}
299+
294300
/// Return the source callee.
295301
///
296302
/// Returns None if the supplied span has no expansion trace,

src/test/compile-fail/attr-usage-inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#[inline]
1414
fn f() {}
1515

16-
#[inline] //~ ERROR: attribute should be applied to function
16+
#[inline] //~ ERROR: attribute should be applied to function or closure
1717
struct S;
1818

1919
fn main() {}

src/test/compile-fail/impl-trait/where-allowed.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

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

1615
// Allowed

src/test/compile-fail/issue-31769.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
// except according to those terms.
1010

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

0 commit comments

Comments
 (0)