Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a710e1f
account for `c_enum_min_bits` in `multiple-reprs` UI test
japaric Jan 20, 2025
b691e9f
Correct comment for FreeBSD and DragonFly BSD in unix/thread
no1wudi Jan 25, 2025
8c24c0a
Remove the common prelude module
ehuss Feb 11, 2025
51b105d
ignore vendor directory in `git status`
jyn514 Feb 13, 2025
1a3efd2
Use `slice::fill` in `io::Repeat` implementation
DaniPopes Feb 13, 2025
2f27236
alloc boxed: docs: use MaybeUninit::write instead of as_mut_ptr
jedbrown Feb 13, 2025
fb3a363
Emit MIR for each bit with on `dont_reset_cast_kind_without_updating_…
pvdrz Feb 14, 2025
46c7236
Move drop elaboration infrastructure.
nnethercote Feb 14, 2025
28b75a3
Move `MirPatch` from `rustc_middle` to `rustc_mir_transform`.
nnethercote Feb 14, 2025
b480a92
Use underline suggestions for purely 'additive' replacements
compiler-errors Feb 13, 2025
f6406df
Consider add-prefix replacements too
compiler-errors Feb 13, 2025
6d71251
Trim suggestion parts to the subset that is purely additive
compiler-errors Feb 13, 2025
4b13dfd
Rollup merge of #135778 - ferrocene:ja-gh135777, r=workingjubilee
matthiaskrgr Feb 14, 2025
678ff2a
Rollup merge of #136052 - no1wudi:fix, r=workingjubilee
matthiaskrgr Feb 14, 2025
c21a76f
Rollup merge of #136886 - ehuss:remove-prelude-common, r=jhpratt
matthiaskrgr Feb 14, 2025
2980f75
Rollup merge of #136956 - jyn514:ignore-vendor, r=Noratrieb
matthiaskrgr Feb 14, 2025
49fb61c
Rollup merge of #136958 - compiler-errors:additive-replacmeent, r=est…
matthiaskrgr Feb 14, 2025
b5fce2a
Rollup merge of #136967 - DaniPopes:io-repeat-fill, r=joboet
matthiaskrgr Feb 14, 2025
145e35a
Rollup merge of #136976 - jedbrown:jed/doc-boxed-deferred-init, r=tgr…
matthiaskrgr Feb 14, 2025
8bf77a4
Rollup merge of #137007 - pvdrz:fix-aarch64-alloc-layout, r=compiler-…
matthiaskrgr Feb 14, 2025
bd094fb
Rollup merge of #137008 - nnethercote:mv-code-into-rustc_mir_transfor…
matthiaskrgr Feb 14, 2025
File filter

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
Use underline suggestions for purely 'additive' replacements
  • Loading branch information
compiler-errors authored and workingjubilee committed Feb 14, 2025
commit b480a9214a7037813d29bc04d9e9dbe92ce10cf3
3 changes: 2 additions & 1 deletion compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1982,7 +1982,8 @@ impl HumanEmitter {
{
debug!(?complete, ?parts, ?highlights);

let has_deletion = parts.iter().any(|p| p.is_deletion(sm) || p.is_replacement(sm));
let has_deletion =
parts.iter().any(|p| p.is_deletion(sm) || p.is_destructive_replacement(sm));
let is_multiline = complete.lines().count() > 1;

if i == 0 {
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,17 @@ impl SubstitutionPart {
!self.snippet.is_empty() && self.replaces_meaningful_content(sm)
}

/// Whether this is a replacement that overwrites source with a snippet
/// in a way that isn't a superset of the original string. For example,
/// replacing "abc" with "abcde" is not destructive, but replacing it
/// it with "abx" is, since the "c" character is lost.
pub fn is_destructive_replacement(&self, sm: &SourceMap) -> bool {
self.is_replacement(sm)
&& !sm
.span_to_snippet(self.span)
.is_ok_and(|snippet| self.snippet.trim_start().starts_with(snippet.trim_start()))
}

fn replaces_meaningful_content(&self, sm: &SourceMap) -> bool {
sm.span_to_snippet(self.span)
.map_or(!self.span.is_empty(), |snippet| !snippet.trim().is_empty())
Expand Down
5 changes: 2 additions & 3 deletions tests/ui/associated-types/defaults-suitability.current.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,8 @@ LL | type Baz = T;
| --- required by a bound in this associated type
help: consider further restricting type parameter `T` with trait `Clone`
|
LL - Self::Baz: Clone,
LL + Self::Baz: Clone, T: std::clone::Clone
|
LL | Self::Baz: Clone, T: std::clone::Clone
| ~~~~~~~~~~~~~~~~~~~~~~

error: aborting due to 8 previous errors

Expand Down
5 changes: 2 additions & 3 deletions tests/ui/associated-types/defaults-suitability.next.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,8 @@ LL | type Baz = T;
| --- required by a bound in this associated type
help: consider further restricting type parameter `T` with trait `Clone`
|
LL - Self::Baz: Clone,
LL + Self::Baz: Clone, T: std::clone::Clone
|
LL | Self::Baz: Clone, T: std::clone::Clone
| ~~~~~~~~~~~~~~~~~~~~~~

error: aborting due to 8 previous errors

Expand Down
10 changes: 4 additions & 6 deletions tests/ui/associated-types/issue-38821.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ LL | impl<T: NotNull> IntoNullable for T {
| unsatisfied trait bound introduced here
help: consider extending the `where` clause, but there might be an alternative better way to express this requirement
|
LL - Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
LL + Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull
|
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
--> $DIR/issue-38821.rs:40:1
Expand All @@ -38,9 +37,8 @@ LL | impl<T: NotNull> IntoNullable for T {
| unsatisfied trait bound introduced here
help: consider extending the `where` clause, but there might be an alternative better way to express this requirement
|
LL - Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
LL + Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull
|
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
--> $DIR/issue-38821.rs:23:10
Expand Down
5 changes: 2 additions & 3 deletions tests/ui/associated-types/issue-54108.current.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ LL | type Size: Add<Output = Self::Size>;
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Encoder::Size`
help: consider further restricting the associated type
|
LL - T: SubEncoder,
LL + T: SubEncoder, <T as SubEncoder>::ActualSize: Add
|
LL | T: SubEncoder, <T as SubEncoder>::ActualSize: Add
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error: aborting due to 1 previous error

Expand Down
5 changes: 2 additions & 3 deletions tests/ui/associated-types/issue-54108.next.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ LL | type Size: Add<Output = Self::Size>;
| ^^^^^^^^^^^^^^^^^^^ required by this bound in `Encoder::Size`
help: consider further restricting the associated type
|
LL - T: SubEncoder,
LL + T: SubEncoder, <T as SubEncoder>::ActualSize: Add
|
LL | T: SubEncoder, <T as SubEncoder>::ActualSize: Add
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error: aborting due to 1 previous error

Expand Down
5 changes: 2 additions & 3 deletions tests/ui/attributes/rustc_confusables.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ LL | x.inser();
|
help: there is a method `insert` with a similar name
|
LL - x.inser();
LL + x.insert();
|
LL | x.insert();
| ~~~~~~

error[E0599]: no method named `foo` found for struct `rustc_confusables_across_crate::BTreeSet` in the current scope
--> $DIR/rustc_confusables.rs:15:7
Expand Down
10 changes: 4 additions & 6 deletions tests/ui/attributes/rustc_confusables_std_cases.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ LL | let mut x = VecDeque::new();
| ----- earlier `x` shadowed here with type `VecDeque`
help: you might have meant to use `push_back`
|
LL - x.push(1);
LL + x.push_back(1);
|
LL | x.push_back(1);
| ~~~~~~~~~

error[E0599]: no method named `length` found for struct `Vec<{integer}>` in the current scope
--> $DIR/rustc_confusables_std_cases.rs:15:7
Expand Down Expand Up @@ -98,9 +97,8 @@ note: method defined here
--> $SRC_DIR/alloc/src/string.rs:LL:COL
help: you might have meant to use `push_str`
|
LL - String::new().push("");
LL + String::new().push_str("");
|
LL | String::new().push_str("");
| ~~~~~~~~

error[E0599]: no method named `append` found for struct `String` in the current scope
--> $DIR/rustc_confusables_std_cases.rs:24:19
Expand Down
5 changes: 2 additions & 3 deletions tests/ui/borrowck/issue-115259-suggest-iter-mut.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ LL | self.layers.iter().fold(0, |result, mut layer| result + layer.proce
|
help: you may want to use `iter_mut` here
|
LL - self.layers.iter().fold(0, |result, mut layer| result + layer.process())
LL + self.layers.iter_mut().fold(0, |result, mut layer| result + layer.process())
|
LL | self.layers.iter_mut().fold(0, |result, mut layer| result + layer.process())
| ~~~~~~~~

error: aborting due to 1 previous error

Expand Down
5 changes: 2 additions & 3 deletions tests/ui/borrowck/issue-62387-suggest-iter-mut-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ LL | vec.iter().flat_map(|container| container.things()).cloned().co
|
help: you may want to use `iter_mut` here
|
LL - vec.iter().flat_map(|container| container.things()).cloned().collect::<Vec<PathBuf>>();
LL + vec.iter_mut().flat_map(|container| container.things()).cloned().collect::<Vec<PathBuf>>();
|
LL | vec.iter_mut().flat_map(|container| container.things()).cloned().collect::<Vec<PathBuf>>();
| ~~~~~~~~

error: aborting due to 1 previous error

Expand Down
10 changes: 4 additions & 6 deletions tests/ui/borrowck/issue-62387-suggest-iter-mut.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ LL | v.iter().for_each(|a| a.double());
|
help: you may want to use `iter_mut` here
|
LL - v.iter().for_each(|a| a.double());
LL + v.iter_mut().for_each(|a| a.double());
|
LL | v.iter_mut().for_each(|a| a.double());
| ~~~~~~~~

error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference
--> $DIR/issue-62387-suggest-iter-mut.rs:25:39
Expand All @@ -22,9 +21,8 @@ LL | v.iter().rev().rev().for_each(|a| a.double());
|
help: you may want to use `iter_mut` here
|
LL - v.iter().rev().rev().for_each(|a| a.double());
LL + v.iter_mut().rev().rev().for_each(|a| a.double());
|
LL | v.iter_mut().rev().rev().for_each(|a| a.double());
| ~~~~~~~~

error: aborting due to 2 previous errors

Expand Down
5 changes: 2 additions & 3 deletions tests/ui/c-variadic/issue-86053-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize
|
help: a trait with a similar name exists
|
LL - self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) {
LL + self , ... , self , self , ... ) where Fn : FnOnce ( & 'a & 'b usize ) {
|
LL | self , ... , self , self , ... ) where Fn : FnOnce ( & 'a & 'b usize ) {
| ~~
help: you might be missing a type parameter
|
LL | fn ordering4 < 'a , 'b, F > ( a : , self , self , self ,
Expand Down
5 changes: 2 additions & 3 deletions tests/ui/cfg/cfg-method-receiver.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ LL | cbor_map! { #[cfg(test)] 4};
= note: this error originates in the macro `cbor_map` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you must specify a concrete type for this numeric value, like `i32`
|
LL - cbor_map! { #[cfg(test)] 4};
LL + cbor_map! { #[cfg(test)] 4_i32};
|
LL | cbor_map! { #[cfg(test)] 4_i32};
| ~~~~~

error: aborting due to 2 previous errors

Expand Down
5 changes: 2 additions & 3 deletions tests/ui/check-cfg/diagnotics.cargo.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ LL | #[cfg(featur = "foo")]
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
help: there is a config with a similar name and value
|
LL - #[cfg(featur = "foo")]
LL + #[cfg(feature = "foo")]
|
LL | #[cfg(feature = "foo")]
| ~~~~~~~

warning: unexpected `cfg` condition name: `featur`
--> $DIR/diagnotics.rs:17:7
Expand Down
5 changes: 2 additions & 3 deletions tests/ui/check-cfg/diagnotics.rustc.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ LL | #[cfg(featur = "foo")]
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
help: there is a config with a similar name and value
|
LL - #[cfg(featur = "foo")]
LL + #[cfg(feature = "foo")]
|
LL | #[cfg(feature = "foo")]
| ~~~~~~~

warning: unexpected `cfg` condition name: `featur`
--> $DIR/diagnotics.rs:17:7
Expand Down
5 changes: 2 additions & 3 deletions tests/ui/closures/2229_closure_analysis/bad-pattern.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@ LL | let PAT = v1;
= note: the matched value is of type `u32`
help: introduce a variable instead
|
LL - let PAT = v1;
LL + let PAT_var = v1;
|
LL | let PAT_var = v1;
| ~~~~~~~

error: aborting due to 7 previous errors

Expand Down
5 changes: 2 additions & 3 deletions tests/ui/closures/issue-78720.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ LL | _func: F,
|
help: a trait with a similar name exists
|
LL - _func: F,
LL + _func: Fn,
|
LL | _func: Fn,
| ~~
help: you might be missing a type parameter
|
LL | struct Map2<Segment2, F> {
Expand Down
5 changes: 2 additions & 3 deletions tests/ui/compare-method/bad-self-type.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ LL | fn poll(self, _: &mut Context<'_>) -> Poll<()> {
found signature `fn(MyFuture, &mut Context<'_>) -> Poll<_>`
help: change the self-receiver type to match the trait
|
LL - fn poll(self, _: &mut Context<'_>) -> Poll<()> {
LL + fn poll(self: Pin<&mut MyFuture>, _: &mut Context<'_>) -> Poll<()> {
|
LL | fn poll(self: Pin<&mut MyFuture>, _: &mut Context<'_>) -> Poll<()> {
| ~~~~~~~~~~~~~~~~~~~~~~~~

error[E0053]: method `foo` has an incompatible type for trait
--> $DIR/bad-self-type.rs:22:18
Expand Down
5 changes: 2 additions & 3 deletions tests/ui/const-generics/ensure_is_evaluatable.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ LL | [(); N + 1]:,
| ^^^^^ required by this bound in `bar`
help: try adding a `where` bound
|
LL - [(); M + 1]:,
LL + [(); M + 1]:, [(); N + 1]:
|
LL | [(); M + 1]:, [(); N + 1]:
| ~~~~~~~~~~~~~~

error: aborting due to 1 previous error

5 changes: 2 additions & 3 deletions tests/ui/const-generics/fn_with_two_const_inputs.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ LL | [(); N + 1]:,
| ^^^^^ required by this bound in `bar`
help: try adding a `where` bound
|
LL - [(); both(N + 1, M + 1)]:,
LL + [(); both(N + 1, M + 1)]:, [(); N + 1]:
|
LL | [(); both(N + 1, M + 1)]:, [(); N + 1]:
| ~~~~~~~~~~~~~~

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ LL | fn assert_impl<T: Trait>() {}
| ^^^^^ required by this bound in `assert_impl`
help: try adding a `where` bound
|
LL - EvaluatableU128<{N as u128}>:, {
LL + EvaluatableU128<{N as u128}>:, [(); { O as u128 } as usize]: {
|
LL | EvaluatableU128<{N as u128}>:, [(); { O as u128 } as usize]: {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0308]: mismatched types
--> $DIR/abstract-const-as-cast-3.rs:17:5
Expand Down Expand Up @@ -52,9 +51,8 @@ LL | fn assert_impl<T: Trait>() {}
| ^^^^^ required by this bound in `assert_impl`
help: try adding a `where` bound
|
LL - EvaluatableU128<{N as u128}>:, {
LL + EvaluatableU128<{N as u128}>:, [(); { O as u128 } as usize]: {
|
LL | EvaluatableU128<{N as u128}>:, [(); { O as u128 } as usize]: {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0308]: mismatched types
--> $DIR/abstract-const-as-cast-3.rs:20:5
Expand Down Expand Up @@ -116,9 +114,8 @@ LL | fn assert_impl<T: Trait>() {}
| ^^^^^ required by this bound in `assert_impl`
help: try adding a `where` bound
|
LL - EvaluatableU128<{N as _}>:, {
LL + EvaluatableU128<{N as _}>:, [(); { O as u128 } as usize]: {
|
LL | EvaluatableU128<{N as _}>:, [(); { O as u128 } as usize]: {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0308]: mismatched types
--> $DIR/abstract-const-as-cast-3.rs:35:5
Expand Down Expand Up @@ -152,9 +149,8 @@ LL | fn assert_impl<T: Trait>() {}
| ^^^^^ required by this bound in `assert_impl`
help: try adding a `where` bound
|
LL - EvaluatableU128<{N as _}>:, {
LL + EvaluatableU128<{N as _}>:, [(); { O as u128 } as usize]: {
|
LL | EvaluatableU128<{N as _}>:, [(); { O as u128 } as usize]: {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0308]: mismatched types
--> $DIR/abstract-const-as-cast-3.rs:38:5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ LL | bar::<{ T::ASSOC }>();
|
help: try adding a `where` bound
|
LL - fn foo<T: Trait, U: Trait>() where [(); U::ASSOC]:, {
LL + fn foo<T: Trait, U: Trait>() where [(); U::ASSOC]:, [(); { T::ASSOC }]: {
|
LL | fn foo<T: Trait, U: Trait>() where [(); U::ASSOC]:, [(); { T::ASSOC }]: {
| ~~~~~~~~~~~~~~~~~~~~~

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ LL | foo::<_, L>([(); L + 1 + L]);
|
help: try adding a `where` bound
|
LL - [(); (L - 1) + 1 + L]:,
LL + [(); (L - 1) + 1 + L]:, [(); L + 1 + L]:
|
LL | [(); (L - 1) + 1 + L]:, [(); L + 1 + L]:
| ~~~~~~~~~~~~~~~~~~

error: unconstrained generic constant
--> $DIR/issue_114151.rs:17:17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ LL | foo::<_, L>([(); L + 1 + L]);
|
help: try adding a `where` bound
|
LL - [(); (L - 1) + 1 + L]:,
LL + [(); (L - 1) + 1 + L]:, [(); L + 1 + L]:
|
LL | [(); (L - 1) + 1 + L]:, [(); L + 1 + L]:
| ~~~~~~~~~~~~~~~~~~

error: aborting due to 2 previous errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ LL | let f: F = async { 1 };
|
help: a trait with a similar name exists
|
LL - let f: F = async { 1 };
LL + let f: Fn = async { 1 };
|
LL | let f: Fn = async { 1 };
| ~~
help: you might be missing a type parameter
|
LL | fn f<T, F>(
Expand Down
Loading