From 0950d5afe227c7097e59bf797a85267d3a659744 Mon Sep 17 00:00:00 2001 From: Tom Farmer Date: Tue, 5 Oct 2021 18:53:24 +0100 Subject: Issue 89275 fix and test Issue 89275 fix and test Fix librustdoc OverflowError usage rust tidy run Issue 89275 fix and test --- src/librustdoc/clean/blanket_impl.rs | 3 ++- src/test/ui/typeck/issue-89275.rs | 29 +++++++++++++++++++++++++++++ src/test/ui/typeck/issue-89275.stderr | 14 ++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/typeck/issue-89275.rs create mode 100644 src/test/ui/typeck/issue-89275.stderr (limited to 'src') diff --git a/src/librustdoc/clean/blanket_impl.rs b/src/librustdoc/clean/blanket_impl.rs index 8135d4a2085..c2c1d369d6e 100644 --- a/src/librustdoc/clean/blanket_impl.rs +++ b/src/librustdoc/clean/blanket_impl.rs @@ -78,7 +78,8 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> { ); match infcx.evaluate_obligation(&obligation) { Ok(eval_result) if eval_result.may_apply() => {} - Err(traits::OverflowError) => {} + Err(traits::OverflowError::Cannonical) => {} + Err(traits::OverflowError::ErrorReporting) => {} _ => { return false; } diff --git a/src/test/ui/typeck/issue-89275.rs b/src/test/ui/typeck/issue-89275.rs new file mode 100644 index 00000000000..b91c0017548 --- /dev/null +++ b/src/test/ui/typeck/issue-89275.rs @@ -0,0 +1,29 @@ +#![recursion_limit = "5"] // To reduce noise + +//expect mutability error when ambiguous traits are in scope +//and not an overflow error on the span in the main function. + +struct Ratio(T); + +pub trait Pow { + fn pow(self) -> Self; +} + +impl<'a, T> Pow for &'a Ratio +where + &'a T: Pow, +{ + fn pow(self) -> Self { + self + } +} + +fn downcast<'a, W: ?Sized>() -> &'a W { + todo!() +} + +struct Other; + +fn main() { + let other: &mut Other = downcast();//~ERROR 28:29: 28:39: mismatched types [E0308] +} diff --git a/src/test/ui/typeck/issue-89275.stderr b/src/test/ui/typeck/issue-89275.stderr new file mode 100644 index 00000000000..d73e647d21f --- /dev/null +++ b/src/test/ui/typeck/issue-89275.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/issue-89275.rs:28:29 + | +LL | let other: &mut Other = downcast(); + | ---------- ^^^^^^^^^^ types differ in mutability + | | + | expected due to this + | + = note: expected mutable reference `&mut Other` + found reference `&_` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. -- cgit 1.4.1-3-g733a5