Skip to content

Commit 9653f79

Browse files
committed
Auto merge of #54660 - kennytm:rollup, r=kennytm
Rollup of 8 pull requests Successful merges: - #54564 (Add 1.29.1 release notes) - #54567 (Include path in stamp hash for debuginfo tests) - #54577 (rustdoc: give proc-macros their own pages) - #54590 (std: Don't let `rust_panic` get inlined) - #54598 (Remove useless lifetimes from `Pin` `impl`s.) - #54604 (Added help message for `self_in_typedefs` feature gate) - #54635 (Improve docs for std::io::Seek) - #54645 (Compute Android gdb version in compiletest)
2 parents 7e7bc06 + def5f84 commit 9653f79

File tree

24 files changed

+671
-277
lines changed

24 files changed

+671
-277
lines changed

Diff for: RELEASES.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
Version 1.29.1 (2018-09-25)
2+
===========================
3+
4+
Security Notes
5+
--------------
6+
7+
- The standard library's `str::repeat` function contained an out of bounds write
8+
caused by an integer overflow. This has been fixed by deterministically
9+
panicking when an overflow happens.
10+
11+
Thank you to Scott McMurray for responsibily disclosing this vulnerability to
12+
us.
13+
114
Version 1.29.0 (2018-09-13)
215
==========================
316

Diff for: src/libcore/pin.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -293,21 +293,21 @@ where
293293
}
294294

295295
#[unstable(feature = "pin", issue = "49150")]
296-
impl<'a, P: fmt::Debug> fmt::Debug for Pin<P> {
296+
impl<P: fmt::Debug> fmt::Debug for Pin<P> {
297297
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
298298
fmt::Debug::fmt(&self.pointer, f)
299299
}
300300
}
301301

302302
#[unstable(feature = "pin", issue = "49150")]
303-
impl<'a, P: fmt::Display> fmt::Display for Pin<P> {
303+
impl<P: fmt::Display> fmt::Display for Pin<P> {
304304
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
305305
fmt::Display::fmt(&self.pointer, f)
306306
}
307307
}
308308

309309
#[unstable(feature = "pin", issue = "49150")]
310-
impl<'a, P: fmt::Pointer> fmt::Pointer for Pin<P> {
310+
impl<P: fmt::Pointer> fmt::Pointer for Pin<P> {
311311
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
312312
fmt::Pointer::fmt(&self.pointer, f)
313313
}
@@ -319,10 +319,10 @@ impl<'a, P: fmt::Pointer> fmt::Pointer for Pin<P> {
319319
// for other reasons, though, so we just need to take care not to allow such
320320
// impls to land in std.
321321
#[unstable(feature = "pin", issue = "49150")]
322-
impl<'a, P, U> CoerceUnsized<Pin<U>> for Pin<P>
322+
impl<P, U> CoerceUnsized<Pin<U>> for Pin<P>
323323
where
324324
P: CoerceUnsized<U>,
325325
{}
326326

327327
#[unstable(feature = "pin", issue = "49150")]
328-
impl<'a, P> Unpin for Pin<P> {}
328+
impl<P> Unpin for Pin<P> {}

Diff for: src/librustc_mir/hair/pattern/check_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ fn check_legality_of_move_bindings(cx: &MatchVisitor,
539539
.emit();
540540
} else if has_guard && !cx.tcx.allow_bind_by_move_patterns_with_guards() {
541541
let mut err = struct_span_err!(cx.tcx.sess, p.span, E0008,
542-
"cannot bind by-move into a pattern guard");
542+
"cannot bind by-move into a pattern guard");
543543
err.span_label(p.span, "moves value into pattern guard");
544544
if cx.tcx.sess.opts.unstable_features.is_nightly_build() && cx.tcx.use_mir_borrowck() {
545545
err.help("add #![feature(bind_by_move_pattern_guards)] to the \

Diff for: src/librustc_resolve/lib.rs

+29-9
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ use rustc::lint;
4242
use rustc::hir::def::*;
4343
use rustc::hir::def::Namespace::*;
4444
use rustc::hir::def_id::{CRATE_DEF_INDEX, LOCAL_CRATE, DefId};
45-
use rustc::ty;
4645
use rustc::hir::{Freevar, FreevarMap, TraitCandidate, TraitMap, GlobMap};
46+
use rustc::session::config::nightly_options;
47+
use rustc::ty;
4748
use rustc::util::nodemap::{NodeMap, NodeSet, FxHashMap, FxHashSet, DefIdMap};
4849

4950
use rustc_metadata::creader::CrateLoader;
@@ -1381,6 +1382,9 @@ pub struct Resolver<'a, 'b: 'a> {
13811382
/// The current self type if inside an impl (used for better errors).
13821383
current_self_type: Option<Ty>,
13831384

1385+
/// The current self item if inside an ADT (used for better errors).
1386+
current_self_item: Option<NodeId>,
1387+
13841388
/// The idents for the primitive types.
13851389
primitive_type_table: PrimitiveTypeTable,
13861390

@@ -1710,6 +1714,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
17101714

17111715
current_trait_ref: None,
17121716
current_self_type: None,
1717+
current_self_item: None,
17131718

17141719
primitive_type_table: PrimitiveTypeTable::new(),
17151720

@@ -2186,15 +2191,17 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
21862191
}
21872192

21882193
fn resolve_adt(&mut self, item: &Item, generics: &Generics) {
2189-
self.with_type_parameter_rib(HasTypeParameters(generics, ItemRibKind), |this| {
2190-
let item_def_id = this.definitions.local_def_id(item.id);
2191-
if this.session.features_untracked().self_in_typedefs {
2192-
this.with_self_rib(Def::SelfTy(None, Some(item_def_id)), |this| {
2194+
self.with_current_self_item(item, |this| {
2195+
this.with_type_parameter_rib(HasTypeParameters(generics, ItemRibKind), |this| {
2196+
let item_def_id = this.definitions.local_def_id(item.id);
2197+
if this.session.features_untracked().self_in_typedefs {
2198+
this.with_self_rib(Def::SelfTy(None, Some(item_def_id)), |this| {
2199+
visit::walk_item(this, item);
2200+
});
2201+
} else {
21932202
visit::walk_item(this, item);
2194-
});
2195-
} else {
2196-
visit::walk_item(this, item);
2197-
}
2203+
}
2204+
});
21982205
});
21992206
}
22002207

@@ -2435,6 +2442,15 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
24352442
result
24362443
}
24372444

2445+
fn with_current_self_item<T, F>(&mut self, self_item: &Item, f: F) -> T
2446+
where F: FnOnce(&mut Resolver) -> T
2447+
{
2448+
let previous_value = replace(&mut self.current_self_item, Some(self_item.id));
2449+
let result = f(self);
2450+
self.current_self_item = previous_value;
2451+
result
2452+
}
2453+
24382454
/// This is called to resolve a trait reference from an `impl` (i.e. `impl Trait for Foo`)
24392455
fn with_optional_trait_ref<T, F>(&mut self, opt_trait_ref: Option<&TraitRef>, f: F) -> T
24402456
where F: FnOnce(&mut Resolver, Option<DefId>) -> T
@@ -3004,6 +3020,10 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
30043020
"traits and impls"
30053021
};
30063022
err.span_label(span, format!("`Self` is only available in {}", available_in));
3023+
if this.current_self_item.is_some() && nightly_options::is_nightly_build() {
3024+
err.help("add #![feature(self_in_typedefs)] to the crate attributes \
3025+
to enable");
3026+
}
30073027
return (err, Vec::new());
30083028
}
30093029
if is_self_value(path, ns) {

Diff for: src/librustc_typeck/check/method/probe.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ use check::FnCtxt;
1717
use hir::def_id::DefId;
1818
use hir::def::Def;
1919
use namespace::Namespace;
20+
use rustc::hir;
21+
use rustc::lint;
22+
use rustc::session::config::nightly_options;
2023
use rustc::ty::subst::{Subst, Substs};
2124
use rustc::traits::{self, ObligationCause};
2225
use rustc::ty::{self, Ty, ToPolyTraitRef, ToPredicate, TraitRef, TypeFoldable};
@@ -28,8 +31,6 @@ use rustc::middle::stability;
2831
use syntax::ast;
2932
use syntax::util::lev_distance::{lev_distance, find_best_match_for_name};
3033
use syntax_pos::{Span, symbol::Symbol};
31-
use rustc::hir;
32-
use rustc::lint;
3334
use std::mem;
3435
use std::ops::Deref;
3536
use std::rc::Rc;
@@ -1073,9 +1074,9 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
10731074
self.tcx.item_path_str(stable_pick.item.def_id),
10741075
));
10751076

1076-
if ::rustc::session::config::nightly_options::is_nightly_build() {
1077+
if nightly_options::is_nightly_build() {
10771078
for (candidate, feature) in unstable_candidates {
1078-
diag.note(&format!(
1079+
diag.help(&format!(
10791080
"add #![feature({})] to the crate attributes to enable `{}`",
10801081
feature,
10811082
self.tcx.item_path_str(candidate.item.def_id),

Diff for: src/librustdoc/clean/inline.rs

+39-29
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use std::iter::once;
1414

1515
use syntax::ast;
16-
use syntax::ext::base::MacroKind;
16+
use syntax::ext::base::{MacroKind, SyntaxExtension};
1717
use syntax_pos::Span;
1818

1919
use rustc::hir;
@@ -105,12 +105,12 @@ pub fn try_inline(cx: &DocContext, def: Def, name: ast::Name, visited: &mut FxHa
105105
record_extern_fqn(cx, did, clean::TypeKind::Const);
106106
clean::ConstantItem(build_const(cx, did))
107107
}
108-
// FIXME(misdreavus): if attributes/derives come down here we should probably document them
109-
// separately
108+
// FIXME: proc-macros don't propagate attributes or spans across crates, so they look empty
110109
Def::Macro(did, MacroKind::Bang) => {
111-
record_extern_fqn(cx, did, clean::TypeKind::Macro);
112-
if let Some(mac) = build_macro(cx, did, name) {
113-
clean::MacroItem(mac)
110+
let mac = build_macro(cx, did, name);
111+
if let clean::MacroItem(..) = mac {
112+
record_extern_fqn(cx, did, clean::TypeKind::Macro);
113+
mac
114114
} else {
115115
return None;
116116
}
@@ -442,31 +442,41 @@ fn build_static(cx: &DocContext, did: DefId, mutable: bool) -> clean::Static {
442442
}
443443
}
444444

445-
fn build_macro(cx: &DocContext, did: DefId, name: ast::Name) -> Option<clean::Macro> {
445+
fn build_macro(cx: &DocContext, did: DefId, name: ast::Name) -> clean::ItemEnum {
446446
let imported_from = cx.tcx.original_crate_name(did.krate);
447-
let def = match cx.cstore.load_macro_untracked(did, cx.sess()) {
448-
LoadedMacro::MacroDef(macro_def) => macro_def,
449-
// FIXME(jseyfried): document proc macro re-exports
450-
LoadedMacro::ProcMacro(..) => return None,
451-
};
452-
453-
let matchers: hir::HirVec<Span> = if let ast::ItemKind::MacroDef(ref def) = def.node {
454-
let tts: Vec<_> = def.stream().into_trees().collect();
455-
tts.chunks(4).map(|arm| arm[0].span()).collect()
456-
} else {
457-
unreachable!()
458-
};
459-
460-
let source = format!("macro_rules! {} {{\n{}}}",
461-
name.clean(cx),
462-
matchers.iter().map(|span| {
463-
format!(" {} => {{ ... }};\n", span.to_src(cx))
464-
}).collect::<String>());
447+
match cx.cstore.load_macro_untracked(did, cx.sess()) {
448+
LoadedMacro::MacroDef(def) => {
449+
let matchers: hir::HirVec<Span> = if let ast::ItemKind::MacroDef(ref def) = def.node {
450+
let tts: Vec<_> = def.stream().into_trees().collect();
451+
tts.chunks(4).map(|arm| arm[0].span()).collect()
452+
} else {
453+
unreachable!()
454+
};
455+
456+
let source = format!("macro_rules! {} {{\n{}}}",
457+
name.clean(cx),
458+
matchers.iter().map(|span| {
459+
format!(" {} => {{ ... }};\n", span.to_src(cx))
460+
}).collect::<String>());
461+
462+
clean::MacroItem(clean::Macro {
463+
source,
464+
imported_from: Some(imported_from).clean(cx),
465+
})
466+
}
467+
LoadedMacro::ProcMacro(ext) => {
468+
let helpers = match &*ext {
469+
&SyntaxExtension::ProcMacroDerive(_, ref syms, ..) => { syms.clean(cx) }
470+
_ => Vec::new(),
471+
};
472+
473+
clean::ProcMacroItem(clean::ProcMacro {
474+
kind: ext.kind(),
475+
helpers,
476+
})
477+
}
478+
}
465479

466-
Some(clean::Macro {
467-
source,
468-
imported_from: Some(imported_from).clean(cx),
469-
})
470480
}
471481

472482
/// A trait's generics clause actually contains all of the predicates for all of

Diff for: src/librustdoc/clean/mod.rs

+35-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub use self::Visibility::{Public, Inherited};
2121
use rustc_target::spec::abi::Abi;
2222
use syntax::ast::{self, AttrStyle, Ident};
2323
use syntax::attr;
24+
use syntax::ext::base::MacroKind;
2425
use syntax::source_map::{dummy_spanned, Spanned};
2526
use syntax::ptr::P;
2627
use syntax::symbol::keywords::{self, Keyword};
@@ -527,6 +528,7 @@ pub enum ItemEnum {
527528
/// `type`s from an extern block
528529
ForeignTypeItem,
529530
MacroItem(Macro),
531+
ProcMacroItem(ProcMacro),
530532
PrimitiveItem(PrimitiveType),
531533
AssociatedConstItem(Type, Option<String>),
532534
AssociatedTypeItem(Vec<GenericBound>, Option<Type>),
@@ -588,6 +590,7 @@ impl Clean<Item> for doctree::Module {
588590
items.extend(self.traits.iter().map(|x| x.clean(cx)));
589591
items.extend(self.impls.iter().flat_map(|x| x.clean(cx)));
590592
items.extend(self.macros.iter().map(|x| x.clean(cx)));
593+
items.extend(self.proc_macros.iter().map(|x| x.clean(cx)));
591594

592595
// determine if we should display the inner contents or
593596
// the outer `mod` item for the source code.
@@ -2191,6 +2194,8 @@ pub enum TypeKind {
21912194
Typedef,
21922195
Foreign,
21932196
Macro,
2197+
Attr,
2198+
Derive,
21942199
}
21952200

21962201
pub trait GetDefId {
@@ -3727,7 +3732,12 @@ pub fn register_def(cx: &DocContext, def: Def) -> DefId {
37273732
Def::Static(i, _) => (i, TypeKind::Static),
37283733
Def::Variant(i) => (cx.tcx.parent_def_id(i).expect("cannot get parent def id"),
37293734
TypeKind::Enum),
3730-
Def::Macro(i, _) => (i, TypeKind::Macro),
3735+
Def::Macro(i, mac_kind) => match mac_kind {
3736+
MacroKind::Bang => (i, TypeKind::Macro),
3737+
MacroKind::Attr => (i, TypeKind::Attr),
3738+
MacroKind::Derive => (i, TypeKind::Derive),
3739+
MacroKind::ProcMacroStub => unreachable!(),
3740+
},
37313741
Def::SelfTy(Some(def_id), _) => (def_id, TypeKind::Trait),
37323742
Def::SelfTy(_, Some(impl_def_id)) => {
37333743
return impl_def_id
@@ -3782,6 +3792,30 @@ impl Clean<Item> for doctree::Macro {
37823792
}
37833793
}
37843794

3795+
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
3796+
pub struct ProcMacro {
3797+
pub kind: MacroKind,
3798+
pub helpers: Vec<String>,
3799+
}
3800+
3801+
impl Clean<Item> for doctree::ProcMacro {
3802+
fn clean(&self, cx: &DocContext) -> Item {
3803+
Item {
3804+
name: Some(self.name.clean(cx)),
3805+
attrs: self.attrs.clean(cx),
3806+
source: self.whence.clean(cx),
3807+
visibility: Some(Public),
3808+
stability: self.stab.clean(cx),
3809+
deprecation: self.depr.clean(cx),
3810+
def_id: cx.tcx.hir.local_def_id(self.id),
3811+
inner: ProcMacroItem(ProcMacro {
3812+
kind: self.kind,
3813+
helpers: self.helpers.clean(cx),
3814+
}),
3815+
}
3816+
}
3817+
}
3818+
37853819
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
37863820
pub struct Stability {
37873821
pub level: stability::StabilityLevel,

Diff for: src/librustdoc/doctree.rs

+14
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub use self::StructType::*;
1515
use syntax::ast;
1616
use syntax::ast::{Name, NodeId};
1717
use syntax::attr;
18+
use syntax::ext::base::MacroKind;
1819
use syntax::ptr::P;
1920
use syntax::source_map::Spanned;
2021
use syntax_pos::{self, Span};
@@ -46,6 +47,7 @@ pub struct Module {
4647
pub impls: Vec<Impl>,
4748
pub foreigns: Vec<hir::ForeignMod>,
4849
pub macros: Vec<Macro>,
50+
pub proc_macros: Vec<ProcMacro>,
4951
pub is_crate: bool,
5052
}
5153

@@ -75,6 +77,7 @@ impl Module {
7577
impls : Vec::new(),
7678
foreigns : Vec::new(),
7779
macros : Vec::new(),
80+
proc_macros: Vec::new(),
7881
is_crate : false,
7982
}
8083
}
@@ -264,6 +267,17 @@ pub struct Import {
264267
pub whence: Span,
265268
}
266269

270+
pub struct ProcMacro {
271+
pub name: Name,
272+
pub id: NodeId,
273+
pub kind: MacroKind,
274+
pub helpers: Vec<Name>,
275+
pub attrs: hir::HirVec<ast::Attribute>,
276+
pub whence: Span,
277+
pub stab: Option<attr::Stability>,
278+
pub depr: Option<attr::Deprecation>,
279+
}
280+
267281
pub fn struct_type_from_def(vdata: &hir::VariantData) -> StructType {
268282
match *vdata {
269283
hir::VariantData::Struct(..) => Plain,

0 commit comments

Comments
 (0)