diff options
| author | bors <bors@rust-lang.org> | 2021-11-14 01:06:05 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-11-14 01:06:05 +0000 |
| commit | 589ad6a5b7328867d08cbd16863e7f49e720f4d7 (patch) | |
| tree | 93eac15d9196c6546d051baaf46c52d2fb4e5ff8 | |
| parent | b416e3892d9526709f3a248f5ed3a43a970f795e (diff) | |
| parent | c677a8da86e8bc5fb2a2c0fec54e0e71c2caca97 (diff) | |
| download | rust-589ad6a5b7328867d08cbd16863e7f49e720f4d7.tar.gz rust-589ad6a5b7328867d08cbd16863e7f49e720f4d7.zip | |
Auto merge of #90883 - matthiaskrgr:rollup-iu9k5pe, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - #90771 (Fix trait object error code) - #90840 (relate lifetime in `TypeOutlives` bounds on drop impls) - #90853 (rustdoc: Use an empty Vec instead of Option<Vec>) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
| -rw-r--r-- | compiler/rustc_typeck/src/check/dropck.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/html/render/cache.rs | 1 | ||||
| -rw-r--r-- | src/librustdoc/html/render/mod.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/dropck/relate_lt_in_type_outlives_bound.rs | 13 | ||||
| -rw-r--r-- | src/test/ui/dropck/relate_lt_in_type_outlives_bound.stderr | 17 | ||||
| -rw-r--r-- | src/test/ui/editions/dyn-trait-sugg-2021.stderr | 4 |
7 files changed, 46 insertions, 18 deletions
diff --git a/compiler/rustc_typeck/src/check/dropck.rs b/compiler/rustc_typeck/src/check/dropck.rs index bfa0d92ab47..4b4d29307ff 100644 --- a/compiler/rustc_typeck/src/check/dropck.rs +++ b/compiler/rustc_typeck/src/check/dropck.rs @@ -240,8 +240,12 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>( ty::PredicateKind::ConstEvaluatable(a), ty::PredicateKind::ConstEvaluatable(b), ) => tcx.try_unify_abstract_consts((a, b)), - (ty::PredicateKind::TypeOutlives(a), ty::PredicateKind::TypeOutlives(b)) => { - relator.relate(predicate.rebind(a.0), p.rebind(b.0)).is_ok() + ( + ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_a, lt_a)), + ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_b, lt_b)), + ) => { + relator.relate(predicate.rebind(ty_a), p.rebind(ty_b)).is_ok() + && relator.relate(predicate.rebind(lt_a), p.rebind(lt_b)).is_ok() } _ => predicate == p, } diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs index 93b2a595259..aae59eee991 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs @@ -952,7 +952,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut err = rustc_errors::struct_span_err!( self.sess(), self_ty.span, - E0783, + E0782, "{}", msg, ); diff --git a/src/librustdoc/html/render/cache.rs b/src/librustdoc/html/render/cache.rs index b52369773fe..9164916af09 100644 --- a/src/librustdoc/html/render/cache.rs +++ b/src/librustdoc/html/render/cache.rs @@ -205,7 +205,6 @@ crate fn get_index_search_type<'tcx>( inputs.retain(|a| a.ty.name.is_some()); output.retain(|a| a.ty.name.is_some()); - let output = if output.is_empty() { None } else { Some(output) }; Some(IndexItemFunctionType { inputs, output }) } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index e7904aeedd4..dd592de41bd 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -117,7 +117,7 @@ crate struct RenderType { #[derive(Debug)] crate struct IndexItemFunctionType { inputs: Vec<TypeWithKind>, - output: Option<Vec<TypeWithKind>>, + output: Vec<TypeWithKind>, } impl Serialize for IndexItemFunctionType { @@ -126,21 +126,16 @@ impl Serialize for IndexItemFunctionType { S: Serializer, { // If we couldn't figure out a type, just write `null`. - let mut iter = self.inputs.iter(); - if match self.output { - Some(ref output) => iter.chain(output.iter()).any(|i| i.ty.name.is_none()), - None => iter.any(|i| i.ty.name.is_none()), - } { + let has_missing = self.inputs.iter().chain(self.output.iter()).any(|i| i.ty.name.is_none()); + if has_missing { serializer.serialize_none() } else { let mut seq = serializer.serialize_seq(None)?; seq.serialize_element(&self.inputs)?; - if let Some(output) = &self.output { - if output.len() > 1 { - seq.serialize_element(&output)?; - } else { - seq.serialize_element(&output[0])?; - } + match self.output.as_slice() { + [] => {} + [one] => seq.serialize_element(one)?, + all => seq.serialize_element(all)?, } seq.end() } diff --git a/src/test/ui/dropck/relate_lt_in_type_outlives_bound.rs b/src/test/ui/dropck/relate_lt_in_type_outlives_bound.rs new file mode 100644 index 00000000000..42530d31730 --- /dev/null +++ b/src/test/ui/dropck/relate_lt_in_type_outlives_bound.rs @@ -0,0 +1,13 @@ +struct Wrapper<'a, T>(&'a T) +where + T: 'a; + +impl<'a, T> Drop for Wrapper<'a, T> +where + T: 'static, + //~^ error: `Drop` impl requires `T: 'static` but the struct it is implemented for does not +{ + fn drop(&mut self) {} +} + +fn main() {} diff --git a/src/test/ui/dropck/relate_lt_in_type_outlives_bound.stderr b/src/test/ui/dropck/relate_lt_in_type_outlives_bound.stderr new file mode 100644 index 00000000000..5176684e153 --- /dev/null +++ b/src/test/ui/dropck/relate_lt_in_type_outlives_bound.stderr @@ -0,0 +1,17 @@ +error[E0367]: `Drop` impl requires `T: 'static` but the struct it is implemented for does not + --> $DIR/relate_lt_in_type_outlives_bound.rs:7:8 + | +LL | T: 'static, + | ^^^^^^^ + | +note: the implementor must specify the same requirement + --> $DIR/relate_lt_in_type_outlives_bound.rs:1:1 + | +LL | / struct Wrapper<'a, T>(&'a T) +LL | | where +LL | | T: 'a; + | |__________^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0367`. diff --git a/src/test/ui/editions/dyn-trait-sugg-2021.stderr b/src/test/ui/editions/dyn-trait-sugg-2021.stderr index f6e9fa96a15..a7119b073ab 100644 --- a/src/test/ui/editions/dyn-trait-sugg-2021.stderr +++ b/src/test/ui/editions/dyn-trait-sugg-2021.stderr @@ -1,4 +1,4 @@ -error[E0783]: trait objects without an explicit `dyn` are deprecated +error[E0782]: trait objects without an explicit `dyn` are deprecated --> $DIR/dyn-trait-sugg-2021.rs:10:5 | LL | Foo::hi(123); @@ -6,4 +6,4 @@ LL | Foo::hi(123); error: aborting due to previous error -For more information about this error, try `rustc --explain E0783`. +For more information about this error, try `rustc --explain E0782`. |
