diff options
| author | bors <bors@rust-lang.org> | 2020-08-02 01:04:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-08-02 01:04:54 +0000 |
| commit | e18b56345f06c12be4dba9b5d76f306cdf0ab7f9 (patch) | |
| tree | 80be2e591c7eea519d4bb3041578297e02514f15 /src | |
| parent | 5ef872f9619ed78a349c1407ebac719a980209ee (diff) | |
| parent | 82147885bbd373f5f6803bdbc497debb90ca915e (diff) | |
| download | rust-e18b56345f06c12be4dba9b5d76f306cdf0ab7f9.tar.gz rust-e18b56345f06c12be4dba9b5d76f306cdf0ab7f9.zip | |
Auto merge of #75033 - Manishearth:rollup-d8afil1, r=Manishearth
Rollup of 5 pull requests Successful merges: - #74602 (Clarify the doc for MaybeUninit::zeroed on incorrect use) - #74720 (Clean up E0728 explanation) - #74992 (fix rustdoc generic param order) - #75015 (Add Vec::spare_capacity_mut) - #75022 (Use a slice pattern instead of rchunks_exact(_).next()) Failed merges: r? @ghost
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0728.md | 6 | ||||
| -rw-r--r-- | src/librustc_privacy/lib.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/clean/auto_trait.rs | 5 | ||||
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 23 | ||||
| -rw-r--r-- | src/librustdoc/clean/simplify.rs | 13 | ||||
| -rw-r--r-- | src/test/rustdoc/const-generics/const-impl.rs | 4 |
6 files changed, 19 insertions, 34 deletions
diff --git a/src/librustc_error_codes/error_codes/E0728.md b/src/librustc_error_codes/error_codes/E0728.md index 1afbedab0ca..f4968a4f00e 100644 --- a/src/librustc_error_codes/error_codes/E0728.md +++ b/src/librustc_error_codes/error_codes/E0728.md @@ -1,6 +1,6 @@ -[`await`] has been used outside [`async`] function or block. +[`await`] has been used outside [`async`] function or [`async`] block. -Erroneous code examples: +Erroneous code example: ```edition2018,compile_fail,E0728 # use std::pin::Pin; @@ -33,7 +33,7 @@ fn foo() { [`await`] is used to suspend the current computation until the given future is ready to produce a value. So it is legal only within -an [`async`] context, like an `async fn` or an `async` block. +an [`async`] context, like an `async` function or an `async` block. ```edition2018 # use std::pin::Pin; diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 9c5fb4ce734..fc00050f405 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -637,7 +637,7 @@ impl EmbargoVisitor<'tcx> { &mut self, segments: &[hir::PathSegment<'_>], ) { - if let Some([module, segment]) = segments.rchunks_exact(2).next() { + if let [.., module, segment] = segments { if let Some(item) = module .res .and_then(|res| res.mod_def_id()) diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index b170b413146..9c44d27447d 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -480,6 +480,11 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { .clean(self.cx) .params; + debug!( + "param_env_to_generics({:?}): generic_params={:?}", + param_env_def_id, generic_params + ); + let mut has_sized = FxHashSet::default(); let mut ty_to_bounds: FxHashMap<_, FxHashSet<_>> = Default::default(); let mut lifetime_to_bounds: FxHashMap<_, FxHashSet<_>> = Default::default(); diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index cc3a60c596a..5b048372624 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -716,11 +716,11 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx // Bounds in the type_params and lifetimes fields are repeated in the // predicates field (see rustc_typeck::collect::ty_generics), so remove // them. - let stripped_typarams = gens + let stripped_params = gens .params .iter() .filter_map(|param| match param.kind { - ty::GenericParamDefKind::Lifetime => None, + ty::GenericParamDefKind::Lifetime => Some(param.clean(cx)), ty::GenericParamDefKind::Type { synthetic, .. } => { if param.name == kw::SelfUpper { assert_eq!(param.index, 0); @@ -732,7 +732,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx } Some(param.clean(cx)) } - ty::GenericParamDefKind::Const { .. } => None, + ty::GenericParamDefKind::Const { .. } => Some(param.clean(cx)), }) .collect::<Vec<GenericParamDef>>(); @@ -844,8 +844,10 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx // Run through the type parameters again and insert a ?Sized // unbound for any we didn't find to be Sized. - for tp in &stripped_typarams { - if !sized_params.contains(&tp.name) { + for tp in &stripped_params { + if matches!(tp.kind, types::GenericParamDefKind::Type { .. }) + && !sized_params.contains(&tp.name) + { where_predicates.push(WP::BoundPredicate { ty: Type::Generic(tp.name.clone()), bounds: vec![GenericBound::maybe_sized(cx)], @@ -858,16 +860,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx // and instead see `where T: Foo + Bar + Sized + 'a` Generics { - params: gens - .params - .iter() - .flat_map(|param| match param.kind { - ty::GenericParamDefKind::Lifetime => Some(param.clean(cx)), - ty::GenericParamDefKind::Type { .. } => None, - ty::GenericParamDefKind::Const { .. } => Some(param.clean(cx)), - }) - .chain(simplify::ty_params(stripped_typarams).into_iter()) - .collect(), + params: stripped_params, where_predicates: simplify::where_clauses(cx, where_predicates), } } diff --git a/src/librustdoc/clean/simplify.rs b/src/librustdoc/clean/simplify.rs index 0f995a60c22..990189f6ea0 100644 --- a/src/librustdoc/clean/simplify.rs +++ b/src/librustdoc/clean/simplify.rs @@ -12,7 +12,6 @@ //! bounds by special casing scenarios such as these. Fun! use std::collections::BTreeMap; -use std::mem; use rustc_hir::def_id::DefId; use rustc_middle::ty; @@ -118,18 +117,6 @@ pub fn merge_bounds( }) } -pub fn ty_params(mut params: Vec<clean::GenericParamDef>) -> Vec<clean::GenericParamDef> { - for param in &mut params { - match param.kind { - clean::GenericParamDefKind::Type { ref mut bounds, .. } => { - *bounds = mem::take(bounds); - } - _ => panic!("expected only type parameters"), - } - } - params -} - fn trait_is_same_or_supertrait(cx: &DocContext<'_>, child: DefId, trait_: DefId) -> bool { if child == trait_ { return true; diff --git a/src/test/rustdoc/const-generics/const-impl.rs b/src/test/rustdoc/const-generics/const-impl.rs index 7361b22b747..03f5bb2ca43 100644 --- a/src/test/rustdoc/const-generics/const-impl.rs +++ b/src/test/rustdoc/const-generics/const-impl.rs @@ -11,8 +11,8 @@ pub enum Order { } // @has foo/struct.VSet.html '//pre[@class="rust struct"]' 'pub struct VSet<T, const ORDER: Order>' -// @has foo/struct.VSet.html '//h3[@id="impl-Send"]/code' 'impl<const ORDER: Order, T> Send for VSet<T, ORDER>' -// @has foo/struct.VSet.html '//h3[@id="impl-Sync"]/code' 'impl<const ORDER: Order, T> Sync for VSet<T, ORDER>' +// @has foo/struct.VSet.html '//h3[@id="impl-Send"]/code' 'impl<T, const ORDER: Order> Send for VSet<T, ORDER>' +// @has foo/struct.VSet.html '//h3[@id="impl-Sync"]/code' 'impl<T, const ORDER: Order> Sync for VSet<T, ORDER>' pub struct VSet<T, const ORDER: Order> { inner: Vec<T>, } |
