diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2019-10-15 13:29:07 -0700 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2019-10-15 13:55:44 -0700 |
| commit | 9ed463a7404f7f3ecf65ca270f360b2da90b467a (patch) | |
| tree | d587c44a608c0672f2be00cdff2ba4d0027c9814 /src | |
| parent | 9c525ee95bcc99730003e2d4bbb58520337bdefc (diff) | |
| download | rust-9ed463a7404f7f3ecf65ca270f360b2da90b467a.tar.gz rust-9ed463a7404f7f3ecf65ca270f360b2da90b467a.zip | |
Do not suggest restriction on spans originating in macros
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/traits/error_reporting.rs | 31 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-38821.stderr | 4 |
2 files changed, 18 insertions, 17 deletions
diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 8e9a350030c..d5f22afa9af 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -977,20 +977,23 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { }; let mut suggest_restriction = |generics: &hir::Generics, msg| { - err.span_suggestion( - generics.where_clause.span_for_predicates_or_empty_place().shrink_to_hi(), - &format!("consider further restricting {}", msg), - format!( - "{} {} ", - if !generics.where_clause.predicates.is_empty() { - "," - } else { - " where" - }, - trait_ref.to_predicate(), - ), - Applicability::MachineApplicable, - ); + let span = generics.where_clause.span_for_predicates_or_empty_place(); + if !span.from_expansion() && span.desugaring_kind().is_none() { + err.span_suggestion( + generics.where_clause.span_for_predicates_or_empty_place().shrink_to_hi(), + &format!("consider further restricting {}", msg), + format!( + "{} {} ", + if !generics.where_clause.predicates.is_empty() { + "," + } else { + " where" + }, + trait_ref.to_predicate(), + ), + Applicability::MachineApplicable, + ); + } }; // FIXME: Add check for trait bound that is already present, particularly `?Sized` so we diff --git a/src/test/ui/issues/issue-38821.stderr b/src/test/ui/issues/issue-38821.stderr index 3e2af7c44e4..0687fc940de 100644 --- a/src/test/ui/issues/issue-38821.stderr +++ b/src/test/ui/issues/issue-38821.stderr @@ -2,9 +2,7 @@ error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not sat --> $DIR/issue-38821.rs:23:17 | LL | #[derive(Debug, Copy, Clone)] - | ^^^^- help: consider further restricting the associated type: `, <Col as Expression>::SqlType: NotNull` - | | - | the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` + | ^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` | = note: required because of the requirements on the impl of `IntoNullable` for `<Col as Expression>::SqlType` |
