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

Rollup of 9 pull requests #128142

Merged
merged 27 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
91af6b5
Add edge-case examples to `{count,leading,trailing}_{ones,zeros}` met…
fitzgen Jul 2, 2024
6519c14
Reset sigpipe not supported for vxworks
Jul 8, 2024
287b66b
size_of_val_raw: for length 0 this is safe to call
RalfJung Jun 8, 2024
f6fe7e4
lib: replace some `mem::forget`'s with `ManuallyDrop`
GrigorenkoPV Jul 14, 2024
c807ac0
Use verbose suggestion for "wrong # of generics"
estebank Jul 5, 2024
5c2b36a
Change suggestion message wording
estebank Jul 5, 2024
b30fdec
On generic and lifetime removal suggestion, do not leave behind stray…
estebank Jul 5, 2024
921de9d
Revert suggestion verbosity change
estebank Jul 22, 2024
2561d91
Allow unused unsafe for vxworks in read_at and write at
Jul 23, 2024
a598ca0
Disable dirfd for vxworks, Return unsupported error from set_times an…
Jul 23, 2024
5c9f376
Cfg disable on_broken_pipe_flag_used() for vxworks
Jul 23, 2024
786ad3d
Update process vxworks, set default stack size of 256 Kib for vxworks…
Jul 23, 2024
23e346e
make tidy fast without compromising case alternation
donno2048 Jul 23, 2024
b82f878
Gate AsyncFn* under async_closure feature
compiler-errors Jul 23, 2024
0ea5694
Add chroot unsupported implementation for VxWorks
Jul 24, 2024
9b87fbc
Import `core::ffi::c_void` in more places
ChrisDenton Jul 24, 2024
7cd25b1
Forbid unsafe_op_in_unsafe_fn in sys/pal/windows
ChrisDenton Jul 24, 2024
ac26b88
Improve spans on evaluated `cfg_attr`s.
nnethercote Jul 24, 2024
130d15e
Rollup merge of #126152 - RalfJung:size_of_val_raw, r=saethlin
matthiaskrgr Jul 24, 2024
720c6f1
Rollup merge of #127252 - fitzgen:edge-cases-for-bitwise-operations, …
matthiaskrgr Jul 24, 2024
91c03ef
Rollup merge of #127374 - estebank:wrong-generic-args, r=oli-obk
matthiaskrgr Jul 24, 2024
122b0b2
Rollup merge of #127457 - donno2048:master, r=albertlarsan68
matthiaskrgr Jul 24, 2024
ce523d6
Rollup merge of #127480 - biabbas:vxworks, r=workingjubilee
matthiaskrgr Jul 24, 2024
34abb96
Rollup merge of #127733 - GrigorenkoPV:don't-forget, r=Amanieu
matthiaskrgr Jul 24, 2024
e342efe
Rollup merge of #128120 - compiler-errors:async-fn-name, r=oli-obk
matthiaskrgr Jul 24, 2024
f3a7c3f
Rollup merge of #128131 - ChrisDenton:stuff, r=workingjubilee
matthiaskrgr Jul 24, 2024
2dc88bf
Rollup merge of #128133 - nnethercote:fix-cfg_attr-spans, r=petrochenkov
matthiaskrgr Jul 24, 2024
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
Prev Previous commit
Next Next commit
On generic and lifetime removal suggestion, do not leave behind stray…
… `,`
  • Loading branch information
estebank committed Jul 22, 2024
commit b30fdec5fb283641fc0452fa6ca60193a16bb30d
Original file line number Diff line number Diff line change
Expand Up @@ -939,17 +939,20 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
}
}

let span_lo_redundant_lt_args = lt_arg_spans[self.num_expected_lifetime_args()];
let span_lo_redundant_lt_args = if self.num_expected_lifetime_args() == 0 {
lt_arg_spans[0]
} else {
lt_arg_spans[self.num_expected_lifetime_args() - 1]
};
let span_hi_redundant_lt_args = lt_arg_spans[lt_arg_spans.len() - 1];

let span_redundant_lt_args = span_lo_redundant_lt_args.to(span_hi_redundant_lt_args);
let span_redundant_lt_args =
span_lo_redundant_lt_args.shrink_to_hi().to(span_hi_redundant_lt_args);
debug!("span_redundant_lt_args: {:?}", span_redundant_lt_args);

let num_redundant_lt_args = lt_arg_spans.len() - self.num_expected_lifetime_args();
let msg_lifetimes = format!(
"remove the lifetime argument{s}",
s = pluralize!(num_redundant_lt_args),
);
let msg_lifetimes =
format!("remove the lifetime argument{s}", s = pluralize!(num_redundant_lt_args));

err.span_suggestion_verbose(
span_redundant_lt_args,
Expand Down Expand Up @@ -978,11 +981,16 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
}

let span_lo_redundant_type_or_const_args =
gen_arg_spans[self.num_expected_type_or_const_args()];
if self.num_expected_type_or_const_args() == 0 {
gen_arg_spans[0]
} else {
gen_arg_spans[self.num_expected_type_or_const_args() - 1]
};
let span_hi_redundant_type_or_const_args = gen_arg_spans[gen_arg_spans.len() - 1];
let span_redundant_type_or_const_args = span_lo_redundant_type_or_const_args
.shrink_to_hi()
.to(span_hi_redundant_type_or_const_args);

let span_redundant_type_or_const_args =
span_lo_redundant_type_or_const_args.to(span_hi_redundant_type_or_const_args);
debug!("span_redundant_type_or_const_args: {:?}", span_redundant_type_or_const_args);

let num_redundant_gen_args =
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-ui/mismatched_arg_count.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | type Alias<'a, T> = <T as Trait<'a>>::Assoc;
help: remove the lifetime argument
|
LL - fn bar<'a, T: Trait<'a>>(_: Alias<'a, 'a, T>) {}
LL + fn bar<'a, T: Trait<'a>>(_: Alias<'a, , T>) {}
LL + fn bar<'a, T: Trait<'a>>(_: Alias<'a, T>) {}
|

error: aborting due to 1 previous error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME>,
help: remove the unnecessary generic argument
|
LL - Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME>,
LL + Dst: BikeshedIntrinsicFrom<Src, Context, >,
LL + Dst: BikeshedIntrinsicFrom<Src, Context>,
|

error[E0308]: mismatched types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ LL | struct All<'a, T, const N: usize> {
help: remove the unnecessary generic argument
|
LL - let a: All<_, _, _>;
LL + let a: All<_, _, >;
LL + let a: All<_, _>;
|

error: aborting due to 4 previous errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | fn foo<const N: usize>(
help: remove the unnecessary generic argument
|
LL - foo::<_, L>([(); L + 1 + L]);
LL + foo::<_, >([(); L + 1 + L]);
LL + foo::<_>([(); L + 1 + L]);
|

error[E0308]: mismatched types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ LL | fn foo<const X: usize, const Y: usize>() -> usize {
help: remove the unnecessary generic argument
|
LL - foo::<0, 0, 0>();
LL + foo::<0, 0, >();
LL + foo::<0, 0>();
|

error: aborting due to 2 previous errors
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/const-generics/invalid-constant-in-args.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | let _: Cell<&str, "a"> = Cell::new("");
help: remove the unnecessary generic argument
|
LL - let _: Cell<&str, "a"> = Cell::new("");
LL + let _: Cell<&str, > = Cell::new("");
LL + let _: Cell<&str> = Cell::new("");
|

error: aborting due to 1 previous error
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/constructor-lifetime-args.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ LL | struct S<'a, 'b>(&'a u8, &'b u8);
help: remove the lifetime argument
|
LL - S::<'static, 'static, 'static>(&0, &0);
LL + S::<'static, 'static, >(&0, &0);
LL + S::<'static, 'static>(&0, &0);
|

error[E0107]: enum takes 2 lifetime arguments but 1 lifetime argument was supplied
Expand Down Expand Up @@ -65,7 +65,7 @@ LL | enum E<'a, 'b> {
help: remove the lifetime argument
|
LL - E::V::<'static, 'static, 'static>(&0);
LL + E::V::<'static, 'static, >(&0);
LL + E::V::<'static, 'static>(&0);
|

error: aborting due to 4 previous errors
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/error-codes/E0107.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ LL | struct Foo<'a>(&'a str);
help: remove the lifetime arguments
|
LL - foo2: Foo<'a, 'b, 'c>,
LL + foo2: Foo<'a, >,
LL + foo2: Foo<'a>,
|

error[E0107]: struct takes 1 lifetime argument but 2 lifetime arguments were supplied
Expand All @@ -64,7 +64,7 @@ LL | struct Qux<'a, T>(&'a T);
help: remove the lifetime argument
|
LL - qux1: Qux<'a, 'b, i32>,
LL + qux1: Qux<'a, , i32>,
LL + qux1: Qux<'a, i32>,
|

error[E0107]: struct takes 1 lifetime argument but 2 lifetime arguments were supplied
Expand All @@ -81,7 +81,7 @@ LL | struct Qux<'a, T>(&'a T);
help: remove the lifetime argument
|
LL - qux2: Qux<'a, i32, 'b>,
LL + qux2: Qux<'a, i32, >,
LL + qux2: Qux<'a>,
|

error[E0107]: struct takes 1 lifetime argument but 3 lifetime arguments were supplied
Expand All @@ -98,7 +98,7 @@ LL | struct Qux<'a, T>(&'a T);
help: remove the lifetime arguments
|
LL - qux3: Qux<'a, 'b, 'c, i32>,
LL + qux3: Qux<'a, , i32>,
LL + qux3: Qux<'a, i32>,
|

error[E0107]: struct takes 1 lifetime argument but 3 lifetime arguments were supplied
Expand All @@ -115,7 +115,7 @@ LL | struct Qux<'a, T>(&'a T);
help: remove the lifetime arguments
|
LL - qux4: Qux<'a, i32, 'b, 'c>,
LL + qux4: Qux<'a, i32, >,
LL + qux4: Qux<'a>,
|

error[E0107]: struct takes 1 lifetime argument but 3 lifetime arguments were supplied
Expand All @@ -132,7 +132,7 @@ LL | struct Qux<'a, T>(&'a T);
help: remove the lifetime argument
|
LL - qux5: Qux<'a, 'b, i32, 'c>,
LL + qux5: Qux<'a, , i32, 'c>,
LL + qux5: Qux<'a, i32, 'c>,
|

error[E0107]: struct takes 0 lifetime arguments but 2 lifetime arguments were supplied
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | type E<'a, T>;
help: remove the lifetime argument
|
LL - type FErr1 = Self::E<'static, 'static>;
LL + type FErr1 = Self::E<'static, >;
LL + type FErr1 = Self::E<'static>;
|

error[E0107]: associated type takes 1 generic argument but 0 generic arguments were supplied
Expand Down Expand Up @@ -45,7 +45,7 @@ LL | type E<'a, T>;
help: remove the unnecessary generic argument
|
LL - type FErr2<T> = Self::E<'static, T, u32>;
LL + type FErr2<T> = Self::E<'static, T, >;
LL + type FErr2<T> = Self::E<'static, T>;
|

error: aborting due to 3 previous errors
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/generics/bad-mid-path-type-params.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | fn new<U>(x: T, _: U) -> S<T> {
help: remove the unnecessary generic argument
|
LL - let _ = S::new::<isize,f64>(1, 1.0);
LL + let _ = S::new::<isize,>(1, 1.0);
LL + let _ = S::new::<isize>(1, 1.0);
|

error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supplied
Expand Down Expand Up @@ -46,7 +46,7 @@ LL | fn new<U>(x: T, y: U) -> Self;
help: remove the unnecessary generic argument
|
LL - let _: S2 = Trait::new::<isize,f64>(1, 1.0);
LL + let _: S2 = Trait::new::<isize,>(1, 1.0);
LL + let _: S2 = Trait::new::<isize>(1, 1.0);
|

error[E0107]: trait takes 0 lifetime arguments but 1 lifetime argument was supplied
Expand Down Expand Up @@ -80,7 +80,7 @@ LL | fn new<U>(x: T, y: U) -> Self;
help: remove the unnecessary generic argument
|
LL - let _: S2 = Trait::<'a,isize>::new::<f64,f64>(1, 1.0);
LL + let _: S2 = Trait::<'a,isize>::new::<f64,>(1, 1.0);
LL + let _: S2 = Trait::<'a,isize>::new::<f64>(1, 1.0);
|

error: aborting due to 5 previous errors
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/generics/foreign-generic-mismatch.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ LL | pub fn lt_arg<'a: 'a>() {}
help: remove the lifetime argument
|
LL - foreign_generic_mismatch::lt_arg::<'static, 'static>();
LL + foreign_generic_mismatch::lt_arg::<'static, >();
LL + foreign_generic_mismatch::lt_arg::<'static>();
|

error: aborting due to 2 previous errors
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/generics/generic-arg-mismatch-recover.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | struct Foo<'a, T: 'a>(&'a T);
help: remove the lifetime argument
|
LL - Foo::<'static, 'static, ()>(&0);
LL + Foo::<'static, , ()>(&0);
LL + Foo::<'static, ()>(&0);
|

error[E0107]: struct takes 1 lifetime argument but 2 lifetime arguments were supplied
Expand All @@ -29,7 +29,7 @@ LL | struct Bar<'a>(&'a ());
help: remove the lifetime argument
|
LL - Bar::<'static, 'static, ()>(&());
LL + Bar::<'static, , ()>(&());
LL + Bar::<'static, ()>(&());
|

error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | struct Vec<T, A = Heap>(
help: remove the unnecessary generic argument
|
LL - Vec::<isize, Heap, bool>::new();
LL + Vec::<isize, Heap, >::new();
LL + Vec::<isize, Heap>::new();
|

error: aborting due to 1 previous error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LL | struct Vec<T, A = Heap>(
help: remove the unnecessary generic argument
|
LL - let _: Vec<isize, Heap, bool>;
LL + let _: Vec<isize, Heap, >;
LL + let _: Vec<isize, Heap>;
|

error: aborting due to 1 previous error
Expand Down
Loading