Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2f305ff
Remove an unnecessary `?`.
nnethercote Jul 16, 2024
48cdfc3
Inline `Parser::parse_item_common_`.
nnethercote Jul 16, 2024
d247489
Reorder `Parser::parse_expr_dot_or_call_with` arguments.
nnethercote Jul 16, 2024
96cc9c9
Inline and remove `Parser::parse_and_disallow_postfix_after_cast`.
nnethercote Jul 16, 2024
96b39f1
Inline and remove `Parser::parse_expr_dot_or_call_with_`.
nnethercote Jul 16, 2024
8cb6bc3
Fix a comment.
nnethercote Jul 16, 2024
9c4f3db
Remove references to `maybe_whole_expr`.
nnethercote Jul 16, 2024
538b31e
Make language around `ToOwned` for `BorrowedFd` more precise
tbu- Jun 28, 2024
2162f3f
Mention how you can go from `BorrowedFd` to `OwnedFd` and back
tbu- Jun 28, 2024
a651050
lift_to_tcx -> lift_to_interner
compiler-errors Jul 16, 2024
8d90f44
tcx -> cx in rustc_type_ir
compiler-errors Jul 16, 2024
0b5ce54
Fix relations
compiler-errors Jul 16, 2024
5483945
rewrite dump-ice-to-disk to rmake
Oneirical Jul 9, 2024
f54fa62
rewrite panic-abort-eh_frame to rmake
Oneirical Jul 9, 2024
a9e1466
Add `llvm_components_contain` to `run-make-support`
Rejyr Jul 15, 2024
a8b6e3f
Migrate `atomic-lock-free` to `rmake`
Rejyr Jul 15, 2024
e38032f
Fix associated item removal suggestion
estebank Jul 9, 2024
8eb5185
Accurate `use` rename suggestion span
estebank Jul 10, 2024
be9d961
More accurate span for type parameter suggestion
estebank Jul 10, 2024
f6c4679
More accurate span for anonymous argument suggestion
estebank Jul 10, 2024
483161d
Rollup merge of #127077 - tbu-:pr_doc_fd_to_owned, r=workingjubilee
tgross35 Jul 18, 2024
c0cd3ca
Rollup merge of #127523 - Oneirical:treasure-test, r=jieyouxu
tgross35 Jul 18, 2024
af30f40
Rollup merge of #127787 - Rejyr:migrate-atomic-lock-free-rmake, r=jie…
tgross35 Jul 18, 2024
caf888c
Rollup merge of #127806 - nnethercote:parser-improvements, r=spastorino
tgross35 Jul 18, 2024
fe9940c
Rollup merge of #127810 - compiler-errors:less-tcx, r=lcnr
tgross35 Jul 18, 2024
9b001ce
Rollup merge of #127878 - estebank:assoc-item-removal, r=fmease
tgross35 Jul 18, 2024
a5fd37e
Rollup merge of #127886 - estebank:as-rename-suggestion, r=compiler-e…
tgross35 Jul 18, 2024
1bdc0fb
Rollup merge of #127888 - estebank:type-param-sugg, r=compiler-errors
tgross35 Jul 18, 2024
6973719
Rollup merge of #127889 - estebank:anon-arg-sugg, r=compiler-errors
tgross35 Jul 18, 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
18 changes: 10 additions & 8 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
};

let mut suggestion = None;
let mut span = binding_span;
match import.kind {
ImportKind::Single { type_ns_only: true, .. } => {
suggestion = Some(format!("self as {suggested_name}"))
Expand All @@ -381,12 +382,13 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
{
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(binding_span) {
if pos <= snippet.len() {
suggestion = Some(format!(
"{} as {}{}",
&snippet[..pos],
suggested_name,
if snippet.ends_with(';') { ";" } else { "" }
))
span = binding_span
.with_lo(binding_span.lo() + BytePos(pos as u32))
.with_hi(
binding_span.hi()
- BytePos(if snippet.ends_with(';') { 1 } else { 0 }),
);
suggestion = Some(format!(" as {suggested_name}"));
}
}
}
Expand All @@ -402,9 +404,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}

if let Some(suggestion) = suggestion {
err.subdiagnostic(ChangeImportBindingSuggestion { span: binding_span, suggestion });
err.subdiagnostic(ChangeImportBindingSuggestion { span, suggestion });
} else {
err.subdiagnostic(ChangeImportBinding { span: binding_span });
err.subdiagnostic(ChangeImportBinding { span });
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/blind/blind-item-block-item-shadow.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LL | use foo::Bar;
help: you can use `as` to change the binding name of the import
|
LL | use foo::Bar as OtherBar;
| ~~~~~~~~~~~~~~~~~~~~
| +++++++++++

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/blind/blind-item-item-shadow.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | use foo::foo;
help: you can use `as` to change the binding name of the import
|
LL | use foo::foo as other_foo;
| ~~~~~~~~~~~~~~~~~~~~~
| ++++++++++++

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/duplicate/duplicate-check-macro-exports.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | macro_rules! panic { () => {} }
help: you can use `as` to change the binding name of the import
|
LL | pub use std::panic as other_panic;
| ~~~~~~~~~~~~~~~~~~~~~~~~~
| ++++++++++++++

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/error-codes/E0252.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LL | use bar::baz;
help: you can use `as` to change the binding name of the import
|
LL | use bar::baz as other_baz;
| ~~~~~~~~~~~~~~~~~~~~~
| ++++++++++++

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/error-codes/E0254.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | use foo::alloc;
help: you can use `as` to change the binding name of the import
|
LL | use foo::alloc as other_alloc;
| ~~~~~~~~~~~~~~~~~~~~~~~~~
| ++++++++++++++

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/error-codes/E0255.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | fn foo() {}
help: you can use `as` to change the binding name of the import
|
LL | use bar::foo as other_foo;
| ~~~~~~~~~~~~~~~~~~~~~
| ++++++++++++

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/imports/double-import.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LL | use sub2::foo;
help: you can use `as` to change the binding name of the import
|
LL | use sub2::foo as other_foo;
| ~~~~~~~~~~~~~~~~~~~~~~
| ++++++++++++

error: aborting due to 1 previous error

Expand Down
6 changes: 3 additions & 3 deletions tests/ui/imports/issue-19498.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | mod A {}
help: you can use `as` to change the binding name of the import
|
LL | use self::A as OtherA;
| ~~~~~~~~~~~~~~~~~
| +++++++++

error[E0255]: the name `B` is defined multiple times
--> $DIR/issue-19498.rs:5:1
Expand All @@ -26,7 +26,7 @@ LL | pub mod B {}
help: you can use `as` to change the binding name of the import
|
LL | use self::B as OtherB;
| ~~~~~~~~~~~~~~~~~
| +++++++++

error[E0255]: the name `D` is defined multiple times
--> $DIR/issue-19498.rs:9:5
Expand All @@ -40,7 +40,7 @@ LL | mod D {}
help: you can use `as` to change the binding name of the import
|
LL | use C::D as OtherD;
| ~~~~~~~~~~~~~~
| +++++++++

error: aborting due to 3 previous errors

Expand Down
10 changes: 5 additions & 5 deletions tests/ui/imports/issue-24081.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | type Add = bool;
help: you can use `as` to change the binding name of the import
|
LL | use std::ops::Add as OtherAdd;
| ~~~~~~~~~~~~~~~~~~~~~~~~~
| +++++++++++

error[E0255]: the name `Sub` is defined multiple times
--> $DIR/issue-24081.rs:9:1
Expand All @@ -26,7 +26,7 @@ LL | struct Sub { x: f32 }
help: you can use `as` to change the binding name of the import
|
LL | use std::ops::Sub as OtherSub;
| ~~~~~~~~~~~~~~~~~~~~~~~~~
| +++++++++++

error[E0255]: the name `Mul` is defined multiple times
--> $DIR/issue-24081.rs:11:1
Expand All @@ -41,7 +41,7 @@ LL | enum Mul { A, B }
help: you can use `as` to change the binding name of the import
|
LL | use std::ops::Mul as OtherMul;
| ~~~~~~~~~~~~~~~~~~~~~~~~~
| +++++++++++

error[E0255]: the name `Div` is defined multiple times
--> $DIR/issue-24081.rs:13:1
Expand All @@ -56,7 +56,7 @@ LL | mod Div { }
help: you can use `as` to change the binding name of the import
|
LL | use std::ops::Div as OtherDiv;
| ~~~~~~~~~~~~~~~~~~~~~~~~~
| +++++++++++

error[E0255]: the name `Rem` is defined multiple times
--> $DIR/issue-24081.rs:15:1
Expand All @@ -71,7 +71,7 @@ LL | trait Rem { }
help: you can use `as` to change the binding name of the import
|
LL | use std::ops::Rem as OtherRem;
| ~~~~~~~~~~~~~~~~~~~~~~~~~
| +++++++++++

error: aborting due to 5 previous errors

Expand Down
8 changes: 4 additions & 4 deletions tests/ui/imports/issue-25396.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LL | use bar::baz;
help: you can use `as` to change the binding name of the import
|
LL | use bar::baz as other_baz;
| ~~~~~~~~~~~~~~~~~~~~~
| ++++++++++++

error[E0252]: the name `Quux` is defined multiple times
--> $DIR/issue-25396.rs:7:5
Expand All @@ -24,7 +24,7 @@ LL | use bar::Quux;
help: you can use `as` to change the binding name of the import
|
LL | use bar::Quux as OtherQuux;
| ~~~~~~~~~~~~~~~~~~~~~~
| ++++++++++++

error[E0252]: the name `blah` is defined multiple times
--> $DIR/issue-25396.rs:10:5
Expand All @@ -38,7 +38,7 @@ LL | use bar::blah;
help: you can use `as` to change the binding name of the import
|
LL | use bar::blah as other_blah;
| ~~~~~~~~~~~~~~~~~~~~~~~
| +++++++++++++

error[E0252]: the name `WOMP` is defined multiple times
--> $DIR/issue-25396.rs:13:5
Expand All @@ -52,7 +52,7 @@ LL | use bar::WOMP;
help: you can use `as` to change the binding name of the import
|
LL | use bar::WOMP as OtherWOMP;
| ~~~~~~~~~~~~~~~~~~~~~~
| ++++++++++++

error: aborting due to 4 previous errors

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/imports/issue-32354-suggest-import-rename.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LL | use extension2::ConstructorExtension;
help: you can use `as` to change the binding name of the import
|
LL | use extension2::ConstructorExtension as OtherConstructorExtension;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| ++++++++++++++++++++++++++++

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/imports/issue-45829/import-self.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ LL | use foo::self;
help: you can use `as` to change the binding name of the import
|
LL | use foo as other_foo;
| ~~~~~~~~~~~~~~~~
| ~~~~~~~~~~~~

error[E0252]: the name `A` is defined multiple times
--> $DIR/import-self.rs:16:11
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/imports/issue-45829/issue-45829.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LL | use foo::{A, B as A};
help: you can use `as` to change the binding name of the import
|
LL | use foo::{A, B as OtherA};
| ~~~~~~~~~~~
| ~~~~~~~~~

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/imports/issue-45829/rename-use-vs-extern.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LL | use std as issue_45829_b;
help: you can use `as` to change the binding name of the import
|
LL | use std as other_issue_45829_b;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
| ~~~~~~~~~~~~~~~~~~~~~~

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/imports/issue-45829/rename-use-with-tabs.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LL | use foo::{A, bar::B as A};
help: you can use `as` to change the binding name of the import
|
LL | use foo::{A, bar::B as OtherA};
| ~~~~~~~~~~~~~~~~
| ~~~~~~~~~

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/imports/issue-45829/rename-with-path.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LL | use std::{collections::HashMap as A, sync::Arc as A};
help: you can use `as` to change the binding name of the import
|
LL | use std::{collections::HashMap as A, sync::Arc as OtherA};
| ~~~~~~~~~~~~~~~~~~~
| ~~~~~~~~~

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/imports/issue-45829/rename.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LL | use std as core;
help: you can use `as` to change the binding name of the import
|
LL | use std as other_core;
| ~~~~~~~~~~~~~~~~~
| ~~~~~~~~~~~~~

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/imports/issue-52891.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ LL | use issue_52891::b::inner;
help: you can use `as` to change the binding name of the import
|
LL | use issue_52891::b::inner as other_inner;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| ++++++++++++++

error[E0254]: the name `issue_52891` is defined multiple times
--> $DIR/issue-52891.rs:31:19
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/imports/issue-8640.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LL | mod bar {}
help: you can use `as` to change the binding name of the import
|
LL | use baz::bar as other_bar;
| ~~~~~~~~~~~~~~~~~~~~~
| ++++++++++++

error: aborting due to 1 previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LL | use std::slice as std;
help: you can use `as` to change the binding name of the import
|
LL | use std::slice as other_std;
| ~~~~~~~~~~~~~~~~~~~~~~~
| ~~~~~~~~~~~~

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/resolve/resolve-conflict-item-vs-import.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | fn transmute() {}
help: you can use `as` to change the binding name of the import
|
LL | use std::mem::transmute as other_transmute;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| ++++++++++++++++++

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/resolve/resolve-conflict-type-vs-import.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | struct Iter;
help: you can use `as` to change the binding name of the import
|
LL | use std::slice::Iter as OtherIter;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| ++++++++++++

error: aborting due to 1 previous error

Expand Down
12 changes: 6 additions & 6 deletions tests/ui/variants/variant-namespacing.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | pub use variant_namespacing::XE::{XStruct, XTuple, XUnit};
help: you can use `as` to change the binding name of the import
|
LL | pub use variant_namespacing::XE::{XStruct as OtherXStruct, XTuple, XUnit};
| ~~~~~~~~~~~~~~~~~~~~~~~
| +++++++++++++++

error[E0255]: the name `XTuple` is defined multiple times
--> $DIR/variant-namespacing.rs:24:44
Expand All @@ -26,7 +26,7 @@ LL | pub use variant_namespacing::XE::{XStruct, XTuple, XUnit};
help: you can use `as` to change the binding name of the import
|
LL | pub use variant_namespacing::XE::{XStruct, XTuple as OtherXTuple, XUnit};
| ~~~~~~~~~~~~~~~~~~~~~
| ++++++++++++++

error[E0255]: the name `XUnit` is defined multiple times
--> $DIR/variant-namespacing.rs:24:52
Expand All @@ -41,7 +41,7 @@ LL | pub use variant_namespacing::XE::{XStruct, XTuple, XUnit};
help: you can use `as` to change the binding name of the import
|
LL | pub use variant_namespacing::XE::{XStruct, XTuple, XUnit as OtherXUnit};
| ~~~~~~~~~~~~~~~~~~~
| +++++++++++++

error[E0255]: the name `Struct` is defined multiple times
--> $DIR/variant-namespacing.rs:28:13
Expand All @@ -56,7 +56,7 @@ LL | pub use E::{Struct, Tuple, Unit};
help: you can use `as` to change the binding name of the import
|
LL | pub use E::{Struct as OtherStruct, Tuple, Unit};
| ~~~~~~~~~~~~~~~~~~~~~
| ++++++++++++++

error[E0255]: the name `Tuple` is defined multiple times
--> $DIR/variant-namespacing.rs:28:21
Expand All @@ -71,7 +71,7 @@ LL | pub use E::{Struct, Tuple, Unit};
help: you can use `as` to change the binding name of the import
|
LL | pub use E::{Struct, Tuple as OtherTuple, Unit};
| ~~~~~~~~~~~~~~~~~~~
| +++++++++++++

error[E0255]: the name `Unit` is defined multiple times
--> $DIR/variant-namespacing.rs:28:28
Expand All @@ -86,7 +86,7 @@ LL | pub use E::{Struct, Tuple, Unit};
help: you can use `as` to change the binding name of the import
|
LL | pub use E::{Struct, Tuple, Unit as OtherUnit};
| ~~~~~~~~~~~~~~~~~
| ++++++++++++

error: aborting due to 6 previous errors

Expand Down