Skip to content

Commit 868b51b

Browse files
committedApr 16, 2020
Auto merge of #71223 - Dylan-DPC:rollup-z5itu39, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #70611 (Add long error explanation for E0708 #61137) - #71197 (Don't use the HirId to NodeId map in MIR) - #71211 (Update cargo) - #71219 (Minor fixes to doc comments of 'VecDeque') - #71221 (Dogfood or_patterns in rustdoc) Failed merges: r? @ghost
2 parents 7f3df57 + f51d2d0 commit 868b51b

File tree

14 files changed

+81
-46
lines changed

14 files changed

+81
-46
lines changed
 

‎src/liballoc/collections/vec_deque.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ impl<T> VecDeque<T> {
488488
VecDeque { tail: 0, head: 0, buf: RawVec::with_capacity(cap) }
489489
}
490490

491-
/// Retrieves an element in the `VecDeque` by index.
491+
/// Provides a reference to the element at the given index.
492492
///
493493
/// Element at index 0 is the front of the queue.
494494
///
@@ -513,7 +513,7 @@ impl<T> VecDeque<T> {
513513
}
514514
}
515515

516-
/// Retrieves an element in the `VecDeque` mutably by index.
516+
/// Provides a mutable reference to the element at the given index.
517517
///
518518
/// Element at index 0 is the front of the queue.
519519
///
@@ -651,7 +651,7 @@ impl<T> VecDeque<T> {
651651
}
652652
}
653653

654-
/// Tries to reserves the minimum capacity for exactly `additional` more elements to
654+
/// Tries to reserve the minimum capacity for exactly `additional` more elements to
655655
/// be inserted in the given `VecDeque<T>`. After calling `reserve_exact`,
656656
/// capacity will be greater than or equal to `self.len() + additional`.
657657
/// Does nothing if the capacity is already sufficient.
@@ -662,7 +662,7 @@ impl<T> VecDeque<T> {
662662
///
663663
/// # Errors
664664
///
665-
/// If the capacity overflows, or the allocator reports a failure, then an error
665+
/// If the capacity overflows `usize`, or the allocator reports a failure, then an error
666666
/// is returned.
667667
///
668668
/// # Examples
@@ -678,7 +678,7 @@ impl<T> VecDeque<T> {
678678
/// // Pre-reserve the memory, exiting if we can't
679679
/// output.try_reserve_exact(data.len())?;
680680
///
681-
/// // Now we know this can't OOM in the middle of our complex work
681+
/// // Now we know this can't OOM(Out-Of-Memory) in the middle of our complex work
682682
/// output.extend(data.iter().map(|&val| {
683683
/// val * 2 + 5 // very complicated
684684
/// }));
@@ -700,7 +700,7 @@ impl<T> VecDeque<T> {
700700
///
701701
/// # Errors
702702
///
703-
/// If the capacity overflows, or the allocator reports a failure, then an error
703+
/// If the capacity overflows `usize`, or the allocator reports a failure, then an error
704704
/// is returned.
705705
///
706706
/// # Examples

‎src/librustc_error_codes/error_codes.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ E0703: include_str!("./error_codes/E0703.md"),
394394
E0704: include_str!("./error_codes/E0704.md"),
395395
E0705: include_str!("./error_codes/E0705.md"),
396396
E0706: include_str!("./error_codes/E0706.md"),
397+
E0708: include_str!("./error_codes/E0708.md"),
397398
E0710: include_str!("./error_codes/E0710.md"),
398399
E0712: include_str!("./error_codes/E0712.md"),
399400
E0713: include_str!("./error_codes/E0713.md"),
@@ -604,8 +605,6 @@ E0751: include_str!("./error_codes/E0751.md"),
604605
E0696, // `continue` pointing to a labeled block
605606
// E0702, // replaced with a generic attribute input check
606607
// E0707, // multiple elided lifetimes used in arguments of `async fn`
607-
E0708, // `async` non-`move` closures with parameters are not currently
608-
// supported
609608
// E0709, // multiple different lifetimes used in arguments of `async fn`
610609
E0711, // a feature has been declared with conflicting stability attributes
611610
E0717, // rustc_promotable without stability attribute
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
`async` non-`move` closures with parameters are currently not supported.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,edition2018
6+
#![feature(async_closure)]
7+
8+
fn main() {
9+
let add_one = async |num: u8| { // error!
10+
num + 1
11+
};
12+
}
13+
```
14+
15+
`async` with non-move is currently not supported with the current
16+
version, you can use successfully by using move:
17+
18+
```edition2018
19+
#![feature(async_closure)]
20+
21+
fn main() {
22+
let add_one = async move |num: u8| { // ok!
23+
num + 1
24+
};
25+
}
26+
```

‎src/librustc_mir/transform/check_unsafety.rs

+13-7
Original file line numberDiff line numberDiff line change
@@ -641,13 +641,19 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: DefId) {
641641
}
642642
}
643643

644-
let mut unsafe_blocks: Vec<_> = unsafe_blocks.iter().collect();
645-
unsafe_blocks.sort_by_cached_key(|(hir_id, _)| tcx.hir().hir_id_to_node_id(*hir_id));
646-
let used_unsafe: FxHashSet<_> =
647-
unsafe_blocks.iter().flat_map(|&&(id, used)| used.then_some(id)).collect();
648-
for &(block_id, is_used) in unsafe_blocks {
649-
if !is_used {
650-
report_unused_unsafe(tcx, &used_unsafe, block_id);
644+
let (mut unsafe_used, mut unsafe_unused): (FxHashSet<_>, Vec<_>) = Default::default();
645+
for &(block_id, is_used) in unsafe_blocks.iter() {
646+
if is_used {
647+
unsafe_used.insert(block_id);
648+
} else {
649+
unsafe_unused.push(block_id);
651650
}
652651
}
652+
// The unused unsafe blocks might not be in source order; sort them so that the unused unsafe
653+
// error messages are properly aligned and the issue-45107 and lint-unused-unsafe tests pass.
654+
unsafe_unused.sort_by_cached_key(|hir_id| tcx.hir().span(*hir_id));
655+
656+
for &block_id in &unsafe_unused {
657+
report_unused_unsafe(tcx, &unsafe_used, block_id);
658+
}
653659
}

‎src/librustdoc/clean/mod.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,11 @@ impl Clean<Lifetime> for hir::Lifetime {
377377
fn clean(&self, cx: &DocContext<'_>) -> Lifetime {
378378
let def = cx.tcx.named_region(self.hir_id);
379379
match def {
380-
Some(rl::Region::EarlyBound(_, node_id, _))
381-
| Some(rl::Region::LateBound(_, node_id, _))
382-
| Some(rl::Region::Free(_, node_id)) => {
380+
Some(
381+
rl::Region::EarlyBound(_, node_id, _)
382+
| rl::Region::LateBound(_, node_id, _)
383+
| rl::Region::Free(_, node_id),
384+
) => {
383385
if let Some(lt) = cx.lt_substs.borrow().get(&node_id).cloned() {
384386
return lt;
385387
}

‎src/librustdoc/clean/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ pub fn resolve_type(cx: &DocContext<'_>, path: Path, id: hir::HirId) -> Type {
586586
Res::Def(DefKind::TyParam, _) if path.segments.len() == 1 => {
587587
return Generic(format!("{:#}", path.print()));
588588
}
589-
Res::SelfTy(..) | Res::Def(DefKind::TyParam, _) | Res::Def(DefKind::AssocTy, _) => true,
589+
Res::SelfTy(..) | Res::Def(DefKind::TyParam | DefKind::AssocTy, _) => true,
590590
_ => false,
591591
};
592592
let did = register_res(&*cx, path.res);

‎src/librustdoc/html/highlight.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,7 @@ impl<'a> Classifier<'a> {
235235
// If this '&' or '*' token is followed by a non-whitespace token, assume that it's the
236236
// reference or dereference operator or a reference or pointer type, instead of the
237237
// bit-and or multiplication operator.
238-
token::BinOp(token::And) | token::BinOp(token::Star)
239-
if self.peek()? != &token::Whitespace =>
240-
{
238+
token::BinOp(token::And | token::Star) if self.peek()? != &token::Whitespace => {
241239
Class::RefKeyWord
242240
}
243241

@@ -275,9 +273,7 @@ impl<'a> Classifier<'a> {
275273
| token::ModSep
276274
| token::LArrow
277275
| token::OpenDelim(_)
278-
| token::CloseDelim(token::Brace)
279-
| token::CloseDelim(token::Paren)
280-
| token::CloseDelim(token::NoDelim) => Class::None,
276+
| token::CloseDelim(token::Brace | token::Paren | token::NoDelim) => Class::None,
281277

282278
token::Question => Class::QuestionMark,
283279

‎src/librustdoc/html/markdown.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ pub fn plain_summary_line(md: &str) -> String {
850850
Event::Start(Tag::Heading(_)) => (None, 1),
851851
Event::Code(code) => (Some(format!("`{}`", code)), 0),
852852
Event::Text(ref s) if self.is_in > 0 => (Some(s.as_ref().to_owned()), 0),
853-
Event::End(Tag::Paragraph) | Event::End(Tag::Heading(_)) => (None, -1),
853+
Event::End(Tag::Paragraph | Tag::Heading(_)) => (None, -1),
854854
_ => (None, 0),
855855
};
856856
if is_in > 0 || (is_in < 0 && self.is_in > 0) {
@@ -909,7 +909,7 @@ pub fn markdown_links(md: &str) -> Vec<(String, Option<Range<usize>>)> {
909909
debug!("found link: {}", dest);
910910
links.push(match dest {
911911
CowStr::Borrowed(s) => (s.to_owned(), locate(s)),
912-
s @ CowStr::Boxed(..) | s @ CowStr::Inlined(..) => (s.into_string(), None),
912+
s @ (CowStr::Boxed(..) | CowStr::Inlined(..)) => (s.into_string(), None),
913913
});
914914
}
915915
}

‎src/librustdoc/html/render/cache.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,13 @@ impl DocFolder for Cache {
294294
// for where the type was defined. On the other
295295
// hand, `paths` always has the right
296296
// information if present.
297-
Some(&(ref fqp, ItemType::Trait))
298-
| Some(&(ref fqp, ItemType::Struct))
299-
| Some(&(ref fqp, ItemType::Union))
300-
| Some(&(ref fqp, ItemType::Enum)) => Some(&fqp[..fqp.len() - 1]),
297+
Some(&(
298+
ref fqp,
299+
ItemType::Trait
300+
| ItemType::Struct
301+
| ItemType::Union
302+
| ItemType::Enum,
303+
)) => Some(&fqp[..fqp.len() - 1]),
301304
Some(..) => Some(&*self.stack),
302305
None => None,
303306
};

‎src/librustdoc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#![feature(box_syntax)]
88
#![feature(in_band_lifetimes)]
99
#![feature(nll)]
10+
#![feature(or_patterns)]
1011
#![feature(test)]
1112
#![feature(vec_remove_item)]
1213
#![feature(ptr_offset_from)]

‎src/librustdoc/passes/collect_intra_doc_links.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
149149
// In case this is a trait item, skip the
150150
// early return and try looking for the trait.
151151
let value = match res {
152-
Res::Def(DefKind::AssocFn, _) | Res::Def(DefKind::AssocConst, _) => true,
152+
Res::Def(DefKind::AssocFn | DefKind::AssocConst, _) => true,
153153
Res::Def(DefKind::AssocTy, _) => false,
154154
Res::Def(DefKind::Variant, _) => {
155155
return handle_variant(cx, res, extra_fragment);
@@ -226,10 +226,10 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
226226
}
227227
let ty_res = ty_res.map_id(|_| panic!("unexpected node_id"));
228228
match ty_res {
229-
Res::Def(DefKind::Struct, did)
230-
| Res::Def(DefKind::Union, did)
231-
| Res::Def(DefKind::Enum, did)
232-
| Res::Def(DefKind::TyAlias, did) => {
229+
Res::Def(
230+
DefKind::Struct | DefKind::Union | DefKind::Enum | DefKind::TyAlias,
231+
did,
232+
) => {
233233
let item = cx
234234
.tcx
235235
.inherent_impls(did)
@@ -814,7 +814,7 @@ fn ambiguity_error(
814814

815815
for (res, ns) in candidates {
816816
let (action, mut suggestion) = match res {
817-
Res::Def(DefKind::AssocFn, _) | Res::Def(DefKind::Fn, _) => {
817+
Res::Def(DefKind::AssocFn | DefKind::Fn, _) => {
818818
("add parentheses", format!("{}()", path_str))
819819
}
820820
Res::Def(DefKind::Macro(..), _) => {

‎src/librustdoc/visit_ast.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,15 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
309309
let attrs = clean::inline::load_attrs(self.cx, res_did);
310310
let self_is_hidden = attrs.lists(sym::doc).has_word(sym::hidden);
311311
match res {
312-
Res::Def(DefKind::Trait, did)
313-
| Res::Def(DefKind::Struct, did)
314-
| Res::Def(DefKind::Union, did)
315-
| Res::Def(DefKind::Enum, did)
316-
| Res::Def(DefKind::ForeignTy, did)
317-
| Res::Def(DefKind::TyAlias, did)
318-
if !self_is_hidden =>
319-
{
312+
Res::Def(
313+
DefKind::Trait
314+
| DefKind::Struct
315+
| DefKind::Union
316+
| DefKind::Enum
317+
| DefKind::ForeignTy
318+
| DefKind::TyAlias,
319+
did,
320+
) if !self_is_hidden => {
320321
self.cx.renderinfo.get_mut().access_levels.map.insert(did, AccessLevel::Public);
321322
}
322323
Res::Def(DefKind::Mod, did) => {

‎src/test/ui/async-await/no-params-non-move-async-closure.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ LL | let _ = async |x: u8| {};
88

99
error: aborting due to previous error
1010

11+
For more information about this error, try `rustc --explain E0708`.

0 commit comments

Comments
 (0)
Please sign in to comment.