From c8f12de2e49f12873b7d23e90ebba9e77a920563 Mon Sep 17 00:00:00 2001 From: mu001999 Date: Sun, 26 Oct 2025 19:49:41 +0800 Subject: [PATCH] Rewrite build_reduced_graph_for_use_tree --- .../src/error_codes/E0430.md | 4 +- .../src/error_codes/E0431.md | 4 +- compiler/rustc_resolve/messages.ftl | 14 +- .../rustc_resolve/src/build_reduced_graph.rs | 174 ++- compiler/rustc_resolve/src/diagnostics.rs | 6 - compiler/rustc_resolve/src/errors.rs | 41 +- compiler/rustc_resolve/src/ident.rs | 72 +- compiler/rustc_resolve/src/lib.rs | 14 - tests/ui/delegation/target-expr-pass.rs | 2 +- .../dollar-crate/dollar-crate-is-keyword-2.rs | 2 +- .../dollar-crate-is-keyword-2.stderr | 19 +- .../dollar-crate/dollar-crate-is-keyword.rs | 3 +- .../dollar-crate-is-keyword.stderr | 21 +- tests/ui/error-codes/E0430.rs | 3 +- tests/ui/error-codes/E0430.stderr | 13 +- tests/ui/error-codes/E0431.rs | 2 +- tests/ui/error-codes/E0431.stderr | 10 +- tests/ui/imports/import-crate-var.rs | 2 +- tests/ui/imports/import-crate-var.stderr | 7 +- tests/ui/imports/issue-47623.rs | 2 +- tests/ui/imports/issue-47623.stderr | 3 +- .../single-segment.rs | 2 +- .../single-segment.stderr | 7 +- tests/ui/use/use-crate-self.rs | 2 +- tests/ui/use/use-crate-self.stderr | 7 +- tests/ui/use/use-keyword.rs | 8 +- tests/ui/use/use-keyword.stderr | 22 - tests/ui/use/use-mod/use-mod-2.rs | 6 +- tests/ui/use/use-mod/use-mod-2.stderr | 21 +- tests/ui/use/use-mod/use-mod.rs | 3 +- tests/ui/use/use-mod/use-mod.stderr | 29 +- ...tderr => use-path-segment-kw.e2015.stderr} | 1096 ++++++++-------- tests/ui/use/use-path-segment-kw.e2018.stderr | 1130 +++++++++++++++++ tests/ui/use/use-path-segment-kw.rs | 224 ++-- 34 files changed, 1975 insertions(+), 1000 deletions(-) delete mode 100644 tests/ui/use/use-keyword.stderr rename tests/ui/use/{use-path-segment-kw.stderr => use-path-segment-kw.e2015.stderr} (56%) create mode 100644 tests/ui/use/use-path-segment-kw.e2018.stderr diff --git a/compiler/rustc_error_codes/src/error_codes/E0430.md b/compiler/rustc_error_codes/src/error_codes/E0430.md index 8cca0f21e5943..83b2bebca11b9 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0430.md +++ b/compiler/rustc_error_codes/src/error_codes/E0430.md @@ -1,8 +1,10 @@ +#### Note: this error code is no longer emitted by the compiler. + The `self` import appears more than once in the list. Erroneous code example: -```compile_fail,E0430 +```ignore (error is no longer emitted) use something::{self, self}; // error: `self` import can only appear once in // the list ``` diff --git a/compiler/rustc_error_codes/src/error_codes/E0431.md b/compiler/rustc_error_codes/src/error_codes/E0431.md index 1b70f5f1d7b76..6689ed0ee4a52 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0431.md +++ b/compiler/rustc_error_codes/src/error_codes/E0431.md @@ -1,8 +1,10 @@ +#### Note: this error code is no longer emitted by the compiler. + An invalid `self` import was made. Erroneous code example: -```compile_fail,E0431 +```ignore (error is no longer emitted) use {self}; // error: `self` import can only appear in an import list with a // non-empty prefix ``` diff --git a/compiler/rustc_resolve/messages.ftl b/compiler/rustc_resolve/messages.ftl index 4a980b2bd747d..a42861a2ffd02 100644 --- a/compiler/rustc_resolve/messages.ftl +++ b/compiler/rustc_resolve/messages.ftl @@ -213,8 +213,6 @@ resolve_ident_in_scope_but_it_is_desc = resolve_implicit_elided_lifetimes_not_allowed_here = implicit elided lifetime not allowed here -resolve_imported_crate = `$crate` may not be imported - resolve_imported_macro_not_found = imported macro not found resolve_imports_cannot_refer_to = @@ -397,14 +395,6 @@ resolve_remove_surrounding_derive = resolve_remove_unnecessary_import = remove unnecessary import -resolve_self_import_can_only_appear_once_in_the_list = - `self` import can only appear once in an import list - .label = can only appear once in an import list - -resolve_self_import_only_in_import_list_with_non_empty_prefix = - `self` import can only appear in an import list with a non-empty prefix - .label = can only appear in an import list with a non-empty prefix - resolve_self_imports_only_allowed_within = `self` imports are only allowed within a {"{"} {"}"} list @@ -487,8 +477,8 @@ resolve_unexpected_res_use_at_op_in_slice_pat_with_range_sugg = resolve_unknown_diagnostic_attribute = unknown diagnostic attribute resolve_unknown_diagnostic_attribute_typo_sugg = an attribute with a similar name exists -resolve_unnamed_crate_root_import = - crate root imports need to be explicitly named: `use crate as name;` +resolve_unnamed_import = imports need to be explicitly named +resolve_unnamed_import_sugg = try renaming it with a name resolve_unreachable_label = use of unreachable label `{$name}` diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index cd12d5ad10cf7..3ed4f0a719c0d 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -564,97 +564,98 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> { let prefix = crate_root.into_iter().chain(prefix_iter).collect::>(); debug!("build_reduced_graph_for_use_tree: prefix={:?}", prefix); - let empty_for_self = |prefix: &[Segment]| { - prefix.is_empty() || prefix.len() == 1 && prefix[0].ident.name == kw::PathRoot - }; match use_tree.kind { ast::UseTreeKind::Simple(rename) => { let mut ident = use_tree.ident(); let mut module_path = prefix; let mut source = module_path.pop().unwrap(); - let mut type_ns_only = false; - - if nested { - // Correctly handle `self` - if source.ident.name == kw::SelfLower { - type_ns_only = true; - if empty_for_self(&module_path) { - self.r.report_error( - use_tree.span, - ResolutionError::SelfImportOnlyInImportListWithNonEmptyPrefix, + // `true` for `...::{self [as target]}` imports, `false` otherwise. + let type_ns_only = nested + && source.ident.name == kw::SelfLower + && use_tree.prefix.segments.len() == 1; + + match source.ident.name { + kw::DollarCrate => { + if !module_path.is_empty() { + self.r.dcx().span_err( + source.ident.span, + "`$crate` in paths can only be used in start position", ); return; } - - // Replace `use foo::{ self };` with `use foo;` - let self_span = source.ident.span; - source = module_path.pop().unwrap(); - if rename.is_none() { - // Keep the span of `self`, but the name of `foo` - ident = Ident::new(source.ident.name, self_span); + } + kw::Crate => { + if !module_path.is_empty() { + self.r.dcx().span_err( + source.ident.span, + "`crate` in paths can only be used in start position", + ); + return; } } - } else { - // Disallow `self` - if source.ident.name == kw::SelfLower { - let parent = module_path.last(); - - let span = match parent { - // only `::self` from `use foo::self as bar` - Some(seg) => seg.ident.span.shrink_to_hi().to(source.ident.span), - None => source.ident.span, - }; - let span_with_rename = match rename { - // only `self as bar` from `use foo::self as bar` - Some(rename) => source.ident.span.to(rename.span), - None => source.ident.span, - }; - self.r.report_error( - span, - ResolutionError::SelfImportsOnlyAllowedWithin { - root: parent.is_none(), - span_with_rename, - }, - ); - - // Error recovery: replace `use foo::self;` with `use foo;` + kw::Super => { + if module_path.iter().any(|seg| seg.ident.name != kw::Super) { + self.r.dcx().span_err( + source.ident.span, + "`super` in paths can only be used in start position or after another `super`", + ); + return; + } + } + kw::SelfLower => { if let Some(parent) = module_path.pop() { + // Suggest `use prefix::{self};` for `use prefix::self;` + if !type_ns_only + && (parent.ident.name != kw::PathRoot + || self.r.path_root_is_crate_root(parent.ident)) + { + let span_with_rename = match rename { + Some(rename) => source.ident.span.to(rename.span), + None => source.ident.span, + }; + + self.r.report_error( + parent.ident.span.shrink_to_hi().to(source.ident.span), + ResolutionError::SelfImportsOnlyAllowedWithin { + root: parent.ident.name == kw::PathRoot, + span_with_rename, + }, + ); + } + + let self_span = source.ident.span; source = parent; if rename.is_none() { - ident = source.ident; + ident = Ident::new(source.ident.name, self_span); } } } + _ => {} + } - // Disallow `use $crate;` - if source.ident.name == kw::DollarCrate && module_path.is_empty() { - let crate_root = self.r.resolve_crate_root(source.ident); - let crate_name = match crate_root.kind { - ModuleKind::Def(.., name) => name, - ModuleKind::Block => unreachable!(), - }; - // HACK(eddyb) unclear how good this is, but keeping `$crate` - // in `source` breaks `tests/ui/imports/import-crate-var.rs`, - // while the current crate doesn't have a valid `crate_name`. - if let Some(crate_name) = crate_name { - // `crate_name` should not be interpreted as relative. - module_path.push(Segment::from_ident_and_id( - Ident::new(kw::PathRoot, source.ident.span), - self.r.next_node_id(), - )); - source.ident.name = crate_name; - } - if rename.is_none() { - ident.name = sym::dummy; - } - - self.r.dcx().emit_err(errors::CrateImported { span: item.span }); - } + // Deny `use ::{self};` after edition 2015 + if source.ident.name == kw::PathRoot + && !self.r.path_root_is_crate_root(source.ident) + { + self.r.dcx().span_err(use_tree.span, "extern prelude cannot be imported"); + return; } - if ident.name == kw::Crate { - self.r.dcx().emit_err(errors::UnnamedCrateRootImport { span: ident.span }); + // Deny importing path-kw without renaming + if rename.is_none() && ident.is_path_segment_keyword() { + let ident = use_tree.ident(); + + // Don't suggest `use xx::self as name;` for `use xx::self;` + // But it's OK to suggest `use xx::{self as name};` for `use xx::{self};` + let sugg = if !type_ns_only && ident.name == kw::SelfLower { + None + } else { + Some(errors::UnnamedImportSugg { span: ident.span, ident }) + }; + + self.r.dcx().emit_err(errors::UnnamedImport { span: ident.span, sugg }); + return; } let kind = ImportKind::Single { @@ -684,32 +685,6 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> { } } ast::UseTreeKind::Nested { ref items, .. } => { - // Ensure there is at most one `self` in the list - let self_spans = items - .iter() - .filter_map(|(use_tree, _)| { - if let ast::UseTreeKind::Simple(..) = use_tree.kind - && use_tree.ident().name == kw::SelfLower - { - return Some(use_tree.span); - } - - None - }) - .collect::>(); - if self_spans.len() > 1 { - let mut e = self.r.into_struct_error( - self_spans[0], - ResolutionError::SelfImportCanOnlyAppearOnceInTheList, - ); - - for other_span in self_spans.iter().skip(1) { - e.span_label(*other_span, "another `self` import appears here"); - } - - e.emit(); - } - for &(ref tree, id) in items { self.build_reduced_graph_for_use_tree( // This particular use tree @@ -721,7 +696,10 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> { // Empty groups `a::b::{}` are turned into synthetic `self` imports // `a::b::c::{self as _}`, so that their prefixes are correctly // resolved and checked for privacy/stability/etc. - if items.is_empty() && !empty_for_self(&prefix) { + if items.is_empty() + && !prefix.is_empty() + && (prefix.len() > 1 || prefix[0].ident.name != kw::PathRoot) + { let new_span = prefix[prefix.len() - 1].ident.span; let tree = ast::UseTree { prefix: ast::Path::from_ident(Ident::new(kw::SelfLower, new_span)), diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 33c111708e366..4f4345a88e489 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -902,12 +902,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { mpart_suggestion, }) } - ResolutionError::SelfImportCanOnlyAppearOnceInTheList => { - self.dcx().create_err(errs::SelfImportCanOnlyAppearOnceInTheList { span }) - } - ResolutionError::SelfImportOnlyInImportListWithNonEmptyPrefix => { - self.dcx().create_err(errs::SelfImportOnlyInImportListWithNonEmptyPrefix { span }) - } ResolutionError::FailedToResolve { segment, label, suggestion, module } => { let mut err = struct_span_code_err!(self.dcx(), span, E0433, "failed to resolve: {label}"); diff --git a/compiler/rustc_resolve/src/errors.rs b/compiler/rustc_resolve/src/errors.rs index af58d88ec35f2..5bcd78f0f72c0 100644 --- a/compiler/rustc_resolve/src/errors.rs +++ b/compiler/rustc_resolve/src/errors.rs @@ -233,22 +233,6 @@ pub(crate) struct UnreachableLabelWithSimilarNameExists { pub(crate) ident_span: Span, } -#[derive(Diagnostic)] -#[diag(resolve_self_import_can_only_appear_once_in_the_list, code = E0430)] -pub(crate) struct SelfImportCanOnlyAppearOnceInTheList { - #[primary_span] - #[label] - pub(crate) span: Span, -} - -#[derive(Diagnostic)] -#[diag(resolve_self_import_only_in_import_list_with_non_empty_prefix, code = E0431)] -pub(crate) struct SelfImportOnlyInImportListWithNonEmptyPrefix { - #[primary_span] - #[label] - pub(crate) span: Span, -} - #[derive(Diagnostic)] #[diag(resolve_cannot_capture_dynamic_environment_in_fn_item, code = E0434)] #[help] @@ -611,13 +595,6 @@ pub(crate) struct MacroExpandedMacroExportsAccessedByAbsolutePaths { pub definition: Span, } -#[derive(Diagnostic)] -#[diag(resolve_imported_crate)] -pub(crate) struct CrateImported { - #[primary_span] - pub(crate) span: Span, -} - #[derive(Diagnostic)] #[diag(resolve_macro_use_extern_crate_self)] pub(crate) struct MacroUseExternCrateSelf { @@ -928,11 +905,25 @@ pub(crate) struct ArgumentsMacroUseNotAllowed { pub(crate) span: Span, } +#[derive(Subdiagnostic)] +#[multipart_suggestion( + resolve_unnamed_import_sugg, + applicability = "maybe-incorrect", + style = "verbose" +)] +pub(crate) struct UnnamedImportSugg { + #[suggestion_part(code = "{ident} as name")] + pub(crate) span: Span, + pub(crate) ident: Ident, +} + #[derive(Diagnostic)] -#[diag(resolve_unnamed_crate_root_import)] -pub(crate) struct UnnamedCrateRootImport { +#[diag(resolve_unnamed_import)] +pub(crate) struct UnnamedImport { #[primary_span] pub(crate) span: Span, + #[subdiagnostic] + pub(crate) sugg: Option, } #[derive(Diagnostic)] diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs index f59b5a0aad9a7..f7cee76b76fb2 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -857,6 +857,23 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ) } + fn resolve_super_in_module( + &self, + ident: Ident, + module: Option>, + parent_scope: &ParentScope<'ra>, + ) -> Option> { + let mut ctxt = ident.span.ctxt().normalize_to_macros_2_0(); + module + .unwrap_or_else(|| self.resolve_self(&mut ctxt, parent_scope.module)) + .parent + .map(|parent| self.resolve_self(&mut ctxt, parent)) + } + + pub(crate) fn path_root_is_crate_root(&self, ident: Ident) -> bool { + ident.name == kw::PathRoot && ident.span.is_rust_2015() && self.tcx.sess.is_rust_2015() + } + /// Attempts to resolve `ident` in namespace `ns` of `module`. #[instrument(level = "debug", skip(self))] fn resolve_ident_in_virt_module_unadjusted<'r>( @@ -870,8 +887,16 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ignore_import: Option>, ) -> Result, Determinacy> { match module { - ModuleOrUniformRoot::Module(module) => self - .resolve_ident_in_module_unadjusted( + ModuleOrUniformRoot::Module(module) => { + if ns == TypeNS + && ident.name == kw::Super + && let Some(module) = + self.resolve_super_in_module(ident, Some(module), parent_scope) + { + return Ok(module.self_binding.unwrap()); + } + + self.resolve_ident_in_module_unadjusted( module, ident, ns, @@ -881,7 +906,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ignore_binding, ignore_import, ) - .map_err(|determinacy| determinacy.into_value()), + .map_err(|determinacy| determinacy.into_value()) + } ModuleOrUniformRoot::ModuleAndExternPrelude(module) => self.resolve_ident_in_scope_set( ident, ScopeSet::ModuleAndExternPrelude(ns, module), @@ -908,13 +934,23 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } ModuleOrUniformRoot::CurrentScope => { if ns == TypeNS { - if ident.name == kw::Crate || ident.name == kw::DollarCrate { + if ident.name == kw::SelfLower { + let mut ctxt = ident.span.ctxt().normalize_to_macros_2_0(); + let module = self.resolve_self(&mut ctxt, parent_scope.module); + return Ok(module.self_binding.unwrap()); + } + if ident.name == kw::Super + && let Some(module) = + self.resolve_super_in_module(ident, None, parent_scope) + { + return Ok(module.self_binding.unwrap()); + } + if ident.name == kw::Crate + || ident.name == kw::DollarCrate + || self.path_root_is_crate_root(ident) + { let module = self.resolve_crate_root(ident); return Ok(module.self_binding.unwrap()); - } else if ident.name == kw::Super || ident.name == kw::SelfLower { - // FIXME: Implement these with renaming requirements so that e.g. - // `use super;` doesn't work, but `use super as name;` does. - // Fall through here to get an error from `early_resolve_...`. } } @@ -1750,19 +1786,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { if ns == TypeNS { if allow_super && name == kw::Super { - let mut ctxt = ident.span.ctxt().normalize_to_macros_2_0(); - let self_module = match segment_idx { - 0 => Some(self.resolve_self(&mut ctxt, parent_scope.module)), - _ => match module { - Some(ModuleOrUniformRoot::Module(module)) => Some(module), - _ => None, - }, + let parent = if segment_idx == 0 { + self.resolve_super_in_module(ident, None, parent_scope) + } else if let Some(ModuleOrUniformRoot::Module(module)) = module { + self.resolve_super_in_module(ident, Some(module), parent_scope) + } else { + None }; - if let Some(self_module) = self_module - && let Some(parent) = self_module.parent - { - module = - Some(ModuleOrUniformRoot::Module(self.resolve_self(&mut ctxt, parent))); + if let Some(parent) = parent { + module = Some(ModuleOrUniformRoot::Module(parent)); continue; } return PathResult::failed( diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index ed47f3124f939..b5ee4c6fd2033 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -262,10 +262,6 @@ enum ResolutionError<'ra> { UndeclaredLabel { name: Symbol, suggestion: Option }, /// Error E0429: `self` imports are only allowed within a `{ }` list. SelfImportsOnlyAllowedWithin { root: bool, span_with_rename: Span }, - /// Error E0430: `self` import can only appear once in the list. - SelfImportCanOnlyAppearOnceInTheList, - /// Error E0431: `self` import can only appear in an import list with a non-empty prefix. - SelfImportOnlyInImportListWithNonEmptyPrefix, /// Error E0433: failed to resolve. FailedToResolve { segment: Option, @@ -365,16 +361,6 @@ impl Segment { } } - fn from_ident_and_id(ident: Ident, id: NodeId) -> Segment { - Segment { - ident, - id: Some(id), - has_generic_args: false, - has_lifetime_args: false, - args_span: DUMMY_SP, - } - } - fn names_to_string(segments: &[Segment]) -> String { names_to_string(segments.iter().map(|seg| seg.ident.name)) } diff --git a/tests/ui/delegation/target-expr-pass.rs b/tests/ui/delegation/target-expr-pass.rs index 9e326a19b8f1c..2d5cf7aace2bc 100644 --- a/tests/ui/delegation/target-expr-pass.rs +++ b/tests/ui/delegation/target-expr-pass.rs @@ -25,7 +25,7 @@ struct S(F); //~ WARN struct `S` is never constructed impl Trait for S { reuse ::bar { #[allow(unused_imports)] - use self::to_reuse::{foo, inner::self}; + use self::to_reuse::{foo, inner::{self}}; let x = foo(12); assert_eq!(x, 12); &self.0 diff --git a/tests/ui/dollar-crate/dollar-crate-is-keyword-2.rs b/tests/ui/dollar-crate/dollar-crate-is-keyword-2.rs index bbab6f8774876..880ec0a6c5508 100644 --- a/tests/ui/dollar-crate/dollar-crate-is-keyword-2.rs +++ b/tests/ui/dollar-crate/dollar-crate-is-keyword-2.rs @@ -2,7 +2,7 @@ mod a {} macro_rules! m { () => { - use a::$crate; //~ ERROR unresolved import `a::$crate` + use a::$crate; //~ ERROR `$crate` in paths can only be used in start position use a::$crate::b; //~ ERROR `$crate` in paths can only be used in start position type A = a::$crate; //~ ERROR `$crate` in paths can only be used in start position } diff --git a/tests/ui/dollar-crate/dollar-crate-is-keyword-2.stderr b/tests/ui/dollar-crate/dollar-crate-is-keyword-2.stderr index d46029710d6f7..6e79a04fddb4f 100644 --- a/tests/ui/dollar-crate/dollar-crate-is-keyword-2.stderr +++ b/tests/ui/dollar-crate/dollar-crate-is-keyword-2.stderr @@ -1,19 +1,19 @@ -error[E0433]: failed to resolve: `$crate` in paths can only be used in start position - --> $DIR/dollar-crate-is-keyword-2.rs:6:16 +error: `$crate` in paths can only be used in start position + --> $DIR/dollar-crate-is-keyword-2.rs:5:16 | -LL | use a::$crate::b; - | ^^^^^^ `$crate` in paths can only be used in start position +LL | use a::$crate; + | ^^^^^^ ... LL | m!(); | ---- in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `a::$crate` - --> $DIR/dollar-crate-is-keyword-2.rs:5:13 +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position + --> $DIR/dollar-crate-is-keyword-2.rs:6:16 | -LL | use a::$crate; - | ^^^^^^^^^ no `$crate` in `a` +LL | use a::$crate::b; + | ^^^^^^ `$crate` in paths can only be used in start position ... LL | m!(); | ---- in this macro invocation @@ -33,5 +33,4 @@ LL | m!(); error: aborting due to 3 previous errors -Some errors have detailed explanations: E0432, E0433. -For more information about an error, try `rustc --explain E0432`. +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/dollar-crate/dollar-crate-is-keyword.rs b/tests/ui/dollar-crate/dollar-crate-is-keyword.rs index d625163dc7e1c..d426256a613cd 100644 --- a/tests/ui/dollar-crate/dollar-crate-is-keyword.rs +++ b/tests/ui/dollar-crate/dollar-crate-is-keyword.rs @@ -6,9 +6,8 @@ macro_rules! m { struct $crate {} //~ ERROR expected identifier, found reserved identifier `$crate` } - use $crate; //~ ERROR `$crate` may not be imported + use $crate; //~ ERROR imports need to be explicitly named use $crate as $crate; //~ ERROR expected identifier, found reserved identifier `$crate` - //~^ ERROR `$crate` may not be imported } } diff --git a/tests/ui/dollar-crate/dollar-crate-is-keyword.stderr b/tests/ui/dollar-crate/dollar-crate-is-keyword.stderr index b027822307417..224380c7ba919 100644 --- a/tests/ui/dollar-crate/dollar-crate-is-keyword.stderr +++ b/tests/ui/dollar-crate/dollar-crate-is-keyword.stderr @@ -20,27 +20,20 @@ LL | m!(); | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: `$crate` may not be imported - --> $DIR/dollar-crate-is-keyword.rs:9:9 +error: imports need to be explicitly named + --> $DIR/dollar-crate-is-keyword.rs:9:13 | LL | use $crate; - | ^^^^^^^^^^^ + | ^^^^^^ ... LL | m!(); | ---- in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: `$crate` may not be imported - --> $DIR/dollar-crate-is-keyword.rs:10:9 +help: try renaming it with a name | -LL | use $crate as $crate; - | ^^^^^^^^^^^^^^^^^^^^^ -... -LL | m!(); - | ---- in this macro invocation - | - = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) +LL | use $crate as name; + | +++++++ -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/error-codes/E0430.rs b/tests/ui/error-codes/E0430.rs index ba2f671d66cf1..0c13cddb5320f 100644 --- a/tests/ui/error-codes/E0430.rs +++ b/tests/ui/error-codes/E0430.rs @@ -1,5 +1,4 @@ -use std::fmt::{self, self}; //~ ERROR E0430 - //~^ ERROR E0252 +use std::fmt::{self, self}; //~ ERROR the name `fmt` is defined multiple times fn main () { } diff --git a/tests/ui/error-codes/E0430.stderr b/tests/ui/error-codes/E0430.stderr index 69a0d6e11b29d..a806b835a9732 100644 --- a/tests/ui/error-codes/E0430.stderr +++ b/tests/ui/error-codes/E0430.stderr @@ -1,11 +1,3 @@ -error[E0430]: `self` import can only appear once in an import list - --> $DIR/E0430.rs:1:16 - | -LL | use std::fmt::{self, self}; - | ^^^^ ---- another `self` import appears here - | | - | can only appear once in an import list - error[E0252]: the name `fmt` is defined multiple times --> $DIR/E0430.rs:1:22 | @@ -16,7 +8,6 @@ LL | use std::fmt::{self, self}; | = note: `fmt` must be defined only once in the type namespace of this module -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0252, E0430. -For more information about an error, try `rustc --explain E0252`. +For more information about this error, try `rustc --explain E0252`. diff --git a/tests/ui/error-codes/E0431.rs b/tests/ui/error-codes/E0431.rs index 2e2ccba171518..836cf560a456c 100644 --- a/tests/ui/error-codes/E0431.rs +++ b/tests/ui/error-codes/E0431.rs @@ -1,4 +1,4 @@ -use {self}; //~ ERROR E0431 +use {self}; //~ ERROR imports need to be explicitly named fn main () { } diff --git a/tests/ui/error-codes/E0431.stderr b/tests/ui/error-codes/E0431.stderr index f77c62bec6819..a9604efa0e41d 100644 --- a/tests/ui/error-codes/E0431.stderr +++ b/tests/ui/error-codes/E0431.stderr @@ -1,9 +1,13 @@ -error[E0431]: `self` import can only appear in an import list with a non-empty prefix +error: imports need to be explicitly named --> $DIR/E0431.rs:1:6 | LL | use {self}; - | ^^^^ can only appear in an import list with a non-empty prefix + | ^^^^ + | +help: try renaming it with a name + | +LL | use {self as name}; + | +++++++ error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0431`. diff --git a/tests/ui/imports/import-crate-var.rs b/tests/ui/imports/import-crate-var.rs index 2f3b38d5f752d..64c93853ac2af 100644 --- a/tests/ui/imports/import-crate-var.rs +++ b/tests/ui/imports/import-crate-var.rs @@ -4,5 +4,5 @@ fn main() { m!(); - //~^ ERROR `$crate` may not be imported + //~^ ERROR imports need to be explicitly named } diff --git a/tests/ui/imports/import-crate-var.stderr b/tests/ui/imports/import-crate-var.stderr index 41a8772d28fa5..f5b947eb4df4a 100644 --- a/tests/ui/imports/import-crate-var.stderr +++ b/tests/ui/imports/import-crate-var.stderr @@ -1,10 +1,15 @@ -error: `$crate` may not be imported +error: imports need to be explicitly named --> $DIR/import-crate-var.rs:6:5 | LL | m!(); | ^^^^ | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) +help: try renaming it with a name + --> $DIR/auxiliary/import_crate_var.rs:5:15 + | +LL | use $crate as name; + | +++++++ error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-47623.rs b/tests/ui/imports/issue-47623.rs index ad8aa4c1a2bd6..55c2a596d9dcb 100644 --- a/tests/ui/imports/issue-47623.rs +++ b/tests/ui/imports/issue-47623.rs @@ -1,3 +1,3 @@ -use self; //~ERROR `self` imports are only allowed within a { } list +use self; //~ERROR imports need to be explicitly named fn main() {} diff --git a/tests/ui/imports/issue-47623.stderr b/tests/ui/imports/issue-47623.stderr index be42a4a5b1d8d..64f443bf69e48 100644 --- a/tests/ui/imports/issue-47623.stderr +++ b/tests/ui/imports/issue-47623.stderr @@ -1,4 +1,4 @@ -error[E0429]: `self` imports are only allowed within a { } list +error: imports need to be explicitly named --> $DIR/issue-47623.rs:1:5 | LL | use self; @@ -6,4 +6,3 @@ LL | use self; error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0429`. diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.rs b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.rs index d73558d8271d2..0828927a3976e 100644 --- a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.rs +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.rs @@ -2,7 +2,7 @@ //@ compile-flags:--extern xcrate //@ edition:2018 -use crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` +use crate; //~ ERROR imports need to be explicitly named use *; //~ ERROR cannot glob-import all possible crates fn main() { diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.stderr b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.stderr index 253cc1bc57a5f..13eb4e25ed6bb 100644 --- a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.stderr +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.stderr @@ -1,8 +1,13 @@ -error: crate root imports need to be explicitly named: `use crate as name;` +error: imports need to be explicitly named --> $DIR/single-segment.rs:5:5 | LL | use crate; | ^^^^^ + | +help: try renaming it with a name + | +LL | use crate as name; + | +++++++ error: cannot glob-import all possible crates --> $DIR/single-segment.rs:6:5 diff --git a/tests/ui/use/use-crate-self.rs b/tests/ui/use/use-crate-self.rs index 65ab948147cdc..1bc294d1351b6 100644 --- a/tests/ui/use/use-crate-self.rs +++ b/tests/ui/use/use-crate-self.rs @@ -1,4 +1,4 @@ use crate::{self}; - //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` + //~^ ERROR imports need to be explicitly named fn main() {} diff --git a/tests/ui/use/use-crate-self.stderr b/tests/ui/use/use-crate-self.stderr index a8f65b128fe16..1e83090b35e4b 100644 --- a/tests/ui/use/use-crate-self.stderr +++ b/tests/ui/use/use-crate-self.stderr @@ -1,8 +1,13 @@ -error: crate root imports need to be explicitly named: `use crate as name;` +error: imports need to be explicitly named --> $DIR/use-crate-self.rs:1:13 | LL | use crate::{self}; | ^^^^ + | +help: try renaming it with a name + | +LL | use crate::{self as name}; + | +++++++ error: aborting due to 1 previous error diff --git a/tests/ui/use/use-keyword.rs b/tests/ui/use/use-keyword.rs index 95f3036516760..03104407ed2f8 100644 --- a/tests/ui/use/use-keyword.rs +++ b/tests/ui/use/use-keyword.rs @@ -1,16 +1,10 @@ -// Check that imports with naked super and self don't fail during parsing -// FIXME: this shouldn't fail during name resolution either +//@ check-pass mod a { mod b { use self as A; - //~^ ERROR `self` imports are only allowed within a { } list use super as B; - //~^ ERROR unresolved import `super` [E0432] - //~| NOTE no `super` in the root use super::{self as C}; - //~^ ERROR unresolved import `super` [E0432] - //~| NOTE no `super` in the root } } diff --git a/tests/ui/use/use-keyword.stderr b/tests/ui/use/use-keyword.stderr deleted file mode 100644 index 501d14be52177..0000000000000 --- a/tests/ui/use/use-keyword.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0429]: `self` imports are only allowed within a { } list - --> $DIR/use-keyword.rs:6:13 - | -LL | use self as A; - | ^^^^ - -error[E0432]: unresolved import `super` - --> $DIR/use-keyword.rs:8:13 - | -LL | use super as B; - | ^^^^^^^^^^ no `super` in the root - -error[E0432]: unresolved import `super` - --> $DIR/use-keyword.rs:11:21 - | -LL | use super::{self as C}; - | ^^^^^^^^^ no `super` in the root - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0429, E0432. -For more information about an error, try `rustc --explain E0429`. diff --git a/tests/ui/use/use-mod/use-mod-2.rs b/tests/ui/use/use-mod/use-mod-2.rs index 57ff135c4d85a..f04d902336940 100644 --- a/tests/ui/use/use-mod/use-mod-2.rs +++ b/tests/ui/use/use-mod/use-mod-2.rs @@ -1,11 +1,9 @@ mod foo { use self::{self}; - //~^ ERROR unresolved import `self` [E0432] - //~| NOTE no `self` in the root + //~^ ERROR imports need to be explicitly named use super::{self}; - //~^ ERROR unresolved import `super` [E0432] - //~| NOTE no `super` in the root + //~^ ERROR imports need to be explicitly named } fn main() {} diff --git a/tests/ui/use/use-mod/use-mod-2.stderr b/tests/ui/use/use-mod/use-mod-2.stderr index 8437678497724..1609937bbbf49 100644 --- a/tests/ui/use/use-mod/use-mod-2.stderr +++ b/tests/ui/use/use-mod/use-mod-2.stderr @@ -1,15 +1,24 @@ -error[E0432]: unresolved import `self` +error: imports need to be explicitly named --> $DIR/use-mod-2.rs:2:16 | LL | use self::{self}; - | ^^^^ no `self` in the root + | ^^^^ + | +help: try renaming it with a name + | +LL | use self::{self as name}; + | +++++++ -error[E0432]: unresolved import `super` - --> $DIR/use-mod-2.rs:6:17 +error: imports need to be explicitly named + --> $DIR/use-mod-2.rs:5:17 | LL | use super::{self}; - | ^^^^ no `super` in the root + | ^^^^ + | +help: try renaming it with a name + | +LL | use super::{self as name}; + | +++++++ error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/use/use-mod/use-mod.rs b/tests/ui/use/use-mod/use-mod.rs index 87064c6a42b11..5e1149dba3a85 100644 --- a/tests/ui/use/use-mod/use-mod.rs +++ b/tests/ui/use/use-mod/use-mod.rs @@ -1,13 +1,12 @@ use foo::bar::{ self, -//~^ ERROR `self` import can only appear once in an import list Bar, self //~^ ERROR the name `bar` is defined multiple times }; use {self}; -//~^ ERROR `self` import can only appear in an import list with a non-empty prefix +//~^ ERROR imports need to be explicitly named mod foo { pub mod bar { diff --git a/tests/ui/use/use-mod/use-mod.stderr b/tests/ui/use/use-mod/use-mod.stderr index 0cae5eb14aeeb..385b3f3b6e616 100644 --- a/tests/ui/use/use-mod/use-mod.stderr +++ b/tests/ui/use/use-mod/use-mod.stderr @@ -1,24 +1,20 @@ -error[E0430]: `self` import can only appear once in an import list - --> $DIR/use-mod.rs:2:5 - | -LL | self, - | ^^^^ can only appear once in an import list -... -LL | self - | ---- another `self` import appears here - -error[E0431]: `self` import can only appear in an import list with a non-empty prefix - --> $DIR/use-mod.rs:9:6 +error: imports need to be explicitly named + --> $DIR/use-mod.rs:8:6 | LL | use {self}; - | ^^^^ can only appear in an import list with a non-empty prefix + | ^^^^ + | +help: try renaming it with a name + | +LL | use {self as name}; + | +++++++ error[E0252]: the name `bar` is defined multiple times - --> $DIR/use-mod.rs:5:5 + --> $DIR/use-mod.rs:4:5 | LL | self, | ---- previous import of the module `bar` here -... +LL | Bar, LL | self | ^^^^ | | @@ -27,7 +23,6 @@ LL | self | = note: `bar` must be defined only once in the type namespace of this module -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0252, E0430, E0431. -For more information about an error, try `rustc --explain E0252`. +For more information about this error, try `rustc --explain E0252`. diff --git a/tests/ui/use/use-path-segment-kw.stderr b/tests/ui/use/use-path-segment-kw.e2015.stderr similarity index 56% rename from tests/ui/use/use-path-segment-kw.stderr rename to tests/ui/use/use-path-segment-kw.e2015.stderr index 407e99059b2a3..6a386ae697328 100644 --- a/tests/ui/use/use-path-segment-kw.stderr +++ b/tests/ui/use/use-path-segment-kw.e2015.stderr @@ -1,127 +1,300 @@ -error: crate root imports need to be explicitly named: `use crate as name;` - --> $DIR/use-path-segment-kw.rs:98:13 +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:95:13 | LL | use crate; | ^^^^^ + | +help: try renaming it with a name + | +LL | use crate as name; + | +++++++ -error: crate root imports need to be explicitly named: `use crate as name;` - --> $DIR/use-path-segment-kw.rs:102:15 +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:99:15 | LL | use ::crate; | ^^^^^ -error: crate root imports need to be explicitly named: `use crate as name;` - --> $DIR/use-path-segment-kw.rs:105:16 +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:100:15 + | +LL | use ::crate as _crate2; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:101:16 | LL | use ::{crate}; | ^^^^^ -error: crate root imports need to be explicitly named: `use crate as name;` - --> $DIR/use-path-segment-kw.rs:110:21 +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:102:16 + | +LL | use ::{crate as _nested_crate2}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:105:21 | LL | use foobar::crate; | ^^^^^ -error: crate root imports need to be explicitly named: `use crate as name;` - --> $DIR/use-path-segment-kw.rs:113:22 +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:106:21 + | +LL | use foobar::crate as _crate3; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:107:22 | LL | use foobar::{crate}; | ^^^^^ -error: crate root imports need to be explicitly named: `use crate as name;` - --> $DIR/use-path-segment-kw.rs:118:20 +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:108:22 + | +LL | use foobar::{crate as _nested_crate3}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:111:20 | LL | use crate::crate; | ^^^^^ -error: crate root imports need to be explicitly named: `use crate as name;` - --> $DIR/use-path-segment-kw.rs:121:21 +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:112:20 + | +LL | use crate::crate as _crate4; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:113:21 | LL | use crate::{crate}; | ^^^^^ -error: crate root imports need to be explicitly named: `use crate as name;` - --> $DIR/use-path-segment-kw.rs:126:20 +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:114:21 + | +LL | use crate::{crate as _nested_crate4}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:117:20 | LL | use super::crate; | ^^^^^ -error: crate root imports need to be explicitly named: `use crate as name;` - --> $DIR/use-path-segment-kw.rs:129:21 +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:118:20 + | +LL | use super::crate as _crate5; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:119:21 | LL | use super::{crate}; | ^^^^^ -error: crate root imports need to be explicitly named: `use crate as name;` - --> $DIR/use-path-segment-kw.rs:134:19 +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:120:21 + | +LL | use super::{crate as _nested_crate5}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:123:19 | LL | use self::crate; | ^^^^^ -error: crate root imports need to be explicitly named: `use crate as name;` - --> $DIR/use-path-segment-kw.rs:137:20 +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:124:19 + | +LL | use self::crate as _crate6; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:125:20 | LL | use self::{crate}; | ^^^^^ -error[E0429]: `self` imports are only allowed within a { } list - --> $DIR/use-path-segment-kw.rs:184:13 +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:126:20 | -LL | use self; - | ^^^^ +LL | use self::{crate as _nested_crate6}; + | ^^^^^ -error[E0429]: `self` imports are only allowed within a { } list - --> $DIR/use-path-segment-kw.rs:185:17 +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:133:13 | -LL | pub use self as _self; - | ^^^^ +LL | use super; + | ^^^^^ + | +help: try renaming it with a name + | +LL | use super as name; + | +++++++ -error[E0429]: `self` imports are only allowed within a { } list - --> $DIR/use-path-segment-kw.rs:188:13 +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:137:15 | -LL | use ::self; - | ^^^^^^ +LL | use ::super; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:138:15 | -help: consider importing the module directly +LL | use ::super as _super2; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:139:16 | -LL - use ::self; -LL + use ; +LL | use ::{super}; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:140:16 | -help: alternatively, use the multi-path `use` syntax to import `self` +LL | use ::{super as _nested_super2}; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:143:21 | -LL | use ::{self}; - | + + +LL | use foobar::super; + | ^^^^^ -error[E0429]: `self` imports are only allowed within a { } list - --> $DIR/use-path-segment-kw.rs:190:13 +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:144:21 | -LL | use ::self as _self2; - | ^^^^^^ +LL | use foobar::super as _super3; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:145:22 | -help: consider importing the module directly +LL | use foobar::{super}; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:146:22 | -LL - use ::self as _self2; -LL + use as _self2; +LL | use foobar::{super as _nested_super3}; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:149:20 | -help: alternatively, use the multi-path `use` syntax to import `self` +LL | use crate::super; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:150:20 | -LL | use ::{self as _self2}; - | + + +LL | use crate::super as _super4; + | ^^^^^ -error[E0431]: `self` import can only appear in an import list with a non-empty prefix - --> $DIR/use-path-segment-kw.rs:192:16 +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:151:21 | -LL | use ::{self}; - | ^^^^ can only appear in an import list with a non-empty prefix +LL | use crate::{super}; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:152:21 + | +LL | use crate::{super as _nested_super4}; + | ^^^^^ + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:155:20 + | +LL | use super::super; + | ^^^^^ + | +help: try renaming it with a name + | +LL | use super::super as name; + | +++++++ + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:157:21 + | +LL | use super::{super}; + | ^^^^^ + | +help: try renaming it with a name + | +LL | use super::{super as name}; + | +++++++ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:161:19 + | +LL | use self::super; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:162:19 + | +LL | use self::super as _super6; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:163:20 + | +LL | use self::{super}; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:164:20 + | +LL | use self::{super as _nested_super6}; + | ^^^^^ + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:171:13 + | +LL | use self; + | ^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:175:13 + | +LL | use ::self; + | ^^^^^^ + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:175:15 + | +LL | use ::self; + | ^^^^ -error[E0431]: `self` import can only appear in an import list with a non-empty prefix - --> $DIR/use-path-segment-kw.rs:193:16 +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:178:13 | -LL | use ::{self as _nested_self2}; - | ^^^^^^^^^^^^^^^^^^^^^ can only appear in an import list with a non-empty prefix +LL | use ::self as _self2; + | ^^^^^^ + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:180:16 + | +LL | use ::{self}; + | ^^^^ + | +help: try renaming it with a name + | +LL | use ::{self as name}; + | +++++++ error[E0429]: `self` imports are only allowed within a { } list - --> $DIR/use-path-segment-kw.rs:196:28 + --> $DIR/use-path-segment-kw.rs:185:28 | LL | pub use foobar::qux::self; | ^^^^^^ @@ -137,7 +310,7 @@ LL | pub use foobar::qux::{self}; | + + error[E0429]: `self` imports are only allowed within a { } list - --> $DIR/use-path-segment-kw.rs:197:23 + --> $DIR/use-path-segment-kw.rs:187:23 | LL | pub use foobar::self as _self3; | ^^^^^^ @@ -153,7 +326,7 @@ LL | pub use foobar::{self as _self3}; | + + error[E0429]: `self` imports are only allowed within a { } list - --> $DIR/use-path-segment-kw.rs:202:18 + --> $DIR/use-path-segment-kw.rs:193:18 | LL | use crate::self; | ^^^^^^ @@ -168,14 +341,14 @@ help: alternatively, use the multi-path `use` syntax to import `self` LL | use crate::{self}; | + + -error: crate root imports need to be explicitly named: `use crate as name;` - --> $DIR/use-path-segment-kw.rs:202:13 +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:193:20 | LL | use crate::self; - | ^^^^^ + | ^^^^ error[E0429]: `self` imports are only allowed within a { } list - --> $DIR/use-path-segment-kw.rs:205:22 + --> $DIR/use-path-segment-kw.rs:195:22 | LL | pub use crate::self as _self4; | ^^^^^^ @@ -190,14 +363,19 @@ help: alternatively, use the multi-path `use` syntax to import `self` LL | pub use crate::{self as _self4}; | + + -error: crate root imports need to be explicitly named: `use crate as name;` - --> $DIR/use-path-segment-kw.rs:206:21 +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:196:21 | LL | use crate::{self}; | ^^^^ + | +help: try renaming it with a name + | +LL | use crate::{self as name}; + | +++++++ error[E0429]: `self` imports are only allowed within a { } list - --> $DIR/use-path-segment-kw.rs:211:18 + --> $DIR/use-path-segment-kw.rs:200:18 | LL | use super::self; | ^^^^^^ @@ -212,8 +390,14 @@ help: alternatively, use the multi-path `use` syntax to import `self` LL | use super::{self}; | + + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:200:20 + | +LL | use super::self; + | ^^^^ + error[E0429]: `self` imports are only allowed within a { } list - --> $DIR/use-path-segment-kw.rs:213:22 + --> $DIR/use-path-segment-kw.rs:202:22 | LL | pub use super::self as _self5; | ^^^^^^ @@ -228,8 +412,19 @@ help: alternatively, use the multi-path `use` syntax to import `self` LL | pub use super::{self as _self5}; | + + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:203:21 + | +LL | use super::{self}; + | ^^^^ + | +help: try renaming it with a name + | +LL | use super::{self as name}; + | +++++++ + error[E0429]: `self` imports are only allowed within a { } list - --> $DIR/use-path-segment-kw.rs:219:17 + --> $DIR/use-path-segment-kw.rs:207:17 | LL | use self::self; | ^^^^^^ @@ -244,8 +439,14 @@ help: alternatively, use the multi-path `use` syntax to import `self` LL | use self::{self}; | + + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:207:19 + | +LL | use self::self; + | ^^^^ + error[E0429]: `self` imports are only allowed within a { } list - --> $DIR/use-path-segment-kw.rs:220:21 + --> $DIR/use-path-segment-kw.rs:209:21 | LL | pub use self::self as _self6; | ^^^^^^ @@ -260,769 +461,476 @@ help: alternatively, use the multi-path `use` syntax to import `self` LL | pub use self::{self as _self6}; | + + -error[E0252]: the name `crate` is defined multiple times - --> $DIR/use-path-segment-kw.rs:134:13 - | -LL | use crate; - | ----- previous import of the module `crate` here -... -LL | use self::crate; - | ^^^^^^^^^^^ `crate` reimported here - | - = note: `crate` must be defined only once in the type namespace of this module - -error[E0252]: the name `crate` is defined multiple times - --> $DIR/use-path-segment-kw.rs:137:20 +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:210:20 | -LL | use crate; - | ----- previous import of the module `crate` here -... -LL | use self::{crate}; - | -----------^^^^^-- - | | | - | | `crate` reimported here - | help: remove unnecessary import - | - = note: `crate` must be defined only once in the type namespace of this module - -error[E0252]: the name `crate` is defined multiple times - --> $DIR/use-path-segment-kw.rs:202:13 +LL | use self::{self}; + | ^^^^ | -LL | use crate; - | ----- previous import of the module `crate` here -... -LL | use crate::self; - | ^^^^^^^^^^^ `crate` reimported here +help: try renaming it with a name | - = note: `crate` must be defined only once in the type namespace of this module +LL | use self::{self as name}; + | +++++++ -error[E0252]: the name `crate` is defined multiple times - --> $DIR/use-path-segment-kw.rs:206:21 - | -LL | use crate; - | ----- previous import of the module `crate` here -... -LL | use crate::{self}; - | ------------^^^^-- - | | | - | | `crate` reimported here - | help: remove unnecessary import - | - = note: `crate` must be defined only once in the type namespace of this module - -error: `$crate` may not be imported - --> $DIR/use-path-segment-kw.rs:9:9 +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:11:13 | LL | use $crate; - | ^^^^^^^^^^^ + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) +help: try renaming it with a name + | +LL | use $crate as name; + | +++++++ -error: `$crate` may not be imported - --> $DIR/use-path-segment-kw.rs:10:9 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:15:15 | -LL | pub use $crate as _dollar_crate; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | use ::$crate; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error: crate root imports need to be explicitly named: `use crate as name;` - --> $DIR/use-path-segment-kw.rs:49:21 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:16:15 | -LL | use $crate::crate; - | ^^^^^ +LL | use ::$crate as _dollar_crate2; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error: crate root imports need to be explicitly named: `use crate as name;` - --> $DIR/use-path-segment-kw.rs:52:22 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:17:16 | -LL | use $crate::{crate}; - | ^^^^^ +LL | use ::{$crate}; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0429]: `self` imports are only allowed within a { } list - --> $DIR/use-path-segment-kw.rs:63:19 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:18:16 | -LL | use $crate::self; - | ^^^^^^ +LL | use ::{$crate as _nested_dollar_crate2}; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -help: consider importing the module directly - | -LL - use $crate::self; -LL + use $crate; - | -help: alternatively, use the multi-path `use` syntax to import `self` - | -LL | use $crate::{self}; - | + + -error: `$crate` may not be imported - --> $DIR/use-path-segment-kw.rs:63:9 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:21:21 | -LL | use $crate::self; - | ^^^^^^^^^^^^^^^^^ +LL | use foobar::$crate; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0429]: `self` imports are only allowed within a { } list - --> $DIR/use-path-segment-kw.rs:66:23 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:22:21 | -LL | pub use $crate::self as _m_self8; - | ^^^^^^ +LL | use foobar::$crate as _dollar_crate3; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -help: consider importing the module directly - | -LL - pub use $crate::self as _m_self8; -LL + pub use $crate as _m_self8; - | -help: alternatively, use the multi-path `use` syntax to import `self` - | -LL | pub use $crate::{self as _m_self8}; - | + + -error: `$crate` may not be imported - --> $DIR/use-path-segment-kw.rs:66:9 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:23:22 | -LL | pub use $crate::self as _m_self8; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | use foobar::{$crate}; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0252]: the name `` is defined multiple times - --> $DIR/use-path-segment-kw.rs:63:13 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:24:22 | -LL | use $crate; - | ------ previous import of the module `` here -... -LL | use $crate::self; - | ^^^^^^^^^^^^ `` reimported here +LL | use foobar::{$crate as _nested_dollar_crate3}; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | - = note: `` must be defined only once in the type namespace of this module = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0252]: the name `$crate` is defined multiple times - --> $DIR/use-path-segment-kw.rs:68:22 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:27:20 | -LL | use self::$crate; - | ------------ previous import of the module `$crate` here -... -LL | use $crate::{self}; - | -------------^^^^-- - | | | - | | `$crate` reimported here - | help: remove unnecessary import +LL | use crate::$crate; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | - = note: `$crate` must be defined only once in the type namespace of this module = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `crate` - --> $DIR/use-path-segment-kw.rs:102:13 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:28:20 | -LL | use ::crate; - | ^^^^^^^ no `crate` in the root - -error[E0432]: unresolved import `crate` - --> $DIR/use-path-segment-kw.rs:104:13 - | -LL | use ::crate as _crate2; - | ^^^^^^^^^^^^^^^^^^ no `crate` in the root - -error[E0432]: unresolved import `crate` - --> $DIR/use-path-segment-kw.rs:105:16 - | -LL | use ::{crate}; - | ^^^^^ no `crate` in the root - -error[E0432]: unresolved import `crate` - --> $DIR/use-path-segment-kw.rs:107:16 - | -LL | use ::{crate as _nested_crate2}; - | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root - -error[E0432]: unresolved import `foobar::crate` - --> $DIR/use-path-segment-kw.rs:110:13 - | -LL | use foobar::crate; - | ^^^^^^^^^^^^^ no `crate` in `foo::bar::foobar` - -error[E0432]: unresolved import `foobar::crate` - --> $DIR/use-path-segment-kw.rs:112:13 - | -LL | use foobar::crate as _crate3; - | ^^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in `foo::bar::foobar` - -error[E0432]: unresolved import `foobar::crate` - --> $DIR/use-path-segment-kw.rs:113:22 - | -LL | use foobar::{crate}; - | ^^^^^ no `crate` in `foo::bar::foobar` - -error[E0432]: unresolved import `foobar::crate` - --> $DIR/use-path-segment-kw.rs:115:22 - | -LL | use foobar::{crate as _nested_crate3}; - | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in `foo::bar::foobar` - -error[E0432]: unresolved import `crate::crate` - --> $DIR/use-path-segment-kw.rs:118:13 - | -LL | use crate::crate; - | ^^^^^^^^^^^^ no `crate` in the root - -error[E0432]: unresolved import `crate::crate` - --> $DIR/use-path-segment-kw.rs:120:13 - | -LL | use crate::crate as _crate4; - | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root - -error[E0432]: unresolved import `crate::crate` - --> $DIR/use-path-segment-kw.rs:121:21 - | -LL | use crate::{crate}; - | ^^^^^ no `crate` in the root - -error[E0432]: unresolved import `crate::crate` - --> $DIR/use-path-segment-kw.rs:123:21 - | -LL | use crate::{crate as _nested_crate4}; - | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root - -error[E0432]: unresolved import `super::crate` - --> $DIR/use-path-segment-kw.rs:126:13 - | -LL | use super::crate; - | ^^^^^^^^^^^^ no `crate` in `foo` - -error[E0432]: unresolved import `super::crate` - --> $DIR/use-path-segment-kw.rs:128:13 - | -LL | use super::crate as _crate5; - | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in `foo` - -error[E0432]: unresolved import `super::crate` - --> $DIR/use-path-segment-kw.rs:129:21 - | -LL | use super::{crate}; - | ^^^^^ no `crate` in `foo` - -error[E0432]: unresolved import `super::crate` - --> $DIR/use-path-segment-kw.rs:131:21 - | -LL | use super::{crate as _nested_crate5}; - | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in `foo` - -error[E0432]: unresolved import `super` - --> $DIR/use-path-segment-kw.rs:143:13 - | -LL | use super::{}; - | ^^^^^^^^^ no `super` in the root - -error[E0432]: unresolved import `super` - --> $DIR/use-path-segment-kw.rs:146:13 - | -LL | use super; - | ^^^^^ no `super` in the root - -error[E0432]: unresolved import `super` - --> $DIR/use-path-segment-kw.rs:147:17 - | -LL | pub use super as _super; - | ^^^^^^^^^^^^^^^ no `super` in the root - -error[E0432]: unresolved import `super` - --> $DIR/use-path-segment-kw.rs:150:13 - | -LL | use ::super; - | ^^^^^^^ no `super` in the root - -error[E0432]: unresolved import `super` - --> $DIR/use-path-segment-kw.rs:151:13 - | -LL | use ::super as _super2; - | ^^^^^^^^^^^^^^^^^^ no `super` in the root - -error[E0432]: unresolved import `super` - --> $DIR/use-path-segment-kw.rs:152:16 - | -LL | use ::{super}; - | ^^^^^ no `super` in the root - -error[E0432]: unresolved import `super` - --> $DIR/use-path-segment-kw.rs:153:16 - | -LL | use ::{super as _nested_super2}; - | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root - -error[E0432]: unresolved import `foobar::super` - --> $DIR/use-path-segment-kw.rs:156:13 - | -LL | use foobar::super; - | ^^^^^^^^^^^^^ no `super` in `foo::bar::foobar` - -error[E0432]: unresolved import `foobar::super` - --> $DIR/use-path-segment-kw.rs:157:13 - | -LL | use foobar::super as _super3; - | ^^^^^^^^^^^^^^^^^^^^^^^^ no `super` in `foo::bar::foobar` - -error[E0432]: unresolved import `foobar::super` - --> $DIR/use-path-segment-kw.rs:158:22 - | -LL | use foobar::{super}; - | ^^^^^ no `super` in `foo::bar::foobar` - -error[E0432]: unresolved import `foobar::super` - --> $DIR/use-path-segment-kw.rs:159:22 - | -LL | use foobar::{super as _nested_super3}; - | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in `foo::bar::foobar` - -error[E0432]: unresolved import `crate::super` - --> $DIR/use-path-segment-kw.rs:162:13 - | -LL | use crate::super; - | ^^^^^^^^^^^^ no `super` in the root - -error[E0432]: unresolved import `crate::super` - --> $DIR/use-path-segment-kw.rs:163:13 - | -LL | use crate::super as _super4; - | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root - -error[E0432]: unresolved import `crate::super` - --> $DIR/use-path-segment-kw.rs:164:21 - | -LL | use crate::{super}; - | ^^^^^ no `super` in the root - -error[E0432]: unresolved import `crate::super` - --> $DIR/use-path-segment-kw.rs:165:21 - | -LL | use crate::{super as _nested_super4}; - | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root - -error[E0432]: unresolved import `super::super` - --> $DIR/use-path-segment-kw.rs:168:13 - | -LL | use super::super; - | ^^^^^^^^^^^^ no `super` in `foo` - -error[E0432]: unresolved import `super::super` - --> $DIR/use-path-segment-kw.rs:169:17 - | -LL | pub use super::super as _super5; - | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in `foo` - -error[E0432]: unresolved import `super::super` - --> $DIR/use-path-segment-kw.rs:170:21 - | -LL | use super::{super}; - | ^^^^^ no `super` in `foo` - -error[E0432]: unresolved import `super::super` - --> $DIR/use-path-segment-kw.rs:171:25 - | -LL | pub use super::{super as _nested_super5}; - | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in `foo` - -error[E0432]: unresolved import `self` - --> $DIR/use-path-segment-kw.rs:181:13 - | -LL | use self::{}; - | ^^^^^^^^ no `self` in the root - -error[E0432]: unresolved import `{{root}}` - --> $DIR/use-path-segment-kw.rs:188:13 - | -LL | use ::self; - | ^^^^^^ no `{{root}}` in the root - -error[E0432]: unresolved import `{{root}}` - --> $DIR/use-path-segment-kw.rs:190:13 - | -LL | use ::self as _self2; - | ^^^^^^^^^^^^^^^^ no `{{root}}` in the root - -error[E0432]: unresolved import `super` - --> $DIR/use-path-segment-kw.rs:211:13 - | -LL | use super::self; - | ^^^^^^^^^^^ no `super` in the root - -error[E0432]: unresolved import `super` - --> $DIR/use-path-segment-kw.rs:213:17 - | -LL | pub use super::self as _self5; - | ^^^^^^^^^^^^^^^^^^^^^ no `super` in the root - -error[E0432]: unresolved import `super` - --> $DIR/use-path-segment-kw.rs:215:21 - | -LL | use super::{self}; - | ^^^^ no `super` in the root - -error[E0432]: unresolved import `super` - --> $DIR/use-path-segment-kw.rs:216:25 - | -LL | pub use super::{self as _nested_self5}; - | ^^^^^^^^^^^^^^^^^^^^^ no `super` in the root - -error[E0432]: unresolved import `self` - --> $DIR/use-path-segment-kw.rs:221:20 - | -LL | use self::{self}; - | ^^^^ no `self` in the root - -error[E0432]: unresolved import `self` - --> $DIR/use-path-segment-kw.rs:222:24 - | -LL | pub use self::{self as _nested_self6}; - | ^^^^^^^^^^^^^^^^^^^^^ no `self` in the root - -error[E0432]: unresolved import `$crate` - --> $DIR/use-path-segment-kw.rs:13:13 - | -LL | use ::$crate; - | ^^^^^^^^ no `$crate` in the root +LL | use crate::$crate as _dollar_crate4; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `$crate` - --> $DIR/use-path-segment-kw.rs:14:13 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:29:21 | -LL | use ::$crate as _dollar_crate2; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root +LL | use crate::{$crate}; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `$crate` - --> $DIR/use-path-segment-kw.rs:15:16 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:30:21 | -LL | use ::{$crate}; - | ^^^^^^ no `$crate` in the root +LL | use crate::{$crate as _nested_dollar_crate4}; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `$crate` - --> $DIR/use-path-segment-kw.rs:16:16 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:33:20 | -LL | use ::{$crate as _nested_dollar_crate2}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root +LL | use super::$crate; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `foobar::$crate` - --> $DIR/use-path-segment-kw.rs:19:13 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:34:20 | -LL | use foobar::$crate; - | ^^^^^^^^^^^^^^ no `$crate` in `foo::bar::foobar` +LL | use super::$crate as _dollar_crate5; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `foobar::$crate` - --> $DIR/use-path-segment-kw.rs:20:13 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:35:21 | -LL | use foobar::$crate as _dollar_crate3; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in `foo::bar::foobar` +LL | use super::{$crate}; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `foobar::$crate` - --> $DIR/use-path-segment-kw.rs:21:22 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:36:21 | -LL | use foobar::{$crate}; - | ^^^^^^ no `$crate` in `foo::bar::foobar` +LL | use super::{$crate as _nested_dollar_crate5}; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `foobar::$crate` - --> $DIR/use-path-segment-kw.rs:22:22 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:39:19 | -LL | use foobar::{$crate as _nested_dollar_crate3}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in `foo::bar::foobar` +LL | use self::$crate; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `crate::$crate` - --> $DIR/use-path-segment-kw.rs:25:13 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:40:19 | -LL | use crate::$crate; - | ^^^^^^^^^^^^^ no `$crate` in the root +LL | use self::$crate as _dollar_crate6; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `crate::$crate` - --> $DIR/use-path-segment-kw.rs:26:13 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:41:20 | -LL | use crate::$crate as _dollar_crate4; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root +LL | use self::{$crate}; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `crate::$crate` - --> $DIR/use-path-segment-kw.rs:27:21 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:42:20 | -LL | use crate::{$crate}; - | ^^^^^^ no `$crate` in the root +LL | use self::{$crate as _nested_dollar_crate6}; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `crate::$crate` - --> $DIR/use-path-segment-kw.rs:28:21 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:45:21 | -LL | use crate::{$crate as _nested_dollar_crate4}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root +LL | use $crate::$crate; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `super::$crate` - --> $DIR/use-path-segment-kw.rs:31:13 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:46:21 | -LL | use super::$crate; - | ^^^^^^^^^^^^^ no `$crate` in `foo` +LL | use $crate::$crate as _dollar_crate7; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `super::$crate` - --> $DIR/use-path-segment-kw.rs:32:13 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:47:22 | -LL | use super::$crate as _dollar_crate5; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in `foo` +LL | use $crate::{$crate}; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `super::$crate` - --> $DIR/use-path-segment-kw.rs:33:21 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:48:22 | -LL | use super::{$crate}; - | ^^^^^^ no `$crate` in `foo` +LL | use $crate::{$crate as _nested_dollar_crate7}; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `super::$crate` - --> $DIR/use-path-segment-kw.rs:34:21 +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:51:21 | -LL | use super::{$crate as _nested_dollar_crate5}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in `foo` +LL | use $crate::crate; + | ^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `$crate::$crate` - --> $DIR/use-path-segment-kw.rs:43:13 +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:52:21 | -LL | use $crate::$crate; - | ^^^^^^^^^^^^^^ no `$crate` in the root +LL | use $crate::crate as _m_crate8; + | ^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `$crate::$crate` - --> $DIR/use-path-segment-kw.rs:44:13 +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:53:22 | -LL | use $crate::$crate as _dollar_crate7; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root +LL | use $crate::{crate}; + | ^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `$crate::$crate` - --> $DIR/use-path-segment-kw.rs:45:22 +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:54:22 | -LL | use $crate::{$crate}; - | ^^^^^^ no `$crate` in the root +LL | use $crate::{crate as _m_nested_crate8}; + | ^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `$crate::$crate` - --> $DIR/use-path-segment-kw.rs:46:22 +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:57:21 | -LL | use $crate::{$crate as _nested_dollar_crate7}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root +LL | use $crate::super; + | ^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `$crate::crate` - --> $DIR/use-path-segment-kw.rs:49:13 +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:58:21 | -LL | use $crate::crate; - | ^^^^^^^^^^^^^ no `crate` in the root +LL | use $crate::super as _m_super8; + | ^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `$crate::crate` - --> $DIR/use-path-segment-kw.rs:51:13 +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:59:22 | -LL | use $crate::crate as _m_crate8; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root +LL | use $crate::{super}; + | ^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `$crate::crate` - --> $DIR/use-path-segment-kw.rs:52:22 +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:60:22 | -LL | use $crate::{crate}; - | ^^^^^ no `crate` in the root +LL | use $crate::{super as _m_nested_super8}; + | ^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `$crate::crate` - --> $DIR/use-path-segment-kw.rs:54:22 +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:63:19 | -LL | use $crate::{crate as _m_nested_crate8}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root +LL | use $crate::self; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider importing the module directly + | +LL - use $crate::self; +LL + use $crate; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use $crate::{self}; + | + + -error[E0432]: unresolved import `$crate::super` - --> $DIR/use-path-segment-kw.rs:57:13 +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:63:21 | -LL | use $crate::super; - | ^^^^^^^^^^^^^ no `super` in the root +LL | use $crate::self; + | ^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0432]: unresolved import `$crate::super` - --> $DIR/use-path-segment-kw.rs:58:13 +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:65:23 | -LL | use $crate::super as _m_super8; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root +LL | pub use $crate::self as _m_self8; + | ^^^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider importing the module directly + | +LL - pub use $crate::self as _m_self8; +LL + pub use $crate as _m_self8; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | pub use $crate::{self as _m_self8}; + | + + -error[E0432]: unresolved import `$crate::super` - --> $DIR/use-path-segment-kw.rs:59:22 +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:66:22 | -LL | use $crate::{super}; - | ^^^^^ no `super` in the root +LL | use $crate::{self}; + | ^^^^ ... LL | macro_dollar_crate!(); | --------------------- in this macro invocation | = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) +help: try renaming it with a name + | +LL | use $crate::{self as name}; + | +++++++ -error[E0432]: unresolved import `$crate::super` - --> $DIR/use-path-segment-kw.rs:60:22 +error[E0432]: unresolved import `foobar` + --> $DIR/use-path-segment-kw.rs:185:17 | -LL | use $crate::{super as _m_nested_super8}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root -... -LL | macro_dollar_crate!(); - | --------------------- in this macro invocation +LL | pub use foobar::qux::self; + | ^^^^^^ help: a similar path exists: `self::foobar` + +error[E0432]: unresolved import `foobar` + --> $DIR/use-path-segment-kw.rs:187:17 | - = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) +LL | pub use foobar::self as _self3; + | ^^^^^^^^^^^^^^^^^^^^^^ no `foobar` in the root + +error[E0432]: unresolved import `foobar` + --> $DIR/use-path-segment-kw.rs:189:17 + | +LL | pub use foobar::baz::{self}; + | ^^^^^^ help: a similar path exists: `self::foobar` + +error[E0432]: unresolved import `foobar` + --> $DIR/use-path-segment-kw.rs:190:26 + | +LL | pub use foobar::{self as _nested_self3}; + | ^^^^^^^^^^^^^^^^^^^^^ no `foobar` in the root error[E0573]: expected type, found module `$crate` - --> $DIR/use-path-segment-kw.rs:8:19 + --> $DIR/use-path-segment-kw.rs:10:19 | LL | type A1 = $crate; | ^^^^^^ not a type @@ -1033,37 +941,37 @@ LL | macro_dollar_crate!(); = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0573]: expected type, found module `crate` - --> $DIR/use-path-segment-kw.rs:97:19 + --> $DIR/use-path-segment-kw.rs:94:19 | LL | type B1 = crate; | ^^^^^ not a type error[E0573]: expected type, found module `super` - --> $DIR/use-path-segment-kw.rs:145:19 + --> $DIR/use-path-segment-kw.rs:132:19 | LL | type C1 = super; | ^^^^^ not a type error[E0573]: expected type, found module `super::super` - --> $DIR/use-path-segment-kw.rs:167:19 + --> $DIR/use-path-segment-kw.rs:154:19 | LL | type C5 = super::super; | ^^^^^^^^^^^^ not a type error[E0573]: expected type, found module `self::super` - --> $DIR/use-path-segment-kw.rs:173:19 + --> $DIR/use-path-segment-kw.rs:160:19 | LL | type C6 = self::super; | ^^^^^^^^^^^ not a type error[E0573]: expected type, found module `self` - --> $DIR/use-path-segment-kw.rs:183:19 + --> $DIR/use-path-segment-kw.rs:170:19 | LL | type D1 = self; | ^^^^ not a type error[E0433]: failed to resolve: global paths cannot start with `$crate` - --> $DIR/use-path-segment-kw.rs:12:21 + --> $DIR/use-path-segment-kw.rs:14:21 | LL | type A2 = ::$crate; | ^^^^^^ global paths cannot start with `$crate` @@ -1074,7 +982,7 @@ LL | macro_dollar_crate!(); = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0433]: failed to resolve: `$crate` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:18:27 + --> $DIR/use-path-segment-kw.rs:20:27 | LL | type A3 = foobar::$crate; | ^^^^^^ `$crate` in paths can only be used in start position @@ -1085,7 +993,7 @@ LL | macro_dollar_crate!(); = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0433]: failed to resolve: `$crate` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:24:26 + --> $DIR/use-path-segment-kw.rs:26:26 | LL | type A4 = crate::$crate; | ^^^^^^ `$crate` in paths can only be used in start position @@ -1096,7 +1004,7 @@ LL | macro_dollar_crate!(); = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0433]: failed to resolve: `$crate` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:30:26 + --> $DIR/use-path-segment-kw.rs:32:26 | LL | type A5 = super::$crate; | ^^^^^^ `$crate` in paths can only be used in start position @@ -1107,7 +1015,7 @@ LL | macro_dollar_crate!(); = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0433]: failed to resolve: `$crate` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:36:25 + --> $DIR/use-path-segment-kw.rs:38:25 | LL | type A6 = self::$crate; | ^^^^^^ `$crate` in paths can only be used in start position @@ -1118,7 +1026,7 @@ LL | macro_dollar_crate!(); = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0433]: failed to resolve: `$crate` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:42:27 + --> $DIR/use-path-segment-kw.rs:44:27 | LL | type A7 = $crate::$crate; | ^^^^^^ `$crate` in paths can only be used in start position @@ -1129,7 +1037,7 @@ LL | macro_dollar_crate!(); = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0433]: failed to resolve: `crate` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:48:27 + --> $DIR/use-path-segment-kw.rs:50:27 | LL | type A8 = $crate::crate; | ^^^^^ `crate` in paths can only be used in start position @@ -1162,84 +1070,84 @@ LL | macro_dollar_crate!(); = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0433]: failed to resolve: global paths cannot start with `crate` - --> $DIR/use-path-segment-kw.rs:101:21 + --> $DIR/use-path-segment-kw.rs:98:21 | LL | type B2 = ::crate; | ^^^^^ global paths cannot start with `crate` error[E0433]: failed to resolve: `crate` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:109:27 + --> $DIR/use-path-segment-kw.rs:104:27 | LL | type B3 = foobar::crate; | ^^^^^ `crate` in paths can only be used in start position error[E0433]: failed to resolve: `crate` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:117:26 + --> $DIR/use-path-segment-kw.rs:110:26 | LL | type B4 = crate::crate; | ^^^^^ `crate` in paths can only be used in start position error[E0433]: failed to resolve: `crate` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:125:26 + --> $DIR/use-path-segment-kw.rs:116:26 | LL | type B5 = super::crate; | ^^^^^ `crate` in paths can only be used in start position error[E0433]: failed to resolve: `crate` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:133:25 + --> $DIR/use-path-segment-kw.rs:122:25 | LL | type B6 = self::crate; | ^^^^^ `crate` in paths can only be used in start position error[E0433]: failed to resolve: global paths cannot start with `super` - --> $DIR/use-path-segment-kw.rs:149:21 + --> $DIR/use-path-segment-kw.rs:136:21 | LL | type C2 = ::super; | ^^^^^ global paths cannot start with `super` error[E0433]: failed to resolve: `super` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:155:27 + --> $DIR/use-path-segment-kw.rs:142:27 | LL | type C3 = foobar::super; | ^^^^^ `super` in paths can only be used in start position error[E0433]: failed to resolve: `super` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:161:26 + --> $DIR/use-path-segment-kw.rs:148:26 | LL | type C4 = crate::super; | ^^^^^ `super` in paths can only be used in start position error[E0433]: failed to resolve: global paths cannot start with `self` - --> $DIR/use-path-segment-kw.rs:187:21 + --> $DIR/use-path-segment-kw.rs:174:21 | LL | type D2 = ::self; | ^^^^ global paths cannot start with `self` error[E0433]: failed to resolve: `self` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:195:27 + --> $DIR/use-path-segment-kw.rs:184:27 | LL | type D3 = foobar::self; | ^^^^ `self` in paths can only be used in start position error[E0433]: failed to resolve: `self` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:201:26 + --> $DIR/use-path-segment-kw.rs:192:26 | LL | type D4 = crate::self; | ^^^^ `self` in paths can only be used in start position error[E0433]: failed to resolve: `self` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:210:26 + --> $DIR/use-path-segment-kw.rs:199:26 | LL | type D5 = super::self; | ^^^^ `self` in paths can only be used in start position error[E0433]: failed to resolve: `self` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:218:25 + --> $DIR/use-path-segment-kw.rs:206:25 | LL | type D6 = self::self; | ^^^^ `self` in paths can only be used in start position -error: aborting due to 141 previous errors +error: aborting due to 128 previous errors -Some errors have detailed explanations: E0252, E0429, E0431, E0432, E0433, E0573. -For more information about an error, try `rustc --explain E0252`. +Some errors have detailed explanations: E0429, E0432, E0433, E0573. +For more information about an error, try `rustc --explain E0429`. diff --git a/tests/ui/use/use-path-segment-kw.e2018.stderr b/tests/ui/use/use-path-segment-kw.e2018.stderr new file mode 100644 index 0000000000000..c99ddb29d2ab5 --- /dev/null +++ b/tests/ui/use/use-path-segment-kw.e2018.stderr @@ -0,0 +1,1130 @@ +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:95:13 + | +LL | use crate; + | ^^^^^ + | +help: try renaming it with a name + | +LL | use crate as name; + | +++++++ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:99:15 + | +LL | use ::crate; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:100:15 + | +LL | use ::crate as _crate2; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:101:16 + | +LL | use ::{crate}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:102:16 + | +LL | use ::{crate as _nested_crate2}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:105:21 + | +LL | use foobar::crate; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:106:21 + | +LL | use foobar::crate as _crate3; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:107:22 + | +LL | use foobar::{crate}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:108:22 + | +LL | use foobar::{crate as _nested_crate3}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:111:20 + | +LL | use crate::crate; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:112:20 + | +LL | use crate::crate as _crate4; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:113:21 + | +LL | use crate::{crate}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:114:21 + | +LL | use crate::{crate as _nested_crate4}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:117:20 + | +LL | use super::crate; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:118:20 + | +LL | use super::crate as _crate5; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:119:21 + | +LL | use super::{crate}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:120:21 + | +LL | use super::{crate as _nested_crate5}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:123:19 + | +LL | use self::crate; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:124:19 + | +LL | use self::crate as _crate6; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:125:20 + | +LL | use self::{crate}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:126:20 + | +LL | use self::{crate as _nested_crate6}; + | ^^^^^ + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:133:13 + | +LL | use super; + | ^^^^^ + | +help: try renaming it with a name + | +LL | use super as name; + | +++++++ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:137:15 + | +LL | use ::super; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:138:15 + | +LL | use ::super as _super2; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:139:16 + | +LL | use ::{super}; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:140:16 + | +LL | use ::{super as _nested_super2}; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:143:21 + | +LL | use foobar::super; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:144:21 + | +LL | use foobar::super as _super3; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:145:22 + | +LL | use foobar::{super}; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:146:22 + | +LL | use foobar::{super as _nested_super3}; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:149:20 + | +LL | use crate::super; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:150:20 + | +LL | use crate::super as _super4; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:151:21 + | +LL | use crate::{super}; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:152:21 + | +LL | use crate::{super as _nested_super4}; + | ^^^^^ + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:155:20 + | +LL | use super::super; + | ^^^^^ + | +help: try renaming it with a name + | +LL | use super::super as name; + | +++++++ + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:157:21 + | +LL | use super::{super}; + | ^^^^^ + | +help: try renaming it with a name + | +LL | use super::{super as name}; + | +++++++ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:161:19 + | +LL | use self::super; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:162:19 + | +LL | use self::super as _super6; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:163:20 + | +LL | use self::{super}; + | ^^^^^ + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:164:20 + | +LL | use self::{super as _nested_super6}; + | ^^^^^ + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:171:13 + | +LL | use self; + | ^^^^ + +error: extern prelude cannot be imported + --> $DIR/use-path-segment-kw.rs:175:13 + | +LL | use ::self; + | ^^^^^^ + +error: extern prelude cannot be imported + --> $DIR/use-path-segment-kw.rs:178:13 + | +LL | use ::self as _self2; + | ^^^^^^^^^^^^^^^^ + +error: extern prelude cannot be imported + --> $DIR/use-path-segment-kw.rs:180:16 + | +LL | use ::{self}; + | ^^^^ + +error: extern prelude cannot be imported + --> $DIR/use-path-segment-kw.rs:182:20 + | +LL | pub use ::{self as _nested_self2}; + | ^^^^^^^^^^^^^^^^^^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:185:28 + | +LL | pub use foobar::qux::self; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - pub use foobar::qux::self; +LL + pub use foobar::qux; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | pub use foobar::qux::{self}; + | + + + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:187:23 + | +LL | pub use foobar::self as _self3; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - pub use foobar::self as _self3; +LL + pub use foobar as _self3; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | pub use foobar::{self as _self3}; + | + + + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:193:18 + | +LL | use crate::self; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - use crate::self; +LL + use crate; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use crate::{self}; + | + + + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:193:20 + | +LL | use crate::self; + | ^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:195:22 + | +LL | pub use crate::self as _self4; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - pub use crate::self as _self4; +LL + pub use crate as _self4; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | pub use crate::{self as _self4}; + | + + + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:196:21 + | +LL | use crate::{self}; + | ^^^^ + | +help: try renaming it with a name + | +LL | use crate::{self as name}; + | +++++++ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:200:18 + | +LL | use super::self; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - use super::self; +LL + use super; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use super::{self}; + | + + + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:200:20 + | +LL | use super::self; + | ^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:202:22 + | +LL | pub use super::self as _self5; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - pub use super::self as _self5; +LL + pub use super as _self5; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | pub use super::{self as _self5}; + | + + + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:203:21 + | +LL | use super::{self}; + | ^^^^ + | +help: try renaming it with a name + | +LL | use super::{self as name}; + | +++++++ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:207:17 + | +LL | use self::self; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - use self::self; +LL + use self; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use self::{self}; + | + + + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:207:19 + | +LL | use self::self; + | ^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:209:21 + | +LL | pub use self::self as _self6; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - pub use self::self as _self6; +LL + pub use self as _self6; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | pub use self::{self as _self6}; + | + + + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:210:20 + | +LL | use self::{self}; + | ^^^^ + | +help: try renaming it with a name + | +LL | use self::{self as name}; + | +++++++ + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:11:13 + | +LL | use $crate; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) +help: try renaming it with a name + | +LL | use $crate as name; + | +++++++ + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:15:15 + | +LL | use ::$crate; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:16:15 + | +LL | use ::$crate as _dollar_crate2; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:17:16 + | +LL | use ::{$crate}; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:18:16 + | +LL | use ::{$crate as _nested_dollar_crate2}; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:21:21 + | +LL | use foobar::$crate; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:22:21 + | +LL | use foobar::$crate as _dollar_crate3; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:23:22 + | +LL | use foobar::{$crate}; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:24:22 + | +LL | use foobar::{$crate as _nested_dollar_crate3}; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:27:20 + | +LL | use crate::$crate; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:28:20 + | +LL | use crate::$crate as _dollar_crate4; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:29:21 + | +LL | use crate::{$crate}; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:30:21 + | +LL | use crate::{$crate as _nested_dollar_crate4}; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:33:20 + | +LL | use super::$crate; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:34:20 + | +LL | use super::$crate as _dollar_crate5; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:35:21 + | +LL | use super::{$crate}; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:36:21 + | +LL | use super::{$crate as _nested_dollar_crate5}; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:39:19 + | +LL | use self::$crate; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:40:19 + | +LL | use self::$crate as _dollar_crate6; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:41:20 + | +LL | use self::{$crate}; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:42:20 + | +LL | use self::{$crate as _nested_dollar_crate6}; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:45:21 + | +LL | use $crate::$crate; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:46:21 + | +LL | use $crate::$crate as _dollar_crate7; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:47:22 + | +LL | use $crate::{$crate}; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:48:22 + | +LL | use $crate::{$crate as _nested_dollar_crate7}; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:51:21 + | +LL | use $crate::crate; + | ^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:52:21 + | +LL | use $crate::crate as _m_crate8; + | ^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:53:22 + | +LL | use $crate::{crate}; + | ^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:54:22 + | +LL | use $crate::{crate as _m_nested_crate8}; + | ^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:57:21 + | +LL | use $crate::super; + | ^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:58:21 + | +LL | use $crate::super as _m_super8; + | ^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:59:22 + | +LL | use $crate::{super}; + | ^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `super` in paths can only be used in start position or after another `super` + --> $DIR/use-path-segment-kw.rs:60:22 + | +LL | use $crate::{super as _m_nested_super8}; + | ^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:63:19 + | +LL | use $crate::self; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider importing the module directly + | +LL - use $crate::self; +LL + use $crate; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use $crate::{self}; + | + + + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:63:21 + | +LL | use $crate::self; + | ^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:65:23 + | +LL | pub use $crate::self as _m_self8; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider importing the module directly + | +LL - pub use $crate::self as _m_self8; +LL + pub use $crate as _m_self8; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | pub use $crate::{self as _m_self8}; + | + + + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:66:22 + | +LL | use $crate::{self}; + | ^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) +help: try renaming it with a name + | +LL | use $crate::{self as name}; + | +++++++ + +error[E0433]: failed to resolve: could not find `_nested_self2` in `bar` + --> $DIR/use-path-segment-kw.rs:231:15 + | +LL | foo::bar::_nested_self2::outer(); + | ^^^^^^^^^^^^^ could not find `_nested_self2` in `bar` + +error[E0573]: expected type, found module `$crate` + --> $DIR/use-path-segment-kw.rs:10:19 + | +LL | type A1 = $crate; + | ^^^^^^ not a type +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0573]: expected type, found module `crate` + --> $DIR/use-path-segment-kw.rs:94:19 + | +LL | type B1 = crate; + | ^^^^^ not a type + +error[E0573]: expected type, found module `super` + --> $DIR/use-path-segment-kw.rs:132:19 + | +LL | type C1 = super; + | ^^^^^ not a type + +error[E0573]: expected type, found module `super::super` + --> $DIR/use-path-segment-kw.rs:154:19 + | +LL | type C5 = super::super; + | ^^^^^^^^^^^^ not a type + +error[E0573]: expected type, found module `self::super` + --> $DIR/use-path-segment-kw.rs:160:19 + | +LL | type C6 = self::super; + | ^^^^^^^^^^^ not a type + +error[E0573]: expected type, found module `self` + --> $DIR/use-path-segment-kw.rs:170:19 + | +LL | type D1 = self; + | ^^^^ not a type + +error[E0433]: failed to resolve: global paths cannot start with `$crate` + --> $DIR/use-path-segment-kw.rs:14:21 + | +LL | type A2 = ::$crate; + | ^^^^^^ global paths cannot start with `$crate` +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:20:27 + | +LL | type A3 = foobar::$crate; + | ^^^^^^ `$crate` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:26:26 + | +LL | type A4 = crate::$crate; + | ^^^^^^ `$crate` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:32:26 + | +LL | type A5 = super::$crate; + | ^^^^^^ `$crate` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:38:25 + | +LL | type A6 = self::$crate; + | ^^^^^^ `$crate` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:44:27 + | +LL | type A7 = $crate::$crate; + | ^^^^^^ `$crate` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:50:27 + | +LL | type A8 = $crate::crate; + | ^^^^^ `crate` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `super` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:56:27 + | +LL | type A9 = $crate::super; + | ^^^^^ `super` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:62:28 + | +LL | type A10 = $crate::self; + | ^^^^ `self` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: global paths cannot start with `crate` + --> $DIR/use-path-segment-kw.rs:98:21 + | +LL | type B2 = ::crate; + | ^^^^^ global paths cannot start with `crate` + +error[E0433]: failed to resolve: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:104:27 + | +LL | type B3 = foobar::crate; + | ^^^^^ `crate` in paths can only be used in start position + +error[E0433]: failed to resolve: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:110:26 + | +LL | type B4 = crate::crate; + | ^^^^^ `crate` in paths can only be used in start position + +error[E0433]: failed to resolve: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:116:26 + | +LL | type B5 = super::crate; + | ^^^^^ `crate` in paths can only be used in start position + +error[E0433]: failed to resolve: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:122:25 + | +LL | type B6 = self::crate; + | ^^^^^ `crate` in paths can only be used in start position + +error[E0433]: failed to resolve: global paths cannot start with `super` + --> $DIR/use-path-segment-kw.rs:136:21 + | +LL | type C2 = ::super; + | ^^^^^ global paths cannot start with `super` + +error[E0433]: failed to resolve: `super` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:142:27 + | +LL | type C3 = foobar::super; + | ^^^^^ `super` in paths can only be used in start position + +error[E0433]: failed to resolve: `super` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:148:26 + | +LL | type C4 = crate::super; + | ^^^^^ `super` in paths can only be used in start position + +error[E0433]: failed to resolve: global paths cannot start with `self` + --> $DIR/use-path-segment-kw.rs:174:21 + | +LL | type D2 = ::self; + | ^^^^ global paths cannot start with `self` + +error[E0433]: failed to resolve: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:184:27 + | +LL | type D3 = foobar::self; + | ^^^^ `self` in paths can only be used in start position + +error[E0433]: failed to resolve: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:192:26 + | +LL | type D4 = crate::self; + | ^^^^ `self` in paths can only be used in start position + +error[E0433]: failed to resolve: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:199:26 + | +LL | type D5 = super::self; + | ^^^^ `self` in paths can only be used in start position + +error[E0433]: failed to resolve: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:206:25 + | +LL | type D6 = self::self; + | ^^^^ `self` in paths can only be used in start position + +error: aborting due to 125 previous errors + +Some errors have detailed explanations: E0429, E0433, E0573. +For more information about an error, try `rustc --explain E0429`. diff --git a/tests/ui/use/use-path-segment-kw.rs b/tests/ui/use/use-path-segment-kw.rs index 680ecd3d03d49..c38ce767e0e10 100644 --- a/tests/ui/use/use-path-segment-kw.rs +++ b/tests/ui/use/use-path-segment-kw.rs @@ -1,4 +1,6 @@ -//@ edition: 2018.. +//@ revisions: e2015 e2018 +//@ [e2015] edition: 2015 +//@ [e2018] edition: 2018.. macro_rules! macro_dollar_crate { () => { @@ -6,67 +8,62 @@ macro_rules! macro_dollar_crate { use $crate::{}; type A1 = $crate; //~ ERROR expected type, found module `$crate` - use $crate; //~ ERROR `$crate` may not be imported - pub use $crate as _dollar_crate; //~ ERROR `$crate` may not be imported + use $crate; //~ ERROR imports need to be explicitly named + pub use $crate as _dollar_crate; type A2 = ::$crate; //~ ERROR failed to resolve: global paths cannot start with `$crate` - use ::$crate; //~ ERROR unresolved import `$crate` - use ::$crate as _dollar_crate2; //~ ERROR unresolved import `$crate` - use ::{$crate}; //~ ERROR unresolved import `$crate` - use ::{$crate as _nested_dollar_crate2}; //~ ERROR unresolved import `$crate` + use ::$crate; //~ ERROR `$crate` in paths can only be used in start position + use ::$crate as _dollar_crate2; //~ ERROR `$crate` in paths can only be used in start position + use ::{$crate}; //~ ERROR `$crate` in paths can only be used in start position + use ::{$crate as _nested_dollar_crate2}; //~ ERROR `$crate` in paths can only be used in start position type A3 = foobar::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position - use foobar::$crate; //~ ERROR unresolved import `foobar::$crate` - use foobar::$crate as _dollar_crate3; //~ ERROR unresolved import `foobar::$crate` - use foobar::{$crate}; //~ ERROR unresolved import `foobar::$crate` - use foobar::{$crate as _nested_dollar_crate3}; //~ ERROR unresolved import `foobar::$crate` + use foobar::$crate; //~ ERROR `$crate` in paths can only be used in start position + use foobar::$crate as _dollar_crate3; //~ ERROR `$crate` in paths can only be used in start position + use foobar::{$crate}; //~ ERROR `$crate` in paths can only be used in start position + use foobar::{$crate as _nested_dollar_crate3}; //~ ERROR `$crate` in paths can only be used in start position type A4 = crate::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position - use crate::$crate; //~ ERROR unresolved import `crate::$crate` - use crate::$crate as _dollar_crate4; //~ ERROR unresolved import `crate::$crate` - use crate::{$crate}; //~ ERROR unresolved import `crate::$crate` - use crate::{$crate as _nested_dollar_crate4}; //~ ERROR unresolved import `crate::$crate` + use crate::$crate; //~ ERROR `$crate` in paths can only be used in start position + use crate::$crate as _dollar_crate4; //~ ERROR `$crate` in paths can only be used in start position + use crate::{$crate}; //~ ERROR `$crate` in paths can only be used in start position + use crate::{$crate as _nested_dollar_crate4}; //~ ERROR `$crate` in paths can only be used in start position type A5 = super::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position - use super::$crate; //~ ERROR unresolved import `super::$crate` - use super::$crate as _dollar_crate5; //~ ERROR unresolved import `super::$crate` - use super::{$crate}; //~ ERROR unresolved import `super::$crate` - use super::{$crate as _nested_dollar_crate5}; //~ ERROR unresolved import `super::$crate` + use super::$crate; //~ ERROR `$crate` in paths can only be used in start position + use super::$crate as _dollar_crate5; //~ ERROR `$crate` in paths can only be used in start position + use super::{$crate}; //~ ERROR `$crate` in paths can only be used in start position + use super::{$crate as _nested_dollar_crate5}; //~ ERROR `$crate` in paths can only be used in start position type A6 = self::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position - use self::$crate; - use self::$crate as _dollar_crate6; - use self::{$crate}; - use self::{$crate as _nested_dollar_crate6}; + use self::$crate; //~ ERROR `$crate` in paths can only be used in start position + use self::$crate as _dollar_crate6; //~ ERROR `$crate` in paths can only be used in start position + use self::{$crate}; //~ ERROR `$crate` in paths can only be used in start position + use self::{$crate as _nested_dollar_crate6}; //~ ERROR `$crate` in paths can only be used in start position type A7 = $crate::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position - use $crate::$crate; //~ ERROR unresolved import `$crate::$crate` - use $crate::$crate as _dollar_crate7; //~ ERROR unresolved import `$crate::$crate` - use $crate::{$crate}; //~ ERROR unresolved import `$crate::$crate` - use $crate::{$crate as _nested_dollar_crate7}; //~ ERROR unresolved import `$crate::$crate` + use $crate::$crate; //~ ERROR `$crate` in paths can only be used in start position + use $crate::$crate as _dollar_crate7; //~ ERROR `$crate` in paths can only be used in start position + use $crate::{$crate}; //~ ERROR `$crate` in paths can only be used in start position + use $crate::{$crate as _nested_dollar_crate7}; //~ ERROR `$crate` in paths can only be used in start position type A8 = $crate::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position - use $crate::crate; //~ ERROR unresolved import `$crate::crate` - //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` - use $crate::crate as _m_crate8; //~ ERROR unresolved import `$crate::crate` - use $crate::{crate}; //~ ERROR unresolved import `$crate::crate` - //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` - use $crate::{crate as _m_nested_crate8}; //~ ERROR unresolved import `$crate::crate` + use $crate::crate; //~ ERROR `crate` in paths can only be used in start position + use $crate::crate as _m_crate8; //~ ERROR `crate` in paths can only be used in start position + use $crate::{crate}; //~ ERROR `crate` in paths can only be used in start position + use $crate::{crate as _m_nested_crate8}; //~ ERROR `crate` in paths can only be used in start position type A9 = $crate::super; //~ ERROR failed to resolve: `super` in paths can only be used in start position - use $crate::super; //~ ERROR unresolved import `$crate::super` - use $crate::super as _m_super8; //~ ERROR unresolved import `$crate::super` - use $crate::{super}; //~ ERROR unresolved import `$crate::super` - use $crate::{super as _m_nested_super8}; //~ ERROR unresolved import `$crate::super` + use $crate::super; //~ ERROR `super` in paths can only be used in start position or after another `super` + use $crate::super as _m_super8; //~ ERROR `super` in paths can only be used in start position or after another `super` + use $crate::{super}; //~ ERROR `super` in paths can only be used in start position or after another `super` + use $crate::{super as _m_nested_super8}; //~ ERROR `super` in paths can only be used in start position or after another `super` type A10 = $crate::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position - use $crate::self; //~ ERROR `$crate` may not be imported + use $crate::self; //~ ERROR imports need to be explicitly named //~^ ERROR `self` imports are only allowed within a { } list - //~^^ ERROR the name `` is defined multiple times pub use $crate::self as _m_self8; //~ ERROR `self` imports are only allowed within a { } list - //~^ ERROR `$crate` may not be imported - use $crate::{self}; - //~^ ERROR the name `$crate` is defined multiple times + use $crate::{self}; //~ ERROR imports need to be explicitly named pub use $crate::{self as _m_nested_self8}; // Good } } @@ -95,131 +92,123 @@ mod foo { use crate::{}; type B1 = crate; //~ ERROR expected type, found module `crate` - use crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` + use crate; //~ ERROR imports need to be explicitly named pub use crate as _crate; // Good type B2 = ::crate; //~ ERROR failed to resolve: global paths cannot start with `crate` - use ::crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` - //~^ ERROR unresolved import `crate` - use ::crate as _crate2; //~ ERROR unresolved import `crate` - use ::{crate}; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` - //~^ ERROR unresolved import `crate` - use ::{crate as _nested_crate2}; //~ ERROR unresolved import `crate` + use ::crate; //~ ERROR `crate` in paths can only be used in start position + use ::crate as _crate2; //~ ERROR `crate` in paths can only be used in start position + use ::{crate}; //~ ERROR `crate` in paths can only be used in start position + use ::{crate as _nested_crate2}; //~ ERROR `crate` in paths can only be used in start position type B3 = foobar::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position - use foobar::crate; //~ ERROR unresolved import `foobar::crate` - //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` - use foobar::crate as _crate3; //~ ERROR unresolved import `foobar::crate` - use foobar::{crate}; //~ ERROR unresolved import `foobar::crate` - //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` - use foobar::{crate as _nested_crate3}; //~ ERROR unresolved import `foobar::crate` + use foobar::crate; //~ ERROR `crate` in paths can only be used in start position + use foobar::crate as _crate3; //~ ERROR `crate` in paths can only be used in start position + use foobar::{crate}; //~ ERROR `crate` in paths can only be used in start position + use foobar::{crate as _nested_crate3}; //~ ERROR `crate` in paths can only be used in start position type B4 = crate::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position - use crate::crate; //~ ERROR unresolved import `crate::crate` - //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` - use crate::crate as _crate4; //~ ERROR unresolved import `crate::crate` - use crate::{crate}; //~ ERROR unresolved import `crate::crate` - //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` - use crate::{crate as _nested_crate4}; //~ ERROR unresolved import `crate::crate` + use crate::crate; //~ ERROR `crate` in paths can only be used in start position + use crate::crate as _crate4; //~ ERROR `crate` in paths can only be used in start position + use crate::{crate}; //~ ERROR `crate` in paths can only be used in start position + use crate::{crate as _nested_crate4}; //~ ERROR `crate` in paths can only be used in start position type B5 = super::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position - use super::crate; //~ ERROR unresolved import `super::crate` - //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` - use super::crate as _crate5; //~ ERROR unresolved import `super::crate` - use super::{crate}; //~ ERROR unresolved import `super::crate` - //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` - use super::{crate as _nested_crate5}; //~ ERROR unresolved import `super::crate` + use super::crate; //~ ERROR `crate` in paths can only be used in start position + use super::crate as _crate5; //~ ERROR `crate` in paths can only be used in start position + use super::{crate}; //~ ERROR `crate` in paths can only be used in start position + use super::{crate as _nested_crate5}; //~ ERROR `crate` in paths can only be used in start position type B6 = self::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position - use self::crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` - //~^ ERROR the name `crate` is defined multiple times - use self::crate as _crate6; - use self::{crate}; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` - //~^ ERROR the name `crate` is defined multiple times - use self::{crate as _nested_crate6}; + use self::crate; //~ ERROR `crate` in paths can only be used in start position + use self::crate as _crate6; //~ ERROR `crate` in paths can only be used in start position + use self::{crate}; //~ ERROR `crate` in paths can only be used in start position + use self::{crate as _nested_crate6}; //~ ERROR `crate` in paths can only be used in start position // --- super --- use super::*; - use super::{}; //~ ERROR unresolved import `super` + use super::{}; type C1 = super; //~ ERROR expected type, found module `super` - use super; //~ ERROR unresolved import `super` - pub use super as _super; //~ ERROR unresolved import `super` + use super; //~ ERROR imports need to be explicitly named + pub use super as _super; type C2 = ::super; //~ ERROR failed to resolve: global paths cannot start with `super` - use ::super; //~ ERROR unresolved import `super` - use ::super as _super2; //~ ERROR unresolved import `super` - use ::{super}; //~ ERROR unresolved import `super` - use ::{super as _nested_super2}; //~ ERROR unresolved import `super` + use ::super; //~ ERROR `super` in paths can only be used in start position or after another `super` + use ::super as _super2; //~ ERROR `super` in paths can only be used in start position or after another `super` + use ::{super}; //~ ERROR `super` in paths can only be used in start position or after another `super` + use ::{super as _nested_super2}; //~ ERROR `super` in paths can only be used in start position or after another `super` type C3 = foobar::super; //~ ERROR failed to resolve: `super` in paths can only be used in start position - use foobar::super; //~ ERROR unresolved import `foobar::super` - use foobar::super as _super3; //~ ERROR unresolved import `foobar::super` - use foobar::{super}; //~ ERROR unresolved import `foobar::super` - use foobar::{super as _nested_super3}; //~ ERROR unresolved import `foobar::super` + use foobar::super; //~ ERROR `super` in paths can only be used in start position or after another `super` + use foobar::super as _super3; //~ ERROR `super` in paths can only be used in start position or after another `super` + use foobar::{super}; //~ ERROR `super` in paths can only be used in start position or after another `super` + use foobar::{super as _nested_super3}; //~ ERROR `super` in paths can only be used in start position or after another `super` type C4 = crate::super; //~ ERROR failed to resolve: `super` in paths can only be used in start position - use crate::super; //~ ERROR unresolved import `crate::super` - use crate::super as _super4; //~ ERROR unresolved import `crate::super` - use crate::{super}; //~ ERROR unresolved import `crate::super` - use crate::{super as _nested_super4}; //~ ERROR unresolved import `crate::super` + use crate::super; //~ ERROR `super` in paths can only be used in start position or after another `super` + use crate::super as _super4; //~ ERROR `super` in paths can only be used in start position or after another `super` + use crate::{super}; //~ ERROR `super` in paths can only be used in start position or after another `super` + use crate::{super as _nested_super4}; //~ ERROR `super` in paths can only be used in start position or after another `super` type C5 = super::super; //~ ERROR expected type, found module `super::super` - use super::super; //~ ERROR unresolved import `super::super` - pub use super::super as _super5; //~ ERROR unresolved import `super::super` - use super::{super}; //~ ERROR unresolved import `super::super` - pub use super::{super as _nested_super5}; //~ ERROR unresolved import `super::super` + use super::super; //~ ERROR imports need to be explicitly named + pub use super::super as _super5; + use super::{super}; //~ ERROR imports need to be explicitly named + pub use super::{super as _nested_super5}; type C6 = self::super; //~ ERROR expected type, found module `self::super` - use self::super; - use self::super as _super6; - use self::{super}; - use self::{super as _nested_super6}; + use self::super; //~ ERROR `super` in paths can only be used in start position or after another `super` + use self::super as _super6; //~ ERROR `super` in paths can only be used in start position or after another `super` + use self::{super}; //~ ERROR `super` in paths can only be used in start position or after another `super` + use self::{super as _nested_super6}; //~ ERROR `super` in paths can only be used in start position or after another `super` // --- self --- // use self::*; // Suppress other errors - use self::{}; //~ ERROR unresolved import `self` + use self::{}; type D1 = self; //~ ERROR expected type, found module `self` - use self; //~ ERROR `self` imports are only allowed within a { } list - pub use self as _self; //~ ERROR `self` imports are only allowed within a { } list + use self; //~ ERROR imports need to be explicitly named + pub use self as _self; type D2 = ::self; //~ ERROR failed to resolve: global paths cannot start with `self` - use ::self; //~ ERROR `self` imports are only allowed within a { } list - //~^ ERROR unresolved import `{{root}}` - use ::self as _self2; //~ ERROR `self` imports are only allowed within a { } list - //~^ ERROR unresolved import `{{root}}` - use ::{self}; //~ ERROR `self` import can only appear in an import list with a non-empty prefix - use ::{self as _nested_self2}; //~ ERROR `self` import can only appear in an import list with a non-empty prefix + use ::self; //[e2018]~ ERROR extern prelude cannot be imported + //[e2015]~^ ERROR imports need to be explicitly named + //[e2015]~^^ ERROR `self` imports are only allowed within a { } list + use ::self as _self2; //[e2018]~ ERROR extern prelude cannot be imported + //[e2015]~^ ERROR `self` imports are only allowed within a { } list + use ::{self}; //[e2018]~ ERROR extern prelude cannot be imported + //[e2015]~^ ERROR imports need to be explicitly named + pub use ::{self as _nested_self2}; //[e2018]~ ERROR extern prelude cannot be imported type D3 = foobar::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position pub use foobar::qux::self; //~ ERROR `self` imports are only allowed within a { } list + //[e2015]~^ ERROR unresolved import `foobar` pub use foobar::self as _self3; //~ ERROR `self` imports are only allowed within a { } list - pub use foobar::baz::{self}; // Good - pub use foobar::{self as _nested_self3}; // Good + //[e2015]~^ ERROR unresolved import `foobar` + pub use foobar::baz::{self}; //[e2015]~ ERROR unresolved import `foobar` + pub use foobar::{self as _nested_self3}; //[e2015]~ ERROR unresolved import `foobar` type D4 = crate::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position - use crate::self; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` + use crate::self; //~ ERROR imports need to be explicitly named //~^ ERROR `self` imports are only allowed within a { } list - //~^^ ERROR the name `crate` is defined multiple times pub use crate::self as _self4; //~ ERROR `self` imports are only allowed within a { } list - use crate::{self}; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` - //~^ ERROR the name `crate` is defined multiple times + use crate::{self}; //~ ERROR imports need to be explicitly named pub use crate::{self as _nested_self4}; // Good type D5 = super::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position - use super::self; //~ ERROR unresolved import `super` + use super::self; //~ ERROR imports need to be explicitly named //~^ ERROR `self` imports are only allowed within a { } list pub use super::self as _self5; //~ ERROR `self` imports are only allowed within a { } list - //~^ ERROR unresolved import `super` - use super::{self}; //~ ERROR unresolved import `super` - pub use super::{self as _nested_self5}; //~ ERROR unresolved import `super` + use super::{self}; //~ ERROR imports need to be explicitly named + pub use super::{self as _nested_self5}; type D6 = self::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position use self::self; //~ ERROR `self` imports are only allowed within a { } list + //~^ ERROR imports need to be explicitly named pub use self::self as _self6; //~ ERROR `self` imports are only allowed within a { } list - use self::{self}; //~ ERROR unresolved import `self` - pub use self::{self as _nested_self6}; //~ ERROR unresolved import `self` + use self::{self}; //~ ERROR imports need to be explicitly named + pub use self::{self as _nested_self6}; } } @@ -239,6 +228,7 @@ fn main() { foo::bar::_self::foobar::inner(); foo::bar::qux::inner(); // Works after recovery foo::bar::baz::inner(); + foo::bar::_nested_self2::outer(); //[e2018]~ ERROR failed to resolve: could not find `_nested_self2` in `bar` foo::bar::_self3::inner(); // Works after recovery foo::bar::_nested_self3::inner(); foo::bar::_self4::outer(); // Works after recovery