Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use smaller spans for missing lifetime/generic args #106533

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -597,11 +597,15 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
let span = self.path_segment.ident.span;

// insert a suggestion of the form "Y<'a, 'b>"
let ident = self.path_segment.ident.name.to_ident_string();
let sugg = format!("{}<{}>", ident, suggested_args);
let sugg = format!("<{}>", suggested_args);
debug!("sugg: {:?}", sugg);

err.span_suggestion_verbose(span, &msg, sugg, Applicability::HasPlaceholders);
err.span_suggestion_verbose(
span.shrink_to_hi(),
&msg,
sugg,
Applicability::HasPlaceholders,
);
}

AngleBrackets::Available => {
Expand Down Expand Up @@ -643,11 +647,15 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
let span = self.path_segment.ident.span;

// insert a suggestion of the form "Y<T, U>"
let ident = self.path_segment.ident.name.to_ident_string();
let sugg = format!("{}<{}>", ident, suggested_args);
let sugg = format!("<{}>", suggested_args);
debug!("sugg: {:?}", sugg);

err.span_suggestion_verbose(span, &msg, sugg, Applicability::HasPlaceholders);
err.span_suggestion_verbose(
span.shrink_to_hi(),
&msg,
sugg,
Applicability::HasPlaceholders,
);
}
AngleBrackets::Available => {
let gen_args_span = self.gen_args.span().unwrap();
Expand Down
44 changes: 22 additions & 22 deletions src/test/rustdoc-ui/issue-105742.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | type Item<'a, T>;
help: add missing lifetime argument
|
LL | <Self as SVec>::Item<'a>,
| ~~~~~~~~
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:13:21
Expand All @@ -28,7 +28,7 @@ LL | type Item<'a, T>;
help: add missing generic argument
|
LL | <Self as SVec>::Item<T>,
| ~~~~~~~
| +++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:18:37
Expand All @@ -44,7 +44,7 @@ LL | type Item<'a, T>;
help: add missing lifetime argument
|
LL | Output = <Index<<Self as SVec>::Item<'a>,
| ~~~~~~~~
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:18:37
Expand All @@ -60,7 +60,7 @@ LL | type Item<'a, T>;
help: add missing generic argument
|
LL | Output = <Index<<Self as SVec>::Item<T>,
| ~~~~~~~
| +++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:23:30
Expand All @@ -76,7 +76,7 @@ LL | type Item<'a, T>;
help: add missing lifetime argument
|
LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item,
| ~~~~~~~~
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:23:30
Expand All @@ -92,7 +92,7 @@ LL | type Item<'a, T>;
help: add missing generic argument
|
LL | Output = <Self as SVec>::Item<T>> as SVec>::Item,
| ~~~~~~~
| +++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:23:46
Expand All @@ -108,7 +108,7 @@ LL | type Item<'a, T>;
help: add missing lifetime argument
|
LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>,
| ~~~~~~~~
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:23:46
Expand All @@ -124,7 +124,7 @@ LL | type Item<'a, T>;
help: add missing generic argument
|
LL | Output = <Self as SVec>::Item> as SVec>::Item<T>,
| ~~~~~~~
| +++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:5:40
Expand All @@ -140,7 +140,7 @@ LL | type Item<'a, T>;
help: add missing lifetime argument
|
LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item<'_> = T, Output = T>) {
| ~~~~~~~~
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:5:40
Expand All @@ -156,7 +156,7 @@ LL | type Item<'a, T>;
help: add missing generic argument
|
LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item<T> = T, Output = T>) {
| ~~~~~~~
| +++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:13:21
Expand All @@ -172,7 +172,7 @@ LL | type Item<'a, T>;
help: add missing lifetime argument
|
LL | <Self as SVec>::Item<'a>,
| ~~~~~~~~
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:13:21
Expand All @@ -188,7 +188,7 @@ LL | type Item<'a, T>;
help: add missing generic argument
|
LL | <Self as SVec>::Item<T>,
| ~~~~~~~
| +++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:18:37
Expand All @@ -204,7 +204,7 @@ LL | type Item<'a, T>;
help: add missing lifetime argument
|
LL | Output = <Index<<Self as SVec>::Item<'a>,
| ~~~~~~~~
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:18:37
Expand All @@ -220,7 +220,7 @@ LL | type Item<'a, T>;
help: add missing generic argument
|
LL | Output = <Index<<Self as SVec>::Item<T>,
| ~~~~~~~
| +++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:23:30
Expand All @@ -236,7 +236,7 @@ LL | type Item<'a, T>;
help: add missing lifetime argument
|
LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item,
| ~~~~~~~~
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:23:30
Expand All @@ -252,7 +252,7 @@ LL | type Item<'a, T>;
help: add missing generic argument
|
LL | Output = <Self as SVec>::Item<T>> as SVec>::Item,
| ~~~~~~~
| +++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:23:46
Expand All @@ -268,7 +268,7 @@ LL | type Item<'a, T>;
help: add missing lifetime argument
|
LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>,
| ~~~~~~~~
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:23:46
Expand All @@ -284,7 +284,7 @@ LL | type Item<'a, T>;
help: add missing generic argument
|
LL | Output = <Self as SVec>::Item> as SVec>::Item<T>,
| ~~~~~~~
| +++

error[E0038]: the trait `SVec` cannot be made into an object
--> $DIR/issue-105742.rs:5:31
Expand Down Expand Up @@ -329,7 +329,7 @@ LL | type Item<'a, T>;
help: add missing lifetime argument
|
LL | fn len(&self) -> <Self as SVec>::Item<'_>;
| ~~~~~~~~
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:35:38
Expand All @@ -345,7 +345,7 @@ LL | type Item<'a, T>;
help: add missing generic argument
|
LL | fn len(&self) -> <Self as SVec>::Item<T>;
| ~~~~~~~
| +++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:35:38
Expand All @@ -361,7 +361,7 @@ LL | type Item<'a, T>;
help: add missing lifetime argument
|
LL | fn len(&self) -> <Self as SVec>::Item<'_>;
| ~~~~~~~~
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:35:38
Expand All @@ -377,7 +377,7 @@ LL | type Item<'a, T>;
help: add missing generic argument
|
LL | fn len(&self) -> <Self as SVec>::Item<T>;
| ~~~~~~~
| +++

error: aborting due to 23 previous errors

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/consts/issue-103790.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ LL | struct S<const S: (), const S: S = { S }>;
help: add missing generic argument
|
LL | struct S<const S: (), const S: S<S> = { S }>;
| ~~~~
| +++

error[E0391]: cycle detected when computing type of `S::S`
--> $DIR/issue-103790.rs:4:32
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | type Assoc<'a> where Self: 'a;
help: add missing lifetime argument
|
LL | fn g(&self) -> Self::Assoc<'_>;
| ~~~~~~~~~
| ++++

error[E0107]: missing generics for associated type `Trait::Assoc`
--> $DIR/elided-in-expr-position.rs:31:26
Expand All @@ -28,7 +28,7 @@ LL | type Assoc<'a> where Self: 'a;
help: add missing lifetime argument
|
LL | fn g(&self) -> Self::Assoc<'_> {
| ~~~~~~~~~
| ++++

error: aborting due to 2 previous errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | type Y<'a>;
help: add missing lifetime argument
|
LL | fn foo<'a, T1: X<Y<'a> = T1>>(t : T1) -> T1::Y<'a> {
| ~~~~~
| ++++

error[E0107]: missing generics for associated type `X::Y`
--> $DIR/gat-trait-path-missing-lifetime.rs:8:20
Expand All @@ -28,7 +28,7 @@ LL | type Y<'a>;
help: add missing lifetime argument
|
LL | fn foo<'a, T1: X<Y<'a> = T1>>(t : T1) -> T1::Y<'a> {
| ~~~~~
| ++++

error: aborting due to 2 previous errors

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/generic-associated-types/issue-71176.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | type A<'a>;
help: add missing lifetime argument
|
LL | inner: Box<dyn Provider<A<'a> = B>>,
| ~~~~~
| ++++

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | type SubType<'a>: SubTrait where Self: 'a;
help: add missing lifetime argument
|
LL | let sub: Box<dyn SuperTrait<SubType<'a> = SubStruct>> = Box::new(SuperStruct::new(0));
| ~~~~~~~~~~~
| ++++

error[E0038]: the trait `SuperTrait` cannot be made into an object
--> $DIR/issue-76535.rs:39:14
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | type SubType<'a>: SubTrait where Self: 'a;
help: add missing lifetime argument
|
LL | let sub: Box<dyn SuperTrait<SubType<'a> = SubStruct>> = Box::new(SuperStruct::new(0));
| ~~~~~~~~~~~
| ++++

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | type Member<T>;
help: add missing generic argument
|
LL | Box::new(Family) as &dyn CollectionFamily<Member<T>=usize>
| ~~~~~~~~~
| +++

error[E0038]: the trait `CollectionFamily` cannot be made into an object
--> $DIR/issue-78671.rs:10:25
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | type Member<T>;
help: add missing generic argument
|
LL | Box::new(Family) as &dyn CollectionFamily<Member<T>=usize>
| ~~~~~~~~~
| +++

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
help: add missing lifetime argument
|
LL | as Box<dyn MapLike<u8, u8, VRefCont<'a> = dyn RefCont<'_, u8>>>;
| ~~~~~~~~~~~~
| ++++

error[E0038]: the trait `MapLike` cannot be made into an object
--> $DIR/issue-79422.rs:47:12
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
help: add missing lifetime argument
|
LL | as Box<dyn MapLike<u8, u8, VRefCont<'a> = dyn RefCont<'_, u8>>>;
| ~~~~~~~~~~~~
| ++++

error[E0271]: type mismatch resolving `<BTreeMap<u8, u8> as MapLike<u8, u8>>::VRefCont<'_> == (dyn RefCont<'_, u8> + 'static)`
--> $DIR/issue-79422.rs:44:13
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/generic-associated-types/issue-79636-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | type Wrapped<B>;
help: add missing generic argument
|
LL | MInner: Monad<Unwrapped = A, Wrapped<B> = MOuter::Wrapped<A>>,
| ~~~~~~~~~~
| +++

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/generic-associated-types/issue-79636-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | type Wrapped<A>: SomeTrait;
help: add missing generic argument
|
LL | W: SomeTrait<Wrapped<A> = W>,
| ~~~~~~~~~~
| +++

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/generic-associated-types/issue-80433.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | type Output<'a>;
help: add missing lifetime argument
|
LL | fn test_simpler<'a>(dst: &'a mut impl TestMut<Output<'a> = &'a mut f32>)
| ~~~~~~~~~~
| ++++

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | type DType<T>: D<T, CType = Self>;
help: add missing generic argument
|
LL | type CType: C<DType<T> = Self>;
| ~~~~~~~~
| +++

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/generic-associated-types/issue-81862.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | type Item<'a>;
help: add missing lifetime argument
|
LL | fn next(&mut self) -> Option<Self::Item<'_>>;
| ~~~~~~~~
| ++++

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | type Y<'a, 'b>;
help: add missing lifetime arguments
|
LL | fn foo<'c, 'd>(_arg: Box<dyn X<Y<'_, '_> = (&'c u32, &'d u32)>>) {}
| ~~~~~~~~~
| ++++++++

error[E0107]: this struct takes 3 lifetime arguments but 2 lifetime arguments were supplied
--> $DIR/missing_lifetime_args.rs:14:26
Expand Down
Loading