Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
76438d2
Add example for iterator_flatten
HintringerFabian Nov 28, 2022
083560b
Add result example + rewording
HintringerFabian Dec 13, 2022
11331b1
Enable atomic cas for bpf targets
tomerze Nov 26, 2022
564435f
Suppress suggestions for nested use tree
compiler-errors Dec 27, 2022
9e2536b
Note alternative import candidates in nested use tree
compiler-errors Dec 27, 2022
d2404d6
Dont clobber `as ..` rename in import suggestion
compiler-errors Dec 27, 2022
050bc95
Fix some totally useless suggestions
compiler-errors Dec 27, 2022
ecdf7f0
Reuse ErrorGuaranteed during relation
compiler-errors Dec 30, 2022
db6d3b3
Filter impl and where-clause candidates that reference errors
compiler-errors Jan 1, 2023
6b01b35
Forbid #[suggestion_*(...)] on Vecs
Xiretza Oct 16, 2022
3e2ae86
rustc_parse: avoid creating unnecessary intermediate strings
Xiretza Dec 27, 2022
58edd7f
Use AddToDiagnostic for "use latest edition" help
Xiretza Oct 5, 2022
27c0c46
Implement IntoDiagnosticArg for ast::Visibility
Xiretza Oct 5, 2022
f94a148
Fix condition for "missing `struct`" diagnostic on tuple structs
Xiretza Oct 6, 2022
5783b8c
tests: rename test cases to match new behaviour
Xiretza Dec 27, 2022
e5282a8
rustc_parse: migrate more to diagnostic structs
Xiretza Oct 14, 2022
e4e17a3
Convert rustc_parse::parser::pat::Expected to enum
Xiretza Nov 8, 2022
5167ca8
migrate parser::ty to diagnostic structs
Xiretza Oct 18, 2022
a37ff4c
rustc_parse: revert conversion of "non-item in item list" diagnostic
Xiretza Dec 13, 2022
02141b6
Make "use latest edition" subdiagnostic translatable
Xiretza Dec 28, 2022
c364d32
Relocate changes
HintringerFabian Jan 9, 2023
31099ee
update test for inductive canonical cycles
lcnr Jan 9, 2023
42aa075
Accept old spelling of Fuchsia target triples
djkoloski Jan 9, 2023
a51a592
Render missing generics suggestion verbosely
compiler-errors Jan 8, 2023
5132e13
No need to take opaques in check_type_bounds
compiler-errors Dec 24, 2022
7c2dff0
Don't suggest dyn as parameter to add
compiler-errors Jan 8, 2023
1d66a67
review comment
compiler-errors Jan 9, 2023
1c766d0
rustdoc: merge common CSS for `a`
notriddle Jan 9, 2023
f769d34
Assert defining anchor is set in take_opaque_types
compiler-errors Jan 9, 2023
9c23629
Add issue number to FIXMEs
tmandry Jan 9, 2023
4adf99b
Rollup merge of #105034 - HintringerFabian:improve_iterator_flatten_d…
compiler-errors Jan 9, 2023
eb22a06
Rollup merge of #105670 - Xiretza:rustc_parse-diagnostics-4, r=davidtwco
compiler-errors Jan 9, 2023
03dc5c9
Rollup merge of #105708 - tomerze:enable-atomic-cas-bpf, r=nagisa
compiler-errors Jan 9, 2023
91d750d
Rollup merge of #106175 - compiler-errors:bad-import-sugg, r=oli-obk
compiler-errors Jan 9, 2023
1e81ca3
Rollup merge of #106204 - compiler-errors:no-take-opaques-in-compare,…
compiler-errors Jan 9, 2023
500261f
Rollup merge of #106309 - compiler-errors:prefer-non-err-candidates, …
compiler-errors Jan 9, 2023
32aeb3f
Rollup merge of #106608 - compiler-errors:missing-generics-verbose, r…
compiler-errors Jan 9, 2023
3f9a928
Rollup merge of #106636 - djkoloski:accept_old_fuchsia_triple, r=tmandry
compiler-errors Jan 9, 2023
b13c1eb
Rollup merge of #106640 - lcnr:update-test, r=jackh726
compiler-errors Jan 9, 2023
312ad66
Rollup merge of #106647 - notriddle:notriddle/a, r=GuillaumeGomez
compiler-errors Jan 9, 2023
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
Dont clobber as .. rename in import suggestion
  • Loading branch information
compiler-errors committed Dec 27, 2022
commit d2404d6dca59d34d5b9f0c66b425b08229f20f4b
9 changes: 8 additions & 1 deletion compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ impl<'a> Resolver<'a> {
found_use,
DiagnosticMode::Normal,
path,
None,
);
err.emit();
} else if let Some((span, msg, sugg, appl)) = suggestion {
Expand Down Expand Up @@ -690,6 +691,7 @@ impl<'a> Resolver<'a> {
FoundUse::Yes,
DiagnosticMode::Pattern,
vec![],
None,
);
}
err
Expand Down Expand Up @@ -1344,6 +1346,7 @@ impl<'a> Resolver<'a> {
FoundUse::Yes,
DiagnosticMode::Normal,
vec![],
None,
);

if macro_kind == MacroKind::Derive && (ident.name == sym::Send || ident.name == sym::Sync) {
Expand Down Expand Up @@ -2325,6 +2328,7 @@ pub(crate) fn import_candidates(
use_placement_span: Option<Span>,
candidates: &[ImportSuggestion],
mode: DiagnosticMode,
append: Option<&str>,
) {
show_candidates(
session,
Expand All @@ -2336,6 +2340,7 @@ pub(crate) fn import_candidates(
FoundUse::Yes,
mode,
vec![],
append,
);
}

Expand All @@ -2353,10 +2358,12 @@ fn show_candidates(
found_use: FoundUse,
mode: DiagnosticMode,
path: Vec<Segment>,
append: Option<&str>,
) {
if candidates.is_empty() {
return;
}
let append = append.unwrap_or("");

let mut accessible_path_strings: Vec<(String, &str, Option<DefId>, &Option<String>)> =
Vec::new();
Expand Down Expand Up @@ -2417,7 +2424,7 @@ fn show_candidates(
// produce an additional newline to separate the new use statement
// from the directly following item.
let additional_newline = if let FoundUse::Yes = found_use { "" } else { "\n" };
candidate.0 = format!("{}{};\n{}", add_use, &candidate.0, additional_newline);
candidate.0 = format!("{add_use}{}{append};\n{additional_newline}", &candidate.0);
}

err.span_suggestions(
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,22 +547,24 @@ impl<'a, 'b> ImportResolver<'a, 'b> {

if let Some(candidates) = &err.candidates {
match &import.kind {
ImportKind::Single { nested: false, .. } => import_candidates(
ImportKind::Single { nested: false, source, target, .. } => import_candidates(
self.r.session,
&self.r.untracked.source_span,
&mut diag,
Some(err.span),
&candidates,
DiagnosticMode::Import,
(source != target).then(|| format!(" as {target}")).as_deref(),
),
ImportKind::Single { nested: true, .. } => {
ImportKind::Single { nested: true, source, target, .. } => {
import_candidates(
self.r.session,
&self.r.untracked.source_span,
&mut diag,
None,
&candidates,
DiagnosticMode::Normal,
(source != target).then(|| format!(" as {target}")).as_deref(),
);
}
_ => {}
Expand Down
16 changes: 16 additions & 0 deletions src/test/ui/imports/bad-import-with-rename.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
mod A {
pub type B = ();
pub type B2 = ();
}

mod C {
use crate::D::B as _;
//~^ ERROR unresolved import `crate::D::B`

use crate::D::B2;
//~^ ERROR unresolved import `crate::D::B2`
}

mod D {}

fn main() {}
25 changes: 25 additions & 0 deletions src/test/ui/imports/bad-import-with-rename.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
error[E0432]: unresolved import `crate::D::B`
--> $DIR/bad-import-with-rename.rs:7:9
|
LL | use crate::D::B as _;
| ^^^^^^^^^^^^^^^^ no `B` in `D`
|
help: consider importing this type alias instead
|
LL | use A::B as _;
| ~~~~~~~~~~

error[E0432]: unresolved import `crate::D::B2`
--> $DIR/bad-import-with-rename.rs:10:9
|
LL | use crate::D::B2;
| ^^^^^^^^^^^^ no `B2` in `D`
|
help: consider importing this type alias instead
|
LL | use A::B2;
| ~~~~~~

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0432`.
4 changes: 2 additions & 2 deletions src/test/ui/test-attrs/inaccessible-test-modules.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ LL | use test as y;
| ~~~~
help: consider importing this module instead
|
LL | use test::test;
| ~~~~~~~~~~~
LL | use test::test as y;
| ~~~~~~~~~~~~~~~~

error: aborting due to 2 previous errors

Expand Down