diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4409d4f33afc2..fcdde9c91e8da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -94,6 +94,10 @@ jobs: CACHE_DOMAIN: ci-caches.rust-lang.org continue-on-error: ${{ matrix.continue_on_error || false }} strategy: + # If the user starts multiple jobs in a try build, let them all finish. + # Try builds are sometimes used to test several jobs at once, and it is useful to know which + # of them would succeed or not. + fail-fast: ${{ needs.calculate_matrix.outputs.run_type != 'try' }} matrix: # Check the `calculate_matrix` job to see how is the matrix defined. include: ${{ fromJSON(needs.calculate_matrix.outputs.jobs) }} diff --git a/Cargo.lock b/Cargo.lock index aa0bc0164e223..6afbc7d22f098 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3807,7 +3807,6 @@ name = "rustc_error_messages" version = "0.0.0" dependencies = [ "fluent-bundle", - "fluent-syntax", "icu_list", "icu_locale", "intl-memoizer", @@ -3818,7 +3817,6 @@ dependencies = [ "rustc_macros", "rustc_serialize", "rustc_span", - "tracing", "unic-langid", ] diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 3e3ccd39e674c..cbf82b05e4d6b 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -786,7 +786,6 @@ pub(crate) unsafe fn llvm_optimize( config.verify_llvm_ir, config.lint_llvm_ir, thin_lto_buffer, - config.emit_thin_lto, config.emit_thin_lto_summary, merge_functions, unroll_loops, @@ -1033,7 +1032,7 @@ pub(crate) fn codegen( "LLVM_module_codegen_make_bitcode", &*module.name, ); - ThinBuffer::new(llmod, config.emit_thin_lto) + ThinBuffer::new(llmod, cgcx.lto != Lto::Fat) }; let data = thin.data(); let _timer = prof diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 4956549f2ed3b..59bf8679d6398 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -2376,7 +2376,6 @@ unsafe extern "C" { VerifyIR: bool, LintIR: bool, ThinLTOBuffer: Option<&mut *mut ThinLTOBuffer>, - EmitThinLTO: bool, EmitThinLTOSummary: bool, MergeFunctions: bool, UnrollLoops: bool, diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 8ffab7a4d8f73..81d173af275f9 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -12,7 +12,6 @@ use rustc_data_structures::jobserver::{self, Acquired}; use rustc_data_structures::memmap::Mmap; use rustc_data_structures::profiling::{SelfProfilerRef, VerboseTimingGuard}; use rustc_errors::emitter::Emitter; -use rustc_errors::translation::Translator; use rustc_errors::{ Diag, DiagArgMap, DiagCtxt, DiagCtxtHandle, DiagMessage, ErrCode, FatalError, FatalErrorMarker, Level, MultiSpan, Style, Suggestions, catch_fatal_errors, @@ -100,7 +99,6 @@ pub struct ModuleConfig { pub emit_ir: bool, pub emit_asm: bool, pub emit_obj: EmitObj, - pub emit_thin_lto: bool, pub emit_thin_lto_summary: bool, // Miscellaneous flags. These are mostly copied from command-line @@ -211,9 +209,6 @@ impl ModuleConfig { false ), emit_obj, - // thin lto summaries prevent fat lto, so do not emit them if fat - // lto is requested. See PR #136840 for background information. - emit_thin_lto: sess.opts.unstable_opts.emit_thin_lto && sess.lto() != Lto::Fat, emit_thin_lto_summary: if_regular!( sess.opts.output_types.contains_key(&OutputType::ThinLinkBitcode), false @@ -2040,10 +2035,6 @@ impl Emitter for SharedEmitter { fn source_map(&self) -> Option<&SourceMap> { None } - - fn translator(&self) -> &Translator { - panic!("shared emitter attempted to translate a diagnostic"); - } } impl SharedEmitterMain { diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index a235d3e0aecdd..fc46102f6a30f 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -34,7 +34,6 @@ use rustc_data_structures::profiling::{ }; pub use rustc_errors::catch_fatal_errors; use rustc_errors::emitter::stderr_destination; -use rustc_errors::translation::Translator; use rustc_errors::{ColorConfig, DiagCtxt, ErrCode, PResult, markdown}; use rustc_feature::find_gated_cfg; // This avoids a false positive with `-Wunused_crate_dependencies`. @@ -107,10 +106,6 @@ use crate::session_diagnostics::{ RLinkWrongFileType, RlinkCorruptFile, RlinkNotAFile, RlinkUnableToRead, UnstableFeatureUsage, }; -pub fn default_translator() -> Translator { - Translator::new() -} - /// Exit status code used for successful compilation and help output. pub const EXIT_SUCCESS: i32 = 0; @@ -1525,11 +1520,9 @@ fn report_ice( extra_info: fn(&DiagCtxt), using_internal_features: &AtomicBool, ) { - let translator = Translator::new(); let emitter = Box::new(rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter::new( stderr_destination(rustc_errors::ColorConfig::Auto), - translator, )); let dcx = rustc_errors::DiagCtxt::new(emitter); let dcx = dcx.handle(); 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_error_messages/Cargo.toml b/compiler/rustc_error_messages/Cargo.toml index db22e065907e3..f280aaff11260 100644 --- a/compiler/rustc_error_messages/Cargo.toml +++ b/compiler/rustc_error_messages/Cargo.toml @@ -6,7 +6,6 @@ edition = "2024" [dependencies] # tidy-alphabetical-start fluent-bundle = "0.16" -fluent-syntax = "0.12" icu_list = { version = "2.0", default-features = false, features = ["alloc"] } icu_locale = { version = "2.0", default-features = false } intl-memoizer = "0.5.1" @@ -17,6 +16,5 @@ rustc_data_structures = { path = "../rustc_data_structures" } rustc_macros = { path = "../rustc_macros" } rustc_serialize = { path = "../rustc_serialize" } rustc_span = { path = "../rustc_span" } -tracing = "0.1" unic-langid = { version = "0.9.0", features = ["macros"] } # tidy-alphabetical-end diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs index 0b30102eb992b..583ca36f07130 100644 --- a/compiler/rustc_error_messages/src/lib.rs +++ b/compiler/rustc_error_messages/src/lib.rs @@ -4,194 +4,16 @@ // tidy-alphabetical-end use std::borrow::Cow; -use std::error::Error; -use std::path::Path; -use std::sync::{Arc, LazyLock}; -use std::{fmt, fs, io}; -use fluent_bundle::FluentResource; pub use fluent_bundle::types::FluentType; pub use fluent_bundle::{self, FluentArgs, FluentError, FluentValue}; -use fluent_syntax::parser::ParserError; -use intl_memoizer::concurrent::IntlLangMemoizer; -use rustc_data_structures::sync::{DynSend, IntoDynSyncSend}; use rustc_macros::{Decodable, Encodable}; use rustc_span::Span; -use tracing::{instrument, trace}; pub use unic_langid::{LanguageIdentifier, langid}; mod diagnostic_impls; pub use diagnostic_impls::DiagArgFromDisplay; -pub type FluentBundle = - IntoDynSyncSend>; - -fn new_bundle(locales: Vec) -> FluentBundle { - IntoDynSyncSend(fluent_bundle::bundle::FluentBundle::new_concurrent(locales)) -} - -#[derive(Debug)] -pub enum TranslationBundleError { - /// Failed to read from `.ftl` file. - ReadFtl(io::Error), - /// Failed to parse contents of `.ftl` file. - ParseFtl(ParserError), - /// Failed to add `FluentResource` to `FluentBundle`. - AddResource(FluentError), - /// `$sysroot/share/locale/$locale` does not exist. - MissingLocale, - /// Cannot read directory entries of `$sysroot/share/locale/$locale`. - ReadLocalesDir(io::Error), - /// Cannot read directory entry of `$sysroot/share/locale/$locale`. - ReadLocalesDirEntry(io::Error), - /// `$sysroot/share/locale/$locale` is not a directory. - LocaleIsNotDir, -} - -impl fmt::Display for TranslationBundleError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - TranslationBundleError::ReadFtl(e) => write!(f, "could not read ftl file: {e}"), - TranslationBundleError::ParseFtl(e) => { - write!(f, "could not parse ftl file: {e}") - } - TranslationBundleError::AddResource(e) => write!(f, "failed to add resource: {e}"), - TranslationBundleError::MissingLocale => write!(f, "missing locale directory"), - TranslationBundleError::ReadLocalesDir(e) => { - write!(f, "could not read locales dir: {e}") - } - TranslationBundleError::ReadLocalesDirEntry(e) => { - write!(f, "could not read locales dir entry: {e}") - } - TranslationBundleError::LocaleIsNotDir => { - write!(f, "`$sysroot/share/locales/$locale` is not a directory") - } - } - } -} - -impl Error for TranslationBundleError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match self { - TranslationBundleError::ReadFtl(e) => Some(e), - TranslationBundleError::ParseFtl(e) => Some(e), - TranslationBundleError::AddResource(e) => Some(e), - TranslationBundleError::MissingLocale => None, - TranslationBundleError::ReadLocalesDir(e) => Some(e), - TranslationBundleError::ReadLocalesDirEntry(e) => Some(e), - TranslationBundleError::LocaleIsNotDir => None, - } - } -} - -impl From<(FluentResource, Vec)> for TranslationBundleError { - fn from((_, mut errs): (FluentResource, Vec)) -> Self { - TranslationBundleError::ParseFtl(errs.pop().expect("failed ftl parse with no errors")) - } -} - -impl From> for TranslationBundleError { - fn from(mut errs: Vec) -> Self { - TranslationBundleError::AddResource( - errs.pop().expect("failed adding resource to bundle with no errors"), - ) - } -} - -/// Returns Fluent bundle with the user's locale resources from -/// `$sysroot/share/locale/$requested_locale/*.ftl`. -/// -/// If `-Z additional-ftl-path` was provided, load that resource and add it to the bundle -/// (overriding any conflicting messages). -#[instrument(level = "trace")] -pub fn fluent_bundle( - sysroot_candidates: &[&Path], - requested_locale: Option, - additional_ftl_path: Option<&Path>, - with_directionality_markers: bool, -) -> Result>, TranslationBundleError> { - if requested_locale.is_none() && additional_ftl_path.is_none() { - return Ok(None); - } - - let fallback_locale = langid!("en-US"); - let requested_fallback_locale = requested_locale.as_ref() == Some(&fallback_locale); - trace!(?requested_fallback_locale); - if requested_fallback_locale && additional_ftl_path.is_none() { - return Ok(None); - } - // If there is only `-Z additional-ftl-path`, assume locale is "en-US", otherwise use user - // provided locale. - let locale = requested_locale.clone().unwrap_or(fallback_locale); - trace!(?locale); - let mut bundle = new_bundle(vec![locale]); - - // Add convenience functions available to ftl authors. - register_functions(&mut bundle); - - // Fluent diagnostics can insert directionality isolation markers around interpolated variables - // indicating that there may be a shift from right-to-left to left-to-right text (or - // vice-versa). These are disabled because they are sometimes visible in the error output, but - // may be worth investigating in future (for example: if type names are left-to-right and the - // surrounding diagnostic messages are right-to-left, then these might be helpful). - bundle.set_use_isolating(with_directionality_markers); - - // If the user requests the default locale then don't try to load anything. - if let Some(requested_locale) = requested_locale { - let mut found_resources = false; - for sysroot in sysroot_candidates { - let mut sysroot = sysroot.to_path_buf(); - sysroot.push("share"); - sysroot.push("locale"); - sysroot.push(requested_locale.to_string()); - trace!(?sysroot); - - if !sysroot.exists() { - trace!("skipping"); - continue; - } - - if !sysroot.is_dir() { - return Err(TranslationBundleError::LocaleIsNotDir); - } - - for entry in sysroot.read_dir().map_err(TranslationBundleError::ReadLocalesDir)? { - let entry = entry.map_err(TranslationBundleError::ReadLocalesDirEntry)?; - let path = entry.path(); - trace!(?path); - if path.extension().and_then(|s| s.to_str()) != Some("ftl") { - trace!("skipping"); - continue; - } - - let resource_str = - fs::read_to_string(path).map_err(TranslationBundleError::ReadFtl)?; - let resource = - FluentResource::try_new(resource_str).map_err(TranslationBundleError::from)?; - trace!(?resource); - bundle.add_resource(resource).map_err(TranslationBundleError::from)?; - found_resources = true; - } - } - - if !found_resources { - return Err(TranslationBundleError::MissingLocale); - } - } - - if let Some(additional_ftl_path) = additional_ftl_path { - let resource_str = - fs::read_to_string(additional_ftl_path).map_err(TranslationBundleError::ReadFtl)?; - let resource = - FluentResource::try_new(resource_str).map_err(TranslationBundleError::from)?; - trace!(?resource); - bundle.add_resource_overriding(resource); - } - - let bundle = Arc::new(bundle); - Ok(Some(bundle)) -} - pub fn register_functions(bundle: &mut fluent_bundle::bundle::FluentBundle) { bundle .add_function("STREQ", |positional, _named| match positional { @@ -201,35 +23,6 @@ pub fn register_functions(bundle: &mut fluent_bundle::bundle::FluentBundle .expect("Failed to add a function to the bundle."); } -/// Type alias for the result of `fallback_fluent_bundle` - a reference-counted pointer to a lazily -/// evaluated fluent bundle. -pub type LazyFallbackBundle = - Arc FluentBundle + DynSend>>>; - -/// Return the default `FluentBundle` with standard "en-US" diagnostic messages. -#[instrument(level = "trace", skip(resources))] -pub fn fallback_fluent_bundle( - resources: Vec<&'static str>, - with_directionality_markers: bool, -) -> LazyFallbackBundle { - Arc::new(LazyLock::new(Box::new(move || { - let mut fallback_bundle = new_bundle(vec![langid!("en-US")]); - - register_functions(&mut fallback_bundle); - - // See comment in `fluent_bundle`. - fallback_bundle.set_use_isolating(with_directionality_markers); - - for resource in resources { - let resource = FluentResource::try_new(resource.to_string()) - .expect("failed to parse fallback fluent resource"); - fallback_bundle.add_resource_overriding(resource); - } - - fallback_bundle - }))) -} - /// Abstraction over a message in a diagnostic to support both translatable and non-translatable /// diagnostic messages. /// diff --git a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs index bdd3266adb66d..b68b5e87df1db 100644 --- a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs +++ b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs @@ -27,7 +27,7 @@ use crate::emitter::{ ConfusionType, Destination, MAX_SUGGESTIONS, OutputTheme, detect_confusion_type, is_different, normalize_whitespace, should_show_source_code, }; -use crate::translation::{Translator, to_fluent_args}; +use crate::translation::{format_diag_message, format_diag_messages, to_fluent_args}; use crate::{ CodeSuggestion, DiagInner, DiagMessage, Emitter, ErrCode, Level, MultiSpan, Style, Subdiag, SuggestionStyle, TerminalUrl, @@ -39,8 +39,6 @@ pub struct AnnotateSnippetEmitter { #[setters(skip)] dst: IntoDynSyncSend, sm: Option>, - #[setters(skip)] - translator: Translator, short_message: bool, ui_testing: bool, ignored_directories_in_source_blocks: Vec, @@ -108,10 +106,6 @@ impl Emitter for AnnotateSnippetEmitter { !self.short_message } - fn translator(&self) -> &Translator { - &self.translator - } - fn supports_color(&self) -> bool { false } @@ -133,11 +127,10 @@ fn annotation_level_for_level(level: Level) -> annotate_snippets::level::Level<' } impl AnnotateSnippetEmitter { - pub fn new(dst: Destination, translator: Translator) -> Self { + pub fn new(dst: Destination) -> Self { Self { dst: IntoDynSyncSend(dst), sm: None, - translator, short_message: false, ui_testing: false, ignored_directories_in_source_blocks: Vec::new(), @@ -169,7 +162,7 @@ impl AnnotateSnippetEmitter { .clone() .secondary_title(Cow::Owned(self.pre_style_msgs(msgs, *level, args))) } else { - annotation_level.clone().primary_title(self.translator.translate_messages(msgs, args)) + annotation_level.clone().primary_title(format_diag_messages(msgs, args)) }; if let Some(c) = code { @@ -185,7 +178,7 @@ impl AnnotateSnippetEmitter { // If we don't have span information, emit and exit let Some(sm) = self.sm.as_ref() else { group = group.elements(children.iter().map(|c| { - let msg = self.translator.translate_messages(&c.messages, args).to_string(); + let msg = format_diag_messages(&c.messages, args).to_string(); let level = annotation_level_for_level(c.level); level.message(msg) })); @@ -202,7 +195,7 @@ impl AnnotateSnippetEmitter { return; }; - let mut file_ann = collect_annotations(args, msp, sm, &self.translator); + let mut file_ann = collect_annotations(args, msp, sm); // Make sure our primary file comes first let primary_span = msp.primary_span().unwrap_or_default(); @@ -256,7 +249,7 @@ impl AnnotateSnippetEmitter { let msg = if c.messages.iter().any(|(_, style)| style != &crate::Style::NoStyle) { Cow::Owned(self.pre_style_msgs(&c.messages, c.level, args)) } else { - self.translator.translate_messages(&c.messages, args) + format_diag_messages(&c.messages, args) }; // This is a secondary message with no span info @@ -270,7 +263,7 @@ impl AnnotateSnippetEmitter { Group::with_title(level.clone().secondary_title(msg)), )); - let mut file_ann = collect_annotations(args, &c.span, sm, &self.translator); + let mut file_ann = collect_annotations(args, &c.span, sm); let primary_span = c.span.primary_span().unwrap_or_default(); if !primary_span.is_dummy() { let primary_lo = sm.lookup_char_pos(primary_span.lo()); @@ -308,9 +301,10 @@ impl AnnotateSnippetEmitter { // do not display this suggestion, it is meant only for tools } SuggestionStyle::HideCodeAlways => { - let msg = self - .translator - .translate_messages(&[(suggestion.msg.to_owned(), Style::HeaderMsg)], args); + let msg = format_diag_messages( + &[(suggestion.msg.to_owned(), Style::HeaderMsg)], + args, + ); group = group.element(annotate_snippets::Level::HELP.message(msg)); } SuggestionStyle::HideCodeInline @@ -367,9 +361,7 @@ impl AnnotateSnippetEmitter { if substitutions.is_empty() { continue; } - let mut msg = self - .translator - .translate_message(&suggestion.msg, args) + let mut msg = format_diag_message(&suggestion.msg, args) .map_err(Report::new) .unwrap() .to_string(); @@ -555,7 +547,7 @@ impl AnnotateSnippetEmitter { ) -> String { msgs.iter() .filter_map(|(m, style)| { - let text = self.translator.translate_message(m, args).map_err(Report::new).unwrap(); + let text = format_diag_message(m, args).map_err(Report::new).unwrap(); let style = style.anstyle(level); if text.is_empty() { None } else { Some(format!("{style}{text}{style:#}")) } }) @@ -688,7 +680,6 @@ fn collect_annotations( args: &FluentArgs<'_>, msp: &MultiSpan, sm: &Arc, - translator: &Translator, ) -> Vec<(Arc, Vec)> { let mut output: Vec<(Arc, Vec)> = vec![]; @@ -704,9 +695,7 @@ fn collect_annotations( let kind = if is_primary { AnnotationKind::Primary } else { AnnotationKind::Context }; let label = label.as_ref().map(|m| { - normalize_whitespace( - &translator.translate_message(m, args).map_err(Report::new).unwrap(), - ) + normalize_whitespace(&format_diag_message(m, args).map_err(Report::new).unwrap()) }); let ann = Annotation { kind, span, label }; diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 4ceb5cf06f938..8571f1584fe8d 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -25,7 +25,7 @@ use rustc_span::{FileName, SourceFile, Span}; use tracing::{debug, warn}; use crate::timings::TimingRecord; -use crate::translation::Translator; +use crate::translation::format_diag_message; use crate::{ CodeSuggestion, DiagInner, DiagMessage, Level, MultiSpan, Style, Subdiag, SuggestionStyle, }; @@ -88,8 +88,6 @@ pub trait Emitter { fn source_map(&self) -> Option<&SourceMap>; - fn translator(&self) -> &Translator; - /// Formats the substitutions of the primary_span /// /// There are a lot of conditions to this method, but in short: @@ -108,11 +106,7 @@ pub trait Emitter { fluent_args: &FluentArgs<'_>, ) { if let Some((sugg, rest)) = suggestions.split_first() { - let msg = self - .translator() - .translate_message(&sugg.msg, fluent_args) - .map_err(Report::new) - .unwrap(); + let msg = format_diag_message(&sugg.msg, fluent_args).map_err(Report::new).unwrap(); if rest.is_empty() // ^ if there is only one suggestion // don't display multi-suggestions as labels @@ -383,15 +377,9 @@ impl Emitter for EmitterWithNote { diag.sub(Level::Note, self.note.clone(), MultiSpan::new()); self.emitter.emit_diagnostic(diag); } - - fn translator(&self) -> &Translator { - self.emitter.translator() - } } -pub struct SilentEmitter { - pub translator: Translator, -} +pub struct SilentEmitter; impl Emitter for SilentEmitter { fn source_map(&self) -> Option<&SourceMap> { @@ -399,10 +387,6 @@ impl Emitter for SilentEmitter { } fn emit_diagnostic(&mut self, _diag: DiagInner) {} - - fn translator(&self) -> &Translator { - &self.translator - } } /// Maximum number of suggestions to be shown diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index 310a64745bad6..f956fe9490796 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -32,7 +32,7 @@ use crate::emitter::{ should_show_source_code, }; use crate::timings::{TimingRecord, TimingSection}; -use crate::translation::{Translator, to_fluent_args}; +use crate::translation::{format_diag_message, format_diag_messages, to_fluent_args}; use crate::{CodeSuggestion, MultiSpan, SpanLabel, Subdiag, Suggestions, TerminalUrl}; #[cfg(test)] @@ -45,8 +45,6 @@ pub struct JsonEmitter { #[setters(skip)] sm: Option>, #[setters(skip)] - translator: Translator, - #[setters(skip)] pretty: bool, ui_testing: bool, ignored_directories_in_source_blocks: Vec, @@ -63,7 +61,6 @@ impl JsonEmitter { pub fn new( dst: Box, sm: Option>, - translator: Translator, pretty: bool, json_rendered: HumanReadableErrorType, color_config: ColorConfig, @@ -71,7 +68,6 @@ impl JsonEmitter { JsonEmitter { dst: IntoDynSyncSend(dst), sm, - translator, pretty, ui_testing: false, ignored_directories_in_source_blocks: Vec::new(), @@ -180,10 +176,6 @@ impl Emitter for JsonEmitter { fn should_show_explain(&self) -> bool { !self.json_rendered.short() } - - fn translator(&self) -> &Translator { - &self.translator - } } // The following data types are provided just for serialisation. @@ -310,7 +302,7 @@ impl Diagnostic { let args = to_fluent_args(diag.args.iter()); let sugg_to_diag = |sugg: &CodeSuggestion| { let translated_message = - je.translator.translate_message(&sugg.msg, &args).map_err(Report::new).unwrap(); + format_diag_message(&sugg.msg, &args).map_err(Report::new).unwrap(); Diagnostic { message: translated_message.to_string(), code: None, @@ -341,7 +333,7 @@ impl Diagnostic { } } - let translated_message = je.translator.translate_messages(&diag.messages, &args); + let translated_message = format_diag_messages(&diag.messages, &args); let code = if let Some(code) = diag.code { Some(DiagnosticCode { @@ -373,7 +365,7 @@ impl Diagnostic { choice => choice, }, ); - AnnotateSnippetEmitter::new(dst, je.translator.clone()) + AnnotateSnippetEmitter::new(dst) .short_message(je.json_rendered.short) .sm(je.sm.clone()) .diagnostic_width(je.diagnostic_width) @@ -403,7 +395,7 @@ impl Diagnostic { args: &FluentArgs<'_>, je: &JsonEmitter, ) -> Diagnostic { - let translated_message = je.translator.translate_messages(&subdiag.messages, args); + let translated_message = format_diag_messages(&subdiag.messages, args); Diagnostic { message: translated_message.to_string(), code: None, @@ -427,7 +419,7 @@ impl DiagnosticSpan { span.is_primary, span.label .as_ref() - .map(|m| je.translator.translate_message(m, args).unwrap()) + .map(|m| format_diag_message(m, args).unwrap()) .map(|m| m.to_string()), suggestion, je, diff --git a/compiler/rustc_errors/src/json/tests.rs b/compiler/rustc_errors/src/json/tests.rs index ffcf9947a7a86..71b66f2e0223b 100644 --- a/compiler/rustc_errors/src/json/tests.rs +++ b/compiler/rustc_errors/src/json/tests.rs @@ -45,13 +45,11 @@ fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) { rustc_span::create_default_session_globals_then(|| { let sm = Arc::new(SourceMap::new(FilePathMapping::empty())); sm.new_source_file(filename(&sm, "test.rs"), code.to_owned()); - let translator = Translator::new(); let output = Arc::new(Mutex::new(Vec::new())); let je = JsonEmitter::new( Box::new(Shared { data: output.clone() }), Some(sm), - translator, true, // pretty HumanReadableErrorType { short: true, unicode: false }, ColorConfig::Never, diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 989d28eac455d..837a41c191e15 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -54,9 +54,8 @@ use rustc_data_structures::stable_hasher::StableHasher; use rustc_data_structures::sync::{DynSend, Lock}; use rustc_data_structures::{AtomicRef, assert_matches}; pub use rustc_error_messages::{ - DiagArg, DiagArgFromDisplay, DiagArgName, DiagArgValue, DiagMessage, FluentBundle, IntoDiagArg, - LanguageIdentifier, LazyFallbackBundle, MultiSpan, SpanLabel, fallback_fluent_bundle, - fluent_bundle, into_diag_arg_using_display, + DiagArg, DiagArgFromDisplay, DiagArgName, DiagArgValue, DiagMessage, IntoDiagArg, + LanguageIdentifier, MultiSpan, SpanLabel, fluent_bundle, into_diag_arg_using_display, }; use rustc_hashes::Hash128; use rustc_lint_defs::LintExpectationId; @@ -71,6 +70,7 @@ use tracing::debug; use crate::emitter::TimingEvent; use crate::timings::TimingRecord; +use crate::translation::format_diag_message; pub mod annotate_snippet_emitter_writer; pub mod codes; @@ -479,8 +479,7 @@ impl DiagCtxt { pub fn make_silent(&self) { let mut inner = self.inner.borrow_mut(); - let translator = inner.emitter.translator().clone(); - inner.emitter = Box::new(emitter::SilentEmitter { translator }); + inner.emitter = Box::new(emitter::SilentEmitter {}); } pub fn set_emitter(&self, emitter: Box) { @@ -1438,12 +1437,7 @@ impl DiagCtxtInner { args: impl Iterator>, ) -> String { let args = crate::translation::to_fluent_args(args); - self.emitter - .translator() - .translate_message(&message, &args) - .map_err(Report::new) - .unwrap() - .to_string() + format_diag_message(&message, &args).map_err(Report::new).unwrap().to_string() } fn eagerly_translate_for_subdiag( diff --git a/compiler/rustc_errors/src/translation.rs b/compiler/rustc_errors/src/translation.rs index c6d30032f1af4..5317132018325 100644 --- a/compiler/rustc_errors/src/translation.rs +++ b/compiler/rustc_errors/src/translation.rs @@ -1,14 +1,13 @@ use std::borrow::Cow; use std::error::Report; -use std::sync::Arc; -pub use rustc_error_messages::{FluentArgs, LazyFallbackBundle}; +pub use rustc_error_messages::FluentArgs; use rustc_error_messages::{langid, register_functions}; use tracing::{debug, trace}; use crate::error::TranslateError; use crate::fluent_bundle::FluentResource; -use crate::{DiagArg, DiagMessage, FluentBundle, Style, fluent_bundle}; +use crate::{DiagArg, DiagMessage, Style, fluent_bundle}; /// Convert diagnostic arguments (a rustc internal type that exists to implement /// `Encodable`/`Decodable`) into `FluentArgs` which is necessary to perform translation. @@ -29,63 +28,48 @@ pub fn to_fluent_args<'iter>(iter: impl Iterator>) -> Flue args } -#[derive(Clone)] -pub struct Translator { - /// Localized diagnostics for the locale requested by the user. If no language was requested by - /// the user then this will be `None` and `fallback_fluent_bundle` should be used. - pub fluent_bundle: Option>, +/// Convert `DiagMessage`s to a string +pub fn format_diag_messages( + messages: &[(DiagMessage, Style)], + args: &FluentArgs<'_>, +) -> Cow<'static, str> { + Cow::Owned( + messages + .iter() + .map(|(m, _)| format_diag_message(m, args).map_err(Report::new).unwrap()) + .collect::(), + ) } -impl Translator { - pub fn new() -> Translator { - Translator { fluent_bundle: None } - } - - /// Convert `DiagMessage`s to a string, performing translation if necessary. - pub fn translate_messages( - &self, - messages: &[(DiagMessage, Style)], - args: &FluentArgs<'_>, - ) -> Cow<'_, str> { - Cow::Owned( - messages - .iter() - .map(|(m, _)| self.translate_message(m, args).map_err(Report::new).unwrap()) - .collect::(), - ) - } - - /// Convert a `DiagMessage` to a string, performing translation if necessary. - pub fn translate_message<'a>( - &'a self, - message: &'a DiagMessage, - args: &'a FluentArgs<'_>, - ) -> Result, TranslateError<'a>> { - trace!(?message, ?args); - match message { - DiagMessage::Str(msg) => Ok(Cow::Borrowed(msg)), - // This translates an inline fluent diagnostic message - // It does this by creating a new `FluentBundle` with only one message, - // and then translating using this bundle. - DiagMessage::Inline(msg) => { - const GENERATED_MSG_ID: &str = "generated_msg"; - let resource = - FluentResource::try_new(format!("{GENERATED_MSG_ID} = {msg}\n")).unwrap(); - let mut bundle = fluent_bundle::FluentBundle::new(vec![langid!("en-US")]); - bundle.set_use_isolating(false); - bundle.add_resource(resource).unwrap(); - register_functions(&mut bundle); - let message = bundle.get_message(GENERATED_MSG_ID).unwrap(); - let value = message.value().unwrap(); +/// Convert a `DiagMessage` to a string +pub fn format_diag_message<'a>( + message: &'a DiagMessage, + args: &'a FluentArgs<'_>, +) -> Result, TranslateError<'a>> { + trace!(?message, ?args); + match message { + DiagMessage::Str(msg) => Ok(Cow::Borrowed(msg)), + // This translates an inline fluent diagnostic message + // It does this by creating a new `FluentBundle` with only one message, + // and then translating using this bundle. + DiagMessage::Inline(msg) => { + const GENERATED_MSG_ID: &str = "generated_msg"; + let resource = + FluentResource::try_new(format!("{GENERATED_MSG_ID} = {msg}\n")).unwrap(); + let mut bundle = fluent_bundle::FluentBundle::new(vec![langid!("en-US")]); + bundle.set_use_isolating(false); + bundle.add_resource(resource).unwrap(); + register_functions(&mut bundle); + let message = bundle.get_message(GENERATED_MSG_ID).unwrap(); + let value = message.value().unwrap(); - let mut errs = vec![]; - let translated = bundle.format_pattern(value, Some(args), &mut errs).to_string(); - debug!(?translated, ?errs); - if errs.is_empty() { - Ok(Cow::Owned(translated)) - } else { - Err(TranslateError::fluent(&Cow::Borrowed(GENERATED_MSG_ID), args, errs)) - } + let mut errs = vec![]; + let translated = bundle.format_pattern(value, Some(args), &mut errs).to_string(); + debug!(?translated, ?errs); + if errs.is_empty() { + Ok(Cow::Owned(translated)) + } else { + Err(TranslateError::fluent(&Cow::Borrowed(GENERATED_MSG_ID), args, errs)) } } } diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 2c3afcc7a0360..91b7f234d5f64 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -435,16 +435,6 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se let temps_dir = config.opts.unstable_opts.temps_dir.as_deref().map(PathBuf::from); - let bundle = match rustc_errors::fluent_bundle( - &config.opts.sysroot.all_paths().collect::>(), - config.opts.unstable_opts.translate_lang.clone(), - config.opts.unstable_opts.translate_additional_ftl.as_deref(), - config.opts.unstable_opts.translate_directionality_markers, - ) { - Ok(bundle) => bundle, - Err(e) => early_dcx.early_fatal(format!("failed to load fluent bundle: {e}")), - }; - let mut sess = rustc_session::build_session( config.opts, CompilerIO { @@ -453,7 +443,6 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se output_file: config.output_file, temps_dir, }, - bundle, config.lint_caps, target, util::rustc_version_str().unwrap_or("unknown"), diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 5ebf898f45a34..88056a0db966d 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -71,7 +71,6 @@ where let sess = build_session( sessopts, io, - None, Default::default(), target, "", @@ -796,7 +795,6 @@ fn test_unstable_options_tracking_hash() { tracked!(dwarf_version, Some(5)); tracked!(embed_metadata, false); tracked!(embed_source, true); - tracked!(emit_thin_lto, false); tracked!(emscripten_wasm_eh, false); tracked!(export_executable_symbols, true); tracked!(fewer_names, Some(true)); diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 7aa4ddea78e1d..f6b4d6cc15439 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -566,7 +566,7 @@ extern "C" LLVMRustResult LLVMRustOptimize( LLVMModuleRef ModuleRef, LLVMTargetMachineRef TMRef, LLVMRustPassBuilderOptLevel OptLevelRust, LLVMRustOptStage OptStage, bool IsLinkerPluginLTO, bool NoPrepopulatePasses, bool VerifyIR, - bool LintIR, LLVMRustThinLTOBuffer **ThinLTOBufferRef, bool EmitThinLTO, + bool LintIR, LLVMRustThinLTOBuffer **ThinLTOBufferRef, bool EmitThinLTOSummary, bool MergeFunctions, bool UnrollLoops, bool SLPVectorize, bool LoopVectorize, bool DisableSimplifyLibCalls, bool EmitLifetimeMarkers, registerEnzymeAndPassPipelineFn EnzymePtr, @@ -808,31 +808,26 @@ extern "C" LLVMRustResult LLVMRustOptimize( } ModulePassManager MPM; - bool NeedThinLTOBufferPasses = EmitThinLTO; + bool NeedThinLTOBufferPasses = true; auto ThinLTOBuffer = std::make_unique(); raw_string_ostream ThinLTODataOS(ThinLTOBuffer->data); raw_string_ostream ThinLinkDataOS(ThinLTOBuffer->thin_link_data); bool IsLTO = OptStage == LLVMRustOptStage::ThinLTO || OptStage == LLVMRustOptStage::FatLTO; if (!NoPrepopulatePasses) { + for (const auto &C : PipelineStartEPCallbacks) + PB.registerPipelineStartEPCallback(C); + for (const auto &C : OptimizerLastEPCallbacks) + PB.registerOptimizerLastEPCallback(C); + // The pre-link pipelines don't support O0 and require using // buildO0DefaultPipeline() instead. At the same time, the LTO pipelines do // support O0 and using them is required. if (OptLevel == OptimizationLevel::O0 && !IsLTO) { - for (const auto &C : PipelineStartEPCallbacks) - PB.registerPipelineStartEPCallback(C); - for (const auto &C : OptimizerLastEPCallbacks) - PB.registerOptimizerLastEPCallback(C); - // We manually schedule ThinLTOBufferPasses below, so don't pass the value // to enable it here. MPM = PB.buildO0DefaultPipeline(OptLevel); } else { - for (const auto &C : PipelineStartEPCallbacks) - PB.registerPipelineStartEPCallback(C); - for (const auto &C : OptimizerLastEPCallbacks) - PB.registerOptimizerLastEPCallback(C); - switch (OptStage) { case LLVMRustOptStage::PreLinkNoLTO: if (ThinLTOBufferRef) { @@ -840,12 +835,8 @@ extern "C" LLVMRustResult LLVMRustOptimize( // bitcode for embedding is obtained after performing // `ThinLTOPreLinkDefaultPipeline`. MPM.addPass(PB.buildThinLTOPreLinkDefaultPipeline(OptLevel)); - if (EmitThinLTO) { - MPM.addPass(ThinLTOBitcodeWriterPass( - ThinLTODataOS, EmitThinLTOSummary ? &ThinLinkDataOS : nullptr)); - } else { - MPM.addPass(BitcodeWriterPass(ThinLTODataOS)); - } + MPM.addPass(ThinLTOBitcodeWriterPass( + ThinLTODataOS, EmitThinLTOSummary ? &ThinLinkDataOS : nullptr)); *ThinLTOBufferRef = ThinLTOBuffer.release(); MPM.addPass(PB.buildModuleOptimizationPipeline( OptLevel, ThinOrFullLTOPhase::None)); @@ -870,6 +861,7 @@ extern "C" LLVMRustResult LLVMRustOptimize( break; case LLVMRustOptStage::FatLTO: MPM = PB.buildLTODefaultPipeline(OptLevel, nullptr); + NeedThinLTOBufferPasses = false; break; } } @@ -895,9 +887,11 @@ extern "C" LLVMRustResult LLVMRustOptimize( MPM.addPass(CanonicalizeAliasesPass()); MPM.addPass(NameAnonGlobalPass()); } - // For `-Copt-level=0`, ThinLTO, or LTO. + // For `-Copt-level=0`, and the pre-link fat/thin LTO stages. if (ThinLTOBufferRef && *ThinLTOBufferRef == nullptr) { - if (EmitThinLTO) { + // thin lto summaries prevent fat lto, so do not emit them if fat + // lto is requested. See PR #136840 for background information. + if (OptStage != LLVMRustOptStage::PreLinkFatLTO) { MPM.addPass(ThinLTOBitcodeWriterPass( ThinLTODataOS, EmitThinLTOSummary ? &ThinLinkDataOS : nullptr)); } else { diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index 58ea9ec5aa22f..5a93c7cbdc7a9 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -874,52 +874,6 @@ pub(crate) struct UpperRangeBoundCannotBeMin { pub(crate) span: Span, } -#[derive(LintDiagnostic)] -#[diag( - "leading irrefutable {$count -> - [one] pattern - *[other] patterns -} in let chain" -)] -#[note( - "{$count -> - [one] this pattern - *[other] these patterns -} will always match" -)] -#[help( - "consider moving {$count -> - [one] it - *[other] them -} outside of the construct" -)] -pub(crate) struct LeadingIrrefutableLetPatterns { - pub(crate) count: usize, -} - -#[derive(LintDiagnostic)] -#[diag( - "trailing irrefutable {$count -> - [one] pattern - *[other] patterns -} in let chain" -)] -#[note( - "{$count -> - [one] this pattern - *[other] these patterns -} will always match" -)] -#[help( - "consider moving {$count -> - [one] it - *[other] them -} into the body" -)] -pub(crate) struct TrailingIrrefutableLetPatterns { - pub(crate) count: usize, -} - #[derive(LintDiagnostic)] #[diag("pattern binding `{$name}` is named the same as one of the variants of the type `{$ty_path}`", code = E0170)] pub(crate) struct BindingsWithVariantName { diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index e5b94ab763a19..9231b425c4c37 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -167,9 +167,9 @@ impl<'p, 'tcx> Visitor<'p, 'tcx> for MatchVisitor<'p, 'tcx> { { let mut chain_refutabilities = Vec::new(); let Ok(()) = self.visit_land(ex, &mut chain_refutabilities) else { return }; - // If at least one of the operands is a `let ... = ...`. - if chain_refutabilities.iter().any(|x| x.is_some()) { - self.check_let_chain(chain_refutabilities, ex.span); + // Lint only single irrefutable let binding. + if let [Some((_, Irrefutable))] = chain_refutabilities[..] { + self.lint_single_let(ex.span); } return; } @@ -430,18 +430,9 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> { assert!(self.let_source != LetSource::None); let scrut = scrutinee.map(|id| &self.thir[id]); if let LetSource::PlainLet = self.let_source { - self.check_binding_is_irrefutable(pat, "local binding", scrut, Some(span)) - } else { - let Ok(refutability) = self.is_let_irrefutable(pat, scrut) else { return }; - if matches!(refutability, Irrefutable) { - report_irrefutable_let_patterns( - self.tcx, - self.hir_source, - self.let_source, - 1, - span, - ); - } + self.check_binding_is_irrefutable(pat, "local binding", scrut, Some(span)); + } else if let Ok(Irrefutable) = self.is_let_irrefutable(pat, scrut) { + self.lint_single_let(span); } } @@ -549,74 +540,8 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> { } #[instrument(level = "trace", skip(self))] - fn check_let_chain( - &mut self, - chain_refutabilities: Vec>, - whole_chain_span: Span, - ) { - assert!(self.let_source != LetSource::None); - - if chain_refutabilities.iter().all(|r| matches!(*r, Some((_, Irrefutable)))) { - // The entire chain is made up of irrefutable `let` statements - report_irrefutable_let_patterns( - self.tcx, - self.hir_source, - self.let_source, - chain_refutabilities.len(), - whole_chain_span, - ); - return; - } - - if let Some(until) = - chain_refutabilities.iter().position(|r| !matches!(*r, Some((_, Irrefutable)))) - && until > 0 - { - // The chain has a non-zero prefix of irrefutable `let` statements. - - // Check if the let source is while, for there is no alternative place to put a prefix, - // and we shouldn't lint. - // For let guards inside a match, prefixes might use bindings of the match pattern, - // so can't always be moved out. - // For `else if let`, an extra indentation level would be required to move the bindings. - // FIXME: Add checking whether the bindings are actually used in the prefix, - // and lint if they are not. - if !matches!( - self.let_source, - LetSource::WhileLet | LetSource::IfLetGuard | LetSource::ElseIfLet - ) { - // Emit the lint - let prefix = &chain_refutabilities[..until]; - let span_start = prefix[0].unwrap().0; - let span_end = prefix.last().unwrap().unwrap().0; - let span = span_start.to(span_end); - let count = prefix.len(); - self.tcx.emit_node_span_lint( - IRREFUTABLE_LET_PATTERNS, - self.hir_source, - span, - LeadingIrrefutableLetPatterns { count }, - ); - } - } - - if let Some(from) = - chain_refutabilities.iter().rposition(|r| !matches!(*r, Some((_, Irrefutable)))) - && from != (chain_refutabilities.len() - 1) - { - // The chain has a non-empty suffix of irrefutable `let` statements - let suffix = &chain_refutabilities[from + 1..]; - let span_start = suffix[0].unwrap().0; - let span_end = suffix.last().unwrap().unwrap().0; - let span = span_start.to(span_end); - let count = suffix.len(); - self.tcx.emit_node_span_lint( - IRREFUTABLE_LET_PATTERNS, - self.hir_source, - span, - TrailingIrrefutableLetPatterns { count }, - ); - } + fn lint_single_let(&mut self, let_span: Span) { + report_irrefutable_let_patterns(self.tcx, self.hir_source, self.let_source, 1, let_span); } fn analyze_binding( diff --git a/compiler/rustc_mir_transform/src/check_alignment.rs b/compiler/rustc_mir_transform/src/check_alignment.rs index e06883dd0fd10..5085905aa42b6 100644 --- a/compiler/rustc_mir_transform/src/check_alignment.rs +++ b/compiler/rustc_mir_transform/src/check_alignment.rs @@ -82,7 +82,7 @@ fn insert_alignment_check<'tcx>( // If this target does not have reliable alignment, further limit the mask by anding it with // the mask for the highest reliable alignment. - #[allow(irrefutable_let_patterns)] + #[cfg_attr(bootstrap, expect(irrefutable_let_patterns))] if let max_align = tcx.sess.target.max_reliable_alignment() && max_align < Align::MAX { diff --git a/compiler/rustc_parse/src/parser/tests.rs b/compiler/rustc_parse/src/parser/tests.rs index ac9c3e63e8534..f9c3384458488 100644 --- a/compiler/rustc_parse/src/parser/tests.rs +++ b/compiler/rustc_parse/src/parser/tests.rs @@ -13,7 +13,6 @@ use rustc_ast_pretty::pprust::item_to_string; use rustc_data_structures::assert_matches; use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter; use rustc_errors::emitter::OutputTheme; -use rustc_errors::translation::Translator; use rustc_errors::{AutoStream, DiagCtxt, MultiSpan, PResult}; use rustc_session::parse::ParseSess; use rustc_span::source_map::{FilePathMapping, SourceMap}; @@ -42,11 +41,10 @@ fn string_to_parser(psess: &ParseSess, source_str: String) -> Parser<'_> { fn create_test_handler(theme: OutputTheme) -> (DiagCtxt, Arc, Arc>>) { let output = Arc::new(Mutex::new(Vec::new())); let source_map = Arc::new(SourceMap::new(FilePathMapping::empty())); - let translator = Translator::new(); let shared: Box = Box::new(Shared { data: output.clone() }); let auto_stream = AutoStream::never(shared); let dcx = DiagCtxt::new(Box::new( - AnnotateSnippetEmitter::new(auto_stream, translator) + AnnotateSnippetEmitter::new(auto_stream) .sm(Some(source_map.clone())) .diagnostic_width(Some(140)) .theme(theme), diff --git a/compiler/rustc_public/src/compiler_interface.rs b/compiler/rustc_public/src/compiler_interface.rs index 82ee546c59910..b0ea1e0f5b847 100644 --- a/compiler/rustc_public/src/compiler_interface.rs +++ b/compiler/rustc_public/src/compiler_interface.rs @@ -562,12 +562,12 @@ impl<'tcx> CompilerInterface<'tcx> { cnst.internal(&mut *tables, cx.tcx).to_string() } - /// `Span` of an item. - pub(crate) fn span_of_an_item(&self, def_id: DefId) -> Span { + /// `Span` of a `DefId`. + pub(crate) fn span_of_a_def(&self, def_id: DefId) -> Span { let mut tables = self.tables.borrow_mut(); let cx = &*self.cx.borrow(); let did = tables[def_id]; - cx.span_of_an_item(did).stable(&mut *tables, cx) + cx.span_of_a_def(did).stable(&mut *tables, cx) } pub(crate) fn ty_const_pretty(&self, ct: TyConstId) -> String { diff --git a/compiler/rustc_public/src/crate_def.rs b/compiler/rustc_public/src/crate_def.rs index 02297c5317621..e534004af4d3c 100644 --- a/compiler/rustc_public/src/crate_def.rs +++ b/compiler/rustc_public/src/crate_def.rs @@ -34,6 +34,10 @@ impl DefId { pub fn parent(&self) -> Option { with(|cx| cx.def_parent(*self)) } + + pub fn span(&self) -> Span { + with(|cx| cx.span_of_a_def(*self)) + } } /// A trait for retrieving information about a particular definition. @@ -68,8 +72,7 @@ pub trait CrateDef { /// Return the span of this definition. fn span(&self) -> Span { - let def_id = self.def_id(); - with(|cx| cx.span_of_an_item(def_id)) + self.def_id().span() } /// Return registered tool attributes with the given attribute name. diff --git a/compiler/rustc_public/src/lib.rs b/compiler/rustc_public/src/lib.rs index 5da79196dd4ed..e38265e5f0f56 100644 --- a/compiler/rustc_public/src/lib.rs +++ b/compiler/rustc_public/src/lib.rs @@ -155,7 +155,7 @@ impl CrateItem { } pub fn span(&self) -> Span { - with(|cx| cx.span_of_an_item(self.0)) + self.0.span() } pub fn kind(&self) -> ItemKind { diff --git a/compiler/rustc_public/src/unstable/convert/stable/mod.rs b/compiler/rustc_public/src/unstable/convert/stable/mod.rs index add52fc18caaa..4d550487525f3 100644 --- a/compiler/rustc_public/src/unstable/convert/stable/mod.rs +++ b/compiler/rustc_public/src/unstable/convert/stable/mod.rs @@ -82,6 +82,18 @@ impl<'tcx> Stable<'tcx> for rustc_span::Symbol { } } +impl<'tcx> Stable<'tcx> for rustc_span::def_id::DefId { + type T = crate::DefId; + + fn stable<'cx>( + &self, + tables: &mut Tables<'cx, BridgeTys>, + _: &CompilerCtxt<'cx, BridgeTys>, + ) -> Self::T { + tables.create_def_id(*self) + } +} + impl<'tcx> Stable<'tcx> for rustc_span::Span { type T = crate::ty::Span; diff --git a/compiler/rustc_public_bridge/src/context/impls.rs b/compiler/rustc_public_bridge/src/context/impls.rs index 56aa22378072a..4418d68c5c3ac 100644 --- a/compiler/rustc_public_bridge/src/context/impls.rs +++ b/compiler/rustc_public_bridge/src/context/impls.rs @@ -554,8 +554,8 @@ impl<'tcx, B: Bridge> CompilerCtxt<'tcx, B> { ) } - /// `Span` of an item. - pub fn span_of_an_item(&self, def_id: DefId) -> Span { + /// `Span` of a `DefId`. + pub fn span_of_a_def(&self, def_id: DefId) -> Span { self.tcx.def_span(def_id) } diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index d050ec01e0425..c4a0cde2837a0 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -620,97 +620,103 @@ 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; + // `true` for `...::{self [as target]}` imports, `false` otherwise. + let type_ns_only = nested && source.ident.name == kw::SelfLower; - if empty_for_self(&module_path) { - self.r.report_error( - use_tree.span, - ResolutionError::SelfImportOnlyInImportListWithNonEmptyPrefix, + 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 => { + // Allow `self::super` as a valid prefix - `self` at position 0 + // followed by any number of `super` segments. + let valid_prefix = module_path.iter().enumerate().all(|(i, seg)| { + let name = seg.ident.name; + name == kw::Super || (name == kw::SelfLower && i == 0) + }); + + if !valid_prefix { + self.r.dcx().span_err( + source.ident.span, + "`super` in paths can only be used in start position, after `self`, 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 { @@ -740,32 +746,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 @@ -777,7 +757,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 78fd9c1e21a00..ad667df47123f 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -893,12 +893,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, message } => { let mut err = struct_span_code_err!(self.dcx(), span, E0433, "{message}"); err.span_label(span, label); diff --git a/compiler/rustc_resolve/src/errors.rs b/compiler/rustc_resolve/src/errors.rs index a9b2dabc8ebe1..1ca5c17856262 100644 --- a/compiler/rustc_resolve/src/errors.rs +++ b/compiler/rustc_resolve/src/errors.rs @@ -248,22 +248,6 @@ pub(crate) struct UnreachableLabelWithSimilarNameExists { pub(crate) ident_span: Span, } -#[derive(Diagnostic)] -#[diag("`self` import can only appear once in an import list", code = E0430)] -pub(crate) struct SelfImportCanOnlyAppearOnceInTheList { - #[primary_span] - #[label("can only appear once in an import list")] - pub(crate) span: Span, -} - -#[derive(Diagnostic)] -#[diag("`self` import can only appear in an import list with a non-empty prefix", code = E0431)] -pub(crate) struct SelfImportOnlyInImportListWithNonEmptyPrefix { - #[primary_span] - #[label("can only appear in an import list with a non-empty prefix")] - pub(crate) span: Span, -} - #[derive(Diagnostic)] #[diag("can't capture dynamic environment in a fn item", code = E0434)] #[help("use the `|| {\"{\"} ... {\"}\"}` closure form instead")] @@ -638,13 +622,6 @@ pub(crate) struct MacroExpandedMacroExportsAccessedByAbsolutePaths { pub definition: Span, } -#[derive(Diagnostic)] -#[diag("`$crate` may not be imported")] -pub(crate) struct CrateImported { - #[primary_span] - pub(crate) span: Span, -} - #[derive(Diagnostic)] #[diag("`#[macro_use]` is not supported on `extern crate self`")] pub(crate) struct MacroUseExternCrateSelf { @@ -973,11 +950,25 @@ pub(crate) struct ArgumentsMacroUseNotAllowed { pub(crate) span: Span, } +#[derive(Subdiagnostic)] +#[multipart_suggestion( + "try renaming it with a name", + 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("crate root imports need to be explicitly named: `use crate as name;`")] -pub(crate) struct UnnamedCrateRootImport { +#[diag("imports need to be explicitly named")] +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 5d413bc6daab2..59a5c0728a753 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -923,6 +923,23 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { self.resolve_ident_in_module(module, ident, ns, parent_scope, None, None, ignore_import) } + 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() + } + #[instrument(level = "debug", skip(self))] pub(crate) fn resolve_ident_in_module<'r>( self: CmResolver<'r, 'ra, 'tcx>, @@ -936,6 +953,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ) -> Result, Determinacy> { match module { 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_decl.unwrap()); + } + let (ident_key, def) = IdentKey::new_adjusted(ident, module.expansion); let adjusted_parent_scope = match def { Some(def) => ParentScope { module: self.expn_def_scope(def), ..*parent_scope }, @@ -976,7 +1001,21 @@ 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_decl.unwrap()); + } + if ident.name == kw::Super + && let Some(module) = + self.resolve_super_in_module(ident, None, parent_scope) + { + return Ok(module.self_decl.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_decl.unwrap()); } else if ident.name == kw::Super || ident.name == kw::SelfLower { @@ -1754,19 +1793,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 74e313bb4269b..1368e5deb6487 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -274,10 +274,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: Symbol, @@ -378,16 +374,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/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 69f9ad9aa3613..c2de098c68e8d 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -7,7 +7,7 @@ use rustc_abi::Align; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::profiling::TimePassesFormat; use rustc_data_structures::stable_hasher::StableHasher; -use rustc_errors::{ColorConfig, LanguageIdentifier, TerminalUrl}; +use rustc_errors::{ColorConfig, TerminalUrl}; use rustc_feature::UnstableFeatures; use rustc_hashes::Hash64; use rustc_hir::attrs::CollapseMacroDebuginfo; @@ -790,7 +790,6 @@ mod desc { pub(crate) const parse_string: &str = "a string"; pub(crate) const parse_opt_string: &str = parse_string; pub(crate) const parse_string_push: &str = parse_string; - pub(crate) const parse_opt_langid: &str = "a language identifier"; pub(crate) const parse_opt_pathbuf: &str = "a path"; pub(crate) const parse_list: &str = "a space-separated list of strings"; pub(crate) const parse_list_with_polarity: &str = @@ -998,17 +997,6 @@ pub mod parse { } } - /// Parse an optional language identifier, e.g. `en-US` or `zh-CN`. - pub(crate) fn parse_opt_langid(slot: &mut Option, v: Option<&str>) -> bool { - match v { - Some(s) => { - *slot = rustc_errors::LanguageIdentifier::from_str(s).ok(); - true - } - None => false, - } - } - pub(crate) fn parse_opt_pathbuf(slot: &mut Option, v: Option<&str>) -> bool { match v { Some(s) => { @@ -2335,8 +2323,6 @@ options! { "embed source text in DWARF debug sections (default: no)"), emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED], "emit a section containing stack size metadata (default: no)"), - emit_thin_lto: bool = (true, parse_bool, [TRACKED], - "emit the bc module with thin LTO info (default: yes)"), emscripten_wasm_eh: bool = (true, parse_bool, [TRACKED], "Use WebAssembly error handling for wasm32-unknown-emscripten"), enforce_type_length_limit: bool = (false, parse_bool, [TRACKED], @@ -2713,15 +2699,6 @@ written to standard error output)"), "for every macro invocation, print its name and arguments (default: no)"), track_diagnostics: bool = (false, parse_bool, [UNTRACKED], "tracks where in rustc a diagnostic was emitted"), - // Diagnostics are considered side-effects of a query (see `QuerySideEffect`) and are saved - // alongside query results and changes to translation options can affect diagnostics - so - // translation options should be tracked. - translate_additional_ftl: Option = (None, parse_opt_pathbuf, [TRACKED], - "additional fluent translation to preferentially use (for testing translation)"), - translate_directionality_markers: bool = (false, parse_bool, [TRACKED], - "emit directionality isolation markers in translated diagnostics"), - translate_lang: Option = (None, parse_opt_langid, [TRACKED], - "language identifier for diagnostic output"), translate_remapped_path_to_local_path: bool = (true, parse_bool, [TRACKED], "translate remapped paths into local paths when possible (default: yes)"), trap_unreachable: Option = (None, parse_opt_bool, [TRACKED], diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index 62c23424f371f..9c12c480cacdd 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -10,7 +10,6 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet}; use rustc_data_structures::sync::{AppendOnlyVec, Lock}; use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter; use rustc_errors::emitter::{EmitterWithNote, stderr_destination}; -use rustc_errors::translation::Translator; use rustc_errors::{ BufferedEarlyLint, ColorConfig, DecorateDiagCompat, Diag, DiagCtxt, DiagCtxtHandle, DiagMessage, EmissionGuarantee, MultiSpan, StashKey, @@ -281,10 +280,9 @@ pub struct ParseSess { impl ParseSess { /// Used for testing. pub fn new() -> Self { - let translator = Translator::new(); let sm = Arc::new(SourceMap::new(FilePathMapping::empty())); let emitter = Box::new( - AnnotateSnippetEmitter::new(stderr_destination(ColorConfig::Auto), translator) + AnnotateSnippetEmitter::new(stderr_destination(ColorConfig::Auto)) .sm(Some(Arc::clone(&sm))), ); let dcx = DiagCtxt::new(emitter); @@ -314,12 +312,8 @@ impl ParseSess { } pub fn emitter_with_note(note: String) -> Self { - let translator = Translator::new(); let sm = Arc::new(SourceMap::new(FilePathMapping::empty())); - let emitter = Box::new(AnnotateSnippetEmitter::new( - stderr_destination(ColorConfig::Auto), - translator, - )); + let emitter = Box::new(AnnotateSnippetEmitter::new(stderr_destination(ColorConfig::Auto))); let dcx = DiagCtxt::new(Box::new(EmitterWithNote { emitter, note })); ParseSess::with_dcx(dcx, sm) } diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 427f3e7fa5089..dc18b05c75763 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -16,7 +16,6 @@ use rustc_errors::codes::*; use rustc_errors::emitter::{DynEmitter, HumanReadableErrorType, OutputTheme, stderr_destination}; use rustc_errors::json::JsonEmitter; use rustc_errors::timings::TimingSectionHandler; -use rustc_errors::translation::Translator; use rustc_errors::{ Diag, DiagCtxt, DiagCtxtHandle, DiagMessage, Diagnostic, ErrorGuaranteed, FatalAbort, TerminalUrl, @@ -914,11 +913,7 @@ impl Session { // JUSTIFICATION: part of session construction #[allow(rustc::bad_opt_access)] -fn default_emitter( - sopts: &config::Options, - source_map: Arc, - translator: Translator, -) -> Box { +fn default_emitter(sopts: &config::Options, source_map: Arc) -> Box { let macro_backtrace = sopts.unstable_opts.macro_backtrace; let track_diagnostics = sopts.unstable_opts.track_diagnostics; let terminal_url = match sopts.unstable_opts.terminal_urls { @@ -940,21 +935,17 @@ fn default_emitter( match sopts.error_format { config::ErrorOutputType::HumanReadable { kind, color_config } => match kind { HumanReadableErrorType { short, unicode } => { - let emitter = - AnnotateSnippetEmitter::new(stderr_destination(color_config), translator) - .sm(source_map) - .short_message(short) - .diagnostic_width(sopts.diagnostic_width) - .macro_backtrace(macro_backtrace) - .track_diagnostics(track_diagnostics) - .terminal_url(terminal_url) - .theme(if unicode { OutputTheme::Unicode } else { OutputTheme::Ascii }) - .ignored_directories_in_source_blocks( - sopts - .unstable_opts - .ignore_directory_in_diagnostics_source_blocks - .clone(), - ); + let emitter = AnnotateSnippetEmitter::new(stderr_destination(color_config)) + .sm(source_map) + .short_message(short) + .diagnostic_width(sopts.diagnostic_width) + .macro_backtrace(macro_backtrace) + .track_diagnostics(track_diagnostics) + .terminal_url(terminal_url) + .theme(if unicode { OutputTheme::Unicode } else { OutputTheme::Ascii }) + .ignored_directories_in_source_blocks( + sopts.unstable_opts.ignore_directory_in_diagnostics_source_blocks.clone(), + ); Box::new(emitter.ui_testing(sopts.unstable_opts.ui_testing)) } }, @@ -962,7 +953,6 @@ fn default_emitter( JsonEmitter::new( Box::new(io::BufWriter::new(io::stderr())), source_map, - translator, pretty, json_rendered, color_config, @@ -984,7 +974,6 @@ fn default_emitter( pub fn build_session( sopts: config::Options, io: CompilerIO, - fluent_bundle: Option>, driver_lint_caps: FxHashMap, target: Target, cfg_version: &'static str, @@ -1002,9 +991,8 @@ pub fn build_session( let cap_lints_allow = sopts.lint_cap.is_some_and(|cap| cap == lint::Allow); let can_emit_warnings = !(warnings_allow || cap_lints_allow); - let translator = Translator { fluent_bundle }; let source_map = rustc_span::source_map::get_source_map().unwrap(); - let emitter = default_emitter(&sopts, Arc::clone(&source_map), translator); + let emitter = default_emitter(&sopts, Arc::clone(&source_map)); let mut dcx = DiagCtxt::new(emitter).with_flags(sopts.unstable_opts.dcx_flags(can_emit_warnings)); @@ -1441,13 +1429,10 @@ impl EarlyDiagCtxt { } fn mk_emitter(output: ErrorOutputType) -> Box { - // FIXME(#100717): early errors aren't translated at the moment, so this is fine, but it will - // need to reference every crate that might emit an early error for translation to work. - let translator = Translator::new(); let emitter: Box = match output { config::ErrorOutputType::HumanReadable { kind, color_config } => match kind { HumanReadableErrorType { short, unicode } => Box::new( - AnnotateSnippetEmitter::new(stderr_destination(color_config), translator) + AnnotateSnippetEmitter::new(stderr_destination(color_config)) .theme(if unicode { OutputTheme::Unicode } else { OutputTheme::Ascii }) .short_message(short), ), @@ -1456,7 +1441,6 @@ fn mk_emitter(output: ErrorOutputType) -> Box { Box::new(JsonEmitter::new( Box::new(io::BufWriter::new(io::stderr())), Some(Arc::new(SourceMap::new(FilePathMapping::empty()))), - translator, pretty, json_rendered, color_config, diff --git a/compiler/rustc_type_ir/src/predicate.rs b/compiler/rustc_type_ir/src/predicate.rs index ab4677fa0a5fb..113192cc02eb8 100644 --- a/compiler/rustc_type_ir/src/predicate.rs +++ b/compiler/rustc_type_ir/src/predicate.rs @@ -420,6 +420,7 @@ pub struct ExistentialProjection { /// This field exists to prevent the creation of `ExistentialProjection` /// without using [`ExistentialProjection::new_from_args`]. + #[derive_where(skip(Debug))] use_existential_projection_new_instead: (), } diff --git a/library/unwind/src/lib.rs b/library/unwind/src/lib.rs index f2e0cfd32ed67..1e68eda52064e 100644 --- a/library/unwind/src/lib.rs +++ b/library/unwind/src/lib.rs @@ -6,7 +6,7 @@ #![feature(staged_api)] #![cfg_attr( all(target_family = "wasm", any(not(target_os = "emscripten"), emscripten_wasm_eh)), - feature(link_llvm_intrinsics, simd_wasm64) + feature(link_llvm_intrinsics, simd_wasm64, asm_experimental_arch) )] #![allow(internal_features)] #![allow(unused_features)] diff --git a/library/unwind/src/wasm.rs b/library/unwind/src/wasm.rs index cb6e90ba180b2..37d93bdbb67dd 100644 --- a/library/unwind/src/wasm.rs +++ b/library/unwind/src/wasm.rs @@ -2,6 +2,30 @@ #![allow(nonstandard_style)] +// Define the __cpp_exception tag that LLVM's wasm exception handling requires. +// In particular it is required to use either of: +// 1. the wasm_throw llvm intrinsic, or +// 2. the Rust try intrinsic. +// +// This must be provided since LLVM commit +// aee99e8015daa9f53ab1fd4e5b24cc4c694bdc4a which changed the tag from being +// weakly defined in each object file to being an external reference that must +// be linked from somewhere. +// +// We only define this for wasm32-unknown-unknown because on Emscripten/WASI +// targets, this symbol should be defined by the external toolchain. In +// particular, defining this on Emscripten would break Emscripten dynamic +// libraries. +#[cfg(all(target_os = "unknown", panic = "unwind"))] +core::arch::global_asm!( + ".globl __cpp_exception", + #[cfg(target_pointer_width = "64")] + ".tagtype __cpp_exception i64", + #[cfg(target_pointer_width = "32")] + ".tagtype __cpp_exception i32", + "__cpp_exception:", +); + #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq)] pub enum _Unwind_Reason_Code { diff --git a/src/doc/rustc-dev-guide/src/diagnostics/translation.md b/src/doc/rustc-dev-guide/src/diagnostics/translation.md index 018f331193751..112bc661ff8a1 100644 --- a/src/doc/rustc-dev-guide/src/diagnostics/translation.md +++ b/src/doc/rustc-dev-guide/src/diagnostics/translation.md @@ -159,48 +159,6 @@ have such implementations. `set_arg` calls are handled transparently by diagnostic derives but need to be added manually when using diagnostic builder APIs. -### Loading - -rustc makes a distinction between the "fallback bundle" for `en-US` that is used -by default and when another locale is missing a message; and the primary fluent -bundle which is requested by the user. - -Diagnostic emitters implement the `Emitter` trait which has two functions for -accessing the fallback and primary fluent bundles (`fallback_fluent_bundle` and -`fluent_bundle` respectively). - -`Emitter` also has member functions with default implementations for performing -translation of a `DiagMessage` using the results of -`fallback_fluent_bundle` and `fluent_bundle`. - -All of the emitters in rustc load the fallback Fluent bundle lazily, only -reading Fluent resources and parsing them when an error message is first being -translated (for performance reasons - it doesn't make sense to do this if no -error is being emitted). `rustc_error_messages::fallback_fluent_bundle` returns -a `std::lazy::Lazy` which is provided to emitters and evaluated -in the first call to `Emitter::fallback_fluent_bundle`. - -The primary Fluent bundle (for the user's desired locale) is expected to be -returned by `Emitter::fluent_bundle`. This bundle is used preferentially when -translating messages, the fallback bundle is only used if the primary bundle is -missing a message or not provided. - -There are no locale bundles distributed with the compiler, -but mechanisms are implemented for loading them. - -- `-Ztranslate-additional-ftl` can be used to load a specific resource as the - primary bundle for testing purposes. -- `-Ztranslate-lang` can be provided a language identifier (something like - `en-US`) and will load any Fluent resources found in - `$sysroot/share/locale/$locale/` directory (both the user provided - sysroot and any sysroot candidates). - -Primary bundles are not currently loaded lazily and if requested will be loaded -at the start of compilation regardless of whether an error occurs. Lazily -loading primary bundles is possible if it can be assumed that loading a bundle -won't fail. Bundle loading can fail if a requested locale is missing, Fluent -files are malformed, or a message is duplicated in multiple resources. - [Fluent]: https://projectfluent.org [`compiler/rustc_borrowck/messages.ftl`]: https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc_borrowck/messages.ftl [`compiler/rustc_parse/messages.ftl`]: https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc_parse/messages.ftl diff --git a/src/doc/rustc/src/platform-support/wasm32-unknown-unknown.md b/src/doc/rustc/src/platform-support/wasm32-unknown-unknown.md index ec20672f65403..3dc608e704308 100644 --- a/src/doc/rustc/src/platform-support/wasm32-unknown-unknown.md +++ b/src/doc/rustc/src/platform-support/wasm32-unknown-unknown.md @@ -267,3 +267,18 @@ the meantime using `-Cpanic=unwind` will require using [`-Zbuild-std`] and passing the appropriate flags to rustc. [`-Zbuild-std`]: ../../cargo/reference/unstable.html#build-std + +### The exception tag for panics + +Rust panics are currently implemented as a specific class of C++ exceptions. +This is because llvm only supports throwing and catching the C++ exception tag +from `wasm_throw` intrinsic and the lowering for the catchpads emitted by the +Rust try intrinsic. + +In particular, llvm throw and catch blocks expect a `WebAssembly.Tag` symbol +called `__cpp_exception`. If it is not defined somewhere, llvm will generate an +Emscripten style import from `env.__cpp_exception`. We don't want this, so we +define the symbol in `libunwind` but only for wasm32-unknown-unknown. WASI +doesn't currently support unwinding at all, and the Emscripten linker provides +the tag in an appropriate manner depending on what sort of binary is being +linked. diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 7629425ffb559..375f8338319b6 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -157,11 +157,10 @@ pub(crate) fn new_dcx( diagnostic_width: Option, unstable_opts: &UnstableOptions, ) -> rustc_errors::DiagCtxt { - let translator = rustc_driver::default_translator(); let emitter: Box = match error_format { ErrorOutputType::HumanReadable { kind, color_config } => match kind { HumanReadableErrorType { short, unicode } => Box::new( - AnnotateSnippetEmitter::new(stderr_destination(color_config), translator) + AnnotateSnippetEmitter::new(stderr_destination(color_config)) .sm(source_map.map(|sm| sm as _)) .short_message(short) .diagnostic_width(diagnostic_width) @@ -178,7 +177,6 @@ pub(crate) fn new_dcx( JsonEmitter::new( Box::new(io::BufWriter::new(io::stderr())), Some(source_map), - translator, pretty, json_rendered, color_config, diff --git a/src/librustdoc/doctest/make.rs b/src/librustdoc/doctest/make.rs index d30d869cd4c19..a77efaaed8d58 100644 --- a/src/librustdoc/doctest/make.rs +++ b/src/librustdoc/doctest/make.rs @@ -467,7 +467,6 @@ fn parse_source( let filename = FileName::anon_source_code(&wrapped_source); let sm = Arc::new(SourceMap::new(FilePathMapping::empty())); - let translator = rustc_driver::default_translator(); let supports_color = match get_stderr_color_choice(ColorConfig::Auto, &std::io::stderr()) { ColorChoice::Auto => unreachable!(), ColorChoice::AlwaysAnsi | ColorChoice::Always => true, @@ -476,7 +475,7 @@ fn parse_source( info.supports_color = supports_color; // Any errors in parsing should also appear when the doctest is compiled for real, so just // send all the errors that the parser emits directly into a `Sink` instead of stderr. - let emitter = AnnotateSnippetEmitter::new(AutoStream::never(Box::new(io::sink())), translator); + let emitter = AnnotateSnippetEmitter::new(AutoStream::never(Box::new(io::sink()))); // FIXME(misdreavus): pass `-Z treat-err-as-bug` to the doctest parser let dcx = DiagCtxt::new(Box::new(emitter)).disable_warnings(); diff --git a/src/librustdoc/passes/lint/check_code_block_syntax.rs b/src/librustdoc/passes/lint/check_code_block_syntax.rs index 5749b4ac081e1..b3199f11a680a 100644 --- a/src/librustdoc/passes/lint/check_code_block_syntax.rs +++ b/src/librustdoc/passes/lint/check_code_block_syntax.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use rustc_data_structures::sync::Lock; use rustc_errors::emitter::Emitter; -use rustc_errors::translation::{Translator, to_fluent_args}; +use rustc_errors::translation::{format_diag_message, to_fluent_args}; use rustc_errors::{Applicability, DiagCtxt, DiagInner}; use rustc_parse::{source_str_to_stream, unwrap_or_emit_fatal}; use rustc_resolve::rustdoc::source_span_for_markdown_range; @@ -35,8 +35,7 @@ fn check_rust_syntax( code_block: RustCodeBlock, ) { let buffer = Arc::new(Lock::new(Buffer::default())); - let translator = rustc_driver::default_translator(); - let emitter = BufferEmitter { buffer: Arc::clone(&buffer), translator }; + let emitter = BufferEmitter { buffer: Arc::clone(&buffer) }; let sm = Arc::new(SourceMap::new(FilePathMapping::empty())); let dcx = DiagCtxt::new(Box::new(emitter)).disable_warnings(); @@ -145,7 +144,6 @@ struct Buffer { struct BufferEmitter { buffer: Arc>, - translator: Translator, } impl Emitter for BufferEmitter { @@ -153,9 +151,7 @@ impl Emitter for BufferEmitter { let mut buffer = self.buffer.borrow_mut(); let fluent_args = to_fluent_args(diag.args.iter()); - let translated_main_message = self - .translator - .translate_message(&diag.messages[0].0, &fluent_args) + let translated_main_message = format_diag_message(&diag.messages[0].0, &fluent_args) .unwrap_or_else(|e| panic!("{e}")); buffer.messages.push(format!("error from rustc: {translated_main_message}")); @@ -167,8 +163,4 @@ impl Emitter for BufferEmitter { fn source_map(&self) -> Option<&SourceMap> { None } - - fn translator(&self) -> &Translator { - &self.translator - } } diff --git a/src/tools/miri/src/shims/foreign_items.rs b/src/tools/miri/src/shims/foreign_items.rs index 4c25caf56446a..12a170e6a849a 100644 --- a/src/tools/miri/src/shims/foreign_items.rs +++ b/src/tools/miri/src/shims/foreign_items.rs @@ -851,7 +851,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { // Fallback to shims in submodules. _ => { // Math shims - #[expect(irrefutable_let_patterns)] + #[cfg_attr(bootstrap, expect(irrefutable_let_patterns))] if let res = shims::math::EvalContextExt::emulate_foreign_item_inner( this, link_name, abi, args, dest, )? && !matches!(res, EmulateItemResult::NotSupported) diff --git a/src/tools/rustfmt/src/parse/session.rs b/src/tools/rustfmt/src/parse/session.rs index 2a5c8f776427d..83a77e73cb7ea 100644 --- a/src/tools/rustfmt/src/parse/session.rs +++ b/src/tools/rustfmt/src/parse/session.rs @@ -5,7 +5,6 @@ use std::sync::atomic::{AtomicBool, Ordering}; use rustc_data_structures::sync::IntoDynSyncSend; use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter; use rustc_errors::emitter::{DynEmitter, Emitter, SilentEmitter, stderr_destination}; -use rustc_errors::translation::Translator; use rustc_errors::{ColorConfig, Diag, DiagCtxt, DiagInner, Level as DiagnosticLevel}; use rustc_session::parse::ParseSess as RawParseSess; use rustc_span::{ @@ -74,10 +73,6 @@ impl Emitter for SilentOnIgnoredFilesEmitter { } self.handle_non_ignoreable_error(diag); } - - fn translator(&self) -> &Translator { - self.emitter.translator() - } } impl From for ColorConfig { @@ -104,15 +99,13 @@ fn default_dcx( ColorConfig::Never }; - let translator = rustc_driver::default_translator(); - let emitter: Box = if show_parse_errors { Box::new( - AnnotateSnippetEmitter::new(stderr_destination(emit_color), translator) + AnnotateSnippetEmitter::new(stderr_destination(emit_color)) .sm(Some(source_map.clone())), ) } else { - Box::new(SilentEmitter { translator }) + Box::new(SilentEmitter) }; DiagCtxt::new(Box::new(SilentOnIgnoredFilesEmitter { has_non_ignorable_parser_errors: false, @@ -342,10 +335,6 @@ mod tests { fn emit_diagnostic(&mut self, _diag: DiagInner) { self.num_emitted_errors.fetch_add(1, Ordering::Release); } - - fn translator(&self) -> &Translator { - panic!("test emitter attempted to translate a diagnostic"); - } } fn build_diagnostic(level: DiagnosticLevel, span: Option) -> DiagInner { diff --git a/tests/run-make/issue-84395-lto-embed-bitcode/rmake.rs b/tests/run-make/issue-84395-lto-embed-bitcode/rmake.rs index 450d8a9f099b4..42c943b62f37b 100644 --- a/tests/run-make/issue-84395-lto-embed-bitcode/rmake.rs +++ b/tests/run-make/issue-84395-lto-embed-bitcode/rmake.rs @@ -18,7 +18,7 @@ fn main() { .arg("-Clinker-plugin-lto") .arg(format!("-Clinker={}", env_var("CLANG"))) .arg("-Clink-arg=-Wl,--plugin-opt=-lto-embed-bitcode=optimized") - .arg("-Zemit-thin-lto=no") + .arg("-Clto=fat") .run(); llvm_objcopy().dump_section(".llvmbc", "test.bc").arg("test").run(); diff --git a/tests/run-make/translation/broken.ftl b/tests/run-make/translation/broken.ftl deleted file mode 100644 index f1dd6ff0bbd20..0000000000000 --- a/tests/run-make/translation/broken.ftl +++ /dev/null @@ -1,3 +0,0 @@ -# `foo` isn't provided by this diagnostic so it is expected that the fallback message is used. -parse_struct_literal_body_without_path = this is a {$foo} message - .suggestion = this is a test suggestion diff --git a/tests/run-make/translation/missing.ftl b/tests/run-make/translation/missing.ftl deleted file mode 100644 index 6be24dc7bb988..0000000000000 --- a/tests/run-make/translation/missing.ftl +++ /dev/null @@ -1,3 +0,0 @@ -# `parse_struct_literal_body_without_path` isn't provided by this resource at all, so the -# fallback should be used. -foo = bar diff --git a/tests/run-make/translation/rmake.rs b/tests/run-make/translation/rmake.rs deleted file mode 100644 index 4d7fd71a2f4a9..0000000000000 --- a/tests/run-make/translation/rmake.rs +++ /dev/null @@ -1,197 +0,0 @@ -//! Smoke test for the rustc diagnostics translation infrastructure. -//! -//! # References -//! -//! - Current tracking issue: . -//! - Old tracking issue: -//! - Initial translation infra implementation: . - -// This test uses symbolic links to stub out a fake sysroot to save testing time. -//@ needs-symlink -//@ needs-subprocess - -// FIXME(151366) Currently `-Ztranslate-additional-ftl` is currently broken -//@ ignore-test - -#![deny(warnings)] - -use std::path::{Path, PathBuf}; - -use run_make_support::rustc::sysroot; -use run_make_support::{cwd, rfs, run_in_tmpdir, rustc}; - -fn main() { - builtin_fallback_bundle(); - additional_primary_bundle(); - missing_slug_prefers_fallback_bundle(); - broken_primary_bundle_prefers_fallback_bundle(); - locale_sysroot(); - missing_sysroot(); - file_sysroot(); -} - -/// Check that the test works normally, using the built-in fallback bundle. -fn builtin_fallback_bundle() { - rustc().input("test.rs").run_fail().assert_stderr_contains("struct literal body without path"); -} - -/// Check that a primary bundle can be loaded and will be preferentially used where possible. -fn additional_primary_bundle() { - rustc() - .input("test.rs") - .arg("-Ztranslate-additional-ftl=working.ftl") - .run_fail() - .assert_stderr_contains("this is a test message"); -} - -/// Check that a primary bundle without the desired message will use the fallback bundle. -fn missing_slug_prefers_fallback_bundle() { - rustc() - .input("test.rs") - .arg("-Ztranslate-additional-ftl=missing.ftl") - .run_fail() - .assert_stderr_contains("struct literal body without path"); -} - -/// Check that a primary bundle with a broken message (e.g. an interpolated variable is not -/// provided) will use the fallback bundle. -fn broken_primary_bundle_prefers_fallback_bundle() { - // FIXME(#135817): as of the rmake.rs port, the compiler actually ICEs on the additional - // `broken.ftl`, even though the original intention seems to be that it should gracefully - // failover to the fallback bundle. On `aarch64-apple-darwin`, somehow it *doesn't* ICE. - - rustc() - .env("RUSTC_ICE", "0") // disable ICE dump file, not needed - .input("test.rs") - .arg("-Ztranslate-additional-ftl=broken.ftl") - .run_fail(); -} - -#[track_caller] -fn shallow_symlink_dir_entries(src_dir: &Path, dst_dir: &Path) { - for entry in rfs::read_dir(src_dir) { - let entry = entry.unwrap(); - let src_entry_path = entry.path(); - let src_filename = src_entry_path.file_name().unwrap(); - let meta = rfs::symlink_metadata(&src_entry_path); - if meta.is_symlink() || meta.is_file() { - rfs::symlink_file(&src_entry_path, dst_dir.join(src_filename)); - } else if meta.is_dir() { - rfs::symlink_dir(&src_entry_path, dst_dir.join(src_filename)); - } else { - unreachable!() - } - } -} - -#[track_caller] -fn shallow_symlink_dir_entries_materialize_single_dir( - src_dir: &Path, - dst_dir: &Path, - dir_filename: &str, -) { - shallow_symlink_dir_entries(src_dir, dst_dir); - - let dst_symlink_meta = rfs::symlink_metadata(dst_dir.join(dir_filename)); - - if dst_symlink_meta.is_file() || dst_symlink_meta.is_dir() { - unreachable!(); - } - - #[cfg(windows)] - { - use std::os::windows::fs::FileTypeExt as _; - if dst_symlink_meta.file_type().is_symlink_file() { - rfs::remove_file(dst_dir.join(dir_filename)); - } else if dst_symlink_meta.file_type().is_symlink_dir() { - rfs::remove_dir(dst_dir.join(dir_filename)); - } else { - unreachable!(); - } - } - #[cfg(not(windows))] - { - rfs::remove_file(dst_dir.join(dir_filename)); - } - - rfs::create_dir_all(dst_dir.join(dir_filename)); -} - -#[track_caller] -fn setup_fakeroot_parents() -> PathBuf { - let sysroot = sysroot(); - let fakeroot = cwd().join("fakeroot"); - rfs::create_dir_all(&fakeroot); - shallow_symlink_dir_entries_materialize_single_dir(&sysroot, &fakeroot, "lib"); - shallow_symlink_dir_entries_materialize_single_dir( - &sysroot.join("lib"), - &fakeroot.join("lib"), - "rustlib", - ); - shallow_symlink_dir_entries_materialize_single_dir( - &sysroot.join("lib").join("rustlib"), - &fakeroot.join("lib").join("rustlib"), - "src", - ); - shallow_symlink_dir_entries( - &sysroot.join("lib").join("rustlib").join("src"), - &fakeroot.join("lib").join("rustlib").join("src"), - ); - fakeroot -} - -/// Check that a locale can be loaded from the sysroot given a language identifier by making a local -/// copy of the sysroot and adding the custom locale to it. -fn locale_sysroot() { - run_in_tmpdir(|| { - let fakeroot = setup_fakeroot_parents(); - - // When download-rustc is enabled, real sysroot will have a share directory. Delete the link - // to it. - let _ = std::fs::remove_file(fakeroot.join("share")); - - let fake_locale_path = fakeroot.join("share").join("locale").join("zh-CN"); - rfs::create_dir_all(&fake_locale_path); - rfs::symlink_file( - cwd().join("working.ftl"), - fake_locale_path.join("basic-translation.ftl"), - ); - - rustc() - .env("RUSTC_ICE", "0") - .input("test.rs") - .sysroot(&fakeroot) - .arg("-Ztranslate-lang=zh-CN") - .run_fail() - .assert_stderr_contains("this is a test message"); - }); -} - -/// Check that the compiler errors out when the sysroot requested cannot be found. This test might -/// start failing if there actually exists a Klingon translation of rustc's error messages. -fn missing_sysroot() { - run_in_tmpdir(|| { - rustc() - .input("test.rs") - .arg("-Ztranslate-lang=tlh") - .run_fail() - .assert_stderr_contains("missing locale directory"); - }); -} - -/// Check that the compiler errors out when the directory for the locale in the sysroot is actually -/// a file. -fn file_sysroot() { - run_in_tmpdir(|| { - let fakeroot = setup_fakeroot_parents(); - rfs::create_dir_all(fakeroot.join("share").join("locale")); - rfs::write(fakeroot.join("share").join("locale").join("zh-CN"), b"not a dir"); - - rustc() - .input("test.rs") - .sysroot(&fakeroot) - .arg("-Ztranslate-lang=zh-CN") - .run_fail() - .assert_stderr_contains("is not a directory"); - }); -} diff --git a/tests/run-make/translation/test.rs b/tests/run-make/translation/test.rs deleted file mode 100644 index b8f5bff315337..0000000000000 --- a/tests/run-make/translation/test.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Exact error being tested isn't relevant, it just needs to be known that it uses Fluent-backed -// diagnostics. - -struct Foo { - val: (), -} - -fn foo() -> Foo { - val: (), -} - -fn main() { - let x = foo(); - x.val == 42; - let x = { - val: (), - }; -} diff --git a/tests/run-make/translation/working.ftl b/tests/run-make/translation/working.ftl deleted file mode 100644 index 50d126e3fbfec..0000000000000 --- a/tests/run-make/translation/working.ftl +++ /dev/null @@ -1,2 +0,0 @@ -parse_struct_literal_body_without_path = this is a test message - .suggestion = this is a test suggestion diff --git a/tests/ui/README.md b/tests/ui/README.md index 16cdde08431c0..d2b189a0e022c 100644 --- a/tests/ui/README.md +++ b/tests/ui/README.md @@ -440,10 +440,6 @@ Everything to do with `--diagnostic-width`. Exercises `#[diagnostic::*]` namespaced attributes. See [RFC 3368 Diagnostic attribute namespace](https://github.com/rust-lang/rfcs/blob/master/text/3368-diagnostic-attribute-namespace.md). -## `tests/ui/diagnostics-infra` - -This directory contains tests and infrastructure related to the diagnostics system, including support for translatable diagnostics - ## `tests/ui/did_you_mean/` Tests for miscellaneous suggestions. diff --git a/tests/ui/binding/irrefutable-in-let-chains.rs b/tests/ui/binding/irrefutable-in-let-chains.rs new file mode 100644 index 0000000000000..4bfeec184e905 --- /dev/null +++ b/tests/ui/binding/irrefutable-in-let-chains.rs @@ -0,0 +1,120 @@ +// https://github.com/rust-lang/rust/issues/139369 +// Test that the lint `irrefutable_let_patterns` now +// only checks single let binding. +//@ edition: 2024 +//@ check-pass + +use std::ops::Range; + +fn main() { + let opt = Some(None..Some(1)); + + // test `if let` + if let first = &opt {} + //~^ WARN irrefutable `if let` pattern + + if let first = &opt && let Some(second) = first {} + + if let first = &opt && let (a, b) = (1, 2) {} + + if let first = &opt && let None = Some(1) {} + + if 4 * 2 == 0 && let first = &opt {} + + if let first = &opt + && let Some(second) = first + && let None = second.start + && let v = 0 + {} + + if let Range { start: local_start, end: _ } = (None..Some(1)) {} + //~^ WARN irrefutable `if let` pattern + + if let Range { start: local_start, end: _ } = (None..Some(1)) + && let None = local_start + {} + + if let (a, b, c) = (Some(1), Some(1), Some(1)) {} + //~^ WARN irrefutable `if let` pattern + + if let (a, b, c) = (Some(1), Some(1), Some(1)) && let None = Some(1) {} + + if let Some(ref first) = opt + && let Range { start: local_start, end: _ } = first + && let None = local_start + {} + + // test `else if let` + if opt == Some(None..None) { + } else if let x = opt.clone().map(|_| 1) { + //~^ WARN irrefutable `if let` pattern + } + + if opt == Some(None..None) { + } else if let x = opt.clone().map(|_| 1) + && x == Some(1) + {} + + if opt == Some(None..None) { + } else if opt.is_some() && let x = &opt + {} + + if opt == Some(None..None) { + } else { + if let x = opt.clone().map(|_| 1) && x == Some(1) + {} + } + + // test `if let guard` + match opt { + Some(ref first) if let second = first => {} + //~^ WARN irrefutable `if let` guard pattern + _ => {} + } + + match opt { + Some(ref first) + if let second = first + && let _third = second + && let v = 4 + 4 => {} + _ => {} + } + + match opt { + Some(ref first) + if let Range { start: local_start, end: _ } = first + && let None = local_start => {} + _ => {} + } + + match opt { + Some(ref first) + if let Range { start: Some(_), end: local_end } = first + && let v = local_end + && let w = v => {} + _ => {} + } + + // test `while let` + while let first = &opt {} + //~^ WARN irrefutable `while let` pattern + + while let first = &opt + && let (a, b) = (1, 2) + {} + + while let first = &opt + && let Some(second) = first + && let None = second.start + {} + + while let Some(ref first) = opt + && let second = first + && let _third = second + {} + + while let Some(ref first) = opt + && let Range { start: local_start, end: _ } = first + && let None = local_start + {} +} diff --git a/tests/ui/binding/irrefutable-in-let-chains.stderr b/tests/ui/binding/irrefutable-in-let-chains.stderr new file mode 100644 index 0000000000000..4ff3c8b048ff6 --- /dev/null +++ b/tests/ui/binding/irrefutable-in-let-chains.stderr @@ -0,0 +1,57 @@ +warning: irrefutable `if let` pattern + --> $DIR/irrefutable-in-let-chains.rs:13:8 + | +LL | if let first = &opt {} + | ^^^^^^^^^^^^^^^^ + | + = note: this pattern will always match, so the `if let` is useless + = help: consider replacing the `if let` with a `let` + = note: `#[warn(irrefutable_let_patterns)]` on by default + +warning: irrefutable `if let` pattern + --> $DIR/irrefutable-in-let-chains.rs:30:8 + | +LL | if let Range { start: local_start, end: _ } = (None..Some(1)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this pattern will always match, so the `if let` is useless + = help: consider replacing the `if let` with a `let` + +warning: irrefutable `if let` pattern + --> $DIR/irrefutable-in-let-chains.rs:37:8 + | +LL | if let (a, b, c) = (Some(1), Some(1), Some(1)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this pattern will always match, so the `if let` is useless + = help: consider replacing the `if let` with a `let` + +warning: irrefutable `if let` pattern + --> $DIR/irrefutable-in-let-chains.rs:49:15 + | +LL | } else if let x = opt.clone().map(|_| 1) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this pattern will always match, so the `if let` is useless + = help: consider replacing the `if let` with a `let` + +warning: irrefutable `if let` guard pattern + --> $DIR/irrefutable-in-let-chains.rs:70:28 + | +LL | Some(ref first) if let second = first => {} + | ^^^^^^^^^^^^^^^^^^ + | + = note: this pattern will always match, so the guard is useless + = help: consider removing the guard and adding a `let` inside the match arm + +warning: irrefutable `while let` pattern + --> $DIR/irrefutable-in-let-chains.rs:99:11 + | +LL | while let first = &opt {} + | ^^^^^^^^^^^^^^^^ + | + = note: this pattern will always match, so the loop will never exit + = help: consider instead using a `loop { ... }` with a `let` inside it + +warning: 6 warnings emitted + diff --git a/tests/ui/delegation/generics/generic-params-defaults.rs b/tests/ui/delegation/generics/generic-params-defaults.rs new file mode 100644 index 0000000000000..b6d70a557abdd --- /dev/null +++ b/tests/ui/delegation/generics/generic-params-defaults.rs @@ -0,0 +1,14 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +trait Trait<'a, 'b, 'c, A = usize, B = u32, C = String, const N: usize = 123> { + fn foo(&self) { + //~^ ERROR: defaults for generic parameters are not allowed here + //~| WARN: this was previously accepted by the compiler but is being phased out + } +} + +reuse Trait::foo; +//~^ ERROR: type annotations needed + +fn main() {} diff --git a/tests/ui/delegation/generics/generic-params-defaults.stderr b/tests/ui/delegation/generics/generic-params-defaults.stderr new file mode 100644 index 0000000000000..43eb840c95915 --- /dev/null +++ b/tests/ui/delegation/generics/generic-params-defaults.stderr @@ -0,0 +1,35 @@ +error: defaults for generic parameters are not allowed here + --> $DIR/generic-params-defaults.rs:5:12 + | +LL | fn foo(&self) { + | ^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 + = note: `#[deny(invalid_type_param_default)]` (part of `#[deny(future_incompatible)]`) on by default + +error[E0282]: type annotations needed + --> $DIR/generic-params-defaults.rs:11:14 + | +LL | reuse Trait::foo; + | ^^^ cannot infer type of the type parameter `T` declared on the method `foo` + | +help: consider specifying the generic argument + | +LL | reuse Trait::foo::; + | +++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0282`. +Future incompatibility report: Future breakage diagnostic: +error: defaults for generic parameters are not allowed here + --> $DIR/generic-params-defaults.rs:5:12 + | +LL | fn foo(&self) { + | ^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 + = note: `#[deny(invalid_type_param_default)]` (part of `#[deny(future_incompatible)]`) on by default + diff --git a/tests/ui/delegation/generics/generic-params-same-names.rs b/tests/ui/delegation/generics/generic-params-same-names.rs new file mode 100644 index 0000000000000..14b1276941d22 --- /dev/null +++ b/tests/ui/delegation/generics/generic-params-same-names.rs @@ -0,0 +1,19 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +trait Trait<'a, 'b, 'c, A, B, C, const N: usize> { + fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) { + //~^ ERROR: lifetime name `'a` shadows a lifetime name that is already in scope + //~| ERROR: lifetime name `'b` shadows a lifetime name that is already in scope + //~| ERROR: lifetime name `'c` shadows a lifetime name that is already in scope + //~| ERROR: the name `A` is already used for a generic parameter in this item's generic parameters + //~| ERROR: the name `B` is already used for a generic parameter in this item's generic parameters + //~| ERROR: the name `C` is already used for a generic parameter in this item's generic parameters + //~| ERROR: the name `N` is already used for a generic parameter in this item's generic parameters + } +} + +reuse Trait::foo; +//~^ ERROR: type annotations needed + +fn main() {} diff --git a/tests/ui/delegation/generics/generic-params-same-names.stderr b/tests/ui/delegation/generics/generic-params-same-names.stderr new file mode 100644 index 0000000000000..6fc31553123e1 --- /dev/null +++ b/tests/ui/delegation/generics/generic-params-same-names.stderr @@ -0,0 +1,76 @@ +error[E0496]: lifetime name `'a` shadows a lifetime name that is already in scope + --> $DIR/generic-params-same-names.rs:5:12 + | +LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> { + | -- first declared here +LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) { + | ^^ lifetime `'a` already in scope + +error[E0496]: lifetime name `'b` shadows a lifetime name that is already in scope + --> $DIR/generic-params-same-names.rs:5:16 + | +LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> { + | -- first declared here +LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) { + | ^^ lifetime `'b` already in scope + +error[E0496]: lifetime name `'c` shadows a lifetime name that is already in scope + --> $DIR/generic-params-same-names.rs:5:20 + | +LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> { + | -- first declared here +LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) { + | ^^ lifetime `'c` already in scope + +error[E0403]: the name `A` is already used for a generic parameter in this item's generic parameters + --> $DIR/generic-params-same-names.rs:5:24 + | +LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> { + | - first use of `A` +LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) { + | ^ already used + +error[E0403]: the name `B` is already used for a generic parameter in this item's generic parameters + --> $DIR/generic-params-same-names.rs:5:27 + | +LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> { + | - first use of `B` +LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) { + | ^ already used + +error[E0403]: the name `C` is already used for a generic parameter in this item's generic parameters + --> $DIR/generic-params-same-names.rs:5:30 + | +LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> { + | - first use of `C` +LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) { + | ^ already used + +error[E0403]: the name `N` is already used for a generic parameter in this item's generic parameters + --> $DIR/generic-params-same-names.rs:5:39 + | +LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> { + | - first use of `N` +LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) { + | ^ already used + +error[E0284]: type annotations needed + --> $DIR/generic-params-same-names.rs:16:14 + | +LL | reuse Trait::foo; + | ^^^ cannot infer the value of the const parameter `N` declared on the method `foo` + | +note: required by a const generic parameter in `Trait::foo` + --> $DIR/generic-params-same-names.rs:5:33 + | +LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) { + | ^^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` +help: consider specifying the generic arguments + | +LL | reuse Trait::foo::; + | ++++++++++++++ + +error: aborting due to 8 previous errors + +Some errors have detailed explanations: E0284, E0403, E0496. +For more information about an error, try `rustc --explain E0284`. diff --git a/tests/ui/delegation/generics/generics-gen-args-errors.rs b/tests/ui/delegation/generics/generics-gen-args-errors.rs new file mode 100644 index 0000000000000..045fc7c75dea9 --- /dev/null +++ b/tests/ui/delegation/generics/generics-gen-args-errors.rs @@ -0,0 +1,114 @@ +//@ compile-flags: -Z deduplicate-diagnostics=yes + +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +mod test_1 { + fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + reuse foo as bar; + //~^ ERROR: type annotations needed + + fn check() { + bar::<1, 2, 3, 4, 5, 6>(); + //~^ ERROR: function takes 3 generic arguments but 6 generic arguments were supplied + + bar::(); + //~^ ERROR: expected value, found struct `String` [E0423] + + bar::<'static, 'static, 'static, 'static, 'static>(); + //~^ ERROR: function takes 2 lifetime arguments but 5 lifetime arguments were supplied + + bar::(); + //~^ ERROR: constant provided when a type was expected + + bar(); + + bar::<_, _, _, _, _>(); + //~^ ERROR: function takes 3 generic arguments but 5 generic arguments were supplied + + bar::(); + //~^ ERROR: cannot find type `asd` in this scope + //~| ERROR: cannot find type `asd` in this scope + //~| ERROR: cannot find type `asd` in this scope + //~| ERROR: unresolved item provided when a constant was expected + + reuse foo:: as xd; + //~^ ERROR can't use generic parameters from outer item + //~| ERROR can't use generic parameters from outer item + //~| ERROR can't use generic parameters from outer item + //~| ERROR: unresolved item provided when a constant was expected + } +} + +mod test_2 { + fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + + reuse foo::<> as bar1; + //~^ ERROR: type annotations needed + + reuse foo:: as bar2; + //~^ ERROR: function takes 3 generic arguments but 2 generic arguments were supplied + + reuse foo::<'static, _, 'asdasd, 'static, 'static, 'static, _> as bar3; + //~^ ERROR: use of undeclared lifetime name `'asdasd` + //~| ERROR: function takes 2 lifetime arguments but 5 lifetime arguments were supplied + //~| ERROR: function takes 3 generic arguments but 2 generic arguments were supplied + reuse foo:: as bar4; + //~^ ERROR: cannot find type `asdasd` in this scope + //~| ERROR: function takes 2 lifetime arguments but 1 lifetime argument was supplied + + reuse foo::<1, 2, _, 4, 5, _> as bar5; + //~^ ERROR: function takes 3 generic arguments but 6 generic arguments were supplied + + reuse foo::<1, 2,asd,String, { let x = 0; }> as bar6; + //~^ ERROR: cannot find type `asd` in this scope + //~| ERROR: function takes 3 generic arguments but 5 generic arguments were supplied + + reuse foo::<"asdasd", asd, "askdn", 'static, 'a> as bar7; + //~^ ERROR: use of undeclared lifetime name `'a` + //~| ERROR: cannot find type `asd` in this scope + //~| ERROR: constant provided when a type was expected + + reuse foo::<{}, {}, {}> as bar8; + //~^ ERROR: constant provided when a type was expected +} + +mod test_3 { + trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { + fn foo<'d: 'd, U, const M: bool>(self) {} + } + + reuse Trait::::foo as bar1; + //~^ ERROR: cannot find type `asd` in this scope + //~| ERROR: cannot find type `asd` in this scope + //~| ERROR: cannot find type `asd` in this scope + //~| ERROR: cannot find type `asd` in this scope + //~| ERROR: cannot find type `asd` in this scope + //~| ERROR: cannot find type `asdasa` in this scope + //~| ERROR: trait takes 2 generic arguments but 6 generic arguments were supplied + + reuse Trait::<'static, 'static>::foo as bar2; + //~^ ERROR: trait takes 3 lifetime arguments but 2 lifetime arguments were supplied + reuse Trait::<1, 2, 3, 4, 5>::foo as bar3; + //~^ ERROR: trait takes 2 generic arguments but 5 generic arguments were supplied + + reuse Trait::<1, 2, true>::foo as bar4; + //~^ ERROR: trait takes 2 generic arguments but 3 generic arguments were supplied + + reuse Trait::<'static>::foo as bar5; + //~^ ERROR: trait takes 3 lifetime arguments but 1 lifetime argument was supplied + + reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; + //~^ ERROR: cannot find type `DDDD` in this scope [E0425] + //~| ERROR: trait takes 3 lifetime arguments but 1 lifetime argument was supplied + //~| ERROR: trait takes 2 generic arguments but 3 generic arguments were supplied + //~| ERROR: method takes 2 generic arguments but 6 generic arguments were supplied + + reuse Trait::::foo::<1, 2, 3, _, 6> as bar7; + //~^ ERROR: missing lifetime specifiers [E0106] + //~| ERROR: trait takes 3 lifetime arguments but 1 lifetime argument was supplied + //~| ERROR: trait takes 2 generic arguments but 5 generic arguments were supplied + //~| ERROR: method takes 2 generic arguments but 5 generic arguments were supplied +} + +fn main() {} diff --git a/tests/ui/delegation/generics/generics-gen-args-errors.stderr b/tests/ui/delegation/generics/generics-gen-args-errors.stderr new file mode 100644 index 0000000000000..5c04fa2c23248 --- /dev/null +++ b/tests/ui/delegation/generics/generics-gen-args-errors.stderr @@ -0,0 +1,563 @@ +error[E0401]: can't use generic parameters from outer item + --> $DIR/generics-gen-args-errors.rs:35:21 + | +LL | fn check() { + | - type parameter from outer item +... +LL | reuse foo:: as xd; + | ^ -- generic parameter used in this inner delegated function + | | + | use of generic parameter from outer item + | + = note: nested items are independent from their parent item for everything except for privacy and name resolution + +error[E0401]: can't use generic parameters from outer item + --> $DIR/generics-gen-args-errors.rs:35:24 + | +LL | fn check() { + | - type parameter from outer item +... +LL | reuse foo:: as xd; + | ^ -- generic parameter used in this inner delegated function + | | + | use of generic parameter from outer item + | + = note: nested items are independent from their parent item for everything except for privacy and name resolution + +error[E0401]: can't use generic parameters from outer item + --> $DIR/generics-gen-args-errors.rs:35:27 + | +LL | fn check() { + | - type parameter from outer item +... +LL | reuse foo:: as xd; + | ^ -- generic parameter used in this inner delegated function + | | + | use of generic parameter from outer item + | + = note: nested items are independent from their parent item for everything except for privacy and name resolution + +error[E0261]: use of undeclared lifetime name `'asdasd` + --> $DIR/generics-gen-args-errors.rs:52:29 + | +LL | reuse foo::<'static, _, 'asdasd, 'static, 'static, 'static, _> as bar3; + | ^^^^^^^ undeclared lifetime + | +help: consider introducing lifetime `'asdasd` here + | +LL | reuse foo'asdasd, ::<'static, _, 'asdasd, 'static, 'static, 'static, _> as bar3; + | ++++++++ + +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/generics-gen-args-errors.rs:67:50 + | +LL | reuse foo::<"asdasd", asd, "askdn", 'static, 'a> as bar7; + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | reuse foo'a, ::<"asdasd", asd, "askdn", 'static, 'a> as bar7; + | +++ + +error[E0106]: missing lifetime specifiers + --> $DIR/generics-gen-args-errors.rs:107:19 + | +LL | reuse Trait::::foo::<1, 2, 3, _, 6> as bar7; + | ^^^^^ expected 3 lifetime parameters + | +help: consider introducing a named lifetime parameter + | +LL | reuse Trait::, Clone, _, 'static, dyn Send, _>::foo'a, ::<1, 2, 3, _, 6> as bar7; + | ++++++++++++ +++ + +error[E0423]: expected value, found struct `String` + --> $DIR/generics-gen-args-errors.rs:15:33 + | +LL | bar::(); + | ^^^^^^ + | + --> $SRC_DIR/alloc/src/string.rs:LL:COL + | + = note: `String` defined here + +error[E0425]: cannot find type `asd` in this scope + --> $DIR/generics-gen-args-errors.rs:29:15 + | +LL | bar::(); + | ^^^ not found in this scope + | +help: you might be missing a type parameter + | +LL | fn check() { + | +++++ + +error[E0425]: cannot find type `asd` in this scope + --> $DIR/generics-gen-args-errors.rs:29:20 + | +LL | bar::(); + | ^^^ not found in this scope + | +help: you might be missing a type parameter + | +LL | fn check() { + | +++++ + +error[E0425]: cannot find type `asd` in this scope + --> $DIR/generics-gen-args-errors.rs:29:25 + | +LL | bar::(); + | ^^^ not found in this scope + | +help: you might be missing a type parameter + | +LL | fn check() { + | +++++ + +error[E0425]: cannot find type `asdasd` in this scope + --> $DIR/generics-gen-args-errors.rs:56:39 + | +LL | reuse foo:: as bar4; + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `asd` in this scope + --> $DIR/generics-gen-args-errors.rs:63:22 + | +LL | reuse foo::<1, 2,asd,String, { let x = 0; }> as bar6; + | ^^^ not found in this scope + +error[E0425]: cannot find type `asd` in this scope + --> $DIR/generics-gen-args-errors.rs:67:27 + | +LL | reuse foo::<"asdasd", asd, "askdn", 'static, 'a> as bar7; + | ^^^ not found in this scope + +error[E0425]: cannot find type `asd` in this scope + --> $DIR/generics-gen-args-errors.rs:81:19 + | +LL | reuse Trait::::foo as bar1; + | ^^^ not found in this scope + +error[E0425]: cannot find type `asd` in this scope + --> $DIR/generics-gen-args-errors.rs:81:24 + | +LL | reuse Trait::::foo as bar1; + | ^^^ not found in this scope + +error[E0425]: cannot find type `asd` in this scope + --> $DIR/generics-gen-args-errors.rs:81:29 + | +LL | reuse Trait::::foo as bar1; + | ^^^ not found in this scope + +error[E0425]: cannot find type `asd` in this scope + --> $DIR/generics-gen-args-errors.rs:81:34 + | +LL | reuse Trait::::foo as bar1; + | ^^^ not found in this scope + +error[E0425]: cannot find type `asd` in this scope + --> $DIR/generics-gen-args-errors.rs:81:39 + | +LL | reuse Trait::::foo as bar1; + | ^^^ not found in this scope + +error[E0425]: cannot find type `asdasa` in this scope + --> $DIR/generics-gen-args-errors.rs:81:44 + | +LL | reuse Trait::::foo as bar1; + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `DDDD` in this scope + --> $DIR/generics-gen-args-errors.rs:101:34 + | +LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; + | ^^^^ not found in this scope + +error[E0284]: type annotations needed + --> $DIR/generics-gen-args-errors.rs:8:11 + | +LL | reuse foo as bar; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `test_1::foo` + --> $DIR/generics-gen-args-errors.rs:7:48 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse foo:: as bar; + | +++++++++++ + +error[E0107]: function takes 3 generic arguments but 6 generic arguments were supplied + --> $DIR/generics-gen-args-errors.rs:12:9 + | +LL | bar::<1, 2, 3, 4, 5, 6>(); + | ^^^ --------- help: remove the unnecessary generic arguments + | | + | expected 3 generic arguments + | +note: function defined here, with 3 generic parameters: `T`, `U`, `N` + --> $DIR/generics-gen-args-errors.rs:8:18 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | - - -------------- +LL | reuse foo as bar; + | ^^^ + +error[E0107]: function takes 2 lifetime arguments but 5 lifetime arguments were supplied + --> $DIR/generics-gen-args-errors.rs:18:9 + | +LL | bar::<'static, 'static, 'static, 'static, 'static>(); + | ^^^ --------------------------- help: remove the lifetime arguments + | | + | expected 2 lifetime arguments + | +note: function defined here, with 2 lifetime parameters: `'a`, `'b` + --> $DIR/generics-gen-args-errors.rs:8:18 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | -- -- +LL | reuse foo as bar; + | ^^^ + +error[E0747]: constant provided when a type was expected + --> $DIR/generics-gen-args-errors.rs:21:23 + | +LL | bar::(); + | ^ + +error[E0107]: function takes 3 generic arguments but 5 generic arguments were supplied + --> $DIR/generics-gen-args-errors.rs:26:9 + | +LL | bar::<_, _, _, _, _>(); + | ^^^ ------ help: remove the unnecessary generic arguments + | | + | expected 3 generic arguments + | +note: function defined here, with 3 generic parameters: `T`, `U`, `N` + --> $DIR/generics-gen-args-errors.rs:8:18 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | - - -------------- +LL | reuse foo as bar; + | ^^^ + +error[E0747]: unresolved item provided when a constant was expected + --> $DIR/generics-gen-args-errors.rs:29:25 + | +LL | bar::(); + | ^^^ + | +help: if this generic argument was intended as a const parameter, surround it with braces + | +LL | bar::(); + | + + + +error[E0747]: unresolved item provided when a constant was expected + --> $DIR/generics-gen-args-errors.rs:35:27 + | +LL | reuse foo:: as xd; + | ^ + | +help: if this generic argument was intended as a const parameter, surround it with braces + | +LL | reuse foo:: as xd; + | + + + +error[E0284]: type annotations needed + --> $DIR/generics-gen-args-errors.rs:46:11 + | +LL | reuse foo::<> as bar1; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `test_2::foo` + --> $DIR/generics-gen-args-errors.rs:44:48 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse foo:: as bar1; + | +++++++ + +error[E0107]: function takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/generics-gen-args-errors.rs:49:11 + | +LL | reuse foo:: as bar2; + | ^^^ ------ ------ supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: function defined here, with 3 generic parameters: `T`, `U`, `N` + --> $DIR/generics-gen-args-errors.rs:44:8 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | ^^^ - - -------------- +help: add missing generic argument + | +LL | reuse foo:: as bar2; + | +++ + +error[E0107]: function takes 2 lifetime arguments but 5 lifetime arguments were supplied + --> $DIR/generics-gen-args-errors.rs:52:11 + | +LL | reuse foo::<'static, _, 'asdasd, 'static, 'static, 'static, _> as bar3; + | ^^^ --------------------------- help: remove the lifetime arguments + | | + | expected 2 lifetime arguments + | +note: function defined here, with 2 lifetime parameters: `'a`, `'b` + --> $DIR/generics-gen-args-errors.rs:44:8 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | ^^^ -- -- + +error[E0107]: function takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/generics-gen-args-errors.rs:52:11 + | +LL | reuse foo::<'static, _, 'asdasd, 'static, 'static, 'static, _> as bar3; + | ^^^ expected 3 generic arguments ------- - supplied 2 generic arguments + | +note: function defined here, with 3 generic parameters: `T`, `U`, `N` + --> $DIR/generics-gen-args-errors.rs:44:8 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | ^^^ - - -------------- +help: add missing generic argument + | +LL | reuse foo::<'static, _, 'asdasd, 'static, 'static, 'static, _, N> as bar3; + | +++ + +error[E0107]: function takes 2 lifetime arguments but 1 lifetime argument was supplied + --> $DIR/generics-gen-args-errors.rs:56:11 + | +LL | reuse foo:: as bar4; + | ^^^ ------ supplied 1 lifetime argument + | | + | expected 2 lifetime arguments + | +note: function defined here, with 2 lifetime parameters: `'a`, `'b` + --> $DIR/generics-gen-args-errors.rs:44:8 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | ^^^ -- -- +help: add missing lifetime argument + | +LL | reuse foo:: as bar4; + | +++++++++ + +error[E0107]: function takes 3 generic arguments but 6 generic arguments were supplied + --> $DIR/generics-gen-args-errors.rs:60:11 + | +LL | reuse foo::<1, 2, _, 4, 5, _> as bar5; + | ^^^ --------- help: remove the unnecessary generic arguments + | | + | expected 3 generic arguments + | +note: function defined here, with 3 generic parameters: `T`, `U`, `N` + --> $DIR/generics-gen-args-errors.rs:44:8 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | ^^^ - - -------------- + +error[E0107]: function takes 3 generic arguments but 5 generic arguments were supplied + --> $DIR/generics-gen-args-errors.rs:63:11 + | +LL | reuse foo::<1, 2,asd,String, { let x = 0; }> as bar6; + | ^^^ ----------------------- help: remove the unnecessary generic arguments + | | + | expected 3 generic arguments + | +note: function defined here, with 3 generic parameters: `T`, `U`, `N` + --> $DIR/generics-gen-args-errors.rs:44:8 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | ^^^ - - -------------- + +error[E0747]: constant provided when a type was expected + --> $DIR/generics-gen-args-errors.rs:67:17 + | +LL | reuse foo::<"asdasd", asd, "askdn", 'static, 'a> as bar7; + | ^^^^^^^^ + +error[E0747]: constant provided when a type was expected + --> $DIR/generics-gen-args-errors.rs:72:17 + | +LL | reuse foo::<{}, {}, {}> as bar8; + | ^^ + +error[E0107]: trait takes 2 generic arguments but 6 generic arguments were supplied + --> $DIR/generics-gen-args-errors.rs:81:11 + | +LL | reuse Trait::::foo as bar1; + | ^^^^^ ----------------------- help: remove the unnecessary generic arguments + | | + | expected 2 generic arguments + | +note: trait defined here, with 2 generic parameters: `T`, `N` + --> $DIR/generics-gen-args-errors.rs:77:11 + | +LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { + | ^^^^^ - -------------- + +error[E0107]: trait takes 3 lifetime arguments but 2 lifetime arguments were supplied + --> $DIR/generics-gen-args-errors.rs:90:11 + | +LL | reuse Trait::<'static, 'static>::foo as bar2; + | ^^^^^ ------- ------- supplied 2 lifetime arguments + | | + | expected 3 lifetime arguments + | +note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a` + --> $DIR/generics-gen-args-errors.rs:77:11 + | +LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { + | ^^^^^ -- -- -- +help: add missing lifetime argument + | +LL | reuse Trait::<'static, 'static, 'static>::foo as bar2; + | +++++++++ + +error[E0107]: trait takes 2 generic arguments but 5 generic arguments were supplied + --> $DIR/generics-gen-args-errors.rs:92:11 + | +LL | reuse Trait::<1, 2, 3, 4, 5>::foo as bar3; + | ^^^^^ --------- help: remove the unnecessary generic arguments + | | + | expected 2 generic arguments + | +note: trait defined here, with 2 generic parameters: `T`, `N` + --> $DIR/generics-gen-args-errors.rs:77:11 + | +LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { + | ^^^^^ - -------------- + +error[E0107]: trait takes 2 generic arguments but 3 generic arguments were supplied + --> $DIR/generics-gen-args-errors.rs:95:11 + | +LL | reuse Trait::<1, 2, true>::foo as bar4; + | ^^^^^ ------ help: remove the unnecessary generic argument + | | + | expected 2 generic arguments + | +note: trait defined here, with 2 generic parameters: `T`, `N` + --> $DIR/generics-gen-args-errors.rs:77:11 + | +LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { + | ^^^^^ - -------------- + +error[E0107]: trait takes 3 lifetime arguments but 1 lifetime argument was supplied + --> $DIR/generics-gen-args-errors.rs:98:11 + | +LL | reuse Trait::<'static>::foo as bar5; + | ^^^^^ ------- supplied 1 lifetime argument + | | + | expected 3 lifetime arguments + | +note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a` + --> $DIR/generics-gen-args-errors.rs:77:11 + | +LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { + | ^^^^^ -- -- -- +help: add missing lifetime arguments + | +LL | reuse Trait::<'static, 'static, 'static>::foo as bar5; + | ++++++++++++++++++ + +error[E0107]: trait takes 3 lifetime arguments but 1 lifetime argument was supplied + --> $DIR/generics-gen-args-errors.rs:101:11 + | +LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; + | ^^^^^ - supplied 1 lifetime argument + | | + | expected 3 lifetime arguments + | +note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a` + --> $DIR/generics-gen-args-errors.rs:77:11 + | +LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { + | ^^^^^ -- -- -- +help: add missing lifetime arguments + | +LL | reuse Trait::<1, 'static, 'static, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; + | ++++++++++++++++++ + +error[E0107]: trait takes 2 generic arguments but 3 generic arguments were supplied + --> $DIR/generics-gen-args-errors.rs:101:11 + | +LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; + | ^^^^^ --------------- help: remove the unnecessary generic argument + | | + | expected 2 generic arguments + | +note: trait defined here, with 2 generic parameters: `T`, `N` + --> $DIR/generics-gen-args-errors.rs:77:11 + | +LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { + | ^^^^^ - -------------- + +error[E0107]: method takes 2 generic arguments but 6 generic arguments were supplied + --> $DIR/generics-gen-args-errors.rs:101:41 + | +LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; + | ^^^ ------------ help: remove the unnecessary generic arguments + | | + | expected 2 generic arguments + | +note: method defined here, with 2 generic parameters: `U`, `M` + --> $DIR/generics-gen-args-errors.rs:78:12 + | +LL | fn foo<'d: 'd, U, const M: bool>(self) {} + | ^^^ - ------------- + +error[E0107]: trait takes 3 lifetime arguments but 1 lifetime argument was supplied + --> $DIR/generics-gen-args-errors.rs:107:11 + | +LL | reuse Trait::::foo::<1, 2, 3, _, 6> as bar7; + | ^^^^^ ----- supplied 1 lifetime argument + | | + | expected 3 lifetime arguments + | +note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a` + --> $DIR/generics-gen-args-errors.rs:77:11 + | +LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { + | ^^^^^ -- -- -- +help: add missing lifetime arguments + | +LL | reuse Trait::::foo::<1, 2, 3, _, 6> as bar7; + | ++++++++++++++++++ + +error[E0107]: trait takes 2 generic arguments but 5 generic arguments were supplied + --> $DIR/generics-gen-args-errors.rs:107:11 + | +LL | reuse Trait::::foo::<1, 2, 3, _, 6> as bar7; + | ^^^^^ --- help: remove the unnecessary generic argument + | | + | expected 2 generic arguments + | +note: trait defined here, with 2 generic parameters: `T`, `N` + --> $DIR/generics-gen-args-errors.rs:77:11 + | +LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { + | ^^^^^ - -------------- + +error[E0107]: method takes 2 generic arguments but 5 generic arguments were supplied + --> $DIR/generics-gen-args-errors.rs:107:59 + | +LL | reuse Trait::::foo::<1, 2, 3, _, 6> as bar7; + | ^^^ --------- help: remove the unnecessary generic arguments + | | + | expected 2 generic arguments + | +note: method defined here, with 2 generic parameters: `U`, `M` + --> $DIR/generics-gen-args-errors.rs:78:12 + | +LL | fn foo<'d: 'd, U, const M: bool>(self) {} + | ^^^ - ------------- + +error: aborting due to 47 previous errors + +Some errors have detailed explanations: E0106, E0107, E0261, E0284, E0401, E0423, E0425, E0747. +For more information about an error, try `rustc --explain E0106`. diff --git a/tests/ui/delegation/generics/impl-trait-wrong-args-count.rs b/tests/ui/delegation/generics/impl-trait-wrong-args-count.rs new file mode 100644 index 0000000000000..08236f7cb9247 --- /dev/null +++ b/tests/ui/delegation/generics/impl-trait-wrong-args-count.rs @@ -0,0 +1,38 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +mod to_reuse { + pub fn bar<'a: 'a, 'b: 'b, A, B>(x: &super::XX) {} + pub fn bar1(x: &super::XX) {} + pub fn bar2(x: &super::XX) {} +} + +trait Trait<'a, 'b, 'c, A, B, const N: usize>: Sized { + fn bar<'x: 'x, 'y: 'y, AA, BB, const NN: usize>(&self) {} + fn bar1<'x: 'x, 'y: 'y, AA, BB, const NN: usize>(&self) {} + fn bar2(&self) {} + fn bar3(&self) {} + fn bar4(&self) {} +} + +struct X<'x1, 'x2, 'x3, 'x4, X1, X2, const X3: usize>( + &'x1 X1, &'x2 X2, &'x3 X1, &'x4 [usize; X3]); +type XX = X::<'static, 'static, 'static, 'static, i32, i32, 3>; + +impl<'a, 'b, 'c, A, B, const N: usize> Trait<'a, 'b, 'c, A, B, N> for XX { + reuse to_reuse::bar; + //~^ ERROR: type annotations needed + + reuse to_reuse::bar1; + + reuse to_reuse::bar2; + //~^ ERROR: type annotations needed + //~| ERROR: type annotations needed + + reuse to_reuse::bar2:: as bar3; + + reuse to_reuse::bar2:: as bar4; +} + +fn main() { +} diff --git a/tests/ui/delegation/generics/impl-trait-wrong-args-count.stderr b/tests/ui/delegation/generics/impl-trait-wrong-args-count.stderr new file mode 100644 index 0000000000000..e70d920a922d4 --- /dev/null +++ b/tests/ui/delegation/generics/impl-trait-wrong-args-count.stderr @@ -0,0 +1,47 @@ +error[E0282]: type annotations needed + --> $DIR/impl-trait-wrong-args-count.rs:23:21 + | +LL | reuse to_reuse::bar; + | ^^^ cannot infer type of the type parameter `A` declared on the function `bar` + | +help: consider specifying the generic arguments + | +LL | reuse to_reuse::bar::; + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/impl-trait-wrong-args-count.rs:28:21 + | +LL | reuse to_reuse::bar2; + | ^^^^ cannot infer the value of the const parameter `X` declared on the function `bar2` + | +note: required by a const generic parameter in `bar2` + --> $DIR/impl-trait-wrong-args-count.rs:7:35 + | +LL | pub fn bar2(x: &super::XX) {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `bar2` +help: consider specifying the generic arguments + | +LL | reuse to_reuse::bar2::; + | ++++++++++++++++++++++++++ + +error[E0284]: type annotations needed + --> $DIR/impl-trait-wrong-args-count.rs:28:21 + | +LL | reuse to_reuse::bar2; + | ^^^^ cannot infer the value of the const parameter `Y` declared on the function `bar2` + | +note: required by a const generic parameter in `bar2` + --> $DIR/impl-trait-wrong-args-count.rs:7:51 + | +LL | pub fn bar2(x: &super::XX) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `bar2` +help: consider specifying the generic arguments + | +LL | reuse to_reuse::bar2::; + | ++++++++++++++++++++++++++ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0282, E0284. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/delegation/generics/mapping/free-to-free.rs b/tests/ui/delegation/generics/mapping/free-to-free.rs new file mode 100644 index 0000000000000..375b0bfa901ff --- /dev/null +++ b/tests/ui/delegation/generics/mapping/free-to-free.rs @@ -0,0 +1,141 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] +#![allow(late_bound_lifetime_arguments)] + +//! This is one of the mapping tests, which tests mapping of delegee parent and child +//! generic params, whose main goal is to create cases with +//! different number of lifetimes/types/consts in delegee child and parent; and in +//! delegation parent if applicable. At some tests predicates are +//! added. At some tests user-specified args are specified in reuse statement. + +// Testing lifetimes + types + consts, reusing without +// user args, checking predicates inheritance +mod test_1 { + fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + + pub fn check() { + reuse foo as bar; + //~^ ERROR: type annotations needed [E0284] + bar::(); + } +} + +// Testing lifetimes + types + consts, reusing without user args, +// providing delegation parent args in invocation +mod test_2 { + fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + + pub fn check() { + reuse foo as bar; + //~^ ERROR: type annotations needed [E0284] + bar::(); + } +} + +// Testing lifetimes + types + consts, reusing without user args, +// providing random types with delegation parent generics specified +mod test_3 { + fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + + pub fn check() { + reuse foo as bar; + //~^ ERROR: type annotations needed [E0284] + bar::(); + } +} + +// Testing late-bound lifetimes + types + consts, reusing without user args, +// providing random types with delegation parent generics specified, +// checking signature inheritance +mod test_4 { + fn foo<'a, 'b, T: Clone, U: Clone, const N: usize>(_t: &'a T, _u: &'b U) {} + + pub fn check() { + reuse foo as bar; + //~^ ERROR: type annotations needed [E0284] + bar::(&1, &2); + } +} + +// Testing late-bound lifetimes + types + consts, reusing without user args, +// providing random types with delegation parent generics specified, +// checking signature inheritance, testing mixed order of types and consts +mod test_5 { + fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {} + + pub fn check() { + reuse foo as bar; + //~^ ERROR: type annotations needed [E0284] + bar::(&1, &2); + } +} + +// Testing late-bound lifetimes + types + consts, reusing with user args, +// checking signature inheritance, testing mixed order of types and consts +mod test_6 { + fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {} + + pub fn check() { + reuse foo:: as bar; + //~^ ERROR: arguments to this function are incorrect [E0308] + bar(&"".to_string(), &"".to_string()); + //~^ ERROR: type annotations needed [E0284] + } +} + +// FIXME(fn_delegation): Uncomment this test when impl Traits in function params are supported + +// mod test_7 { +// fn foo(t: T, u: U, f: impl FnOnce(T, U) -> U) -> U { +// f(t, u) +// } + +// pub fn check() { +// reuse foo as bar; +// assert_eq!(bar::(1, 2, |x, y| y), 2); +// } +// } + +// Testing reuse of local fn with delegation parent generic params specified, +// late-bound lifetimes + types + consts, reusing with user args, +// checking signature inheritance, mixed consts and types ordering +mod test_8 { + pub fn check() { + fn foo<'a, 'b, const N: usize, T: Clone, U: Clone>(_t: &'a T, _u: &'b U) {} + + reuse foo::<1, String, String> as bar; + //~^ ERROR: arguments to this function are incorrect [E0308] + bar(&"".to_string(), &"".to_string()); + //~^ ERROR: type annotations needed [E0284] + } +} + +// Testing reuse of local fn inside closure, +// late-bound lifetimes + types + consts, reusing with user args, +// checking signature inheritance, mixed consts and types ordering +mod test_9 { + pub fn check() { + let closure = || { + fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {} + + reuse foo:: as bar; + //~^ ERROR: arguments to this function are incorrect [E0308] + bar(&"".to_string(), &"".to_string()); + //~^ ERROR: type annotations needed [E0284] + }; + + closure(); + } +} + +pub fn main() { + test_1::check(); + test_2::check::(); + test_3::check::(); + test_4::check::(); + test_5::check::(); + test_6::check::(); + // test_7::check(); + test_8::check::(); + test_9::check::(); +} diff --git a/tests/ui/delegation/generics/mapping/free-to-free.stderr b/tests/ui/delegation/generics/mapping/free-to-free.stderr new file mode 100644 index 0000000000000..0ecdb5f42e733 --- /dev/null +++ b/tests/ui/delegation/generics/mapping/free-to-free.stderr @@ -0,0 +1,213 @@ +error[E0284]: type annotations needed + --> $DIR/free-to-free.rs:17:15 + | +LL | reuse foo as bar; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `test_1::foo` + --> $DIR/free-to-free.rs:14:48 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse foo:: as bar; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/free-to-free.rs:29:15 + | +LL | reuse foo as bar; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `test_2::foo` + --> $DIR/free-to-free.rs:26:48 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse foo:: as bar; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/free-to-free.rs:41:15 + | +LL | reuse foo as bar; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `test_3::foo` + --> $DIR/free-to-free.rs:38:48 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse foo:: as bar; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/free-to-free.rs:54:15 + | +LL | reuse foo as bar; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `test_4::foo` + --> $DIR/free-to-free.rs:51:40 + | +LL | fn foo<'a, 'b, T: Clone, U: Clone, const N: usize>(_t: &'a T, _u: &'b U) {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse foo:: as bar; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/free-to-free.rs:67:15 + | +LL | reuse foo as bar; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `test_5::foo` + --> $DIR/free-to-free.rs:64:30 + | +LL | fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse foo:: as bar; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/free-to-free.rs:81:9 + | +LL | bar(&"".to_string(), &"".to_string()); + | ^^^ cannot infer the value of the const parameter `N` declared on the function `bar` + | +note: required by a const generic parameter in `test_6::check::bar` + --> $DIR/free-to-free.rs:76:30 + | +LL | fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `bar` +... +LL | reuse foo:: as bar; + | --- required by a bound in this function +help: consider specifying the generic arguments + | +LL | bar::(&"".to_string(), &"".to_string()); + | +++++++++++++++++++++ + +error[E0308]: arguments to this function are incorrect + --> $DIR/free-to-free.rs:79:15 + | +LL | fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {} + | - - found this type parameter + | | + | found this type parameter +... +LL | reuse foo:: as bar; + | ^^^ + | | + | expected `&String`, found `&T` + | expected `&String`, found `&U` + | + = note: expected reference `&String` + found reference `&'a T` + = note: expected reference `&String` + found reference `&'b U` +note: function defined here + --> $DIR/free-to-free.rs:76:8 + | +LL | fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {} + | ^^^ --------- --------- + +error[E0284]: type annotations needed + --> $DIR/free-to-free.rs:108:9 + | +LL | bar(&"".to_string(), &"".to_string()); + | ^^^ cannot infer the value of the const parameter `N` declared on the function `bar` + | +note: required by a const generic parameter in `test_8::check::bar` + --> $DIR/free-to-free.rs:104:24 + | +LL | fn foo<'a, 'b, const N: usize, T: Clone, U: Clone>(_t: &'a T, _u: &'b U) {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `bar` +LL | +LL | reuse foo::<1, String, String> as bar; + | --- required by a bound in this function +help: consider specifying the generic arguments + | +LL | bar::(&"".to_string(), &"".to_string()); + | +++++++++++++++++++++ + +error[E0308]: arguments to this function are incorrect + --> $DIR/free-to-free.rs:106:15 + | +LL | fn foo<'a, 'b, const N: usize, T: Clone, U: Clone>(_t: &'a T, _u: &'b U) {} + | - - found this type parameter + | | + | found this type parameter +LL | +LL | reuse foo::<1, String, String> as bar; + | ^^^ + | | + | expected `&String`, found `&T` + | expected `&String`, found `&U` + | + = note: expected reference `&String` + found reference `&'a T` + = note: expected reference `&String` + found reference `&'b U` +note: function defined here + --> $DIR/free-to-free.rs:104:12 + | +LL | fn foo<'a, 'b, const N: usize, T: Clone, U: Clone>(_t: &'a T, _u: &'b U) {} + | ^^^ --------- --------- + +error[E0284]: type annotations needed + --> $DIR/free-to-free.rs:123:13 + | +LL | bar(&"".to_string(), &"".to_string()); + | ^^^ cannot infer the value of the const parameter `N` declared on the function `bar` + | +note: required by a const generic parameter in `test_9::check::{closure#0}::bar` + --> $DIR/free-to-free.rs:119:38 + | +LL | fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `bar` +LL | +LL | reuse foo:: as bar; + | --- required by a bound in this function +help: consider specifying the generic arguments + | +LL | bar::(&"".to_string(), &"".to_string()); + | +++++++++++++++++++++ + +error[E0308]: arguments to this function are incorrect + --> $DIR/free-to-free.rs:121:19 + | +LL | fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {} + | - - found this type parameter + | | + | found this type parameter +LL | +LL | reuse foo:: as bar; + | ^^^ + | | + | expected `&String`, found `&T` + | expected `&String`, found `&U` + | + = note: expected reference `&String` + found reference `&'a T` + = note: expected reference `&String` + found reference `&'b U` +note: function defined here + --> $DIR/free-to-free.rs:119:16 + | +LL | fn foo<'a, 'b, T: Clone, const N: usize, U: Clone>(_t: &'a T, _u: &'b U) {} + | ^^^ --------- --------- + +error: aborting due to 11 previous errors + +Some errors have detailed explanations: E0284, E0308. +For more information about an error, try `rustc --explain E0284`. diff --git a/tests/ui/delegation/generics/mapping/free-to-trait.rs b/tests/ui/delegation/generics/mapping/free-to-trait.rs new file mode 100644 index 0000000000000..b0404a4aeef83 --- /dev/null +++ b/tests/ui/delegation/generics/mapping/free-to-trait.rs @@ -0,0 +1,268 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] +#![allow(late_bound_lifetime_arguments)] + +//! This is one of the mapping tests, which tests mapping of delegee parent and child +//! generic params, whose main goal is to create cases with +//! different number of lifetimes/types/consts in delegee child and parent; and in +//! delegation parent if applicable. At some tests predicates are +//! added. At some tests user-specified args are specified in reuse statement. + +// Testing lifetimes + types + consts in both parent and child, reusing in +// a function without generic params +mod test_1 { + trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { + fn foo<'d: 'd, U, const M: bool>(self) {} + } + + impl Trait<'static, 'static, 'static, i32, 1> for u8 {} + + pub fn check() { + fn no_ctx() { + reuse Trait::foo as bar; + //~^ ERROR: type annotations needed [E0284] + bar::<'static, 'static, 'static, 'static, u8, i32, 1, String, true>(123); + } + + fn with_ctx<'a, 'b, 'c, A, B, C, const N: usize, const M: bool>() { + reuse Trait::foo as bar; + //~^ ERROR: type annotations needed [E0284] + bar::<'static, 'static, 'static, 'a, u8, i32, 1, A, M>(123); + } + + no_ctx(); + with_ctx::(); + } +} + +// Testing lifetimes + types + consts in both parent and child, add user-specified args to parent +mod test_2 { + trait Trait<'a, T, const N: usize>: Sized { + fn foo<'b: 'b, U, const M: bool>(self) {} + } + + impl Trait<'static, i32, 1> for u8 {} + + pub fn check() { + reuse Trait::<'static, i32, 1>::foo as bar; + //~^ ERROR: the trait bound `Self: test_2::Trait<'static, i32, 1>` is not satisfied [E0277] + + bar::<'static, u8, String, true>(123); + //~^ ERROR: function takes 5 generic arguments but 3 generic arguments were supplied [E0107] + //~| ERROR: function takes 2 lifetime arguments but 1 lifetime argument was supplied [E0107] + } +} + +// Testing lifetimes + types + consts in both parent and child, +// add user-specified args to child +mod test_3 { + trait Trait<'a, T, const N: usize>: Sized { + fn foo<'b: 'b, U, const M: bool>(self) {} + } + + impl Trait<'static, String, 1> for u8 {} + + pub fn check() { + reuse Trait::foo::<'static, i32, true> as bar; + + bar::<'static, u8, String, 1>(123); + //~^ ERROR: function takes 5 generic arguments but 3 generic arguments were supplied [E0107] + //~| ERROR: function takes 2 lifetime arguments but 1 lifetime argument was supplied [E0107] + } +} + +// Testing types/consts in parent, lifetimes + types/consts in child, +// add user-specified args to child +mod test_4 { + trait Trait: Sized { + fn foo<'b: 'b, U, const M: bool>(self) {} + } + + impl Trait for u8 {} + + pub fn check() { + reuse Trait::foo::<'static, i32, true> as bar; + + bar::(123); + //~^ ERROR: function takes 5 generic arguments but 3 generic arguments were supplied [E0107] + } +} + +// Testing consts in parent, lifetimes + types/consts in child, add user-specified args to child +mod test_5 { + trait Trait: Sized { + fn foo<'b: 'b, U, const M: bool>(self) {} + } + + impl Trait<1> for u8 {} + + pub fn check() { + reuse Trait::foo::<'static, i32, true> as bar; + + bar::(123); + //~^ ERROR: function takes 4 generic arguments but 2 generic arguments were supplied [E0107] + } +} + +// Testing no generics in parent, lifetimes + types/consts in child, +// add user-specified args to child +mod test_6 { + trait Trait: Sized { + fn foo<'b: 'b, U, const M: bool>(self) {} + } + + impl Trait for u8 {} + + pub fn check() { + reuse Trait::foo::<'static, i32, true> as bar; + + bar::(123); + //~^ ERROR: function takes 3 generic arguments but 1 generic argument was supplied [E0107] + } +} + +// Testing lifetimes + types/consts in parent, types/consts in child, +// add user-specified args to parent +mod test_7 { + trait Trait<'a, T, const N: usize>: Sized { + fn foo(self) {} + } + + impl Trait<'static, i32, 1> for u8 {} + + pub fn check() { + reuse Trait::<'static, i32, 1>::foo as bar; + //~^ ERROR: the trait bound `Self: test_7::Trait<'static, i32, 1>` is not satisfied [E0277] + + bar::(123); + //~^ ERROR: function takes 5 generic arguments but 3 generic arguments were supplied [E0107] + } +} + +// Testing lifetimes + types/consts in parent, consts in child, add user-specified args to parent +mod test_8 { + trait Trait<'a, T, const N: usize>: Sized { + fn foo(self) {} + } + + impl Trait<'static, i32, 1> for u8 {} + + pub fn check() { + reuse Trait::<'static, i32, 1>::foo as bar; + //~^ ERROR: the trait bound `Self: test_8::Trait<'static, i32, 1>` is not satisfied [E0277] + + bar::(123); + //~^ ERROR: function takes 4 generic arguments but 2 generic arguments were supplied [E0107] + } +} + +// Testing lifetimes + types/consts in parent, none in child, add user-specified args to parent +mod test_9 { + trait Trait<'a, T, const N: usize>: Sized { + fn foo(self) {} + } + + impl Trait<'static, i32, 1> for u8 {} + + pub fn check() { + reuse Trait::<'static, i32, 1>::foo as bar; + //~^ ERROR: the trait bound `Self: test_9::Trait<'static, i32, 1>` is not satisfied [E0277] + + bar::(123); + //~^ ERROR: function takes 3 generic arguments but 1 generic argument was supplied [E0107] + } +} + +// Testing lifetimes + types in parent, lifetimes + types/consts in child, +// adding self ty to reuse, testing using generic params from delegation parent +// context, adding user-specified args to none, parent, parent and child +mod test_10 { + trait Trait<'b, 'c, T> { + fn foo<'d: 'd, U, const M: bool>() {} + } + + impl<'b, 'c, T> Trait<'b, 'c, T> for u8 {} + + pub fn check() { + fn with_ctx<'a, 'b, 'c, A, B, C, const N: usize, const M: bool>() { + reuse ::foo as bar; + //~^ ERROR: missing generics for trait `test_10::Trait` [E0107] + bar::<'a, 'b, 'c, u8, C, A, M>(); + bar::<'static, 'static, 'static, u8, i32, i32, false>(); + + reuse >::foo as bar1; + //~^ ERROR: type annotations needed [E0284] + bar1::<'static, u8, i32, true>(); + //~^ ERROR: function takes 4 generic arguments but 3 generic arguments were supplied [E0107] + //~| ERROR: function takes 3 lifetime arguments but 1 lifetime argument was supplied [E0107] + + reuse >::foo::<'static, u32, true> as bar2; + bar2::(); + //~^ ERROR: function takes 4 generic arguments but 1 generic argument was supplied [E0107] + } + + with_ctx::(); + } +} + +// Testing lifetimes + types in parent, lifetimes + types/consts in child, +// adding self ty to reuse, testing using generic params from delegation parent +// context, testing predicates inheritance +mod test_11 { + trait Bound0 {} + trait Bound1 {} + trait Bound2 {} + + trait Trait<'a: 'static, T, P> + where + Self: Sized, + T: Bound0, + P: Bound2>>>, + { + fn foo<'d: 'd, U: Bound1, const M: bool>() {} + } + + impl Bound0 for u32 {} + impl Bound1 for String {} + impl<'a: 'static, T: Bound0, P: Bound2>>>> Trait<'a, T, P> for usize {} + + struct Struct; + impl Bound2>>> for Struct {} + + pub fn check<'b>() { + reuse ::foo; + //~^ ERROR: missing generics for trait `test_11::Trait` [E0107] + foo::<'static, 'b, usize, u32, Struct, String, false>(); + } +} + +// Testing lifetimes + types/consts in parent with defaults, none in child, +// reuse without user-specified args +mod test_12 { + trait Trait<'a, T = usize, const N: usize = 123>: Sized { + fn foo(self) {} + } + + impl Trait<'static, i32, 1> for u8 {} + + pub fn check() { + reuse Trait::foo as bar; + + bar::(123); + } +} + +pub fn main() { + test_1::check(); + test_2::check(); + test_3::check(); + test_4::check(); + test_5::check(); + test_6::check(); + test_7::check(); + test_8::check(); + test_9::check(); + test_10::check(); + test_11::check(); + test_12::check(); +} diff --git a/tests/ui/delegation/generics/mapping/free-to-trait.stderr b/tests/ui/delegation/generics/mapping/free-to-trait.stderr new file mode 100644 index 0000000000000..b364d7fb22511 --- /dev/null +++ b/tests/ui/delegation/generics/mapping/free-to-trait.stderr @@ -0,0 +1,401 @@ +error[E0284]: type annotations needed + --> $DIR/free-to-trait.rs:22:26 + | +LL | reuse Trait::foo as bar; + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_1::Trait::foo` + --> $DIR/free-to-trait.rs:15:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` +help: consider specifying the generic arguments + | +LL | reuse Trait::foo:: as bar; + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/free-to-trait.rs:28:26 + | +LL | reuse Trait::foo as bar; + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_1::Trait::foo` + --> $DIR/free-to-trait.rs:15:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` +help: consider specifying the generic arguments + | +LL | reuse Trait::foo:: as bar; + | ++++++++ + +error[E0107]: function takes 2 lifetime arguments but 1 lifetime argument was supplied + --> $DIR/free-to-trait.rs:50:9 + | +LL | bar::<'static, u8, String, true>(123); + | ^^^ ------- supplied 1 lifetime argument + | | + | expected 2 lifetime arguments + | +note: function defined here, with 2 lifetime parameters: `'a`, `'b` + --> $DIR/free-to-trait.rs:47:48 + | +LL | trait Trait<'a, T, const N: usize>: Sized { + | -- +LL | fn foo<'b: 'b, U, const M: bool>(self) {} + | -- +... +LL | reuse Trait::<'static, i32, 1>::foo as bar; + | ^^^ +help: add missing lifetime argument + | +LL | bar::<'static, 'static, u8, String, true>(123); + | +++++++++ + +error[E0107]: function takes 5 generic arguments but 3 generic arguments were supplied + --> $DIR/free-to-trait.rs:50:9 + | +LL | bar::<'static, u8, String, true>(123); + | ^^^ -- ------ ---- supplied 3 generic arguments + | | + | expected 5 generic arguments + | +note: function defined here, with 5 generic parameters: `Self`, `T`, `N`, `U`, `M` + --> $DIR/free-to-trait.rs:47:48 + | +LL | trait Trait<'a, T, const N: usize>: Sized { + | ----------------------------------------- +LL | fn foo<'b: 'b, U, const M: bool>(self) {} + | - ------------- +... +LL | reuse Trait::<'static, i32, 1>::foo as bar; + | ^^^ +help: add missing generic arguments + | +LL | bar::<'static, u8, String, true, U, M>(123); + | ++++++ + +error[E0277]: the trait bound `Self: test_2::Trait<'static, i32, 1>` is not satisfied + --> $DIR/free-to-trait.rs:47:41 + | +LL | reuse Trait::<'static, i32, 1>::foo as bar; + | ^^^ the trait `test_2::Trait<'static, i32, 1>` is not implemented for `Self` + +error[E0107]: function takes 2 lifetime arguments but 1 lifetime argument was supplied + --> $DIR/free-to-trait.rs:68:9 + | +LL | bar::<'static, u8, String, 1>(123); + | ^^^ ------- supplied 1 lifetime argument + | | + | expected 2 lifetime arguments + | +note: function defined here, with 2 lifetime parameters: `'a`, `'b` + --> $DIR/free-to-trait.rs:66:51 + | +LL | trait Trait<'a, T, const N: usize>: Sized { + | -- +LL | fn foo<'b: 'b, U, const M: bool>(self) {} + | -- +... +LL | reuse Trait::foo::<'static, i32, true> as bar; + | ^^^ +help: add missing lifetime argument + | +LL | bar::<'static, 'static, u8, String, 1>(123); + | +++++++++ + +error[E0107]: function takes 5 generic arguments but 3 generic arguments were supplied + --> $DIR/free-to-trait.rs:68:9 + | +LL | bar::<'static, u8, String, 1>(123); + | ^^^ -- ------ - supplied 3 generic arguments + | | + | expected 5 generic arguments + | +note: function defined here, with 5 generic parameters: `Self`, `T`, `N`, `U`, `M` + --> $DIR/free-to-trait.rs:66:51 + | +LL | trait Trait<'a, T, const N: usize>: Sized { + | ----------------------------------------- +LL | fn foo<'b: 'b, U, const M: bool>(self) {} + | - ------------- +... +LL | reuse Trait::foo::<'static, i32, true> as bar; + | ^^^ +help: add missing generic arguments + | +LL | bar::<'static, u8, String, 1, U, M>(123); + | ++++++ + +error[E0107]: function takes 5 generic arguments but 3 generic arguments were supplied + --> $DIR/free-to-trait.rs:86:9 + | +LL | bar::(123); + | ^^^ -- ------ - supplied 3 generic arguments + | | + | expected 5 generic arguments + | +note: function defined here, with 5 generic parameters: `Self`, `T`, `N`, `U`, `M` + --> $DIR/free-to-trait.rs:84:51 + | +LL | trait Trait: Sized { + | ------------------------------------- +LL | fn foo<'b: 'b, U, const M: bool>(self) {} + | - ------------- +... +LL | reuse Trait::foo::<'static, i32, true> as bar; + | ^^^ +help: add missing generic arguments + | +LL | bar::(123); + | ++++++ + +error[E0107]: function takes 4 generic arguments but 2 generic arguments were supplied + --> $DIR/free-to-trait.rs:102:9 + | +LL | bar::(123); + | ^^^ -- - supplied 2 generic arguments + | | + | expected 4 generic arguments + | +note: function defined here, with 4 generic parameters: `Self`, `N`, `U`, `M` + --> $DIR/free-to-trait.rs:100:51 + | +LL | trait Trait: Sized { + | ---------------------------------- +LL | fn foo<'b: 'b, U, const M: bool>(self) {} + | - ------------- +... +LL | reuse Trait::foo::<'static, i32, true> as bar; + | ^^^ +help: add missing generic arguments + | +LL | bar::(123); + | ++++++ + +error[E0107]: function takes 3 generic arguments but 1 generic argument was supplied + --> $DIR/free-to-trait.rs:119:9 + | +LL | bar::(123); + | ^^^ -- supplied 1 generic argument + | | + | expected 3 generic arguments + | +note: function defined here, with 3 generic parameters: `Self`, `U`, `M` + --> $DIR/free-to-trait.rs:117:51 + | +LL | trait Trait: Sized { + | ------------------ +LL | fn foo<'b: 'b, U, const M: bool>(self) {} + | - ------------- +... +LL | reuse Trait::foo::<'static, i32, true> as bar; + | ^^^ +help: add missing generic arguments + | +LL | bar::(123); + | ++++++ + +error[E0107]: function takes 5 generic arguments but 3 generic arguments were supplied + --> $DIR/free-to-trait.rs:137:9 + | +LL | bar::(123); + | ^^^ -- ------ ---- supplied 3 generic arguments + | | + | expected 5 generic arguments + | +note: function defined here, with 5 generic parameters: `Self`, `T`, `N`, `U`, `M` + --> $DIR/free-to-trait.rs:134:48 + | +LL | trait Trait<'a, T, const N: usize>: Sized { + | ----------------------------------------- +LL | fn foo(self) {} + | - ------------- +... +LL | reuse Trait::<'static, i32, 1>::foo as bar; + | ^^^ +help: add missing generic arguments + | +LL | bar::(123); + | ++++++ + +error[E0277]: the trait bound `Self: test_7::Trait<'static, i32, 1>` is not satisfied + --> $DIR/free-to-trait.rs:134:41 + | +LL | reuse Trait::<'static, i32, 1>::foo as bar; + | ^^^ the trait `test_7::Trait<'static, i32, 1>` is not implemented for `Self` + +error[E0107]: function takes 4 generic arguments but 2 generic arguments were supplied + --> $DIR/free-to-trait.rs:154:9 + | +LL | bar::(123); + | ^^^ -- ---- supplied 2 generic arguments + | | + | expected 4 generic arguments + | +note: function defined here, with 4 generic parameters: `Self`, `T`, `N`, `M` + --> $DIR/free-to-trait.rs:151:48 + | +LL | trait Trait<'a, T, const N: usize>: Sized { + | ----------------------------------------- +LL | fn foo(self) {} + | ------------- +... +LL | reuse Trait::<'static, i32, 1>::foo as bar; + | ^^^ +help: add missing generic arguments + | +LL | bar::(123); + | ++++++ + +error[E0277]: the trait bound `Self: test_8::Trait<'static, i32, 1>` is not satisfied + --> $DIR/free-to-trait.rs:151:41 + | +LL | reuse Trait::<'static, i32, 1>::foo as bar; + | ^^^ the trait `test_8::Trait<'static, i32, 1>` is not implemented for `Self` + +error[E0107]: function takes 3 generic arguments but 1 generic argument was supplied + --> $DIR/free-to-trait.rs:171:9 + | +LL | bar::(123); + | ^^^ -- supplied 1 generic argument + | | + | expected 3 generic arguments + | +note: function defined here, with 3 generic parameters: `Self`, `T`, `N` + --> $DIR/free-to-trait.rs:168:48 + | +LL | trait Trait<'a, T, const N: usize>: Sized { + | ----------------------------------------- +... +LL | reuse Trait::<'static, i32, 1>::foo as bar; + | ^^^ +help: add missing generic arguments + | +LL | bar::(123); + | ++++++ + +error[E0277]: the trait bound `Self: test_9::Trait<'static, i32, 1>` is not satisfied + --> $DIR/free-to-trait.rs:168:41 + | +LL | reuse Trait::<'static, i32, 1>::foo as bar; + | ^^^ the trait `test_9::Trait<'static, i32, 1>` is not implemented for `Self` + +error[E0107]: function takes 3 lifetime arguments but 1 lifetime argument was supplied + --> $DIR/free-to-trait.rs:195:13 + | +LL | bar1::<'static, u8, i32, true>(); + | ^^^^ ------- supplied 1 lifetime argument + | | + | expected 3 lifetime arguments + | +note: function defined here, with 3 lifetime parameters: `'b`, `'c`, `'d` + --> $DIR/free-to-trait.rs:193:66 + | +LL | trait Trait<'b, 'c, T> { + | -- -- +LL | fn foo<'d: 'd, U, const M: bool>() {} + | -- +... +LL | reuse >::foo as bar1; + | ^^^^ +help: add missing lifetime arguments + | +LL | bar1::<'static, 'static, 'static, u8, i32, true>(); + | ++++++++++++++++++ + +error[E0107]: function takes 4 generic arguments but 3 generic arguments were supplied + --> $DIR/free-to-trait.rs:195:13 + | +LL | bar1::<'static, u8, i32, true>(); + | ^^^^ -- --- ---- supplied 3 generic arguments + | | + | expected 4 generic arguments + | +note: function defined here, with 4 generic parameters: `Self`, `T`, `U`, `M` + --> $DIR/free-to-trait.rs:193:66 + | +LL | trait Trait<'b, 'c, T> { + | ---------------------- +LL | fn foo<'d: 'd, U, const M: bool>() {} + | - ------------- +... +LL | reuse >::foo as bar1; + | ^^^^ +help: add missing generic argument + | +LL | bar1::<'static, u8, i32, true, M>(); + | +++ + +error[E0107]: function takes 4 generic arguments but 1 generic argument was supplied + --> $DIR/free-to-trait.rs:200:13 + | +LL | bar2::(); + | ^^^^ -- supplied 1 generic argument + | | + | expected 4 generic arguments + | +note: function defined here, with 4 generic parameters: `Self`, `T`, `U`, `M` + --> $DIR/free-to-trait.rs:199:88 + | +LL | trait Trait<'b, 'c, T> { + | ---------------------- +LL | fn foo<'d: 'd, U, const M: bool>() {} + | - ------------- +... +LL | reuse >::foo::<'static, u32, true> as bar2; + | ^^^^ +help: add missing generic arguments + | +LL | bar2::(); + | +++++++++ + +error[E0107]: missing generics for trait `test_10::Trait` + --> $DIR/free-to-trait.rs:188:26 + | +LL | reuse ::foo as bar; + | ^^^^^ expected 1 generic argument + | +note: trait defined here, with 1 generic parameter: `T` + --> $DIR/free-to-trait.rs:180:11 + | +LL | trait Trait<'b, 'c, T> { + | ^^^^^ - +help: add missing generic argument + | +LL | reuse >::foo as bar; + | +++ + +error[E0284]: type annotations needed + --> $DIR/free-to-trait.rs:193:59 + | +LL | reuse >::foo as bar1; + | ^^^ cannot infer the value of the const parameter `M` declared on the associated function `foo` + | +note: required by a const generic parameter in `test_10::Trait::foo` + --> $DIR/free-to-trait.rs:181:27 + | +LL | fn foo<'d: 'd, U, const M: bool>() {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0107]: missing generics for trait `test_11::Trait` + --> $DIR/free-to-trait.rs:233:25 + | +LL | reuse ::foo; + | ^^^^^ expected 2 generic arguments + | +note: trait defined here, with 2 generic parameters: `T`, `P` + --> $DIR/free-to-trait.rs:216:11 + | +LL | trait Trait<'a: 'static, T, P> + | ^^^^^ - - +help: add missing generic arguments + | +LL | reuse >::foo; + | ++++++ + +error: aborting due to 22 previous errors + +Some errors have detailed explanations: E0107, E0277, E0284. +For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/delegation/generics/mapping/impl-trait-to-free.rs b/tests/ui/delegation/generics/mapping/impl-trait-to-free.rs new file mode 100644 index 0000000000000..2a7add215dedb --- /dev/null +++ b/tests/ui/delegation/generics/mapping/impl-trait-to-free.rs @@ -0,0 +1,266 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] +#![allow(late_bound_lifetime_arguments)] + +//! This is one of the mapping tests, which tests mapping of delegee parent and child +//! generic params, whose main goal is to create cases with +//! different number of lifetimes/types/consts in delegee child and parent; and in +//! delegation parent if applicable. At some tests predicates are +//! added. At some tests user-specified args are specified in reuse statement. + +// Testing lifetimes + types/consts in child reuses, +// with (un)specified user args with additional generic params in delegation parent +mod test_1 { + mod to_reuse { + pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} + pub fn bar<'a: 'a, 'b: 'b, A, B, const N: usize>(x: &super::XX) {} + } + + trait Trait<'a, 'b, 'c, A, B, const N: usize>: Sized { + fn foo<'x: 'x, 'y: 'y, AA, BB, const NN: usize>() {} + fn bar<'x: 'x, 'y: 'y, AA, BB, const NN: usize>(&self) {} + fn oof() {} + fn rab(&self) {} + } + + struct X<'x1, 'x2, 'x3, 'x4, X1, X2, const X3: usize>( + &'x1 X1, &'x2 X2, &'x3 X1, &'x4 [usize; X3]); + type XX = X::<'static, 'static, 'static, 'static, i32, i32, 3>; + + impl<'a, 'b, 'c, A, B, const N: usize> Trait<'a, 'b, 'c, A, B, N> for XX { + reuse to_reuse::foo; + //~^ ERROR: type annotations needed [E0284] + reuse to_reuse::bar; + //~^ ERROR: type annotations needed [E0284] + + reuse to_reuse::foo::<'a, 'c, A, String, 322> as oof; + reuse to_reuse::bar::<'a, 'c, A, B, 223> as rab; + } + + pub fn check() { + let x = X(&1, &2, &3, &[1, 2, 3]); + + > + ::foo::<'static, 'static, i8, i16, 123>(); + > + ::bar::<'static, 'static, String, i16, 123>(&x); + >::oof(); + >::rab(&x); + } +} + +// Testing types/consts in child reuses, +// with (un)specified user args, with additional generic params in delegation parent +mod test_2 { + mod to_reuse { + pub fn foo() {} + pub fn bar(x: &super::X) {} + } + + trait Trait<'a, 'b, 'c, A, B, const N: usize>: Sized { + fn foo() {} + fn bar(&self) {} + fn oof() {} + fn rab(&self) {} + } + + struct X; + impl<'a, A, B, const N: usize> Trait<'a, 'static, 'static, A, B, N> for X { + reuse to_reuse::foo; + //~^ ERROR: type annotations needed [E0284] + reuse to_reuse::bar; + //~^ ERROR: type annotations needed [E0284] + + reuse to_reuse::foo:: as oof; + reuse to_reuse::bar:: as rab; + } + + pub fn check() { + >::foo::(); + >::bar::(&X); + >::oof(); + >::rab(&X); + } +} + +// Testing none in child reuses, with unspecified user args, +// with additional generic params in delegation parent +mod test_3 { + mod to_reuse { + pub fn foo() {} + pub fn bar(x: &super::X) {} + } + + trait Trait<'a, 'b, 'c, A, B, const N: usize>: Sized { + fn foo() {} + fn bar(&self) {} + } + + struct X; + impl<'a, A, B, const N: usize> Trait<'a, 'static, 'static, A, B, N> for X { + reuse to_reuse::foo; + reuse to_reuse::bar; + } + + pub fn check() { + >::foo(); + >::bar(&X); + } +} + +// Testing lifetimes + types/consts in child reuses, +// with (un)specified user args, with additional generic params in delegation parent +mod test_4 { + mod to_reuse { + pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} + pub fn bar<'a: 'a, 'b: 'b, A, B, const N: usize>(x: &super::X) {} + } + + trait Trait: Sized { + fn foo<'x: 'x, 'y: 'y, AA, BB, const NN: usize>() {} + fn bar<'x: 'x, 'y: 'y, AA, BB, const NN: usize>(&self) {} + fn oof() {} + fn rab(&self) {} + } + + struct X; + impl<'a, 'c, A, B, const N: usize> Trait for X { + reuse to_reuse::foo; + //~^ ERROR: type annotations needed [E0284] + reuse to_reuse::bar; + //~^ ERROR: type annotations needed [E0284] + + reuse to_reuse::foo::<'a, 'c, A, String, 322> as oof; + reuse to_reuse::bar::<'a, 'c, i32, B, 223> as rab; + } + + pub fn check() { + >::foo::<'static, 'static, i8, i16, 123>(); + >::bar::<'static, 'static, X, i16, 123>(&X); + >::oof(); + >::rab(&X); + } +} + +// Testing lifetimes + types/consts in child reuses, +// with (un)specified user args, with additional generic params in delegation parent +mod test_5 { + mod to_reuse { + pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} + pub fn bar<'a: 'a, 'b: 'b, A, B, const N: usize>(x: &super::X::) {} + } + + trait Trait: Sized { + fn foo<'x: 'x, 'y: 'y, AA, BB, const NN: usize>() {} + fn bar<'x: 'x, 'y: 'y, AA, BB, const NN: usize>(&self) {} + fn oof() {} + fn rab(&self) {} + } + + struct X(A, B); + impl<'a, 'c, A, B> Trait for X { + reuse to_reuse::foo::<'a, 'c, A, B, 322> as oof; + reuse to_reuse::bar::<'a, 'c, A, B, 223> as rab; + } + + pub fn check() { + as Trait>::oof(); + as Trait>::rab(&X(1, 2)); + } +} + +// Testing types/consts in child reuses, +// with (un)specified user args, with additional generic params in delegation parent +mod test_6 { + mod to_reuse { + pub fn foo() {} + pub fn bar(x: &super::X) {} + } + + trait Trait: Sized { + fn foo() {} + fn bar(&self) {} + fn oof() {} + fn rab(&self) {} + } + + struct X; + impl<'a, 'c, A, B, const N: usize> Trait for X { + reuse to_reuse::foo; + //~^ ERROR: type annotations needed [E0284] + reuse to_reuse::bar; + //~^ ERROR: type annotations needed [E0284] + + reuse to_reuse::foo:: as oof; + reuse to_reuse::bar:: as rab; + } + + pub fn check() { + >::foo::(); + >::bar::(&X); + >::oof(); + >::rab(&X); + } +} + +// Testing none in child reuses, with unspecified user args, +// with additional generic params in delegation parent +mod test_7 { + mod to_reuse { + pub fn foo() {} + pub fn bar(x: &super::X) {} + } + + trait Trait: Sized { + fn foo() {} + fn bar(&self) {} + } + + struct X; + impl<'a, 'c, A, B, const N: usize> Trait for X { + reuse to_reuse::foo; + reuse to_reuse::bar; + } + + pub fn check() { + >::foo(); + >::bar(&X); + } +} + +// Testing none in child reuses, with unspecified user args +mod test_8 { + mod to_reuse { + pub fn foo() {} + pub fn bar(x: &super::X) {} + } + + trait Trait: Sized { + fn foo() {} + fn bar(&self) {} + } + + struct X; + impl Trait for X { + reuse to_reuse::foo; + reuse to_reuse::bar; + } + + pub fn check() { + ::foo(); + ::bar(&X); + X::foo(); + X::bar(&X); + } +} + +fn main() { + test_1::check(); + test_2::check(); + test_3::check(); + test_4::check(); + test_5::check(); + test_6::check(); + test_7::check(); + test_8::check(); +} diff --git a/tests/ui/delegation/generics/mapping/impl-trait-to-free.stderr b/tests/ui/delegation/generics/mapping/impl-trait-to-free.stderr new file mode 100644 index 0000000000000..37c45e11b7978 --- /dev/null +++ b/tests/ui/delegation/generics/mapping/impl-trait-to-free.stderr @@ -0,0 +1,131 @@ +error[E0284]: type annotations needed + --> $DIR/impl-trait-to-free.rs:31:25 + | +LL | reuse to_reuse::foo; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `test_1::to_reuse::foo` + --> $DIR/impl-trait-to-free.rs:15:42 + | +LL | pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse to_reuse::foo::; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/impl-trait-to-free.rs:33:25 + | +LL | reuse to_reuse::bar; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `bar` + | +note: required by a const generic parameter in `test_1::to_reuse::bar` + --> $DIR/impl-trait-to-free.rs:16:42 + | +LL | pub fn bar<'a: 'a, 'b: 'b, A, B, const N: usize>(x: &super::XX) {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `bar` +help: consider specifying the generic arguments + | +LL | reuse to_reuse::bar::; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/impl-trait-to-free.rs:69:25 + | +LL | reuse to_reuse::foo; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `test_2::to_reuse::foo` + --> $DIR/impl-trait-to-free.rs:56:26 + | +LL | pub fn foo() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse to_reuse::foo::; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/impl-trait-to-free.rs:71:25 + | +LL | reuse to_reuse::bar; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `bar` + | +note: required by a const generic parameter in `test_2::to_reuse::bar` + --> $DIR/impl-trait-to-free.rs:57:26 + | +LL | pub fn bar(x: &super::X) {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `bar` +help: consider specifying the generic arguments + | +LL | reuse to_reuse::bar::; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/impl-trait-to-free.rs:128:25 + | +LL | reuse to_reuse::foo; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `test_4::to_reuse::foo` + --> $DIR/impl-trait-to-free.rs:115:42 + | +LL | pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse to_reuse::foo::; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/impl-trait-to-free.rs:130:25 + | +LL | reuse to_reuse::bar; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `bar` + | +note: required by a const generic parameter in `test_4::to_reuse::bar` + --> $DIR/impl-trait-to-free.rs:116:42 + | +LL | pub fn bar<'a: 'a, 'b: 'b, A, B, const N: usize>(x: &super::X) {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `bar` +help: consider specifying the generic arguments + | +LL | reuse to_reuse::bar::; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/impl-trait-to-free.rs:189:25 + | +LL | reuse to_reuse::foo; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `test_6::to_reuse::foo` + --> $DIR/impl-trait-to-free.rs:176:26 + | +LL | pub fn foo() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse to_reuse::foo::; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/impl-trait-to-free.rs:191:25 + | +LL | reuse to_reuse::bar; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `bar` + | +note: required by a const generic parameter in `test_6::to_reuse::bar` + --> $DIR/impl-trait-to-free.rs:177:26 + | +LL | pub fn bar(x: &super::X) {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `bar` +help: consider specifying the generic arguments + | +LL | reuse to_reuse::bar::; + | +++++++++++ + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/delegation/generics/mapping/impl-trait-to-trait.rs b/tests/ui/delegation/generics/mapping/impl-trait-to-trait.rs new file mode 100644 index 0000000000000..1bbedf9cb2222 --- /dev/null +++ b/tests/ui/delegation/generics/mapping/impl-trait-to-trait.rs @@ -0,0 +1,241 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] +#![allow(late_bound_lifetime_arguments)] + +//! This is one of the mapping tests, which tests mapping of delegee parent and child +//! generic params, whose main goal is to create cases with +//! different number of lifetimes/types/consts in delegee child and parent; and in +//! delegation parent if applicable. At some tests predicates are +//! added. At some tests user-specified args are specified in reuse statement. + +// Testing types in parent, types in child reuse, +// testing predicates inheritance, +// with additional generic params in delegation parent +mod test_1 { + trait Trait0 {} + + trait Trait1 { + fn foo(&self) + where + T: Trait0, + U: Trait0, + { + } + } + + struct F; + impl Trait1 for F {} + + struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); + + impl<'a, 'b, 'c, T, A, B> Trait1 for S<'a, 'b, 'c, A, B> { + reuse Trait1::::foo { &self.0 } + //~^ ERROR: type annotations needed [E0283] + } + + impl Trait0 for u16 {} + + pub fn check() { + let s = S(F, &123, &123, &123); + as Trait1>::foo::(&s); + } +} + +// Testing none in parent, none in child reuse, +// with additional generic params in delegation parent +mod test_2 { + trait Trait { + fn foo(&self) {} + } + + struct F; + impl Trait for F {} + + struct S<'a, 'b, 'c, A, B, const C: bool>(F, &'a A, &'b B, &'c B); + + impl<'a, 'b, 'c, A, B, const C: bool> Trait for S<'a, 'b, 'c, A, B, C> { + reuse Trait::foo { &self.0 } + } + + pub fn check() { + let s = S(F, &123, &123, &123); + as Trait>::foo(&s); + } +} + +// Testing lifetimes + types in parent, none in child reuse, +// with additional generic params in delegation parent +mod test_3 { + trait Trait<'a, 'b, 'c, X, Y, Z> { + fn foo(&self) {} + } + + struct F; + impl<'a, 'b, 'c, X, Y, Z> Trait<'a, 'b, 'c, X, Y, Z> for F {} + + struct S<'a, 'b, 'c, A, B, const C: bool>(F, &'a A, &'b B, &'c B); + + impl<'a, 'b, 'c, A, B, const C: bool> Trait<'a, 'b, 'static, A, String, bool> + for S<'a, 'b, 'c, A, B, C> { + reuse Trait::<'a, 'b, 'static, A, String, bool>::foo { &self.0 } + } + + pub fn check() { + let s = S(F, &123, &123, &123); + + as Trait<'static, 'static, 'static, i32, String, bool>>::foo(&s); + } +} + +// Testing lifetimes + types in parent, lifetimes + types/consts in child reuse, +// with additional generic params in delegation parent +mod test_4 { + trait Trait<'a, 'b, 'c, X, Y, Z> { + fn foo<'x: 'x, 'y: 'y, 'z: 'z, A, B, C, const XX: usize>(&self) {} + } + + struct F; + impl<'a, 'b, 'c, X, Y, Z> Trait<'a, 'b, 'c, X, Y, Z> for F {} + + struct S<'a, 'b, 'c, A, B, const C: bool>(F, &'a A, &'b B, &'c B); + + impl<'a, 'b, 'c, A, B, const C: bool> Trait<'a, 'b, 'static, A, String, bool> + for S<'a, 'b, 'c, A, B, C> { + reuse Trait::<'a, 'b, 'static, A, String, bool>::foo { &self.0 } + //~^ ERROR: type annotations needed [E0284] + } + + pub fn check() { + let s = S(F, &123, &123, &123); + + as Trait<'static, 'static, 'static, i32, String, bool>> + ::foo::<'static, 'static, 'static, i32, i32, i32, 1>(&s); + } +} + +// Testing types in parent, lifetimes in child reuse +// with additional generic params in delegation parent +mod test_5 { + trait Trait { + fn foo<'a: 'a, 'b: 'b, 'c: 'c>(&self) {} + } + + struct F; + impl Trait for F {} + + struct S<'a, 'b, 'c, A, B, const C: bool>(F, &'a A, &'b B, &'c B); + + impl<'a, 'b, 'c, A, B, const C: bool> Trait for S<'a, 'b, 'c, A, B, C> { + reuse Trait::::foo { &self.0 } + } + + pub fn check() { + let s = S(F, &123, &123, &123); + as Trait> + ::foo::<'static, 'static, 'static>(&s); + as Trait>::foo(&s); + } +} + +// Testing types in parent, types in child reuse +// with additional generic params in delegation parent +mod test_6 { + trait Trait { + fn foo(&self) {} + } + + struct F; + impl Trait for F {} + + struct S<'a, 'b, 'c, A, B, const C: bool>(F, &'a A, &'b B, &'c B); + + impl<'a, 'b, 'c, A, B, const C: bool> Trait for S<'a, 'b, 'c, A, B, C> { + reuse Trait::::foo { &self.0 } + //~^ ERROR: type annotations needed [E0282] + } + + pub fn check() { + let s = S(F, &123, &123, &123); + as Trait>::foo::(&s); + } +} + +// Testing types in parent, none in child reuse +// with additional generic params in delegation parent +mod test_7 { + trait Trait { + fn foo(&self) {} + } + + struct F; + impl Trait for F {} + + struct S<'a, 'b, 'c, A, B, const C: bool>(F, &'a A, &'b B, &'c B); + + impl<'a, 'b, 'c, A, B, const C: bool> Trait for S<'a, 'b, 'c, A, B, C> { + reuse Trait::::foo { &self.0 } + } + + pub fn check() { + let s = S(F, &123, &123, &123); + as Trait>::foo(&s); + } +} + +// Testing lifetimes in parent, none in child reuse +// with additional generic params in delegation parent +mod test_8 { + trait Trait<'a, 'b, 'c> { + fn foo(&self) {} + } + + struct F; + impl<'a, 'b, 'c> Trait<'a, 'b, 'c> for F {} + + struct S<'a, 'b, 'c, A, B, const C: bool>(F, &'a A, &'b B, &'c B); + + impl<'a, 'b, 'c, A, B, const C: bool> Trait<'a, 'b, 'c> for S<'a, 'b, 'c, A, B, C> { + reuse Trait::<'a, 'static, 'b>::foo { &self.0 } + } + + pub fn check() { + let s = S(F, &123, &123, &123); + as Trait<'static, 'static, 'static>>::foo(&s); + } +} + +// Testing lifetimes in parent, lifetimes in child reuse +// with additional generic params in delegation parent +mod test_9 { + trait Trait<'a, 'b, 'c> { + fn foo<'x: 'x, 'y: 'y>(&self) {} + } + + struct F; + impl<'a, 'b, 'c> Trait<'a, 'b, 'c> for F {} + + struct S<'a, 'b, 'c, A, B, const C: bool>(F, &'a A, &'b B, &'c B); + + impl<'a, 'b, 'c, A, B, const C: bool> Trait<'a, 'b, 'c> for S<'a, 'b, 'c, A, B, C> { + reuse Trait::<'a, 'static, 'b>::foo { &self.0 } + } + + pub fn check() { + let s = S(F, &123, &123, &123); + as Trait<'static, 'static, 'static>>::foo(&s); + as Trait<'static, 'static, 'static>> + ::foo::<'static, 'static>(&s); + } +} + +fn main() { + test_1::check(); + test_2::check(); + test_3::check(); + test_4::check(); + test_5::check(); + test_6::check(); + test_7::check(); + test_8::check(); + test_9::check(); +} diff --git a/tests/ui/delegation/generics/mapping/impl-trait-to-trait.stderr b/tests/ui/delegation/generics/mapping/impl-trait-to-trait.stderr new file mode 100644 index 0000000000000..8e7118b1bd273 --- /dev/null +++ b/tests/ui/delegation/generics/mapping/impl-trait-to-trait.stderr @@ -0,0 +1,43 @@ +error[E0283]: type annotations needed + --> $DIR/impl-trait-to-trait.rs:32:28 + | +LL | reuse Trait1::::foo { &self.0 } + | ^^^ cannot infer type of the type parameter `U` declared on the method `foo` + | + = note: cannot satisfy `_: Trait0` +help: the trait `Trait0` is implemented for `u16` + --> $DIR/impl-trait-to-trait.rs:36:5 + | +LL | impl Trait0 for u16 {} + | ^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `Trait1::foo` + --> $DIR/impl-trait-to-trait.rs:21:16 + | +LL | fn foo(&self) + | --- required by a bound in this associated function +... +LL | U: Trait0, + | ^^^^^^ required by this bound in `Trait1::foo` + +error[E0284]: type annotations needed + --> $DIR/impl-trait-to-trait.rs:104:58 + | +LL | reuse Trait::<'a, 'b, 'static, A, String, bool>::foo { &self.0 } + | ^^^ cannot infer the value of the const parameter `XX` declared on the method `foo` + | +note: required by a const generic parameter in `test_4::Trait::foo` + --> $DIR/impl-trait-to-trait.rs:94:49 + | +LL | fn foo<'x: 'x, 'y: 'y, 'z: 'z, A, B, C, const XX: usize>(&self) {} + | ^^^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0282]: type annotations needed + --> $DIR/impl-trait-to-trait.rs:153:41 + | +LL | reuse Trait::::foo { &self.0 } + | ^^^ cannot infer type of the type parameter `A` declared on the method `foo` + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0282, E0283, E0284. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/delegation/generics/mapping/inherent-impl-to-free.rs b/tests/ui/delegation/generics/mapping/inherent-impl-to-free.rs new file mode 100644 index 0000000000000..f55bab484f132 --- /dev/null +++ b/tests/ui/delegation/generics/mapping/inherent-impl-to-free.rs @@ -0,0 +1,130 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] +#![allow(late_bound_lifetime_arguments)] + +//! This is one of the mapping tests, which tests mapping of delegee parent and child +//! generic params, whose main goal is to create cases with +//! different number of lifetimes/types/consts in delegee child and parent; and in +//! delegation parent if applicable. At some tests predicates are +//! added. At some tests user-specified args are specified in reuse statement. + +// Testing lifetimes + types/consts OR types/consts OR none in delegation parent, +// lifetimes + types/consts in child reuse, +// with(out) user-specified args +mod test_1 { + mod to_reuse { + pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} + } + + struct X1<'a, 'b, T, X, const N: usize>(&'a T, &'b X, &'a [i32; N]); + impl<'a, 'b, T, E, const N: usize> X1<'a, 'b, T, E, N> { + reuse to_reuse::foo; + //~^ ERROR: type annotations needed [E0284] + reuse to_reuse::foo::<'static, 'static, i32, String, 1> as bar; + } + + struct X2(T, X, &'static [i32; N]); + impl X2 { + reuse to_reuse::foo; + //~^ ERROR: type annotations needed [E0284] + reuse to_reuse::foo::<'static, 'static, i32, String, 1> as bar; + } + + struct X3; + impl X3 { + reuse to_reuse::foo; + //~^ ERROR: type annotations needed [E0284] + reuse to_reuse::foo::<'static, 'static, i32, String, 1> as bar; + } + + pub fn check() { + X1::<'static, 'static, i32, i32, 1> + ::foo::<'static, 'static, String, String, 123>(); + X1::<'static, 'static, i32, i32, 1>::bar(); + //~^ ERROR: type annotations needed [E0284] + + X2::::foo::<'static, 'static, String, String, 123>(); + X2::::bar(); + //~^ ERROR: type annotations needed [E0284] + + X3::foo::<'static, 'static, String, String, 123>(); + X3::bar(); + //~^ ERROR: type annotations needed [E0284] + } +} + +// Testing lifetimes + types/consts OR types/consts OR none in parent, +// types/consts in child reuse, with(out) user-specified args +mod test_2 { + fn foo() {} + + struct X1<'a, 'b, T, X, const N: usize>(&'a T, &'b X, &'a [i32; N]); + impl<'a, 'b, T, E, const N: usize> X1<'a, 'b, T, E, N> { + reuse foo; + //~^ ERROR: type annotations needed [E0284] + reuse foo:: as bar; + } + + struct X2(T, X, &'static [i32; N]); + impl X2 { + reuse foo; + //~^ ERROR: type annotations needed [E0284] + reuse foo:: as bar; + } + + struct X3; + impl X3 { + reuse foo; + //~^ ERROR: type annotations needed [E0284] + reuse foo:: as bar; + } + + pub fn check() { + X1::<'static, 'static, i32, i32, 1>::foo::(); + X1::<'static, 'static, i32, i32, 1>::bar(); + //~^ ERROR: type annotations needed [E0284] + + X2::::foo::(); + X2::::bar(); + //~^ ERROR: type annotations needed [E0284] + + X3::foo::(); + X3::bar(); + //~^ ERROR: type annotations needed [E0284] + } +} + +// Testing lifetimes + types/consts OR types/consts OR none in parent, +// none in child reuse +mod test_3 { + fn foo() {} + + struct X1<'a, 'b, T, X, const N: usize>(&'a T, &'b X, &'a [i32; N]); + impl<'a, 'b, T, E, const N: usize> X1<'a, 'b, T, E, N> { + reuse foo; + } + + struct X2(T, X, &'static [i32; N]); + impl X2 { + reuse foo; + } + + struct X3; + impl X3 { + reuse foo; + } + + pub fn check() { + X1::<'static, 'static, i32, i32, 1>::foo(); + + X2::::foo(); + + X3::foo(); + } +} + +fn main() { + test_1::check(); + test_2::check(); + test_3::check(); +} diff --git a/tests/ui/delegation/generics/mapping/inherent-impl-to-free.stderr b/tests/ui/delegation/generics/mapping/inherent-impl-to-free.stderr new file mode 100644 index 0000000000000..a8ccc88263eb3 --- /dev/null +++ b/tests/ui/delegation/generics/mapping/inherent-impl-to-free.stderr @@ -0,0 +1,213 @@ +error[E0284]: type annotations needed + --> $DIR/inherent-impl-to-free.rs:21:25 + | +LL | reuse to_reuse::foo; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `to_reuse::foo` + --> $DIR/inherent-impl-to-free.rs:16:42 + | +LL | pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse to_reuse::foo::; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/inherent-impl-to-free.rs:28:25 + | +LL | reuse to_reuse::foo; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `to_reuse::foo` + --> $DIR/inherent-impl-to-free.rs:16:42 + | +LL | pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse to_reuse::foo::; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/inherent-impl-to-free.rs:35:25 + | +LL | reuse to_reuse::foo; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `to_reuse::foo` + --> $DIR/inherent-impl-to-free.rs:16:42 + | +LL | pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse to_reuse::foo::; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/inherent-impl-to-free.rs:43:9 + | +LL | X1::<'static, 'static, i32, i32, 1>::bar(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` + | +note: required by a const generic parameter in `test_1::X1::<'a, 'b, T, E, N>::bar` + --> $DIR/inherent-impl-to-free.rs:16:42 + | +LL | pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `X1::<'a, 'b, T, E, N>::bar` +... +LL | reuse to_reuse::foo::<'static, 'static, i32, String, 1> as bar; + | --- required by a bound in this associated function +help: consider specifying the generic arguments + | +LL | X1::<'static, 'static, i32, i32, 1>::bar::(); + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/inherent-impl-to-free.rs:47:9 + | +LL | X2::::bar(); + | ^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` + | +note: required by a const generic parameter in `test_1::X2::::bar` + --> $DIR/inherent-impl-to-free.rs:16:42 + | +LL | pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `X2::::bar` +... +LL | reuse to_reuse::foo::<'static, 'static, i32, String, 1> as bar; + | --- required by a bound in this associated function +help: consider specifying the generic arguments + | +LL | X2::::bar::(); + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/inherent-impl-to-free.rs:51:9 + | +LL | X3::bar(); + | ^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` + | +note: required by a const generic parameter in `test_1::X3::bar` + --> $DIR/inherent-impl-to-free.rs:16:42 + | +LL | pub fn foo<'a: 'a, 'b: 'b, A, B, const N: usize>() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `X3::bar` +... +LL | reuse to_reuse::foo::<'static, 'static, i32, String, 1> as bar; + | --- required by a bound in this associated function +help: consider specifying the generic arguments + | +LL | X3::bar::(); + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/inherent-impl-to-free.rs:63:15 + | +LL | reuse foo; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `test_2::foo` + --> $DIR/inherent-impl-to-free.rs:59:18 + | +LL | fn foo() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse foo::; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/inherent-impl-to-free.rs:70:15 + | +LL | reuse foo; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `test_2::foo` + --> $DIR/inherent-impl-to-free.rs:59:18 + | +LL | fn foo() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse foo::; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/inherent-impl-to-free.rs:77:15 + | +LL | reuse foo; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `test_2::foo` + --> $DIR/inherent-impl-to-free.rs:59:18 + | +LL | fn foo() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse foo::; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/inherent-impl-to-free.rs:84:9 + | +LL | X1::<'static, 'static, i32, i32, 1>::bar(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` + | +note: required by a const generic parameter in `test_2::X1::<'a, 'b, T, E, N>::bar` + --> $DIR/inherent-impl-to-free.rs:59:18 + | +LL | fn foo() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `X1::<'a, 'b, T, E, N>::bar` +... +LL | reuse foo:: as bar; + | --- required by a bound in this associated function +help: consider specifying the generic arguments + | +LL | X1::<'static, 'static, i32, i32, 1>::bar::(); + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/inherent-impl-to-free.rs:88:9 + | +LL | X2::::bar(); + | ^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` + | +note: required by a const generic parameter in `test_2::X2::::bar` + --> $DIR/inherent-impl-to-free.rs:59:18 + | +LL | fn foo() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `X2::::bar` +... +LL | reuse foo:: as bar; + | --- required by a bound in this associated function +help: consider specifying the generic arguments + | +LL | X2::::bar::(); + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/inherent-impl-to-free.rs:92:9 + | +LL | X3::bar(); + | ^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` + | +note: required by a const generic parameter in `test_2::X3::bar` + --> $DIR/inherent-impl-to-free.rs:59:18 + | +LL | fn foo() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `X3::bar` +... +LL | reuse foo:: as bar; + | --- required by a bound in this associated function +help: consider specifying the generic arguments + | +LL | X3::bar::(); + | +++++++++++ + +error: aborting due to 12 previous errors + +For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/delegation/generics/mapping/inherent-impl-to-trait.rs b/tests/ui/delegation/generics/mapping/inherent-impl-to-trait.rs new file mode 100644 index 0000000000000..a490ce46b9ac1 --- /dev/null +++ b/tests/ui/delegation/generics/mapping/inherent-impl-to-trait.rs @@ -0,0 +1,228 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] +#![allow(late_bound_lifetime_arguments)] + +//! This is one of the mapping tests, which tests mapping of delegee parent and child +//! generic params, whose main goal is to create cases with +//! different number of lifetimes/types/consts in delegee child and parent; and in +//! delegation parent if applicable. At some tests predicates are +//! added. At some tests user-specified args are specified in reuse statement. + +// Testing types in parent, none in child, +// user-specified args in parent, checking predicates inheritance, +// with additional generic params in delegation parent +mod test_1 { + trait Trait { + fn foo(&self) {} + } + + struct F; + impl Trait for F {} + + struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); + impl<'a, 'b, 'c, A, B> S<'a, 'b, 'c, A, B> { + reuse Trait::::foo { &self.0 } + } + + pub fn check() { + let s = S(F, &123, &123, &123); + S::<'static, 'static, 'static, i32, i32>::foo(&s); + //~^ ERROR: type annotations needed [E0283] + s.foo(); + } +} + +// Testing lifetimes + types/consts in parent, none in child, +// with additional generic params in delegation parent +mod test_2 { + trait Trait<'x, 'y, T, const B: bool> { + fn foo(&self) {} + } + + struct F; + impl<'x, 'y, T, const B: bool> Trait<'x, 'y, T, B> for F {} + + struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); + impl<'a, 'b, 'c, A, B> S<'a, 'b, 'c, A, B> { + reuse Trait::<'a, 'b, String, true>::foo { &self.0 } + } + + pub fn check() { + let s = S(F, &123, &123, &123); + S::<'static, 'static, 'static, i32, i32>::foo(&s); + //~^ ERROR: type annotations needed [E0284] + s.foo(); + //~^ ERROR: type annotations needed [E0284] + } +} + +// Testing lifetimes in parent, none in child, +// with additional generic params in delegation parent +mod test_3 { + trait Trait<'x, 'y> { + fn foo(&self) {} + } + + struct F; + impl<'x, 'y> Trait<'x, 'y> for F {} + + struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); + impl<'a, 'b, 'c, A, B> S<'a, 'b, 'c, A, B> { + reuse Trait::<'a, 'b>::foo { &self.0 } + } + + pub fn check() { + let s = S(F, &123, &123, &123); + S::<'static, 'static, 'static, i32, i32>::foo(&s); + s.foo(); + } +} + +// Testing none in parent, none in child, +// with additional generic params in delegation parent +mod test_4 { + trait Trait { + fn foo(&self) {} + } + + struct F; + impl Trait for F {} + + struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); + impl<'a, 'b, 'c, A, B> S<'a, 'b, 'c, A, B> { + reuse Trait::foo { &self.0 } + } + + pub fn check() { + let s = S(F, &123, &123, &123); + S::<'static, 'static, 'static, i32, i32>::foo(&s); + s.foo(); + } +} + +// Testing none in parent, lifetimes in child, +// with additional generic params in delegation parent +mod test_5 { + trait Trait { + fn foo<'a: 'a, 'b: 'b>(&self) {} + } + + struct F; + impl Trait for F {} + + struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); + impl<'a, 'b, 'c, A, B> S<'a, 'b, 'c, A, B> { + reuse Trait::foo::<'a, 'b> { &self.0 } + } + + pub fn check() { + let s = S(F, &123, &123, &123); + S::<'static, 'static, 'static, i32, i32>::foo(&s); + s.foo(); + } +} + +// Testing none in parent, lifetimes + types in child, +// with additional generic params in delegation parent +mod test_6 { + trait Trait { + fn foo<'a: 'a, 'b: 'b, A, B, C>(&self) {} + } + + struct F; + impl Trait for F {} + + struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); + impl<'a, 'b, 'c, A, B> S<'a, 'b, 'c, A, B> { + reuse Trait::foo::<'a, 'b, A, B, String> { &self.0 } + } + + pub fn check() { + let s = S(F, &123, &123, &123); + S::<'static, 'static, 'static, i32, i32>::foo(&s); + //~^ ERROR: type annotations needed [E0282] + s.foo(); + } +} + +// Testing lifetimes in parent, lifetimes + types in child, +// with additional generic params in delegation parent +mod test_7 { + trait Trait<'x, 'y, 'z> { + fn foo<'a: 'a, 'b: 'b, A, B, C>(&self) {} + } + + struct F; + impl<'a, 'b, 'c> Trait<'a, 'b, 'c> for F {} + + struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); + impl<'a, 'b, 'c, A, B> S<'a, 'b, 'c, A, B> { + reuse Trait::<'a, 'b, 'c>::foo::<'a, 'b, A, B, String> { &self.0 } + } + + pub fn check() { + let s = S(F, &123, &123, &123); + S::<'static, 'static, 'static, i32, i32>::foo(&s); + //~^ ERROR: type annotations needed [E0282] + s.foo(); + } +} + +// Testing lifetimes + types in parent, lifetimes + types in child, +// with additional generic params in delegation parent +mod test_8 { + trait Trait<'x, 'y, 'z, X, Y, Z> { + fn foo<'a: 'a, 'b: 'b, A, B, C>(&self) {} + } + + struct F; + impl<'a, 'b, 'c, X, Y, Z> Trait<'a, 'b, 'c, X, Y, Z> for F {} + + struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); + impl<'a, 'b, 'c, A, B> S<'a, 'b, 'c, A, B> { + reuse Trait::<'a, 'b, 'c, B, A, i32>::foo::<'a, 'b, A, B, String> { &self.0 } + } + + pub fn check() { + let s = S(F, &123, &123, &123); + S::<'static, 'static, 'static, i32, i32>::foo(&s); + //~^ ERROR: type annotations needed [E0282] + s.foo(); + } +} + +// Testing lifetimes + types in parent, lifetimes + types in child, +// with additional generic params in delegation parent, +// inside a function with generic params +mod test_9 { + trait Trait<'x, 'y, 'z, X, Y, Z> { + fn foo<'a: 'a, 'b: 'b, A, B, C>(&self) {} + } + + struct F; + impl<'a, 'b, 'c, X, Y, Z> Trait<'a, 'b, 'c, X, Y, Z> for F {} + + pub fn check() { + struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B); + impl<'a, 'b, 'c, A, B> S<'a, 'b, 'c, A, B> { + reuse Trait::<'a, 'b, 'c, B, A, i32>::foo::<'a, 'b, A, B, String> { &self.0 } + } + + let s = S(F, &123, &123, &123); + S::<'static, 'static, 'static, i32, i32>::foo(&s); + //~^ ERROR: type annotations needed [E0282] + s.foo(); + } +} + +pub fn main() { + test_1::check(); + test_2::check(); + test_3::check(); + test_4::check(); + test_5::check(); + test_6::check(); + test_7::check(); + test_8::check(); + test_9::check::(); +} diff --git a/tests/ui/delegation/generics/mapping/inherent-impl-to-trait.stderr b/tests/ui/delegation/generics/mapping/inherent-impl-to-trait.stderr new file mode 100644 index 0000000000000..4d7fe3139bc98 --- /dev/null +++ b/tests/ui/delegation/generics/mapping/inherent-impl-to-trait.stderr @@ -0,0 +1,106 @@ +error[E0283]: type annotations needed + --> $DIR/inherent-impl-to-trait.rs:29:9 + | +LL | S::<'static, 'static, 'static, i32, i32>::foo(&s); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the method `foo` + | + = note: cannot satisfy `_: ToString` +note: required by a bound in `test_1::S::<'a, 'b, 'c, A, B>::foo` + --> $DIR/inherent-impl-to-trait.rs:15:20 + | +LL | trait Trait { + | ^^^^^^^^ required by this bound in `S::<'a, 'b, 'c, A, B>::foo` +... +LL | reuse Trait::::foo { &self.0 } + | --- required by a bound in this associated function +help: consider specifying the generic argument + | +LL | S::<'static, 'static, 'static, i32, i32>::foo::(&s); + | +++++ + +error[E0284]: type annotations needed + --> $DIR/inherent-impl-to-trait.rs:52:9 + | +LL | S::<'static, 'static, 'static, i32, i32>::foo(&s); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `B` declared on the method `foo` + | +note: required by a const generic parameter in `test_2::S::<'a, 'b, 'c, A, B>::foo` + --> $DIR/inherent-impl-to-trait.rs:38:28 + | +LL | trait Trait<'x, 'y, T, const B: bool> { + | ^^^^^^^^^^^^^ required by this const generic parameter in `S::<'a, 'b, 'c, A, B>::foo` +... +LL | reuse Trait::<'a, 'b, String, true>::foo { &self.0 } + | --- required by a bound in this associated function +help: consider specifying the generic arguments + | +LL | S::<'static, 'static, 'static, i32, i32>::foo::(&s); + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/inherent-impl-to-trait.rs:54:11 + | +LL | s.foo(); + | ^^^ cannot infer the value of the const parameter `B` declared on the method `foo` + | +note: required by a const generic parameter in `test_2::S::<'a, 'b, 'c, A, B>::foo` + --> $DIR/inherent-impl-to-trait.rs:38:28 + | +LL | trait Trait<'x, 'y, T, const B: bool> { + | ^^^^^^^^^^^^^ required by this const generic parameter in `S::<'a, 'b, 'c, A, B>::foo` +... +LL | reuse Trait::<'a, 'b, String, true>::foo { &self.0 } + | --- required by a bound in this associated function +help: consider specifying the generic arguments + | +LL | s.foo::(); + | ++++++++ + +error[E0282]: type annotations needed + --> $DIR/inherent-impl-to-trait.rs:142:9 + | +LL | S::<'static, 'static, 'static, i32, i32>::foo(&s); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `A` declared on the method `foo` + | +help: consider specifying the generic arguments + | +LL | S::<'static, 'static, 'static, i32, i32>::foo::(&s); + | +++++++++++ + +error[E0282]: type annotations needed + --> $DIR/inherent-impl-to-trait.rs:165:9 + | +LL | S::<'static, 'static, 'static, i32, i32>::foo(&s); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `A` declared on the method `foo` + | +help: consider specifying the generic arguments + | +LL | S::<'static, 'static, 'static, i32, i32>::foo::(&s); + | +++++++++++ + +error[E0282]: type annotations needed + --> $DIR/inherent-impl-to-trait.rs:188:9 + | +LL | S::<'static, 'static, 'static, i32, i32>::foo(&s); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `X` declared on the method `foo` + | +help: consider specifying the generic arguments + | +LL | S::<'static, 'static, 'static, i32, i32>::foo::(&s); + | ++++++++++++++++++++ + +error[E0282]: type annotations needed + --> $DIR/inherent-impl-to-trait.rs:212:9 + | +LL | S::<'static, 'static, 'static, i32, i32>::foo(&s); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `X` declared on the method `foo` + | +help: consider specifying the generic arguments + | +LL | S::<'static, 'static, 'static, i32, i32>::foo::(&s); + | ++++++++++++++++++++ + +error: aborting due to 7 previous errors + +Some errors have detailed explanations: E0282, E0283, E0284. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/delegation/generics/mapping/trait-to-free.rs b/tests/ui/delegation/generics/mapping/trait-to-free.rs new file mode 100644 index 0000000000000..b9cf27d72cb46 --- /dev/null +++ b/tests/ui/delegation/generics/mapping/trait-to-free.rs @@ -0,0 +1,142 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] +#![allow(late_bound_lifetime_arguments)] + +//! This is one of the mapping tests, which tests mapping of delegee parent and child +//! generic params, whose main goal is to create cases with +//! different number of lifetimes/types/consts in delegee child and parent; and in +//! delegation parent if applicable. At some tests predicates are +//! added. At some tests user-specified args are specified in reuse statement. + +// Testing lifetimes + types/consts in child, lifetimes + types/consts in delegation parent, +// with(out) user-specified args +mod test_1 { + fn foo<'a: 'a, 'b: 'b, T: Clone + ToString, U: Clone, const N: usize>() {} + + trait Trait<'a, A, B, C, const N: usize> { + reuse foo; + //~^ ERROR: type annotations needed [E0284] + reuse foo::<'static, 'static, i32, String, 1> as bar; + } + + impl Trait<'static, i32, i32, i32, 1> for u32 {} + pub fn check() { + >::foo::<'static, 'static, i32, String, 1>(); + >::bar(); + //~^ ERROR: type annotations needed [E0284] + } +} + +// Testing types/consts in child, lifetimes + types/consts in delegation parent, +// with(out) user-specified args +mod test_2 { + fn foo() {} + + trait Trait<'a, A, B, C, const N: usize> { + reuse foo; + //~^ ERROR: type annotations needed [E0284] + reuse foo:: as bar; + } + + impl Trait<'static, i32, i32, i32, 1> for u32 {} + pub fn check() { + >::foo::(); + >::bar(); + //~^ ERROR: type annotations needed [E0284] + } +} + +// Testing none in child, lifetimes + types/consts in delegation parent, +// with(out) user-specified args +mod test_3 { + fn foo() {} + + trait Trait<'a, A, B, C, const N: usize> { + reuse foo; + } + + impl Trait<'static, i32, i32, i32, 1> for u32 {} + pub fn check() { + >::foo(); + } +} + +// Testing lifetimes + types/consts in child, types/consts in delegation parent, +// with(out) user-specified args +mod test_4 { + fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + + trait Trait { + reuse foo; + //~^ ERROR: type annotations needed [E0284] + reuse foo::<'static, 'static, i32, String, 1> as bar; + } + + impl Trait for u32 {} + pub fn check() { + >::foo::<'static, 'static, i32, String, 1>(); + >::bar(); + //~^ ERROR: type annotations needed [E0284] + } +} + +// Testing lifetimes + types/consts in child, none in delegation parent, +// with(out) user-specified args +mod test_5 { + fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + + trait Trait { + reuse foo; + //~^ ERROR: type annotations needed [E0284] + reuse foo::<'static, 'static, i32, String, 1> as bar; + } + + impl Trait for u32 {} + pub fn check() { + ::foo::<'static, 'static, i32, String, 1>(); + ::bar(); + //~^ ERROR: type annotations needed [E0284] + } +} + +// Testing types/consts in child, none in delegation parent, with(out) user-specified args +mod test_6 { + fn foo() {} + + trait Trait { + reuse foo; + //~^ ERROR: type annotations needed [E0284] + reuse foo:: as bar; + } + + impl Trait for u32 {} + pub fn check() { + ::foo::(); + ::bar(); + //~^ ERROR: type annotations needed [E0284] + } +} + +// Testing none in child, none in delegation parent, with(out) user-specified args +mod test_7 { + fn foo() {} + + trait Trait { + reuse foo; + } + + impl Trait for u32 {} + pub fn check() { + ::foo(); + } +} + +pub fn main() { + test_1::check(); + test_2::check(); + test_3::check(); + test_4::check(); + test_5::check(); + test_6::check(); + test_7::check(); +} diff --git a/tests/ui/delegation/generics/mapping/trait-to-free.stderr b/tests/ui/delegation/generics/mapping/trait-to-free.stderr new file mode 100644 index 0000000000000..fee638c6aa4b8 --- /dev/null +++ b/tests/ui/delegation/generics/mapping/trait-to-free.stderr @@ -0,0 +1,166 @@ +error[E0284]: type annotations needed + --> $DIR/trait-to-free.rs:17:15 + | +LL | reuse foo; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `test_1::foo` + --> $DIR/trait-to-free.rs:14:59 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone + ToString, U: Clone, const N: usize>() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse foo::; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-free.rs:25:9 + | +LL | >::bar(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` + | +note: required by a const generic parameter in `test_1::Trait::bar` + --> $DIR/trait-to-free.rs:14:59 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone + ToString, U: Clone, const N: usize>() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `Trait::bar` +... +LL | reuse foo::<'static, 'static, i32, String, 1> as bar; + | --- required by a bound in this associated function + +error[E0284]: type annotations needed + --> $DIR/trait-to-free.rs:36:15 + | +LL | reuse foo; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `test_2::foo` + --> $DIR/trait-to-free.rs:33:32 + | +LL | fn foo() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse foo::; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-free.rs:44:9 + | +LL | >::bar(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` + | +note: required by a const generic parameter in `test_2::Trait::bar` + --> $DIR/trait-to-free.rs:33:32 + | +LL | fn foo() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `Trait::bar` +... +LL | reuse foo:: as bar; + | --- required by a bound in this associated function + +error[E0284]: type annotations needed + --> $DIR/trait-to-free.rs:70:15 + | +LL | reuse foo; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `test_4::foo` + --> $DIR/trait-to-free.rs:67:48 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse foo::; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-free.rs:78:9 + | +LL | >::bar(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` + | +note: required by a const generic parameter in `test_4::Trait::bar` + --> $DIR/trait-to-free.rs:67:48 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `Trait::bar` +... +LL | reuse foo::<'static, 'static, i32, String, 1> as bar; + | --- required by a bound in this associated function + +error[E0284]: type annotations needed + --> $DIR/trait-to-free.rs:89:15 + | +LL | reuse foo; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `test_5::foo` + --> $DIR/trait-to-free.rs:86:48 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse foo::; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-free.rs:97:9 + | +LL | ::bar(); + | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` + | +note: required by a const generic parameter in `test_5::Trait::bar` + --> $DIR/trait-to-free.rs:86:48 + | +LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `Trait::bar` +... +LL | reuse foo::<'static, 'static, i32, String, 1> as bar; + | --- required by a bound in this associated function +help: consider specifying the generic arguments + | +LL | ::bar::(); + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-free.rs:107:15 + | +LL | reuse foo; + | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` + | +note: required by a const generic parameter in `test_6::foo` + --> $DIR/trait-to-free.rs:104:32 + | +LL | fn foo() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` +help: consider specifying the generic arguments + | +LL | reuse foo::; + | +++++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-free.rs:115:9 + | +LL | ::bar(); + | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the associated function `bar` + | +note: required by a const generic parameter in `test_6::Trait::bar` + --> $DIR/trait-to-free.rs:104:32 + | +LL | fn foo() {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `Trait::bar` +... +LL | reuse foo:: as bar; + | --- required by a bound in this associated function +help: consider specifying the generic arguments + | +LL | ::bar::(); + | +++++++++++ + +error: aborting due to 10 previous errors + +For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/delegation/generics/mapping/trait-to-trait.rs b/tests/ui/delegation/generics/mapping/trait-to-trait.rs new file mode 100644 index 0000000000000..ea66efd784bfa --- /dev/null +++ b/tests/ui/delegation/generics/mapping/trait-to-trait.rs @@ -0,0 +1,895 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] +#![allow(late_bound_lifetime_arguments)] + +//! This is one of the mapping tests, which tests mapping of delegee parent and child +//! generic params, whose main goal is to create cases with +//! different number of lifetimes/types/consts in delegee child and parent; and in +//! delegation parent if applicable. At some tests predicates are +//! added. At some tests user-specified args are specified in reuse statement. + +// Testing lifetimes + types in parent, +// lifetimes + types/consts in child, +// in delegation parent with: +// lifetimes + types OR none OR lifetimes OR types, +// with(out) user-specified args, with different target expr +mod test_1 { + trait Trait<'b, 'c, 'a, T>: Sized { + fn foo<'d: 'd, U, const M: bool>(&self) {} + } + + impl<'b, 'c, 'a, T> Trait<'b, 'c, 'a, T> for u8 {} + + trait Trait2<'a, 'b, 'c, X, Y, Z> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static, i32>::foo::<'static, String, false> as bar2 { + Self::get() + } + + reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static, i32>::foo::<'static, String, false> + as bar4 { self.get_self() } + + // FIXME(fn_delegation): Uncomment those tests when proper support for + // generics when method call is generated is added + + // reuse Trait::foo::<'static, String, false> as bar5 { Self::get() } + // reuse Trait::foo as bar6 { Self::get() } + // reuse Trait::foo::<'static, String, false> as bar7 { self.get_self() } + // reuse Trait::foo as bar8 { self.get_self() } + } + + trait Trait3 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static, i32>::foo::<'static, String, false> + as bar2 { Self::get() } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static, i32>::foo::<'static, String, false> + as bar4 { self.get_self() } + } + + trait Trait4<'a, 'b, 'c> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static, i32>::foo::<'static, String, false> + as bar2 { Self::get() } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static, i32>::foo::<'static, String, false> + as bar4 { self.get_self() } + } + + trait Trait5 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static, i32>::foo::<'static, String, false> + as bar2 { Self::get() } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static, i32>::foo::<'static, String, false> + as bar4 { self.get_self() } + } + + impl<'a, 'b, 'c, X, Y, Z> Trait2<'a, 'b, 'c, X, Y, Z> for u32 {} + impl Trait3 for u32 {} + impl<'a, 'b, 'c> Trait4<'a, 'b, 'c> for u32 {} + impl Trait5 for u32 {} + + pub fn check<'a: 'a>() { + > + ::bar1::<'static, String, true>(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + //~| ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + ::bar1::<'static, String, true>(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + //~| ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + >::bar1::<'static, String, true>(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + //~| ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + >::bar1::<'static, String, true>(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + //~| ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + + >::bar2(&123); + ::bar2(&123); + >::bar2(&123); + >::bar2(&123); + + > + ::bar3::<'static, String, true>(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + //~| ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + ::bar3::<'static, String, true>(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + //~| ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + >::bar3::<'static, String, true>(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + //~| ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + >::bar3::<'static, String, true>(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + //~| ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + + >::bar4(&123); + ::bar4(&123); + >::bar4(&123); + >::bar4(&123); + } +} + +// Testing types in parent, +// lifetimes + types/consts in child, +// in delegation parent with: +// lifetimes + types OR none OR lifetimes OR types, +// with(out) user-specified args, with different target expr +mod test_2 { + trait Trait: Sized { + fn foo<'d: 'd, U, const M: bool>(&self) {} + } + + impl Trait for u8 {} + + trait Trait2<'a, 'b, 'c, X, Y, Z> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::::foo::<'static, String, false> as bar2 { Self::get() } + reuse Trait::::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::::foo::<'static, String, false> as bar4 { self.get_self() } + } + + trait Trait3 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::::foo::<'static, String, false> as bar2 { Self::get() } + reuse Trait::::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::::foo::<'static, String, false> as bar4 { self.get_self() } + } + + trait Trait4<'a, 'b, 'c> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::::foo::<'static, String, false> as bar2 { Self::get() } + reuse Trait::::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::::foo::<'static, String, false> as bar4 { self.get_self() } + } + + trait Trait5 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::::foo::<'static, String, false> as bar2 { Self::get() } + reuse Trait::::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::::foo::<'static, String, false> as bar4 { self.get_self() } + } + + impl<'a, 'b, 'c, X, Y, Z> Trait2<'a, 'b, 'c, X, Y, Z> for u32 {} + impl Trait3 for u32 {} + impl<'a, 'b, 'c> Trait4<'a, 'b, 'c> for u32 {} + impl Trait5 for u32 {} + + pub fn check<'a: 'a>() { + > + ::bar1::<'static, String, true>(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + ::bar1::<'static, String, true>(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + >::bar1::<'static, String, true>(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + >::bar1::<'static, String, true>(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + + >::bar2(&123); + ::bar2(&123); + >::bar2(&123); + >::bar2(&123); + + > + ::bar3::<'static, String, true>(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + ::bar3::<'static, String, true>(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + >::bar3::<'static, String, true>(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + >::bar3::<'static, String, true>(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + + >::bar4(&123); + ::bar4(&123); + >::bar4(&123); + >::bar4(&123); + } +} + +// Testing lifetimes in parent, +// lifetimes + types/consts in child, +// in delegation parent with: +// lifetimes + types OR none OR lifetimes OR types, +// with(out) user-specified args, with different target expr +mod test_3 { + trait Trait<'b, 'c, 'a>: Sized { + fn foo<'d: 'd, U, const M: bool>(&self) {} + } + + impl<'b, 'c, 'a> Trait<'b, 'c, 'a> for u8 {} + + trait Trait2<'a, 'b, 'c, X, Y, Z> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'static, 'static, 'static>::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static>::foo::<'static, String, false> as bar2 { + Self::get() + } + reuse Trait::<'static, 'static, 'static>::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static>::foo::<'static, String, false> as bar4 { + self.get_self() + } + } + + trait Trait3 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'static, 'static, 'static>::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static>::foo::<'static, String, false> as bar2 { + Self::get() + } + reuse Trait::<'static, 'static, 'static>::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static>::foo::<'static, String, false> as bar4 { + self.get_self() + } + } + + trait Trait4<'a, 'b, 'c> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'static, 'static, 'static>::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static>::foo::<'static, String, false> as bar2 { + Self::get() + } + reuse Trait::<'static, 'static, 'static>::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static>::foo::<'static, String, false> as bar4 { + self.get_self() + } + } + + trait Trait5 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'static, 'static, 'static>::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static>::foo::<'static, String, false> + as bar2 { Self::get() } + reuse Trait::<'static, 'static, 'static>::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static>::foo::<'static, String, false> + as bar4 { self.get_self() } + } + + impl<'a, 'b, 'c, X, Y, Z> Trait2<'a, 'b, 'c, X, Y, Z> for u32 {} + impl Trait3 for u32 {} + impl<'a, 'b, 'c> Trait4<'a, 'b, 'c> for u32 {} + impl Trait5 for u32 {} + + pub fn check<'a: 'a>() { + > + ::bar1::<'static, String, true>(&123); + //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + ::bar1::<'static, String, true>(&123); + //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + >::bar1::<'static, String, true>(&123); + //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + >::bar1::<'static, String, true>(&123); + //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + + >::bar2(&123); + ::bar2(&123); + >::bar2(&123); + >::bar2(&123); + + > + ::bar3::<'static, String, true>(&123); + //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + ::bar3::<'static, String, true>(&123); + //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + >::bar3::<'static, String, true>(&123); + //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + >::bar3::<'static, String, true>(&123); + //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + + >::bar4(&123); + ::bar4(&123); + >::bar4(&123); + >::bar4(&123); + } +} + +// Testing none in parent, +// lifetimes + types/consts in child, +// in delegation parent with: +// lifetimes + types OR none OR lifetimes OR types, +// with(out) user-specified args, with different target expr +mod test_4 { + trait Trait: Sized { + fn foo<'d: 'd, U, const M: bool>(&self) {} + } + + impl Trait for u8 {} + + trait Trait2<'a, 'b, 'c, X, Y, Z> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::foo::<'static, String, false> as bar2 { Self::get() } + reuse Trait::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::foo::<'static, String, false> as bar4 { self.get_self() } + } + + trait Trait3 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::foo::<'static, String, false> as bar2 { Self::get() } + reuse Trait::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::foo::<'static, String, false> as bar4 { self.get_self() } + } + + trait Trait4<'a, 'b, 'c> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::foo::<'static, String, false> as bar2 { Self::get() } + reuse Trait::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::foo::<'static, String, false> as bar4 { self.get_self() } + } + + trait Trait5 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::foo::<'static, String, false> as bar2 { Self::get() } + reuse Trait::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::foo::<'static, String, false> as bar4 { self.get_self() } + } + + impl<'a, 'b, 'c, X, Y, Z> Trait2<'a, 'b, 'c, X, Y, Z> for u32 {} + impl Trait3 for u32 {} + impl<'a, 'b, 'c> Trait4<'a, 'b, 'c> for u32 {} + impl Trait5 for u32 {} + + pub fn check<'a: 'a>() { + > + ::bar1::<'static, String, true>(&123); + ::bar1::<'static, String, true>(&123); + >::bar1::<'static, String, true>(&123); + >::bar1::<'static, String, true>(&123); + + >::bar2(&123); + //~^ ERROR: type annotations needed [E0284] + ::bar2(&123); + //~^ ERROR: type annotations needed [E0284] + >::bar2(&123); + //~^ ERROR: type annotations needed [E0284] + >::bar2(&123); + //~^ ERROR: type annotations needed [E0284] + + > + ::bar3::<'static, String, true>(&123); + ::bar3::<'static, String, true>(&123); + >::bar3::<'static, String, true>(&123); + >::bar3::<'static, String, true>(&123); + + >::bar4(&123); + //~^ ERROR: type annotations needed [E0284] + ::bar4(&123); + //~^ ERROR: type annotations needed [E0284] + >::bar4(&123); + //~^ ERROR: type annotations needed [E0284] + >::bar4(&123); + //~^ ERROR: type annotations needed [E0284] + } +} + +// Testing lifetimes + types in parent, +// types/consts in child, +// in delegation parent with: +// lifetimes + types OR none OR lifetimes OR types, +// with(out) user-specified args, with different target expr +mod test_5 { + trait Trait<'b, 'c, 'a, T>: Sized { + fn foo(&self) {} + } + + impl<'b, 'c, 'a, T> Trait<'b, 'c, 'a, T> for u8 {} + + trait Trait2<'a, 'b, 'c, X, Y, Z> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static, i32>::foo:: as bar2 { + Self::get() + } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static, i32>::foo:: as bar4 { + self.get_self() + } + } + + trait Trait3 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static, i32>::foo:: as bar2 { + Self::get() + } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static, i32>::foo:: as bar4 { + self.get_self() + } + } + + trait Trait4<'a, 'b, 'c> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static, i32>::foo:: as bar2 { + Self::get() + } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static, i32>::foo:: as bar4 { + self.get_self() + } + } + + trait Trait5 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static, i32>::foo:: as bar2 { + Self::get() + } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + //~^ ERROR: type annotations needed [E0284] + reuse Trait::<'static, 'static, 'static, i32>::foo:: as bar4 { + self.get_self() + } + } + + impl<'a, 'b, 'c, X, Y, Z> Trait2<'a, 'b, 'c, X, Y, Z> for u32 {} + impl Trait3 for u32 {} + impl<'a, 'b, 'c> Trait4<'a, 'b, 'c> for u32 {} + impl Trait5 for u32 {} + + pub fn check<'a: 'a>() { + >::bar1::(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + ::bar1::(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + >::bar1::(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + >::bar1::(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + + >::bar2(&123); + ::bar2(&123); + >::bar2(&123); + >::bar2(&123); + + >::bar3::(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + ::bar3::(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + >::bar3::(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + >::bar3::(&123); + //~^ ERROR: method takes 3 generic arguments but 2 generic arguments were supplied [E0107] + + >::bar4(&123); + ::bar4(&123); + >::bar4(&123); + >::bar4(&123); + } +} + +// Testing lifetimes + types in parent, +// none in child, +// in delegation parent with: +// lifetimes + types OR none OR lifetimes OR types, +// with(out) user-specified args, with different target expr +mod test_6 { + trait Trait<'b, 'c, 'a, T>: Sized { + fn foo(&self) {} + } + + impl<'b, 'c, 'a, T> Trait<'b, 'c, 'a, T> for u8 {} + + trait Trait2<'a, 'b, 'c, X, Y, Z> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + } + + trait Trait3 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + } + + trait Trait4<'a, 'b, 'c> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + } + + trait Trait5 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + } + + impl<'a, 'b, 'c, X, Y, Z> Trait2<'a, 'b, 'c, X, Y, Z> for u32 {} + impl Trait3 for u32 {} + impl<'a, 'b, 'c> Trait4<'a, 'b, 'c> for u32 {} + impl Trait5 for u32 {} + + pub fn check<'a: 'a>() { + >::bar1(&123); + //~^ ERROR: type annotations needed [E0282] + ::bar1(&123); + >::bar1(&123); + >::bar1(&123); + + >::bar3(&123); + ::bar3(&123); + >::bar3(&123); + >::bar3(&123); + } +} + +// Testing types in parent, +// none in child, +// in delegation parent with: +// lifetimes + types OR none OR lifetimes OR types, +// with user-specified args, with different target expr +mod test_7 { + trait Trait: Sized { + fn foo(&self) {} + } + + impl Trait for u8 {} + + trait Trait2<'a, 'b, 'c, X, Y, Z> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::::foo as bar1 { Self::get() } + reuse Trait::::foo as bar3 { self.get_self() } + } + + trait Trait3 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::::foo as bar1 { Self::get() } + reuse Trait::::foo as bar3 { self.get_self() } + } + + trait Trait4<'a, 'b, 'c> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::::foo as bar1 { Self::get() } + reuse Trait::::foo as bar3 { self.get_self() } + } + + trait Trait5 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::::foo as bar1 { Self::get() } + reuse Trait::::foo as bar3 { self.get_self() } + } + + impl<'a, 'b, 'c, X, Y, Z> Trait2<'a, 'b, 'c, X, Y, Z> for u32 {} + impl Trait3 for u32 {} + impl<'a, 'b, 'c> Trait4<'a, 'b, 'c> for u32 {} + impl Trait5 for u32 {} + + pub fn check<'a: 'a>() { + >::bar1(&123); + //~^ ERROR: type annotations needed [E0282] + ::bar1(&123); + >::bar1(&123); + >::bar1(&123); + + >::bar3(&123); + ::bar3(&123); + >::bar3(&123); + >::bar3(&123); + } +} + +// Testing none in parent, +// none in child, +// in delegation parent with: +// lifetimes + types OR none OR lifetimes OR types, +// without user-specified args, with different target expr +mod test_8 { + trait Trait: Sized { + fn foo(&self) {} + } + + impl Trait for u8 {} + + trait Trait2<'a, 'b, 'c, X, Y, Z> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::foo as bar1 { Self::get() } + reuse Trait::foo as bar3 { self.get_self() } + } + + trait Trait3 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::foo as bar1 { Self::get() } + reuse Trait::foo as bar3 { self.get_self() } + } + + trait Trait4<'a, 'b, 'c> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::foo as bar1 { Self::get() } + reuse Trait::foo as bar3 { self.get_self() } + } + + trait Trait5 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::foo as bar1 { Self::get() } + reuse Trait::foo as bar3 { self.get_self() } + } + + impl<'a, 'b, 'c, X, Y, Z> Trait2<'a, 'b, 'c, X, Y, Z> for u32 {} + impl Trait3 for u32 {} + impl<'a, 'b, 'c> Trait4<'a, 'b, 'c> for u32 {} + impl Trait5 for u32 {} + + pub fn check<'a: 'a>() { + >::bar1(&123); + ::bar1(&123); + >::bar1(&123); + >::bar1(&123); + + >::bar3(&123); + ::bar3(&123); + >::bar3(&123); + >::bar3(&123); + } +} + +// Testing types in parent, +// lifetimes in child, +// in delegation parent with: +// lifetimes + types OR none OR lifetimes OR types, +// with(out) user-specified args, with different target expr +mod test_9 { + trait Trait: Sized { + fn foo<'a: 'a, 'b: 'b>(&self) {} + } + + impl Trait for u8 {} + + trait Trait2<'a, 'b, 'c, X, Y, Z> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::::foo as bar1 { Self::get() } + reuse Trait::::foo::<'static, 'static> as bar2 { Self::get() } + reuse Trait::::foo as bar3 { self.get_self() } + reuse Trait::::foo::<'static, 'static> as bar4 { self.get_self() } + } + + trait Trait3 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::::foo as bar1 { Self::get() } + reuse Trait::::foo::<'static, 'static> as bar2 { Self::get() } + reuse Trait::::foo as bar3 { self.get_self() } + reuse Trait::::foo::<'static, 'static> as bar4 { self.get_self() } + } + + trait Trait4<'a, 'b, 'c> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::::foo as bar1 { Self::get() } + reuse Trait::::foo::<'static, 'static> as bar2 { Self::get() } + reuse Trait::::foo as bar3 { self.get_self() } + reuse Trait::::foo::<'static, 'static> as bar4 { self.get_self() } + } + + trait Trait5 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::::foo as bar1 { Self::get() } + reuse Trait::::foo::<'static, 'static> as bar2 { Self::get() } + reuse Trait::::foo as bar3 { self.get_self() } + reuse Trait::::foo::<'static, 'static> as bar4 { self.get_self() } + } + + impl<'a, 'b, 'c, X, Y, Z> Trait2<'a, 'b, 'c, X, Y, Z> for u32 {} + impl Trait3 for u32 {} + impl<'a, 'b, 'c> Trait4<'a, 'b, 'c> for u32 {} + impl Trait5 for u32 {} + + pub fn check<'a: 'a>() { + > + //~^ ERROR: type annotations needed [E0282] + ::bar1::<'static, 'static>(&123); + ::bar1::<'static, 'static>(&123); + >::bar1::<'a, 'a>(&123); + >::bar1::<'a, 'a>(&123); + + >::bar2(&123); + ::bar2(&123); + >::bar2(&123); + >::bar2(&123); + + > + ::bar3::<'static, 'static>(&123); + ::bar3::<'static, 'static>(&123); + >::bar3::<'static, 'static>(&123); + >::bar3::<'static, 'static>(&123); + + >::bar4(&123); + ::bar4(&123); + >::bar4(&123); + >::bar4(&123); + } +} + +// Testing lifetimes in parent, +// lifetimes in child, +// in delegation parent with: +// lifetimes + types OR none OR lifetimes OR types, +// with(out) user-specified args, with different target expr +mod test_10 { + trait Trait<'x, 'y, 'z>: Sized { + fn foo<'a: 'a, 'b: 'b>(&self) {} + } + + impl<'x, 'y, 'z> Trait<'x, 'y, 'z> for u8 {} + + trait Trait2<'a, 'b, 'c, X, Y, Z> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'a, 'b, 'static>::foo as bar1 { Self::get() } + reuse Trait::<'a, 'b, 'static>::foo::<'static, 'static> as bar2 { Self::get() } + reuse Trait::<'a, 'b, 'static>::foo as bar3 { self.get_self() } + reuse Trait::<'a, 'b, 'static>::foo::<'static, 'static> as bar4 { self.get_self() } + } + + trait Trait3 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'static, 'static, 'static>::foo as bar1 { Self::get() } + reuse Trait::<'static, 'static, 'static>::foo::<'static, 'static> as bar2 { + Self::get() + } + reuse Trait::<'static, 'static, 'static>::foo as bar3 { self.get_self() } + reuse Trait::<'static, 'static, 'static>::foo::<'static, 'static> as bar4 { + self.get_self() + } + } + + trait Trait4<'a, 'b, 'c> { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'a, 'b, 'static>::foo as bar1 { Self::get() } + reuse Trait::<'a, 'b, 'static>::foo::<'static, 'static> as bar2 { Self::get() } + reuse Trait::<'a, 'b, 'static>::foo as bar3 { self.get_self() } + reuse Trait::<'a, 'b, 'static>::foo::<'static, 'static> as bar4 { self.get_self() } + } + + trait Trait5 { + fn get() -> &'static u8 { &0 } + fn get_self(&self) -> &'static u8 { &0 } + reuse Trait::<'static, 'static, 'static>::foo as bar1 { Self::get() } + reuse Trait::<'static, 'static, 'static>::foo::<'static, 'static> as bar2 { + Self::get() + } + reuse Trait::<'static, 'static, 'static>::foo as bar3 { self.get_self() } + reuse Trait::<'static, 'static, 'static>::foo::<'static, 'static> as bar4 { + self.get_self() + } + } + + impl<'a, 'b, 'c, X, Y, Z> Trait2<'a, 'b, 'c, X, Y, Z> for u32 {} + impl Trait3 for u32 {} + impl<'a, 'b, 'c> Trait4<'a, 'b, 'c> for u32 {} + impl Trait5 for u32 {} + + pub fn check<'a: 'a>() { + > + ::bar1::<'static, 'static>(&123); + //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + ::bar1::<'static, 'static>(&123); + //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + >::bar1::<'a, 'a>(&123); + //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + >::bar1::<'a, 'a>(&123); + //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + + >::bar2(&123); + ::bar2(&123); + >::bar2(&123); + >::bar2(&123); + + > + ::bar3::<'static, 'static>(&123); + //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + ::bar3::<'static, 'static>(&123); + //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + >::bar3::<'static, 'static>(&123); + //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + >::bar3::<'static, 'static>(&123); + //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + + >::bar4(&123); + ::bar4(&123); + >::bar4(&123); + >::bar4(&123); + } +} + +pub fn main() { + test_1::check(); + test_2::check(); + test_3::check(); + test_4::check(); + test_5::check(); + test_6::check(); + test_7::check(); + test_8::check(); + test_9::check(); + test_10::check(); +} diff --git a/tests/ui/delegation/generics/mapping/trait-to-trait.stderr b/tests/ui/delegation/generics/mapping/trait-to-trait.stderr new file mode 100644 index 0000000000000..712fcc1670e5b --- /dev/null +++ b/tests/ui/delegation/generics/mapping/trait-to-trait.stderr @@ -0,0 +1,1544 @@ +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:26:56 + | +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_1::Trait::foo` + --> $DIR/trait-to-trait.rs:18:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:32:56 + | +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_1::Trait::foo` + --> $DIR/trait-to-trait.rs:18:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:49:56 + | +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_1::Trait::foo` + --> $DIR/trait-to-trait.rs:18:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:53:56 + | +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_1::Trait::foo` + --> $DIR/trait-to-trait.rs:18:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:62:56 + | +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_1::Trait::foo` + --> $DIR/trait-to-trait.rs:18:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:66:56 + | +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_1::Trait::foo` + --> $DIR/trait-to-trait.rs:18:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:75:56 + | +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_1::Trait::foo` + --> $DIR/trait-to-trait.rs:18:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:79:56 + | +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_1::Trait::foo` + --> $DIR/trait-to-trait.rs:18:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:92:22 + | +LL | ::bar1::<'static, String, true>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:18:42 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:92:15 + | +LL | ::bar1::<'static, String, true>(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:26:63 + | +LL | trait Trait<'b, 'c, 'a, T>: Sized { + | - +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | - ------------- +... +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + | ^^^^ +help: add missing generic argument + | +LL | ::bar1::<'static, String, true, M>(&123); + | +++ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:95:33 + | +LL | ::bar1::<'static, String, true>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:18:42 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:95:26 + | +LL | ::bar1::<'static, String, true>(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:49:63 + | +LL | trait Trait<'b, 'c, 'a, T>: Sized { + | - +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | - ------------- +... +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + | ^^^^ +help: add missing generic argument + | +LL | ::bar1::<'static, String, true, M>(&123); + | +++ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:98:50 + | +LL | >::bar1::<'static, String, true>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:18:42 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:98:43 + | +LL | >::bar1::<'static, String, true>(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:62:63 + | +LL | trait Trait<'b, 'c, 'a, T>: Sized { + | - +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | - ------------- +... +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + | ^^^^ +help: add missing generic argument + | +LL | >::bar1::<'static, String, true, M>(&123); + | +++ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:101:51 + | +LL | >::bar1::<'static, String, true>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:18:42 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:101:44 + | +LL | >::bar1::<'static, String, true>(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:75:63 + | +LL | trait Trait<'b, 'c, 'a, T>: Sized { + | - +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | - ------------- +... +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + | ^^^^ +help: add missing generic argument + | +LL | >::bar1::<'static, String, true, M>(&123); + | +++ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:111:22 + | +LL | ::bar3::<'static, String, true>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:18:42 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:111:15 + | +LL | ::bar3::<'static, String, true>(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:32:63 + | +LL | trait Trait<'b, 'c, 'a, T>: Sized { + | - +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | - ------------- +... +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + | ^^^^ +help: add missing generic argument + | +LL | ::bar3::<'static, String, true, M>(&123); + | +++ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:114:33 + | +LL | ::bar3::<'static, String, true>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:18:42 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:114:26 + | +LL | ::bar3::<'static, String, true>(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:53:63 + | +LL | trait Trait<'b, 'c, 'a, T>: Sized { + | - +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | - ------------- +... +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + | ^^^^ +help: add missing generic argument + | +LL | ::bar3::<'static, String, true, M>(&123); + | +++ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:117:50 + | +LL | >::bar3::<'static, String, true>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:18:42 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:117:43 + | +LL | >::bar3::<'static, String, true>(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:66:63 + | +LL | trait Trait<'b, 'c, 'a, T>: Sized { + | - +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | - ------------- +... +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + | ^^^^ +help: add missing generic argument + | +LL | >::bar3::<'static, String, true, M>(&123); + | +++ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:120:51 + | +LL | >::bar3::<'static, String, true>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:18:42 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:120:44 + | +LL | >::bar3::<'static, String, true>(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:79:63 + | +LL | trait Trait<'b, 'c, 'a, T>: Sized { + | - +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | - ------------- +... +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + | ^^^^ +help: add missing generic argument + | +LL | >::bar3::<'static, String, true, M>(&123); + | +++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:146:29 + | +LL | reuse Trait::::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_2::Trait::foo` + --> $DIR/trait-to-trait.rs:138:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:149:29 + | +LL | reuse Trait::::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_2::Trait::foo` + --> $DIR/trait-to-trait.rs:138:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:157:29 + | +LL | reuse Trait::::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_2::Trait::foo` + --> $DIR/trait-to-trait.rs:138:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:160:29 + | +LL | reuse Trait::::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_2::Trait::foo` + --> $DIR/trait-to-trait.rs:138:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:168:29 + | +LL | reuse Trait::::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_2::Trait::foo` + --> $DIR/trait-to-trait.rs:138:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:171:29 + | +LL | reuse Trait::::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_2::Trait::foo` + --> $DIR/trait-to-trait.rs:138:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:179:29 + | +LL | reuse Trait::::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_2::Trait::foo` + --> $DIR/trait-to-trait.rs:138:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:182:29 + | +LL | reuse Trait::::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_2::Trait::foo` + --> $DIR/trait-to-trait.rs:138:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:194:15 + | +LL | ::bar1::<'static, String, true>(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:146:36 + | +LL | trait Trait: Sized { + | - +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | - ------------- +... +LL | reuse Trait::::foo as bar1 { Self::get() } + | ^^^^ +help: add missing generic argument + | +LL | ::bar1::<'static, String, true, M>(&123); + | +++ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:196:26 + | +LL | ::bar1::<'static, String, true>(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:157:36 + | +LL | trait Trait: Sized { + | - +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | - ------------- +... +LL | reuse Trait::::foo as bar1 { Self::get() } + | ^^^^ +help: add missing generic argument + | +LL | ::bar1::<'static, String, true, M>(&123); + | +++ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:198:43 + | +LL | >::bar1::<'static, String, true>(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:168:36 + | +LL | trait Trait: Sized { + | - +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | - ------------- +... +LL | reuse Trait::::foo as bar1 { Self::get() } + | ^^^^ +help: add missing generic argument + | +LL | >::bar1::<'static, String, true, M>(&123); + | +++ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:200:44 + | +LL | >::bar1::<'static, String, true>(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:179:36 + | +LL | trait Trait: Sized { + | - +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | - ------------- +... +LL | reuse Trait::::foo as bar1 { Self::get() } + | ^^^^ +help: add missing generic argument + | +LL | >::bar1::<'static, String, true, M>(&123); + | +++ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:209:15 + | +LL | ::bar3::<'static, String, true>(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:149:36 + | +LL | trait Trait: Sized { + | - +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | - ------------- +... +LL | reuse Trait::::foo as bar3 { self.get_self() } + | ^^^^ +help: add missing generic argument + | +LL | ::bar3::<'static, String, true, M>(&123); + | +++ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:211:26 + | +LL | ::bar3::<'static, String, true>(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:160:36 + | +LL | trait Trait: Sized { + | - +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | - ------------- +... +LL | reuse Trait::::foo as bar3 { self.get_self() } + | ^^^^ +help: add missing generic argument + | +LL | ::bar3::<'static, String, true, M>(&123); + | +++ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:213:43 + | +LL | >::bar3::<'static, String, true>(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:171:36 + | +LL | trait Trait: Sized { + | - +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | - ------------- +... +LL | reuse Trait::::foo as bar3 { self.get_self() } + | ^^^^ +help: add missing generic argument + | +LL | >::bar3::<'static, String, true, M>(&123); + | +++ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:215:44 + | +LL | >::bar3::<'static, String, true>(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:182:36 + | +LL | trait Trait: Sized { + | - +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | - ------------- +... +LL | reuse Trait::::foo as bar3 { self.get_self() } + | ^^^^ +help: add missing generic argument + | +LL | >::bar3::<'static, String, true, M>(&123); + | +++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:240:51 + | +LL | reuse Trait::<'static, 'static, 'static>::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_3::Trait::foo` + --> $DIR/trait-to-trait.rs:232:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` +help: consider specifying the generic arguments + | +LL | reuse Trait::<'static, 'static, 'static>::foo:: as bar1 { Self::get() } + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:245:51 + | +LL | reuse Trait::<'static, 'static, 'static>::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_3::Trait::foo` + --> $DIR/trait-to-trait.rs:232:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` +help: consider specifying the generic arguments + | +LL | reuse Trait::<'static, 'static, 'static>::foo:: as bar3 { self.get_self() } + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:255:51 + | +LL | reuse Trait::<'static, 'static, 'static>::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_3::Trait::foo` + --> $DIR/trait-to-trait.rs:232:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` +help: consider specifying the generic arguments + | +LL | reuse Trait::<'static, 'static, 'static>::foo:: as bar1 { Self::get() } + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:260:51 + | +LL | reuse Trait::<'static, 'static, 'static>::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_3::Trait::foo` + --> $DIR/trait-to-trait.rs:232:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` +help: consider specifying the generic arguments + | +LL | reuse Trait::<'static, 'static, 'static>::foo:: as bar3 { self.get_self() } + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:270:51 + | +LL | reuse Trait::<'static, 'static, 'static>::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_3::Trait::foo` + --> $DIR/trait-to-trait.rs:232:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` +help: consider specifying the generic arguments + | +LL | reuse Trait::<'static, 'static, 'static>::foo:: as bar1 { Self::get() } + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:275:51 + | +LL | reuse Trait::<'static, 'static, 'static>::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_3::Trait::foo` + --> $DIR/trait-to-trait.rs:232:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` +help: consider specifying the generic arguments + | +LL | reuse Trait::<'static, 'static, 'static>::foo:: as bar3 { self.get_self() } + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:285:51 + | +LL | reuse Trait::<'static, 'static, 'static>::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_3::Trait::foo` + --> $DIR/trait-to-trait.rs:232:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` +help: consider specifying the generic arguments + | +LL | reuse Trait::<'static, 'static, 'static>::foo:: as bar1 { Self::get() } + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:289:51 + | +LL | reuse Trait::<'static, 'static, 'static>::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_3::Trait::foo` + --> $DIR/trait-to-trait.rs:232:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` +help: consider specifying the generic arguments + | +LL | reuse Trait::<'static, 'static, 'static>::foo:: as bar3 { self.get_self() } + | ++++++++ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:302:22 + | +LL | ::bar1::<'static, String, true>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:232:42 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:304:33 + | +LL | ::bar1::<'static, String, true>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:232:42 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:306:50 + | +LL | >::bar1::<'static, String, true>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:232:42 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:308:51 + | +LL | >::bar1::<'static, String, true>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:232:42 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:317:22 + | +LL | ::bar3::<'static, String, true>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:232:42 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:319:33 + | +LL | ::bar3::<'static, String, true>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:232:42 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:321:50 + | +LL | >::bar3::<'static, String, true>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:232:42 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:323:51 + | +LL | >::bar3::<'static, String, true>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:232:42 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:348:22 + | +LL | reuse Trait::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_4::Trait::foo` + --> $DIR/trait-to-trait.rs:340:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` +help: consider specifying the generic arguments + | +LL | reuse Trait::foo:: as bar1 { Self::get() } + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:351:22 + | +LL | reuse Trait::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_4::Trait::foo` + --> $DIR/trait-to-trait.rs:340:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` +help: consider specifying the generic arguments + | +LL | reuse Trait::foo:: as bar3 { self.get_self() } + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:359:22 + | +LL | reuse Trait::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_4::Trait::foo` + --> $DIR/trait-to-trait.rs:340:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` +help: consider specifying the generic arguments + | +LL | reuse Trait::foo:: as bar1 { Self::get() } + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:362:22 + | +LL | reuse Trait::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_4::Trait::foo` + --> $DIR/trait-to-trait.rs:340:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` +help: consider specifying the generic arguments + | +LL | reuse Trait::foo:: as bar3 { self.get_self() } + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:370:22 + | +LL | reuse Trait::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_4::Trait::foo` + --> $DIR/trait-to-trait.rs:340:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` +help: consider specifying the generic arguments + | +LL | reuse Trait::foo:: as bar1 { Self::get() } + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:373:22 + | +LL | reuse Trait::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_4::Trait::foo` + --> $DIR/trait-to-trait.rs:340:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` +help: consider specifying the generic arguments + | +LL | reuse Trait::foo:: as bar3 { self.get_self() } + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:381:22 + | +LL | reuse Trait::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_4::Trait::foo` + --> $DIR/trait-to-trait.rs:340:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` +help: consider specifying the generic arguments + | +LL | reuse Trait::foo:: as bar1 { Self::get() } + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:384:22 + | +LL | reuse Trait::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_4::Trait::foo` + --> $DIR/trait-to-trait.rs:340:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` +help: consider specifying the generic arguments + | +LL | reuse Trait::foo:: as bar3 { self.get_self() } + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:401:9 + | +LL | >::bar2(&123); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `M` declared on the method `bar2` + | +note: required by a const generic parameter in `test_4::Trait2::bar2` + --> $DIR/trait-to-trait.rs:340:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait2::bar2` +... +LL | reuse Trait::foo::<'static, String, false> as bar2 { Self::get() } + | ---- required by a bound in this associated function + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:403:9 + | +LL | ::bar2(&123); + | ^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `M` declared on the method `bar2` + | +note: required by a const generic parameter in `test_4::Trait3::bar2` + --> $DIR/trait-to-trait.rs:340:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait3::bar2` +... +LL | reuse Trait::foo::<'static, String, false> as bar2 { Self::get() } + | ---- required by a bound in this associated function +help: consider specifying the generic arguments + | +LL | ::bar2::(&123); + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:405:9 + | +LL | >::bar2(&123); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `M` declared on the method `bar2` + | +note: required by a const generic parameter in `test_4::Trait4::bar2` + --> $DIR/trait-to-trait.rs:340:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait4::bar2` +... +LL | reuse Trait::foo::<'static, String, false> as bar2 { Self::get() } + | ---- required by a bound in this associated function +help: consider specifying the generic arguments + | +LL | >::bar2::(&123); + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:407:9 + | +LL | >::bar2(&123); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `M` declared on the method `bar2` + | +note: required by a const generic parameter in `test_4::Trait5::bar2` + --> $DIR/trait-to-trait.rs:340:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait5::bar2` +... +LL | reuse Trait::foo::<'static, String, false> as bar2 { Self::get() } + | ---- required by a bound in this associated function + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:416:9 + | +LL | >::bar4(&123); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `M` declared on the method `bar4` + | +note: required by a const generic parameter in `test_4::Trait2::bar4` + --> $DIR/trait-to-trait.rs:340:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait2::bar4` +... +LL | reuse Trait::foo::<'static, String, false> as bar4 { self.get_self() } + | ---- required by a bound in this associated function + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:418:9 + | +LL | ::bar4(&123); + | ^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `M` declared on the method `bar4` + | +note: required by a const generic parameter in `test_4::Trait3::bar4` + --> $DIR/trait-to-trait.rs:340:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait3::bar4` +... +LL | reuse Trait::foo::<'static, String, false> as bar4 { self.get_self() } + | ---- required by a bound in this associated function +help: consider specifying the generic arguments + | +LL | ::bar4::(&123); + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:420:9 + | +LL | >::bar4(&123); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `M` declared on the method `bar4` + | +note: required by a const generic parameter in `test_4::Trait4::bar4` + --> $DIR/trait-to-trait.rs:340:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait4::bar4` +... +LL | reuse Trait::foo::<'static, String, false> as bar4 { self.get_self() } + | ---- required by a bound in this associated function +help: consider specifying the generic arguments + | +LL | >::bar4::(&123); + | ++++++++ + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:422:9 + | +LL | >::bar4(&123); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `M` declared on the method `bar4` + | +note: required by a const generic parameter in `test_4::Trait5::bar4` + --> $DIR/trait-to-trait.rs:340:27 + | +LL | fn foo<'d: 'd, U, const M: bool>(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait5::bar4` +... +LL | reuse Trait::foo::<'static, String, false> as bar4 { self.get_self() } + | ---- required by a bound in this associated function + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:442:56 + | +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_5::Trait::foo` + --> $DIR/trait-to-trait.rs:434:19 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:447:56 + | +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_5::Trait::foo` + --> $DIR/trait-to-trait.rs:434:19 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:457:56 + | +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_5::Trait::foo` + --> $DIR/trait-to-trait.rs:434:19 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:462:56 + | +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_5::Trait::foo` + --> $DIR/trait-to-trait.rs:434:19 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:472:56 + | +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_5::Trait::foo` + --> $DIR/trait-to-trait.rs:434:19 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:477:56 + | +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_5::Trait::foo` + --> $DIR/trait-to-trait.rs:434:19 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:487:56 + | +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_5::Trait::foo` + --> $DIR/trait-to-trait.rs:434:19 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0284]: type annotations needed + --> $DIR/trait-to-trait.rs:492:56 + | +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + | ^^^ cannot infer the value of the const parameter `M` declared on the method `foo` + | +note: required by a const generic parameter in `test_5::Trait::foo` + --> $DIR/trait-to-trait.rs:434:19 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::foo` + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:505:68 + | +LL | >::bar1::(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:442:63 + | +LL | trait Trait<'b, 'c, 'a, T>: Sized { + | - +LL | fn foo(&self) {} + | - ------------- +... +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + | ^^^^ +help: add missing generic argument + | +LL | >::bar1::(&123); + | +++ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:507:26 + | +LL | ::bar1::(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:457:63 + | +LL | trait Trait<'b, 'c, 'a, T>: Sized { + | - +LL | fn foo(&self) {} + | - ------------- +... +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + | ^^^^ +help: add missing generic argument + | +LL | ::bar1::(&123); + | +++ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:509:43 + | +LL | >::bar1::(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:472:63 + | +LL | trait Trait<'b, 'c, 'a, T>: Sized { + | - +LL | fn foo(&self) {} + | - ------------- +... +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + | ^^^^ +help: add missing generic argument + | +LL | >::bar1::(&123); + | +++ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:511:44 + | +LL | >::bar1::(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:487:63 + | +LL | trait Trait<'b, 'c, 'a, T>: Sized { + | - +LL | fn foo(&self) {} + | - ------------- +... +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar1 { Self::get() } + | ^^^^ +help: add missing generic argument + | +LL | >::bar1::(&123); + | +++ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:519:68 + | +LL | >::bar3::(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:447:63 + | +LL | trait Trait<'b, 'c, 'a, T>: Sized { + | - +LL | fn foo(&self) {} + | - ------------- +... +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + | ^^^^ +help: add missing generic argument + | +LL | >::bar3::(&123); + | +++ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:521:26 + | +LL | ::bar3::(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:462:63 + | +LL | trait Trait<'b, 'c, 'a, T>: Sized { + | - +LL | fn foo(&self) {} + | - ------------- +... +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + | ^^^^ +help: add missing generic argument + | +LL | ::bar3::(&123); + | +++ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:523:43 + | +LL | >::bar3::(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:477:63 + | +LL | trait Trait<'b, 'c, 'a, T>: Sized { + | - +LL | fn foo(&self) {} + | - ------------- +... +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + | ^^^^ +help: add missing generic argument + | +LL | >::bar3::(&123); + | +++ + +error[E0107]: method takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/trait-to-trait.rs:525:44 + | +LL | >::bar3::(&123); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: method defined here, with 3 generic parameters: `T`, `U`, `M` + --> $DIR/trait-to-trait.rs:492:63 + | +LL | trait Trait<'b, 'c, 'a, T>: Sized { + | - +LL | fn foo(&self) {} + | - ------------- +... +LL | reuse Trait::<'static, 'static, 'static, i32>::foo as bar3 { self.get_self() } + | ^^^^ +help: add missing generic argument + | +LL | >::bar3::(&123); + | +++ + +error[E0282]: type annotations needed + --> $DIR/trait-to-trait.rs:581:9 + | +LL | >::bar1(&123); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the method `bar1` + +error[E0282]: type annotations needed + --> $DIR/trait-to-trait.rs:640:9 + | +LL | >::bar1(&123); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the method `bar1` + +error[E0282]: type annotations needed + --> $DIR/trait-to-trait.rs:765:9 + | +LL | / > +LL | | +LL | | ::bar1::<'static, 'static>(&123); + | |______________________________________^ cannot infer type of the type parameter `T` declared on the method `bar1` + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:853:22 + | +LL | ::bar1::<'static, 'static>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:797:32 + | +LL | fn foo<'a: 'a, 'b: 'b>(&self) {} + | ^ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:855:33 + | +LL | ::bar1::<'static, 'static>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:797:32 + | +LL | fn foo<'a: 'a, 'b: 'b>(&self) {} + | ^ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:857:50 + | +LL | >::bar1::<'a, 'a>(&123); + | ^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:797:32 + | +LL | fn foo<'a: 'a, 'b: 'b>(&self) {} + | ^ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:859:51 + | +LL | >::bar1::<'a, 'a>(&123); + | ^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:797:32 + | +LL | fn foo<'a: 'a, 'b: 'b>(&self) {} + | ^ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:868:22 + | +LL | ::bar3::<'static, 'static>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:797:32 + | +LL | fn foo<'a: 'a, 'b: 'b>(&self) {} + | ^ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:870:33 + | +LL | ::bar3::<'static, 'static>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:797:32 + | +LL | fn foo<'a: 'a, 'b: 'b>(&self) {} + | ^ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:872:50 + | +LL | >::bar3::<'static, 'static>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:797:32 + | +LL | fn foo<'a: 'a, 'b: 'b>(&self) {} + | ^ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/trait-to-trait.rs:874:51 + | +LL | >::bar3::<'static, 'static>(&123); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/trait-to-trait.rs:797:32 + | +LL | fn foo<'a: 'a, 'b: 'b>(&self) {} + | ^ + +error: aborting due to 99 previous errors + +Some errors have detailed explanations: E0107, E0282, E0284, E0794. +For more information about an error, try `rustc --explain E0107`. 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/diagnostics-infra/primary-fluent-bundle-missing.rs b/tests/ui/diagnostics-infra/primary-fluent-bundle-missing.rs deleted file mode 100644 index f2965778431c9..0000000000000 --- a/tests/ui/diagnostics-infra/primary-fluent-bundle-missing.rs +++ /dev/null @@ -1,24 +0,0 @@ -//! Regression test for https://github.com/rust-lang/rust/issues/106755 - -//@ compile-flags:-Ztranslate-lang=en_US - -#![feature(negative_impls)] -#![feature(marker_trait_attr)] - -#[marker] -trait MyTrait {} - -struct TestType(::std::marker::PhantomData); - -unsafe impl Send for TestType {} - -impl !Send for TestType {} -//~^ ERROR found both positive and negative implementation -//~| ERROR `!Send` impl requires `T: MyTrait` but the struct it is implemented for does not - -unsafe impl Send for TestType {} //~ ERROR conflicting implementations - -impl !Send for TestType {} -//~^ ERROR `!Send` impls cannot be specialized - -fn main() {} diff --git a/tests/ui/diagnostics-infra/primary-fluent-bundle-missing.stderr b/tests/ui/diagnostics-infra/primary-fluent-bundle-missing.stderr deleted file mode 100644 index 1dc31e161a76a..0000000000000 --- a/tests/ui/diagnostics-infra/primary-fluent-bundle-missing.stderr +++ /dev/null @@ -1,47 +0,0 @@ -error[E0751]: found both positive and negative implementation of trait `Send` for type `TestType<_>`: - --> $DIR/primary-fluent-bundle-missing.rs:15:1 - | -LL | unsafe impl Send for TestType {} - | ------------------------------------------------------ positive implementation here -LL | -LL | impl !Send for TestType {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ negative implementation here - -error[E0119]: conflicting implementations of trait `Send` for type `TestType<_>` - --> $DIR/primary-fluent-bundle-missing.rs:19:1 - | -LL | unsafe impl Send for TestType {} - | ------------------------------------------------------ first implementation here -... -LL | unsafe impl Send for TestType {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>` - -error[E0367]: `!Send` impl requires `T: MyTrait` but the struct it is implemented for does not - --> $DIR/primary-fluent-bundle-missing.rs:15:9 - | -LL | impl !Send for TestType {} - | ^^^^^^^ - | -note: the implementor must specify the same requirement - --> $DIR/primary-fluent-bundle-missing.rs:11:1 - | -LL | struct TestType(::std::marker::PhantomData); - | ^^^^^^^^^^^^^^^^^^ - -error[E0366]: `!Send` impls cannot be specialized - --> $DIR/primary-fluent-bundle-missing.rs:21:1 - | -LL | impl !Send for TestType {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `i32` is not a generic parameter -note: use the same sequence of generic lifetime, type and const parameters as the struct definition - --> $DIR/primary-fluent-bundle-missing.rs:11:1 - | -LL | struct TestType(::std::marker::PhantomData); - | ^^^^^^^^^^^^^^^^^^ - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0119, E0366, E0367, E0751. -For more information about an error, try `rustc --explain E0119`. 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 b007425bd3751..198f3229ace17 100644 --- a/tests/ui/dollar-crate/dollar-crate-is-keyword-2.rs +++ b/tests/ui/dollar-crate/dollar-crate-is-keyword-2.rs @@ -2,8 +2,7 @@ mod a {} macro_rules! m { () => { - use a::$crate; //~ ERROR: unresolved import `a::$crate` - //~^ NOTE: no `$crate` in `a` + 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 //~^ NOTE: can only be used in path 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 fc49e4c3dc3d9..413d51701be19 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]: `$crate` in paths can only be used in start position - --> $DIR/dollar-crate-is-keyword-2.rs:7: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; - | ^^^^^^ can only be used in path 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]: `$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; + | ^^^^^^ can only be used in path start position ... LL | m!(); | ---- in this macro invocation @@ -21,7 +21,7 @@ LL | m!(); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0433]: `$crate` in paths can only be used in start position - --> $DIR/dollar-crate-is-keyword-2.rs:9:21 + --> $DIR/dollar-crate-is-keyword-2.rs:8:21 | LL | type A = a::$crate; | ^^^^^^ can only be used in path start position @@ -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/marker_trait_attr/conflicting-send-impls-for-marker-trait-106755.rs b/tests/ui/marker_trait_attr/conflicting-send-impls-for-marker-trait-106755.rs index 891b8c1f74d6e..d9e8f1f4a5b74 100644 --- a/tests/ui/marker_trait_attr/conflicting-send-impls-for-marker-trait-106755.rs +++ b/tests/ui/marker_trait_attr/conflicting-send-impls-for-marker-trait-106755.rs @@ -1,5 +1,3 @@ -//@ compile-flags:-Ztranslate-lang=en_US - #![feature(negative_impls)] #![feature(marker_trait_attr)] diff --git a/tests/ui/marker_trait_attr/conflicting-send-impls-for-marker-trait-106755.stderr b/tests/ui/marker_trait_attr/conflicting-send-impls-for-marker-trait-106755.stderr index 100b3bf1ae311..729b1616b6d95 100644 --- a/tests/ui/marker_trait_attr/conflicting-send-impls-for-marker-trait-106755.stderr +++ b/tests/ui/marker_trait_attr/conflicting-send-impls-for-marker-trait-106755.stderr @@ -1,5 +1,5 @@ error[E0751]: found both positive and negative implementation of trait `Send` for type `TestType<_>`: - --> $DIR/conflicting-send-impls-for-marker-trait-106755.rs:13:1 + --> $DIR/conflicting-send-impls-for-marker-trait-106755.rs:11:1 | LL | unsafe impl Send for TestType {} | ------------------------------------------------------ positive implementation here @@ -8,7 +8,7 @@ LL | impl !Send for TestType {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ negative implementation here error[E0119]: conflicting implementations of trait `Send` for type `TestType<_>` - --> $DIR/conflicting-send-impls-for-marker-trait-106755.rs:17:1 + --> $DIR/conflicting-send-impls-for-marker-trait-106755.rs:15:1 | LL | unsafe impl Send for TestType {} | ------------------------------------------------------ first implementation here @@ -17,26 +17,26 @@ LL | unsafe impl Send for TestType {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>` error[E0367]: `!Send` impl requires `T: MyTrait` but the struct it is implemented for does not - --> $DIR/conflicting-send-impls-for-marker-trait-106755.rs:13:9 + --> $DIR/conflicting-send-impls-for-marker-trait-106755.rs:11:9 | LL | impl !Send for TestType {} | ^^^^^^^ | note: the implementor must specify the same requirement - --> $DIR/conflicting-send-impls-for-marker-trait-106755.rs:9:1 + --> $DIR/conflicting-send-impls-for-marker-trait-106755.rs:7:1 | LL | struct TestType(::std::marker::PhantomData); | ^^^^^^^^^^^^^^^^^^ error[E0366]: `!Send` impls cannot be specialized - --> $DIR/conflicting-send-impls-for-marker-trait-106755.rs:19:1 + --> $DIR/conflicting-send-impls-for-marker-trait-106755.rs:17:1 | LL | impl !Send for TestType {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `i32` is not a generic parameter note: use the same sequence of generic lifetime, type and const parameters as the struct definition - --> $DIR/conflicting-send-impls-for-marker-trait-106755.rs:9:1 + --> $DIR/conflicting-send-impls-for-marker-trait-106755.rs:7:1 | LL | struct TestType(::std::marker::PhantomData); | ^^^^^^^^^^^^^^^^^^ 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/rfcs/rfc-2294-if-let-guard/warns.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/warns.rs index da21c95dd2568..f37f848d289c4 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/warns.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/warns.rs @@ -1,5 +1,4 @@ #[deny(irrefutable_let_patterns)] - fn irrefutable_let_guard() { match Some(()) { Some(x) if let () = x => {} @@ -21,7 +20,6 @@ fn trailing_irrefutable_pattern_binding() { fn trailing_irrefutable_in_let_chain() { match Some(5) { Some(x) if let Some(y) = Some(x) && let z = 0 => {} - //~^ ERROR trailing irrefutable pattern in let chain _ => {} } } diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/warns.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/warns.stderr index f85bac0ddf5b1..871d0b72b1395 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/warns.stderr +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/warns.stderr @@ -1,5 +1,5 @@ error: irrefutable `if let` guard pattern - --> $DIR/warns.rs:5:20 + --> $DIR/warns.rs:4:20 | LL | Some(x) if let () = x => {} | ^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | #[deny(irrefutable_let_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: irrefutable `if let` guard pattern - --> $DIR/warns.rs:14:14 + --> $DIR/warns.rs:13:14 | LL | o if let x = 0 => {} | ^^^^^^^^^ @@ -21,27 +21,13 @@ LL | o if let x = 0 => {} = note: this pattern will always match, so the guard is useless = help: consider removing the guard and adding a `let` inside the match arm note: the lint level is defined here - --> $DIR/warns.rs:11:8 - | -LL | #[deny(irrefutable_let_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -error: trailing irrefutable pattern in let chain - --> $DIR/warns.rs:23:45 - | -LL | Some(x) if let Some(y) = Some(x) && let z = 0 => {} - | ^^^^^^^^^ - | - = note: this pattern will always match - = help: consider moving it into the body -note: the lint level is defined here - --> $DIR/warns.rs:20:8 + --> $DIR/warns.rs:10:8 | LL | #[deny(irrefutable_let_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/warns.rs:32:25 + --> $DIR/warns.rs:30:25 | LL | x if let None | None = x => {} | ---- ^^^^ no value can reach this @@ -49,10 +35,10 @@ LL | x if let None | None = x => {} | matches all the relevant values | note: the lint level is defined here - --> $DIR/warns.rs:29:8 + --> $DIR/warns.rs:27:8 | LL | #[deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.disallowed.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.disallowed.stderr deleted file mode 100644 index 053a483882789..0000000000000 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.disallowed.stderr +++ /dev/null @@ -1,133 +0,0 @@ -error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:13:8 - | -LL | if let first = &opt && let Some(second) = first && let None = second.start {} - | ^^^^^^^^^^^^^^^^ - | - = note: this pattern will always match - = help: consider moving it outside of the construct -note: the lint level is defined here - --> $DIR/irrefutable-lets.rs:6:30 - | -LL | #![cfg_attr(disallowed, deny(irrefutable_let_patterns))] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -error: irrefutable `if let` patterns - --> $DIR/irrefutable-lets.rs:19:8 - | -LL | if let first = &opt && let (a, b) = (1, 2) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: these patterns will always match, so the `if let` is useless - = help: consider replacing the `if let` with a `let` - -error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:22:8 - | -LL | if let first = &opt && let Some(second) = first && let None = second.start && let v = 0 {} - | ^^^^^^^^^^^^^^^^ - | - = note: this pattern will always match - = help: consider moving it outside of the construct - -error: trailing irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:22:83 - | -LL | if let first = &opt && let Some(second) = first && let None = second.start && let v = 0 {} - | ^^^^^^^^^ - | - = note: this pattern will always match - = help: consider moving it into the body - -error: trailing irrefutable patterns in let chain - --> $DIR/irrefutable-lets.rs:26:37 - | -LL | if let Some(ref first) = opt && let second = first && let _third = second {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: these patterns will always match - = help: consider moving them into the body - -error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:29:8 - | -LL | if let Range { start: local_start, end: _ } = (None..Some(1)) && let None = local_start {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this pattern will always match - = help: consider moving it outside of the construct - -error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:32:8 - | -LL | if let (a, b, c) = (Some(1), Some(1), Some(1)) && let None = Some(1) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this pattern will always match - = help: consider moving it outside of the construct - -error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:35:8 - | -LL | if let first = &opt && let None = Some(1) {} - | ^^^^^^^^^^^^^^^^ - | - = note: this pattern will always match - = help: consider moving it outside of the construct - -error: irrefutable `if let` guard patterns - --> $DIR/irrefutable-lets.rs:44:28 - | -LL | Some(ref first) if let second = first && let _third = second && let v = 4 + 4 => {}, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: these patterns will always match, so the guard is useless - = help: consider removing the guard and adding a `let` inside the match arm - -error: trailing irrefutable patterns in let chain - --> $DIR/irrefutable-lets.rs:59:16 - | -LL | && let v = local_end && let w = v => {}, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: these patterns will always match - = help: consider moving them into the body - -error: irrefutable `while let` patterns - --> $DIR/irrefutable-lets.rs:68:11 - | -LL | while let first = &opt && let (a, b) = (1, 2) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: these patterns will always match, so the loop will never exit - = help: consider instead using a `loop { ... }` with a `let` inside it - -error: trailing irrefutable patterns in let chain - --> $DIR/irrefutable-lets.rs:71:40 - | -LL | while let Some(ref first) = opt && let second = first && let _third = second {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: these patterns will always match - = help: consider moving them into the body - -error: trailing irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:87:12 - | -LL | && let x = &opt - | ^^^^^^^^^^^^ - | - = note: this pattern will always match - = help: consider moving it into the body - -error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:93:12 - | -LL | if let x = opt.clone().map(|_| 1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this pattern will always match - = help: consider moving it outside of the construct - -error: aborting due to 14 previous errors - diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs index a5088a8d37503..79876a1a618f2 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs @@ -1,39 +1,27 @@ -//@ revisions: allowed disallowed -//@[allowed] check-pass +//@ check-pass //@ edition: 2024 -#![cfg_attr(allowed, allow(irrefutable_let_patterns))] -#![cfg_attr(disallowed, deny(irrefutable_let_patterns))] - use std::ops::Range; fn main() { let opt = Some(None..Some(1)); if let first = &opt && let Some(second) = first && let None = second.start {} - //[disallowed]~^ ERROR leading irrefutable pattern in let chain // No lint as the irrefutable pattern is surrounded by other stuff if 4 * 2 == 0 && let first = &opt && let Some(second) = first && let None = second.start {} if let first = &opt && let (a, b) = (1, 2) {} - //[disallowed]~^ ERROR irrefutable `if let` patterns if let first = &opt && let Some(second) = first && let None = second.start && let v = 0 {} - //[disallowed]~^ ERROR leading irrefutable pattern in let chain - //[disallowed]~^^ ERROR trailing irrefutable pattern in let chain if let Some(ref first) = opt && let second = first && let _third = second {} - //[disallowed]~^ ERROR trailing irrefutable patterns in let chain if let Range { start: local_start, end: _ } = (None..Some(1)) && let None = local_start {} - //[disallowed]~^ ERROR leading irrefutable pattern in let chain if let (a, b, c) = (Some(1), Some(1), Some(1)) && let None = Some(1) {} - //[disallowed]~^ ERROR leading irrefutable pattern in let chain if let first = &opt && let None = Some(1) {} - //[disallowed]~^ ERROR leading irrefutable pattern in let chain if let Some(ref first) = opt && let Range { start: local_start, end: _ } = first @@ -42,7 +30,6 @@ fn main() { match opt { Some(ref first) if let second = first && let _third = second && let v = 4 + 4 => {}, - //[disallowed]~^ ERROR irrefutable `if let` guard patterns _ => {} } @@ -57,7 +44,6 @@ fn main() { match opt { Some(ref first) if let Range { start: Some(_), end: local_end } = first && let v = local_end && let w = v => {}, - //[disallowed]~^ ERROR trailing irrefutable patterns in let chain _ => {} } @@ -66,15 +52,13 @@ fn main() { while let first = &opt && let Some(second) = first && let None = second.start {} while let first = &opt && let (a, b) = (1, 2) {} - //[disallowed]~^ ERROR irrefutable `while let` patterns while let Some(ref first) = opt && let second = first && let _third = second {} - //[disallowed]~^ ERROR trailing irrefutable patterns in let chain while let Some(ref first) = opt && let Range { start: local_start, end: _ } = first - && let None = local_start { - } + && let None = local_start + {} // No error. An extra nesting level would be required for the `else if`. if opt == Some(None..None) { @@ -85,13 +69,11 @@ fn main() { if opt == Some(None..None) { } else if opt.is_some() && let x = &opt - //[disallowed]~^ ERROR trailing irrefutable pattern in let chain {} if opt == Some(None..None) { } else { if let x = opt.clone().map(|_| 1) - //[disallowed]~^ ERROR leading irrefutable pattern in let chain && x == Some(1) {} } 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 a5cfa47df3b2a..908e739ec520f 100644 --- a/tests/ui/use/use-path-segment-kw.stderr +++ b/tests/ui/use/use-path-segment-kw.e2015.stderr @@ -1,127 +1,298 @@ -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:97: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:101: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:102:15 + | +LL | use ::crate as _crate2; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:103: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:104:16 + | +LL | use ::{crate as _nested_crate2}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:107: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:108:21 + | +LL | use foobar::crate as _crate3; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:109: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:110: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:113: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:114:20 + | +LL | use crate::crate as _crate4; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:115: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:116: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:119: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:120:20 + | +LL | use super::crate as _crate5; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:121: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:122: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:125: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:126:19 + | +LL | use self::crate as _crate6; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:127: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:128: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:135:13 + | +LL | use super; + | ^^^^^ + | +help: try renaming it with a name | -LL | pub use self as _self; - | ^^^^ +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, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:139:15 | -LL | use ::self; - | ^^^^^^ +LL | use ::super; + | ^^^^^ + +error: `super` in paths can only be used in start position, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:140:15 | -help: consider importing the module directly +LL | use ::super as _super2; + | ^^^^^ + +error: `super` in paths can only be used in start position, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:141:16 | -LL - use ::self; -LL + use ; +LL | use ::{super}; + | ^^^^^ + +error: `super` in paths can only be used in start position, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:142: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, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:145: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, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:146:21 | -LL | use ::self as _self2; - | ^^^^^^ +LL | ... use foobar::super as _super3; + | ^^^^^ + +error: `super` in paths can only be used in start position, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:147:22 | -help: consider importing the module directly +LL | use foobar::{super}; + | ^^^^^ + +error: `super` in paths can only be used in start position, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:148: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, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:151: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, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:152: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, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:153:21 | -LL | use ::{self}; - | ^^^^ can only appear in an import list with a non-empty prefix +LL | use crate::{super}; + | ^^^^^ -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: `super` in paths can only be used in start position, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:154:21 | -LL | use ::{self as _nested_self2}; - | ^^^^^^^^^^^^^^^^^^^^^ can only appear in an import list with a non-empty prefix +LL | ... use crate::{super as _nested_super4}; + | ^^^^^ + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:157: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:159:21 + | +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:163:19 + | +LL | use self::super; + | ^^^^^ + | +help: try renaming it with a name + | +LL | use self::super as name; + | +++++++ + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:165:20 + | +LL | use self::{super}; + | ^^^^^ + | +help: try renaming it with a name + | +LL | use self::{super as name}; + | +++++++ + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:173:13 + | +LL | use self; + | ^^^^ error[E0429]: `self` imports are only allowed within a { } list - --> $DIR/use-path-segment-kw.rs:196:28 + --> $DIR/use-path-segment-kw.rs:177:13 + | +LL | use ::self; + | ^^^^^^ + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:177:15 + | +LL | use ::self; + | ^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:180:13 + | +LL | use ::self as _self2; + | ^^^^^^ + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:182: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:187:28 | LL | pub use foobar::qux::self; | ^^^^^^ @@ -137,7 +308,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:189:23 | LL | pub use foobar::self as _self3; | ^^^^^^ @@ -153,7 +324,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:195:18 | LL | use crate::self; | ^^^^^^ @@ -168,14 +339,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:195: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:197:22 | LL | pub use crate::self as _self4; | ^^^^^^ @@ -190,14 +361,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:198: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:202:18 | LL | use super::self; | ^^^^^^ @@ -212,8 +388,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:202: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:204:22 | LL | pub use super::self as _self5; | ^^^^^^ @@ -228,8 +410,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:205: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:209:17 | LL | use self::self; | ^^^^^^ @@ -244,8 +437,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:209: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:211:21 | LL | pub use self::self as _self6; | ^^^^^^ @@ -260,769 +459,524 @@ 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 +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:212:20 | -LL | use crate; - | ----- previous import of the module `crate` here -... -LL | use self::crate; - | ^^^^^^^^^^^ `crate` reimported here +LL | use self::{self}; + | ^^^^ | - = note: `crate` must be defined only once in the type namespace of this module +help: try renaming it with a name + | +LL | use self::{self as name}; + | +++++++ -error[E0252]: the name `crate` is defined multiple times - --> $DIR/use-path-segment-kw.rs:137:20 +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:216:28 | -LL | use crate; - | ----- previous import of the module `crate` here -... -LL | use self::{crate}; - | -----------^^^^^-- - | | | - | | `crate` reimported here - | help: remove unnecessary import +LL | use crate::foo::bar::self; + | ^^^^^^ | - = 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 +help: consider importing the module directly | -LL | use crate; - | ----- previous import of the module `crate` here -... -LL | use crate::self; - | ^^^^^^^^^^^ `crate` reimported here +LL - use crate::foo::bar::self; +LL + use crate::foo::bar; | - = note: `crate` must be defined only once in the type namespace of this module +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use crate::foo::bar::{self}; + | + + -error[E0252]: the name `crate` is defined multiple times - --> $DIR/use-path-segment-kw.rs:206:21 +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:217:28 | -LL | use crate; - | ----- previous import of the module `crate` here -... -LL | use crate::{self}; - | ------------^^^^-- - | | | - | | `crate` reimported here - | help: remove unnecessary import +LL | use crate::foo::bar::self as _self7; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - use crate::foo::bar::self as _self7; +LL + use crate::foo::bar as _self7; | - = note: `crate` must be defined only once in the type namespace of this module +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use crate::foo::bar::{self as _self7}; + | + + -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 - | -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 +error: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:28:20 | -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, after `self`, 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, after `self`, 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 +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, after `self`, 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, after `self`, 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 +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:187: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; + | ^^^^^^ | - = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) +help: a similar path exists + | +LL | pub use self::foobar::qux::self; + | ++++++ + +error[E0432]: unresolved import `foobar` + --> $DIR/use-path-segment-kw.rs:189:17 + | +LL | pub use foobar::self as _self3; + | ^^^^^^^^^^^^^^^^^^^^^^ no `foobar` in the root + +error[E0432]: unresolved import `foobar` + --> $DIR/use-path-segment-kw.rs:191:17 + | +LL | pub use foobar::baz::{self}; + | ^^^^^^ + | +help: a similar path exists + | +LL | pub use self::foobar::baz::{self}; + | ++++++ + +error[E0432]: unresolved import `foobar` + --> $DIR/use-path-segment-kw.rs:192:26 + | +LL | pub use foobar::{self as _nested_self3}; + | ^^^^^^^^^^^^^^^^^^^^^ no `foobar` in the root + +error[E0433]: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:215:36 + | +LL | type D7 = crate::foo::bar::self; + | ^^^^ can only be used in path start position 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 +987,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:96: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:134: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:156: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:162: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:172:19 | LL | type D1 = self; | ^^^^ not a type error[E0433]: 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; | ^^^^^^ cannot start with this @@ -1074,7 +1028,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]: `$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; | ^^^^^^ can only be used in path start position @@ -1085,7 +1039,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]: `$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; | ^^^^^^ can only be used in path start position @@ -1096,7 +1050,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]: `$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; | ^^^^^^ can only be used in path start position @@ -1107,7 +1061,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]: `$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; | ^^^^^^ can only be used in path start position @@ -1118,7 +1072,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]: `$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; | ^^^^^^ can only be used in path start position @@ -1129,7 +1083,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]: `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; | ^^^^^ can only be used in path start position @@ -1162,84 +1116,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]: global paths cannot start with `crate` - --> $DIR/use-path-segment-kw.rs:101:21 + --> $DIR/use-path-segment-kw.rs:100:21 | LL | type B2 = ::crate; | ^^^^^ cannot start with this error[E0433]: `crate` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:109:27 + --> $DIR/use-path-segment-kw.rs:106:27 | LL | type B3 = foobar::crate; | ^^^^^ can only be used in path start position error[E0433]: `crate` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:117:26 + --> $DIR/use-path-segment-kw.rs:112:26 | LL | type B4 = crate::crate; | ^^^^^ can only be used in path start position error[E0433]: `crate` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:125:26 + --> $DIR/use-path-segment-kw.rs:118:26 | LL | type B5 = super::crate; | ^^^^^ can only be used in path start position error[E0433]: `crate` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:133:25 + --> $DIR/use-path-segment-kw.rs:124:25 | LL | type B6 = self::crate; | ^^^^^ can only be used in path start position error[E0433]: global paths cannot start with `super` - --> $DIR/use-path-segment-kw.rs:149:21 + --> $DIR/use-path-segment-kw.rs:138:21 | LL | type C2 = ::super; | ^^^^^ cannot start with this error[E0433]: `super` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:155:27 + --> $DIR/use-path-segment-kw.rs:144:27 | LL | type C3 = foobar::super; | ^^^^^ can only be used in path start position error[E0433]: `super` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:161:26 + --> $DIR/use-path-segment-kw.rs:150:26 | LL | type C4 = crate::super; | ^^^^^ can only be used in path start position error[E0433]: global paths cannot start with `self` - --> $DIR/use-path-segment-kw.rs:187:21 + --> $DIR/use-path-segment-kw.rs:176:21 | LL | type D2 = ::self; | ^^^^ cannot start with this error[E0433]: `self` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:195:27 + --> $DIR/use-path-segment-kw.rs:186:27 | LL | type D3 = foobar::self; | ^^^^ can only be used in path start position error[E0433]: `self` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:201:26 + --> $DIR/use-path-segment-kw.rs:194:26 | LL | type D4 = crate::self; | ^^^^ can only be used in path start position error[E0433]: `self` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:210:26 + --> $DIR/use-path-segment-kw.rs:201:26 | LL | type D5 = super::self; | ^^^^ can only be used in path start position error[E0433]: `self` in paths can only be used in start position - --> $DIR/use-path-segment-kw.rs:218:25 + --> $DIR/use-path-segment-kw.rs:208:25 | LL | type D6 = self::self; | ^^^^ can only be used in path start position -error: aborting due to 141 previous errors +error: aborting due to 129 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..878fd166b845d --- /dev/null +++ b/tests/ui/use/use-path-segment-kw.e2018.stderr @@ -0,0 +1,1166 @@ +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:97: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:101:15 + | +LL | use ::crate; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:102:15 + | +LL | use ::crate as _crate2; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:103:16 + | +LL | use ::{crate}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:104:16 + | +LL | use ::{crate as _nested_crate2}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:107:21 + | +LL | use foobar::crate; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:108:21 + | +LL | use foobar::crate as _crate3; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:109:22 + | +LL | use foobar::{crate}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:110: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:113:20 + | +LL | use crate::crate; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:114:20 + | +LL | use crate::crate as _crate4; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:115:21 + | +LL | use crate::{crate}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:116: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:119:20 + | +LL | use super::crate; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:120:20 + | +LL | use super::crate as _crate5; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:121:21 + | +LL | use super::{crate}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:122: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:125:19 + | +LL | use self::crate; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:126:19 + | +LL | use self::crate as _crate6; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:127:20 + | +LL | use self::{crate}; + | ^^^^^ + +error: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:128:20 + | +LL | use self::{crate as _nested_crate6}; + | ^^^^^ + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:135: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, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:139:15 + | +LL | use ::super; + | ^^^^^ + +error: `super` in paths can only be used in start position, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:140:15 + | +LL | use ::super as _super2; + | ^^^^^ + +error: `super` in paths can only be used in start position, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:141:16 + | +LL | use ::{super}; + | ^^^^^ + +error: `super` in paths can only be used in start position, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:142:16 + | +LL | ... use ::{super as _nested_super2}; + | ^^^^^ + +error: `super` in paths can only be used in start position, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:145:21 + | +LL | use foobar::super; + | ^^^^^ + +error: `super` in paths can only be used in start position, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:146:21 + | +LL | ... use foobar::super as _super3; + | ^^^^^ + +error: `super` in paths can only be used in start position, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:147:22 + | +LL | use foobar::{super}; + | ^^^^^ + +error: `super` in paths can only be used in start position, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:148:22 + | +LL | ... use foobar::{super as _nested_super3}; + | ^^^^^ + +error: `super` in paths can only be used in start position, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:151:20 + | +LL | use crate::super; + | ^^^^^ + +error: `super` in paths can only be used in start position, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:152:20 + | +LL | ... use crate::super as _super4; + | ^^^^^ + +error: `super` in paths can only be used in start position, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:153:21 + | +LL | use crate::{super}; + | ^^^^^ + +error: `super` in paths can only be used in start position, after `self`, or after another `super` + --> $DIR/use-path-segment-kw.rs:154:21 + | +LL | ... use crate::{super as _nested_super4}; + | ^^^^^ + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:157: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:159:21 + | +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:163:19 + | +LL | use self::super; + | ^^^^^ + | +help: try renaming it with a name + | +LL | use self::super as name; + | +++++++ + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:165:20 + | +LL | use self::{super}; + | ^^^^^ + | +help: try renaming it with a name + | +LL | use self::{super as name}; + | +++++++ + +error: imports need to be explicitly named + --> $DIR/use-path-segment-kw.rs:173:13 + | +LL | use self; + | ^^^^ + +error: extern prelude cannot be imported + --> $DIR/use-path-segment-kw.rs:177:13 + | +LL | use ::self; + | ^^^^^^ + +error: extern prelude cannot be imported + --> $DIR/use-path-segment-kw.rs:180:13 + | +LL | use ::self as _self2; + | ^^^^^^^^^^^^^^^^ + +error: extern prelude cannot be imported + --> $DIR/use-path-segment-kw.rs:182:16 + | +LL | use ::{self}; + | ^^^^ + +error: extern prelude cannot be imported + --> $DIR/use-path-segment-kw.rs:184:20 + | +LL | pub use ::{self as _nested_self2}; + | ^^^^^^^^^^^^^^^^^^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:187: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:189: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:195: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:195:20 + | +LL | use crate::self; + | ^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:197: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:198: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:202: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:202:20 + | +LL | use super::self; + | ^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:204: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:205: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:209: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:209:19 + | +LL | use self::self; + | ^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:211: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:212:20 + | +LL | use self::{self}; + | ^^^^ + | +help: try renaming it with a name + | +LL | use self::{self as name}; + | +++++++ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:216:28 + | +LL | use crate::foo::bar::self; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - use crate::foo::bar::self; +LL + use crate::foo::bar; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use crate::foo::bar::{self}; + | + + + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:217:28 + | +LL | use crate::foo::bar::self as _self7; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - use crate::foo::bar::self as _self7; +LL + use crate::foo::bar as _self7; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use crate::foo::bar::{self as _self7}; + | + + + +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, after `self`, 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, after `self`, 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, after `self`, 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, after `self`, 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]: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:215:36 + | +LL | type D7 = crate::foo::bar::self; + | ^^^^ can only be used in path start position + +error[E0433]: cannot find `_nested_self2` in `bar` + --> $DIR/use-path-segment-kw.rs:241: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:96:19 + | +LL | type B1 = crate; + | ^^^^^ not a type + +error[E0573]: expected type, found module `super` + --> $DIR/use-path-segment-kw.rs:134:19 + | +LL | type C1 = super; + | ^^^^^ not a type + +error[E0573]: expected type, found module `super::super` + --> $DIR/use-path-segment-kw.rs:156:19 + | +LL | type C5 = super::super; + | ^^^^^^^^^^^^ not a type + +error[E0573]: expected type, found module `self::super` + --> $DIR/use-path-segment-kw.rs:162:19 + | +LL | type C6 = self::super; + | ^^^^^^^^^^^ not a type + +error[E0573]: expected type, found module `self` + --> $DIR/use-path-segment-kw.rs:172:19 + | +LL | type D1 = self; + | ^^^^ not a type + +error[E0433]: global paths cannot start with `$crate` + --> $DIR/use-path-segment-kw.rs:14:21 + | +LL | type A2 = ::$crate; + | ^^^^^^ cannot start with this +... +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]: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:20:27 + | +LL | type A3 = foobar::$crate; + | ^^^^^^ can only be used in path 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]: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:26:26 + | +LL | type A4 = crate::$crate; + | ^^^^^^ can only be used in path 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]: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:32:26 + | +LL | type A5 = super::$crate; + | ^^^^^^ can only be used in path 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]: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:38:25 + | +LL | type A6 = self::$crate; + | ^^^^^^ can only be used in path 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]: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:44:27 + | +LL | type A7 = $crate::$crate; + | ^^^^^^ can only be used in path 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]: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:50:27 + | +LL | type A8 = $crate::crate; + | ^^^^^ can only be used in path 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]: `super` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:56:27 + | +LL | type A9 = $crate::super; + | ^^^^^ can only be used in path 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]: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:62:28 + | +LL | type A10 = $crate::self; + | ^^^^ can only be used in path 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]: global paths cannot start with `crate` + --> $DIR/use-path-segment-kw.rs:100:21 + | +LL | type B2 = ::crate; + | ^^^^^ cannot start with this + +error[E0433]: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:106:27 + | +LL | type B3 = foobar::crate; + | ^^^^^ can only be used in path start position + +error[E0433]: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:112:26 + | +LL | type B4 = crate::crate; + | ^^^^^ can only be used in path start position + +error[E0433]: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:118:26 + | +LL | type B5 = super::crate; + | ^^^^^ can only be used in path start position + +error[E0433]: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:124:25 + | +LL | type B6 = self::crate; + | ^^^^^ can only be used in path start position + +error[E0433]: global paths cannot start with `super` + --> $DIR/use-path-segment-kw.rs:138:21 + | +LL | type C2 = ::super; + | ^^^^^ cannot start with this + +error[E0433]: `super` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:144:27 + | +LL | type C3 = foobar::super; + | ^^^^^ can only be used in path start position + +error[E0433]: `super` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:150:26 + | +LL | type C4 = crate::super; + | ^^^^^ can only be used in path start position + +error[E0433]: global paths cannot start with `self` + --> $DIR/use-path-segment-kw.rs:176:21 + | +LL | type D2 = ::self; + | ^^^^ cannot start with this + +error[E0433]: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:186:27 + | +LL | type D3 = foobar::self; + | ^^^^ can only be used in path start position + +error[E0433]: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:194:26 + | +LL | type D4 = crate::self; + | ^^^^ can only be used in path start position + +error[E0433]: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:201:26 + | +LL | type D5 = super::self; + | ^^^^ can only be used in path start position + +error[E0433]: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:208:25 + | +LL | type D6 = self::self; + | ^^^^ can only be used in path start position + +error: aborting due to 126 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 fffc027ac6fd3..be64f239b9fc3 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 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 `$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 `$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 `$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 `$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 `$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 `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 `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, after `self`, or after another `super` + use $crate::super as _m_super8; //~ ERROR `super` in paths can only be used in start position, after `self`, or after another `super` + use $crate::{super}; //~ ERROR `super` in paths can only be used in start position, after `self`, or after another `super` + use $crate::{super as _m_nested_super8}; //~ ERROR `super` in paths can only be used in start position, after `self`, or after another `super` type A10 = $crate::self; //~ ERROR `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 } } @@ -84,6 +81,8 @@ mod foo { pub use super::inner; } + pub mod quxbaz {} + pub fn inner() {} } @@ -95,131 +94,129 @@ 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 `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` + type B2 = ::crate; //~ ERROR global paths cannot start with `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 `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 `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 `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 `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 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, after `self`, or after another `super` + use ::super as _super2; //~ ERROR `super` in paths can only be used in start position, after `self`, or after another `super` + use ::{super}; //~ ERROR `super` in paths can only be used in start position, after `self`, or after another `super` + use ::{super as _nested_super2}; //~ ERROR `super` in paths can only be used in start position, after `self`, or after another `super` type C3 = foobar::super; //~ ERROR `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, after `self`, or after another `super` + use foobar::super as _super3; //~ ERROR `super` in paths can only be used in start position, after `self`, or after another `super` + use foobar::{super}; //~ ERROR `super` in paths can only be used in start position, after `self`, or after another `super` + use foobar::{super as _nested_super3}; //~ ERROR `super` in paths can only be used in start position, after `self`, or after another `super` type C4 = crate::super; //~ ERROR `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, after `self`, or after another `super` + use crate::super as _super4; //~ ERROR `super` in paths can only be used in start position, after `self`, or after another `super` + use crate::{super}; //~ ERROR `super` in paths can only be used in start position, after `self`, or after another `super` + use crate::{super as _nested_super4}; //~ ERROR `super` in paths can only be used in start position, after `self`, 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 imports need to be explicitly named + pub use self::super as _super6; + use self::{super}; //~ ERROR imports need to be explicitly named + pub use self::{super as _nested_super6}; // --- 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 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 `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 `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 `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 `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}; + + type D7 = crate::foo::bar::self; //~ ERROR `self` in paths can only be used in start position + use crate::foo::bar::self; //~ ERROR `self` imports are only allowed within a { } list + use crate::foo::bar::self as _self7; //~ ERROR `self` imports are only allowed within a { } list + use crate::foo::{bar::foobar::quxbaz::self}; + use crate::foo::{bar::foobar::quxbaz::self as _nested_self7}; } } @@ -235,10 +232,13 @@ fn main() { foo::bar::_super::bar::foobar::inner(); foo::bar::_super5::outer(); foo::bar::_nested_super5::outer(); + foo::bar::_super6::bar::foobar::inner(); + foo::bar::_nested_super6::bar::foobar::inner(); foo::bar::_self::foobar::inner(); foo::bar::qux::inner(); // Works after recovery foo::bar::baz::inner(); + foo::bar::_nested_self2::outer(); //[e2018]~ ERROR cannot find `_nested_self2` in `bar` foo::bar::_self3::inner(); // Works after recovery foo::bar::_nested_self3::inner(); foo::bar::_self4::outer(); // Works after recovery