diff --git a/Cargo.lock b/Cargo.lock index f035068a600d9..3862f0b42cd0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -64,9 +64,9 @@ dependencies = [ [[package]] name = "annotate-snippets" -version = "0.12.15" +version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92570a3f9c98e7e84df84b71d0965ac99b1871fcd75a3773a3bd1bad13f64cf7" +checksum = "f211a51805bc641f3ad5b7664c77d2547af685cc33b4cd8d31964027a46f13f1" dependencies = [ "anstyle", "memchr", @@ -3958,7 +3958,7 @@ dependencies = [ name = "rustc_errors" version = "0.0.0" dependencies = [ - "annotate-snippets 0.12.15", + "annotate-snippets 0.12.16", "anstream", "anstyle", "derive_setters", diff --git a/compiler/rustc_attr_parsing/src/parser.rs b/compiler/rustc_attr_parsing/src/parser.rs index 4d714fccc3f61..799b5ccbe4e40 100644 --- a/compiler/rustc_attr_parsing/src/parser.rs +++ b/compiler/rustc_attr_parsing/src/parser.rs @@ -30,8 +30,8 @@ use thin_vec::ThinVec; use crate::ShouldEmit; use crate::session_diagnostics::{ - InvalidMetaItem, InvalidMetaItemQuoteIdentSugg, InvalidMetaItemRemoveNegSugg, MetaBadDelim, - MetaBadDelimSugg, SuffixedLiteralInAttribute, + ExpectedComma, InvalidMetaItem, InvalidMetaItemQuoteIdentSugg, InvalidMetaItemRemoveNegSugg, + MetaBadDelim, MetaBadDelimSugg, SuffixedLiteralInAttribute, }; #[derive(Clone, Debug)] @@ -704,6 +704,29 @@ impl<'a, 'sess> MetaItemListParserContext<'a, 'sess> { self.parser.dcx().create_err(err) } + fn should_continue_parsing_meta_items(&mut self) -> Result> { + if self.parser.eat(exp!(Comma)) { + return Ok(true); + } else if self.parser.token == token::Eof { + return Ok(false); + } + + let mut snapshot = self.parser.create_snapshot_for_diagnostic(); + if matches!(self.should_emit, ShouldEmit::ErrorsAndLints { recovery: Recovery::Allowed }) { + let span = self.parser.prev_token.span.shrink_to_hi(); + self.should_emit = ShouldEmit::Nothing; + match self.parse_meta_item_inner() { + Ok(_) => { + return Err(self.parser.dcx().create_err(ExpectedComma { span })); + } + Err(e) => { + e.cancel(); + } + } + } + snapshot.unexpected_any() + } + fn parse( tokens: TokenStream, psess: &'sess ParseSess, @@ -724,15 +747,11 @@ impl<'a, 'sess> MetaItemListParserContext<'a, 'sess> { while this.parser.token != token::Eof { sub_parsers.push(this.parse_meta_item_inner()?); - if !this.parser.eat(exp!(Comma)) { + if !this.should_continue_parsing_meta_items()? { break; } } - if parser.token != token::Eof { - parser.unexpected()?; - } - Ok(MetaItemListParser { sub_parsers, span }) } } diff --git a/compiler/rustc_attr_parsing/src/session_diagnostics.rs b/compiler/rustc_attr_parsing/src/session_diagnostics.rs index b4afdfd7ce409..6dc629583cebe 100644 --- a/compiler/rustc_attr_parsing/src/session_diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/session_diagnostics.rs @@ -1032,3 +1032,16 @@ pub(crate) struct SanitizeInvalidStatic { pub span: Span, pub field: &'static str, } + +#[derive(Diagnostic)] +#[diag("attribute items not separated with `,`")] +pub(crate) struct ExpectedComma { + #[primary_span] + #[suggestion( + "try adding `,` here", + code = ",", + applicability = "maybe-incorrect", + style = "short" + )] + pub span: Span, +} diff --git a/compiler/rustc_errors/Cargo.toml b/compiler/rustc_errors/Cargo.toml index 386467c3e1edb..b0eed7ae2aad9 100644 --- a/compiler/rustc_errors/Cargo.toml +++ b/compiler/rustc_errors/Cargo.toml @@ -5,7 +5,7 @@ edition = "2024" [dependencies] # tidy-alphabetical-start -annotate-snippets = { version = "0.12.15", features = ["simd"] } +annotate-snippets = { version = "0.12.16", features = ["simd"] } anstream = "0.6.20" anstyle = "1.0.13" derive_setters = "0.1.6" diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 46cc163ca8ed2..9e0f5c24d1101 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -57,6 +57,16 @@ pub(crate) enum PendingDecl<'ra> { Pending, } +enum ImportResolutionKind<'ra> { + Single(PerNS>), + Glob(Vec<(Decl<'ra>, BindingKey, Span /* orig_ident_span */)>), +} + +struct ImportResolution<'ra> { + kind: ImportResolutionKind<'ra>, + imported_module: ModuleOrUniformRoot<'ra>, +} + impl<'ra> PendingDecl<'ra> { pub(crate) fn decl(self) -> Option> { match self { @@ -442,7 +452,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { && (vis == import.vis || max_vis.get().is_none_or(|max_vis| vis.greater_than(max_vis, self.tcx))) { - max_vis.set_unchecked(Some(vis)) + // `set` can't fail because this can only happen during "write_import_resolutions" + max_vis.set(Some(vis), self) } self.arenas.alloc_decl(DeclData { @@ -559,7 +570,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { && glob_decl.ambiguity.get().is_none() { // Do not lose glob ambiguities when re-fetching the glob. - glob_decl.ambiguity.set_unchecked(Some((old_ambig, true))); + glob_decl.ambiguity.set(Some((old_ambig, true)), self); } glob_decl } else if glob_decl.res() != old_glob_decl.res() { @@ -567,7 +578,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { || self.is_rustybuzz_0_4_0(old_glob_decl, glob_decl) || self.is_pdf_0_9_0(old_glob_decl, glob_decl) || self.is_net2_0_2_39(old_glob_decl, glob_decl); - old_glob_decl.ambiguity.set_unchecked(Some((glob_decl, warning))); + old_glob_decl.ambiguity.set(Some((glob_decl, warning)), self); old_glob_decl } else if let old_vis = old_glob_decl.vis() && let vis = glob_decl.vis() @@ -576,17 +587,17 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // We are glob-importing the same item but with a different visibility. // All visibilities here are ordered because all of them are ancestors of `module`. if vis.greater_than(old_vis, self.tcx) { - old_glob_decl.ambiguity_vis_max.set_unchecked(Some(glob_decl)); + old_glob_decl.ambiguity_vis_max.set(Some(glob_decl), self); } else if let old_min_vis = old_glob_decl.min_vis() && old_min_vis != vis && old_min_vis.greater_than(vis, self.tcx) { - old_glob_decl.ambiguity_vis_min.set_unchecked(Some(glob_decl)); + old_glob_decl.ambiguity_vis_min.set(Some(glob_decl), self); } old_glob_decl } else if glob_decl.is_ambiguity_recursive() && !old_glob_decl.is_ambiguity_recursive() { // Overwriting a non-ambiguous glob import with an ambiguous glob import. - old_glob_decl.ambiguity.set_unchecked(Some((glob_decl, true))); + old_glob_decl.ambiguity.set(Some((glob_decl, true)), self); old_glob_decl } else { old_glob_decl @@ -613,7 +624,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // because they can be fetched by glob imports from those modules, and bring traits // into scope both directly and through glob imports. let key = BindingKey::new_disambiguated(ident, ns, || { - module.underscore_disambiguator.update_unchecked(|d| d + 1); + module.underscore_disambiguator.update(self, |d| d + 1); module.underscore_disambiguator.get() }); self.update_local_resolution(module, key, orig_ident_span, |this, resolution| { @@ -650,7 +661,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { let (binding, t) = { let resolution = &mut *self .resolution_or_default(module.to_module(), key, orig_ident_span) - .borrow_mut_unchecked(); + .borrow_mut(self); let old_decl = resolution.determined_decl(); let old_vis = old_decl.map(|d| d.vis()); @@ -665,7 +676,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } }; - let Ok(glob_importers) = module.glob_importers.try_borrow_mut_unchecked() else { + let Ok(glob_importers) = module.glob_importers.try_borrow_mut(self) else { return t; }; @@ -727,11 +738,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // Import resolution // - // This is a fixed-point algorithm. We resolve imports until our efforts - // are stymied by an unresolved import; then we bail out of the current - // module and continue. We terminate successfully once no more imports - // remain or unsuccessfully when no forward progress in resolving imports - // is made. + // This is a batched fixed-point algorithm. Each import is resolved in + // isolation, with any resolutions collected for later. + // After a full pass over the current set of `indeterminate_imports`, + // the collected resolutions are committed together. The process + // repeats until either no imports remain or no further progress can + // be made. /// Resolves all imports for the crate. This method performs the fixed- /// point iteration. @@ -741,16 +753,125 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { while indeterminate_count < prev_indeterminate_count { prev_indeterminate_count = indeterminate_count; indeterminate_count = 0; + let mut resolutions = Vec::new(); self.assert_speculative = true; for import in mem::take(&mut self.indeterminate_imports) { - let import_indeterminate_count = self.cm().resolve_import(import); + let (resolution, import_indeterminate_count) = self.cm().resolve_import(import); indeterminate_count += import_indeterminate_count; match import_indeterminate_count { 0 => self.determined_imports.push(import), _ => self.indeterminate_imports.push(import), } + if let Some(resolution) = resolution { + resolutions.push((import, resolution)); + } } self.assert_speculative = false; + self.write_import_resolutions(resolutions); + } + } + + fn write_import_resolutions( + &mut self, + import_resolutions: Vec<(Import<'ra>, ImportResolution<'ra>)>, + ) { + for (import, resolution) in &import_resolutions { + let ImportResolution { imported_module, .. } = resolution; + import.imported_module.set(Some(*imported_module), self); + + if import.is_glob() + && let ModuleOrUniformRoot::Module(module) = imported_module + && import.parent_scope.module != *module + && module.is_local() + { + module.glob_importers.borrow_mut(self).push(*import); + } + } + + for (import, resolution) in import_resolutions { + let ImportResolution { imported_module, kind: resolution_kind } = resolution; + + match (&import.kind, resolution_kind) { + ( + ImportKind::Single { target, decls, .. }, + ImportResolutionKind::Single(import_decls), + ) => { + self.per_ns(|this, ns| { + match import_decls[ns] { + PendingDecl::Ready(Some(import_decl)) => { + if import_decl.is_assoc_item() + && !this.tcx.features().import_trait_associated_functions() + { + feature_err( + this.tcx.sess, + sym::import_trait_associated_functions, + import.span, + "`use` associated items of traits is unstable", + ) + .emit(); + } + this.plant_decl_into_local_module( + IdentKey::new(*target), + target.span, + ns, + import_decl, + ); + decls[ns].set(PendingDecl::Ready(Some(import_decl)), this); + } + PendingDecl::Ready(None) => { + // Don't remove underscores from `single_imports`, they were never added. + if target.name != kw::Underscore { + let key = BindingKey::new(IdentKey::new(*target), ns); + this.update_local_resolution( + import.parent_scope.module.expect_local(), + key, + target.span, + |_, resolution| { + resolution.single_imports.swap_remove(&import); + }, + ); + } + decls[ns].set(PendingDecl::Ready(None), this); + } + PendingDecl::Pending => {} + } + }); + } + (ImportKind::Glob { id, .. }, ImportResolutionKind::Glob(imported_decls)) => { + let ModuleOrUniformRoot::Module(module) = imported_module else { + self.dcx().emit_err(CannotGlobImportAllCrates { span: import.span }); + continue; + }; + + if module.is_trait() && !self.tcx.features().import_trait_associated_functions() + { + feature_err( + self.tcx.sess, + sym::import_trait_associated_functions, + import.span, + "`use` associated items of traits is unstable", + ) + .emit(); + } + + for (binding, key, orig_ident_span) in imported_decls { + let import_decl = self.new_import_decl(binding, import); + let _ = self + .try_plant_decl_into_local_module( + key.ident, + orig_ident_span, + key.ns, + import_decl, + ) + .expect("planting a glob cannot fail"); + } + + self.record_partial_res(*id, PartialRes::new(module.res().unwrap())); + } + + // Something weird happened, which shouldn't have happened. + _ => unreachable!("mismatched import and resolution kind"), + } } } @@ -1085,12 +1206,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { /// - `0` means its resolution is determined. /// - Other values mean that indeterminate exists under certain namespaces. /// - /// Meanwhile, if resolve successful, the resolved bindings are written - /// into the module. - fn resolve_import<'r>(mut self: CmResolver<'r, 'ra, 'tcx>, import: Import<'ra>) -> usize { + /// Meanwhile, if resolution is successful, its result is returned. + fn resolve_import<'r>( + mut self: CmResolver<'r, 'ra, 'tcx>, + import: Import<'ra>, + ) -> (Option>, usize) { debug!( - "(resolving import for module) resolving import `{}::...` in `{}`", + "(resolving import for module) resolving import `{}::{}` in `{}`", Segment::names_to_string(&import.module_path), + import_kind_to_string(&import.kind), module_to_string(import.parent_scope.module).unwrap_or_else(|| "???".to_string()), ); let module = if let Some(module) = import.imported_module.get() { @@ -1105,21 +1229,24 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { match path_res { PathResult::Module(module) => module, - PathResult::Indeterminate => return 3, - PathResult::NonModule(..) | PathResult::Failed { .. } => return 0, + PathResult::Indeterminate => return (None, 3), + PathResult::NonModule(..) | PathResult::Failed { .. } => return (None, 0), } }; - import.imported_module.set_unchecked(Some(module)); - let (source, target, bindings) = match import.kind { - ImportKind::Single { source, target, ref decls, .. } => (source, target, decls), + let (source, bindings) = match import.kind { + ImportKind::Single { source, ref decls, .. } => (source, decls), ImportKind::Glob { .. } => { - self.get_mut_unchecked().resolve_glob_import(import); - return 0; + let import_resolution = ImportResolution { + imported_module: module, + kind: self.resolve_glob_import(import, module), + }; + return (Some(import_resolution), 0); } _ => unreachable!(), }; + let mut import_decls = PerNS::default(); let mut indeterminate_count = 0; self.per_ns_cm(|mut this, ns| { if bindings[ns].get() != PendingDecl::Pending { @@ -1132,54 +1259,26 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { &import.parent_scope, Some(import), ); - let parent = import.parent_scope.module; - let binding = match binding_result { + let pending_decl = match binding_result { Ok(binding) => { - if binding.is_assoc_item() - && !this.tcx.features().import_trait_associated_functions() - { - feature_err( - this.tcx.sess, - sym::import_trait_associated_functions, - import.span, - "`use` associated items of traits is unstable", - ) - .emit(); - } // We need the `target`, `source` can be extracted. let import_decl = this.new_import_decl(binding, import); - this.get_mut_unchecked().plant_decl_into_local_module( - IdentKey::new(target), - target.span, - ns, - import_decl, - ); PendingDecl::Ready(Some(import_decl)) } - Err(Determinacy::Determined) => { - // Don't remove underscores from `single_imports`, they were never added. - if target.name != kw::Underscore { - let key = BindingKey::new(IdentKey::new(target), ns); - this.get_mut_unchecked().update_local_resolution( - parent.expect_local(), - key, - target.span, - |_, resolution| { - resolution.single_imports.swap_remove(&import); - }, - ); - } - PendingDecl::Ready(None) - } + Err(Determinacy::Determined) => PendingDecl::Ready(None), Err(Determinacy::Undetermined) => { indeterminate_count += 1; PendingDecl::Pending } }; - bindings[ns].set_unchecked(binding); + import_decls[ns] = pending_decl; }); + let import_resolution = ImportResolution { + imported_module: module, + kind: ImportResolutionKind::Single(import_decls), + }; - indeterminate_count + (Some(import_resolution), indeterminate_count) } /// Performs final import resolution, consistency checks and error reporting. @@ -1799,68 +1898,72 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { false } - fn resolve_glob_import(&mut self, import: Import<'ra>) { - // This function is only called for glob imports. - let ImportKind::Glob { id, .. } = import.kind else { unreachable!() }; + fn resolve_glob_import( + &self, + import: Import<'ra>, + imported_module: ModuleOrUniformRoot<'ra>, + ) -> ImportResolutionKind<'ra> { + let import_bindings = match imported_module { + ModuleOrUniformRoot::Module(module) if module != import.parent_scope.module => self + .resolutions(module) + .borrow() + .iter() + .filter_map(|(key, resolution)| { + let res = resolution.borrow(); + let decl = res.determined_decl()?; + let mut key = *key; + let scope = match key.ident.ctxt.update_unchecked(|ctxt| { + ctxt.reverse_glob_adjust(module.expansion, import.span) + }) { + Some(Some(def)) => self.expn_def_scope(def), + Some(None) => import.parent_scope.module, + None => return None, + }; + self.is_accessible_from(decl.vis(), scope).then_some(( + decl, + key, + res.orig_ident_span, + )) + }) + .collect::>(), - let ModuleOrUniformRoot::Module(module) = import.imported_module.get().unwrap() else { - self.dcx().emit_err(CannotGlobImportAllCrates { span: import.span }); - return; + // Errors are reported in `write_imports_resolutions` + _ => vec![], }; - if module.is_trait() && !self.tcx.features().import_trait_associated_functions() { - feature_err( - self.tcx.sess, - sym::import_trait_associated_functions, - import.span, - "`use` associated items of traits is unstable", - ) - .emit(); - } - - if module == import.parent_scope.module { - return; - } - - // Add to module's glob_importers - if module.is_local() { - module.glob_importers.borrow_mut_unchecked().push(import); - } + ImportResolutionKind::Glob(import_bindings) + } - // Ensure that `resolutions` isn't borrowed during `try_define`, - // since it might get updated via a glob cycle. - let bindings = self - .resolutions(module) - .borrow() - .iter() - .filter_map(|(key, resolution)| { - let resolution = resolution.borrow(); - resolution.determined_decl().map(|decl| (*key, decl, resolution.orig_ident_span)) - }) - .collect::>(); - for (mut key, binding, orig_ident_span) in bindings { - let scope = - match key.ident.ctxt.update_unchecked(|ctxt| { - ctxt.reverse_glob_adjust(module.expansion, import.span) - }) { - Some(Some(def)) => self.expn_def_scope(def), - Some(None) => import.parent_scope.module, - None => continue, - }; - if self.is_accessible_from(binding.vis(), scope) { - let import_decl = self.new_import_decl(binding, import); - self.try_plant_decl_into_local_module( - key.ident, - orig_ident_span, - key.ns, - import_decl, - ) - .expect("planting a glob cannot fail"); - } + // Hack for the `rust_embed` regression observed in the crater run of #145108. + fn rust_embed_hack(&self, module: LocalModule<'ra>, decl: Decl<'ra>) -> bool { + // We are looking for this pattern: + // ```rust + // #[macro_use] + // extern crate rust_embed_impl; + // pub use rust_embed_impl::*; + // + // pub use RustEmbed as Embed; + // ``` + if let DeclKind::Import { source_decl, import } = decl.kind + // Check that `decl` is the re-export: "pub use RustEmbed as Embed;" + && let ImportKind::Single { source, .. } = import.kind + && source.name == sym::RustEmbed + // make sure that the import points to the #[macro_use] import + && let DeclKind::Import { import, .. } = source_decl.kind + && matches!(import.kind, ImportKind::MacroUse { .. }) + && self.macro_use_prelude.contains_key(&source.name) // and that the name actually exists in the macro_use_prelude + // Then check that `RustEmbed` exists in the modules Macro namespace. + && let Some(y_decl) = self + .resolution(module.to_module(), BindingKey::new(IdentKey::new(source), MacroNS)) + .and_then(|res| res.best_decl()) + // which comes from "pub use rust_embed_impl::*" + && y_decl.is_glob_import() + && y_decl.vis().is_public() + { + return true; } - // Record the destination of this import - self.record_partial_res(id, PartialRes::new(module.res().unwrap())); + false } // Miscellaneous post-processing, including recording re-exports, @@ -1879,13 +1982,17 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { let mut children = Vec::new(); let mut ambig_children = Vec::new(); - module.to_module().for_each_child(self, |_this, ident, orig_ident_span, _, binding| { - let res = binding.res().expect_non_local(); + module.to_module().for_each_child(self, |this, ident, orig_ident_span, _, decl| { + let res = decl.res().expect_non_local(); if res != def::Res::Err { + let vis = if this.rust_embed_hack(module, decl) { + Visibility::Public + } else { + decl.vis() + }; let ident = ident.orig(orig_ident_span); - let child = - |reexport_chain| ModChild { ident, res, vis: binding.vis(), reexport_chain }; - if let Some((ambig_binding1, ambig_binding2)) = binding.descent_to_ambiguity() { + let child = |reexport_chain| ModChild { ident, res, vis, reexport_chain }; + if let Some((ambig_binding1, ambig_binding2)) = decl.descent_to_ambiguity() { let main = child(ambig_binding1.reexport_chain()); let second = ModChild { ident, @@ -1895,7 +2002,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { }; ambig_children.push(AmbigModChild { main, second }) } else { - children.push(child(binding.reexport_chain())); + children.push(child(decl.reexport_chain())); } } }); diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 9af55565d30b7..090722c496fd8 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -2868,16 +2868,10 @@ mod ref_mut { #[track_caller] pub(crate) fn get_mut(&mut self) -> &mut T { match self.mutable { - false => panic!("Can't mutably borrow speculative resolver"), + false => panic!("can't mutably borrow speculative resolver"), true => self.p, } } - - /// Returns a mutable reference to the inner value without checking if - /// it's in a mutable state. - pub(crate) fn get_mut_unchecked(&mut self) -> &mut T { - self.p - } } /// A wrapper around a [`Cell`] that only allows mutation based on a condition in the resolver. @@ -2901,12 +2895,12 @@ mod ref_mut { self.0.get() } - pub(crate) fn update_unchecked(&self, f: impl FnOnce(T) -> T) + pub(crate) fn update<'ra, 'tcx>(&self, r: &Resolver<'ra, 'tcx>, f: impl FnOnce(T) -> T) where T: Copy, { let old = self.get(); - self.set_unchecked(f(old)); + self.set(f(old), r); } } @@ -2915,7 +2909,10 @@ mod ref_mut { CmCell(Cell::new(value)) } - pub(crate) fn set_unchecked(&self, val: T) { + pub(crate) fn set<'ra, 'tcx>(&self, val: T, r: &Resolver<'ra, 'tcx>) { + if r.assert_speculative { + panic!("not allowed to mutate a `CmCell` during speculative resolution") + } self.0.set(val); } @@ -2941,16 +2938,26 @@ mod ref_mut { #[track_caller] pub(crate) fn borrow_mut<'ra, 'tcx>(&self, r: &Resolver<'ra, 'tcx>) -> RefMut<'_, T> { if r.assert_speculative { - panic!("Not allowed to mutably borrow a CmRefCell during speculative resolution"); + panic!("not allowed to mutably borrow a `CmRefCell` during speculative resolution"); } - self.borrow_mut_unchecked() + self.0.borrow_mut() } - #[track_caller] pub(crate) fn try_borrow_mut_unchecked(&self) -> Result, BorrowMutError> { self.0.try_borrow_mut() } + #[track_caller] + pub(crate) fn try_borrow_mut<'ra, 'tcx>( + &self, + r: &Resolver<'ra, 'tcx>, + ) -> Result, BorrowMutError> { + if r.assert_speculative { + panic!("not allowed to mutably borrow a `CmRefCell` during speculative resolution"); + } + self.0.try_borrow_mut() + } + #[track_caller] pub(crate) fn borrow(&self) -> Ref<'_, T> { self.0.borrow() @@ -2960,7 +2967,7 @@ mod ref_mut { impl CmRefCell { pub(crate) fn take<'ra, 'tcx>(&self, r: &Resolver<'ra, 'tcx>) -> T { if r.assert_speculative { - panic!("Not allowed to mutate a CmRefCell during speculative resolution"); + panic!("not allowed to mutate a CmRefCell during speculative resolution"); } self.0.take() } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 9313e869278db..02fe3171cd9f4 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -294,6 +294,8 @@ symbols! { ResumeTy, Reverse, Rust, + // Temporary name for the rust_embed hack introduced in #145108 + RustEmbed, RustaceansAreAwesome, RwLock, RwLockReadGuard, diff --git a/library/core/src/iter/sources/repeat.rs b/library/core/src/iter/sources/repeat.rs index f578ae86a9fce..bdad4adccabac 100644 --- a/library/core/src/iter/sources/repeat.rs +++ b/library/core/src/iter/sources/repeat.rs @@ -101,11 +101,21 @@ impl Iterator for Repeat { Some(self.element.clone()) } + /// Consumes the iterator and panics. + /// + /// # Panics + /// + /// This method always panics because `Repeat` is infinite. #[track_caller] fn last(self) -> Option { panic!("iterator is infinite"); } + /// Consumes the iterator and panics. + /// + /// # Panics + /// + /// This method always panics because `Repeat` is infinite. #[track_caller] fn count(self) -> usize { panic!("iterator is infinite"); diff --git a/library/stdarch/crates/core_arch/src/aarch64/sve/generated.rs b/library/stdarch/crates/core_arch/src/aarch64/sve/generated.rs index 6c6a2476a43fd..e1157f3440cfb 100644 --- a/library/stdarch/crates/core_arch/src/aarch64/sve/generated.rs +++ b/library/stdarch/crates/core_arch/src/aarch64/sve/generated.rs @@ -12,6 +12,7 @@ use stdarch_test::assert_instr; use super::*; use crate::core_arch::arch::aarch64::*; +use super::{AsSigned, AsUnsigned}; #[doc = "Absolute difference"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/svabd[_f32]_m)"] diff --git a/library/stdarch/crates/stdarch-gen-arm/src/main.rs b/library/stdarch/crates/stdarch-gen-arm/src/main.rs index b7e2aa416fb59..717a1707aafe3 100644 --- a/library/stdarch/crates/stdarch-gen-arm/src/main.rs +++ b/library/stdarch/crates/stdarch-gen-arm/src/main.rs @@ -166,7 +166,7 @@ use super::*;{uses_neon} "#, uses_neon = if generated_input.ctx.uses_neon_types { - "\nuse crate::core_arch::arch::aarch64::*;" + "\nuse crate::core_arch::arch::aarch64::*;\nuse super::{AsSigned, AsUnsigned};" } else { "" }, diff --git a/src/etc/lldb_batchmode/runner.py b/src/etc/lldb_batchmode/runner.py index e9b106390f6f9..cdc5458606858 100644 --- a/src/etc/lldb_batchmode/runner.py +++ b/src/etc/lldb_batchmode/runner.py @@ -98,7 +98,7 @@ def execute_command(command_interpreter, command): "registering breakpoint callback, id = " + str(breakpoint_id) ) callback_command = f"breakpoint command add -s python {str(breakpoint_id)} -o \ - 'import lldb_batchmode; lldb_batchmode.breakpoint_callback'" +'import lldb_batchmode; lldb_batchmode.runner.breakpoint_callback'" command_interpreter.HandleCommand(callback_command, res) if res.Succeeded(): diff --git a/src/etc/lldb_lookup.py b/src/etc/lldb_lookup.py index cc3e8411306d9..77c508f3ebb77 100644 --- a/src/etc/lldb_lookup.py +++ b/src/etc/lldb_lookup.py @@ -114,6 +114,8 @@ def __lldb_init_module(debugger: lldb.SBDebugger, _dict: LLDBOpaque): FEATURE_FLAGS |= LLDBFeature.StaticFields if getattr(lldb, "eFormatterMatchCallback", None) is not None: FEATURE_FLAGS |= LLDBFeature.TypeRecognizers + if getattr(lldb, "eBasicTypeFloat128", None) is not None: + FEATURE_FLAGS |= LLDBFeature.Float128 register_providers_compatibility() diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py index 81841dcc4cbb1..f6c2ab8f2b8c7 100644 --- a/src/etc/lldb_providers.py +++ b/src/etc/lldb_providers.py @@ -1,6 +1,6 @@ from __future__ import annotations import sys -from typing import Generator, List, TYPE_CHECKING, Optional +from typing import Generator, Dict, List, TYPE_CHECKING, Optional from enum import Flag, auto from lldb import ( @@ -9,6 +9,15 @@ eBasicTypeLong, eBasicTypeUnsignedLong, eBasicTypeUnsignedChar, + eBasicTypeUnsignedShort, + eBasicTypeUnsignedLongLong, + eBasicTypeSignedChar, + eBasicTypeShort, + eBasicTypeLongLong, + eBasicTypeFloat, + eBasicTypeDouble, + eBasicTypeHalf, + eBasicTypeChar32, eFormatChar, eTypeIsInteger, ) @@ -67,6 +76,9 @@ class LLDBFeature(Flag): """Added in LLDB 18. Adds functions to `SBType` the inspection of a struct's static fields.""" TypeRecognizers = auto() """Added in LLDB 19. Callback-based type matching for synthetic/summary providers.""" + Float128 = auto() + """Added in LLDB 22.1. Adds builtin support for Float 128's, including an `eBasicTypeFloat128`, + a formatter, and handlers in `TypeSystemClang`""" FEATURE_FLAGS: LLDBFeature = LLDBFeature(0) @@ -198,6 +210,21 @@ def get_template_args(type_name: str) -> Generator[str, None, None]: MSVC_PTR_PREFIX: List[str] = ["ref$<", "ref_mut$<", "ptr_const$<", "ptr_mut$<"] +PRIMITIVE_TYPES: Dict[str, int] = { + "u8": eBasicTypeUnsignedChar, + "u16": eBasicTypeUnsignedShort, + "u32": eBasicTypeUnsignedLong, + "u64": eBasicTypeUnsignedLongLong, + "i8": eBasicTypeSignedChar, + "i16": eBasicTypeShort, + "i32": eBasicTypeLong, + "i64": eBasicTypeLongLong, + "f16": eBasicTypeHalf, + "f32": eBasicTypeFloat, + "f64": eBasicTypeDouble, + "char": eBasicTypeChar32, +} + def resolve_msvc_template_arg(arg_name: str, target: SBTarget) -> SBType: """ @@ -214,6 +241,22 @@ def resolve_msvc_template_arg(arg_name: str, target: SBTarget) -> SBType: current version of LLDB, so instead the types are generated via `base_type.GetPointerType()` and `base_type.GetArrayType()`, which bypass the PDB file and ask clang directly for the type node. """ + + # As of LLDB 22, finding primitives based on `FindFirstType` with their rust name no longer + # works. Instead, we can look them up by their `eBasicType` equivalent. For usize and isize, + # we convert them to their bit-sized counterpart before the lookup + if arg_name == "isize" or arg_name == "usize": + equivalent = f"{arg_name[0]}{target.GetAddressByteSize() * 8}" + return target.GetBasicType(PRIMITIVE_TYPES[equivalent]) + + if (basic_type := PRIMITIVE_TYPES.get(arg_name)) is not None: + return target.GetBasicType(basic_type) + + if arg_name == "f128" and LLDBFeature.Float128 in FEATURE_FLAGS: + from lldb import eBasicTypeFloat128 + + return target.GetBasicType(eBasicTypeFloat128) + result = target.FindFirstType(arg_name) if result.IsValid(): diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower/as_place.rs b/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower/as_place.rs index bb00a79480d84..71014eb661742 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower/as_place.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower/as_place.rs @@ -1,7 +1,7 @@ //! MIR lowering for places use hir_def::FunctionId; -use rustc_type_ir::inherent::{Region as _, Ty as _}; +use rustc_type_ir::inherent::Region as _; use super::*; use crate::{ diff --git a/tests/ui/issues/auxiliary/issue-36954.rs b/tests/ui/cross-crate/auxiliary/const-fn-evaluated-cross-crate.rs similarity index 51% rename from tests/ui/issues/auxiliary/issue-36954.rs rename to tests/ui/cross-crate/auxiliary/const-fn-evaluated-cross-crate.rs index bc444a3817b88..9f0900809b18b 100644 --- a/tests/ui/issues/auxiliary/issue-36954.rs +++ b/tests/ui/cross-crate/auxiliary/const-fn-evaluated-cross-crate.rs @@ -1,3 +1,4 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/36954 #![crate_type = "lib"] const fn foo(i: i32) -> i32 { diff --git a/tests/ui/issues/auxiliary/issue-3012-1.rs b/tests/ui/cross-crate/auxiliary/construct-extern-struct-with-destructor.rs similarity index 70% rename from tests/ui/issues/auxiliary/issue-3012-1.rs rename to tests/ui/cross-crate/auxiliary/construct-extern-struct-with-destructor.rs index 509af2a8d7df3..e01835cce563a 100644 --- a/tests/ui/issues/auxiliary/issue-3012-1.rs +++ b/tests/ui/cross-crate/auxiliary/construct-extern-struct-with-destructor.rs @@ -1,4 +1,5 @@ -#![crate_name="socketlib"] +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/3012 +#![crate_name="construct_extern_struct_with_destructor"] #![crate_type = "lib"] pub mod socket { diff --git a/tests/ui/issues/auxiliary/issue-29265.rs b/tests/ui/cross-crate/auxiliary/cross-crate-static-reference-and-field-access.rs similarity index 62% rename from tests/ui/issues/auxiliary/issue-29265.rs rename to tests/ui/cross-crate/auxiliary/cross-crate-static-reference-and-field-access.rs index 6d26002a2e707..5c50ee0d59ce6 100644 --- a/tests/ui/issues/auxiliary/issue-29265.rs +++ b/tests/ui/cross-crate/auxiliary/cross-crate-static-reference-and-field-access.rs @@ -1,3 +1,4 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/29265 #![crate_type = "lib"] pub struct SomeType { diff --git a/tests/ui/issues/auxiliary/issue-3979-traits.rs b/tests/ui/cross-crate/auxiliary/cross-crate-trait-inheritance-on-default-method.rs similarity index 60% rename from tests/ui/issues/auxiliary/issue-3979-traits.rs rename to tests/ui/cross-crate/auxiliary/cross-crate-trait-inheritance-on-default-method.rs index 5d03a0e9e9931..17796ae23d4e2 100644 --- a/tests/ui/issues/auxiliary/issue-3979-traits.rs +++ b/tests/ui/cross-crate/auxiliary/cross-crate-trait-inheritance-on-default-method.rs @@ -1,4 +1,5 @@ -#![crate_name="issue_3979_traits"] +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/3979 +#![crate_name="cross_crate_trait_inheritance_on_default_method"] #![crate_type = "lib"] diff --git a/tests/ui/issues/auxiliary/issue-2526.rs b/tests/ui/cross-crate/auxiliary/cross-crate-type-alias-with-nested-destructors.rs similarity index 82% rename from tests/ui/issues/auxiliary/issue-2526.rs rename to tests/ui/cross-crate/auxiliary/cross-crate-type-alias-with-nested-destructors.rs index 3b27f658cdae5..879f215b24f4e 100644 --- a/tests/ui/issues/auxiliary/issue-2526.rs +++ b/tests/ui/cross-crate/auxiliary/cross-crate-type-alias-with-nested-destructors.rs @@ -1,4 +1,5 @@ -#![crate_name="issue_2526"] +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/2526 +#![crate_name="cross_crate_type_alias_with_nested_destructors"] #![crate_type = "lib"] use std::marker; diff --git a/tests/ui/issues/auxiliary/issue-38226-aux.rs b/tests/ui/cross-crate/auxiliary/default-trait-method-reachable-through-trait-object.rs similarity index 80% rename from tests/ui/issues/auxiliary/issue-38226-aux.rs rename to tests/ui/cross-crate/auxiliary/default-trait-method-reachable-through-trait-object.rs index a8e964e016fd1..b14a140de18f5 100644 --- a/tests/ui/issues/auxiliary/issue-38226-aux.rs +++ b/tests/ui/cross-crate/auxiliary/default-trait-method-reachable-through-trait-object.rs @@ -1,3 +1,4 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/38226 #![crate_type="rlib"] #[inline(never)] diff --git a/tests/ui/cross-crate/auxiliary/extern-crate-and-impl-inside-method-body.rs b/tests/ui/cross-crate/auxiliary/extern-crate-and-impl-inside-method-body.rs new file mode 100644 index 0000000000000..cd011fc294c44 --- /dev/null +++ b/tests/ui/cross-crate/auxiliary/extern-crate-and-impl-inside-method-body.rs @@ -0,0 +1,2 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/41053 +pub struct Test; diff --git a/tests/ui/cross-crate/auxiliary/extern-generic-tuple-struct-construction.rs b/tests/ui/cross-crate/auxiliary/extern-generic-tuple-struct-construction.rs new file mode 100644 index 0000000000000..1a27ca252a30e --- /dev/null +++ b/tests/ui/cross-crate/auxiliary/extern-generic-tuple-struct-construction.rs @@ -0,0 +1,3 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/4545 +pub struct S(Option); +pub fn mk() -> S { S(None) } diff --git a/tests/ui/cross-crate/auxiliary/extern-repr-enum-with-discriminant-cast.rs b/tests/ui/cross-crate/auxiliary/extern-repr-enum-with-discriminant-cast.rs new file mode 100644 index 0000000000000..85819006c78ae --- /dev/null +++ b/tests/ui/cross-crate/auxiliary/extern-repr-enum-with-discriminant-cast.rs @@ -0,0 +1,5 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/42007 +#[repr(u8)] +pub enum E { + B = 1 as u8, +} diff --git a/tests/ui/cross-crate/auxiliary/extern-trait-bound-with-array-associated-type.rs b/tests/ui/cross-crate/auxiliary/extern-trait-bound-with-array-associated-type.rs new file mode 100644 index 0000000000000..d383b9ff64b80 --- /dev/null +++ b/tests/ui/cross-crate/auxiliary/extern-trait-bound-with-array-associated-type.rs @@ -0,0 +1,7 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/48984 +#![crate_type = "lib"] +#![crate_name = "extern_trait_bound_with_array_associated_type"] + +pub trait Foo { type Item; } + +pub trait Bar: Foo { } diff --git a/tests/ui/issues/auxiliary/issue-2723-a.rs b/tests/ui/cross-crate/auxiliary/fn-declared-inside-closure-body-cross-crate.rs similarity index 57% rename from tests/ui/issues/auxiliary/issue-2723-a.rs rename to tests/ui/cross-crate/auxiliary/fn-declared-inside-closure-body-cross-crate.rs index 661b46d829dfe..6346ebfb54dd4 100644 --- a/tests/ui/issues/auxiliary/issue-2723-a.rs +++ b/tests/ui/cross-crate/auxiliary/fn-declared-inside-closure-body-cross-crate.rs @@ -1,3 +1,4 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/2723 pub unsafe fn f(xs: Vec ) { xs.iter().map(|_x| { unsafe fn q() { panic!(); } }).collect::>(); } diff --git a/tests/ui/issues/auxiliary/issue-2380.rs b/tests/ui/cross-crate/auxiliary/fn-local-impl-returned-as-trait-object.rs similarity index 72% rename from tests/ui/issues/auxiliary/issue-2380.rs rename to tests/ui/cross-crate/auxiliary/fn-local-impl-returned-as-trait-object.rs index 9ec829b417f81..420792577cf04 100644 --- a/tests/ui/issues/auxiliary/issue-2380.rs +++ b/tests/ui/cross-crate/auxiliary/fn-local-impl-returned-as-trait-object.rs @@ -1,3 +1,4 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/2380 #![crate_name="a"] #![crate_type = "lib"] diff --git a/tests/ui/cross-crate/auxiliary/for-loop-in-match-on-self.rs b/tests/ui/cross-crate/auxiliary/for-loop-in-match-on-self.rs index 307f23c10e284..db1f5edb4507e 100644 --- a/tests/ui/cross-crate/auxiliary/for-loop-in-match-on-self.rs +++ b/tests/ui/cross-crate/auxiliary/for-loop-in-match-on-self.rs @@ -1,5 +1,4 @@ -//! Auxiliary crate for . - +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/16643 #![crate_type = "lib"] pub struct TreeBuilder { pub h: H } diff --git a/tests/ui/issues/auxiliary/issue-4208-cc.rs b/tests/ui/cross-crate/auxiliary/generic-fn-with-supertrait-bound-cross-crate.rs similarity index 52% rename from tests/ui/issues/auxiliary/issue-4208-cc.rs rename to tests/ui/cross-crate/auxiliary/generic-fn-with-supertrait-bound-cross-crate.rs index 7b4c8b01a9e2f..ad0fe922d6f2f 100644 --- a/tests/ui/issues/auxiliary/issue-4208-cc.rs +++ b/tests/ui/cross-crate/auxiliary/generic-fn-with-supertrait-bound-cross-crate.rs @@ -1,4 +1,5 @@ -#![crate_name="numeric"] +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/4208 +#![crate_name="generic_fn_with_supertrait_bound_cross_crate"] #![crate_type = "lib"] pub trait Trig { diff --git a/tests/ui/cross-crate/auxiliary/graceful-error-for-mistyped-assoc-const.rs b/tests/ui/cross-crate/auxiliary/graceful-error-for-mistyped-assoc-const.rs new file mode 100644 index 0000000000000..84ac2b5ae9de3 --- /dev/null +++ b/tests/ui/cross-crate/auxiliary/graceful-error-for-mistyped-assoc-const.rs @@ -0,0 +1,4 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/41549 +pub trait Trait { + const CONST: u32; +} diff --git a/tests/ui/cross-crate/auxiliary/impl-extern-trait-with-associated-type.rs b/tests/ui/cross-crate/auxiliary/impl-extern-trait-with-associated-type.rs new file mode 100644 index 0000000000000..5d935380e0649 --- /dev/null +++ b/tests/ui/cross-crate/auxiliary/impl-extern-trait-with-associated-type.rs @@ -0,0 +1,5 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/20389 +pub trait T { + type C; + fn dummy(&self) { } +} diff --git a/tests/ui/cross-crate/auxiliary/imported-struct-not-confused-with-variant.rs b/tests/ui/cross-crate/auxiliary/imported-struct-not-confused-with-variant.rs new file mode 100644 index 0000000000000..4f70e98f22af9 --- /dev/null +++ b/tests/ui/cross-crate/auxiliary/imported-struct-not-confused-with-variant.rs @@ -0,0 +1,5 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/19293 +pub struct Foo (pub isize); +pub enum MyEnum { + Foo(Foo), +} diff --git a/tests/ui/issues/auxiliary/issue-2170-lib.rs b/tests/ui/cross-crate/auxiliary/link-extern-crate-with-drop-type.rs similarity index 68% rename from tests/ui/issues/auxiliary/issue-2170-lib.rs rename to tests/ui/cross-crate/auxiliary/link-extern-crate-with-drop-type.rs index a99385a834dfb..e498dd0758cef 100644 --- a/tests/ui/issues/auxiliary/issue-2170-lib.rs +++ b/tests/ui/cross-crate/auxiliary/link-extern-crate-with-drop-type.rs @@ -1,3 +1,4 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/20389 fn foo(_x: i32) { } diff --git a/tests/ui/cross-crate/auxiliary/macro-generated-module-path-resolution.rs b/tests/ui/cross-crate/auxiliary/macro-generated-module-path-resolution.rs new file mode 100644 index 0000000000000..f808fa793e475 --- /dev/null +++ b/tests/ui/cross-crate/auxiliary/macro-generated-module-path-resolution.rs @@ -0,0 +1,3 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/38190 +#[macro_export] +macro_rules! m { ([$i:item]) => {} } diff --git a/tests/ui/cross-crate/auxiliary/method-call-on-extern-fn-return-value.rs b/tests/ui/cross-crate/auxiliary/method-call-on-extern-fn-return-value.rs new file mode 100644 index 0000000000000..02f85ee90ee6b --- /dev/null +++ b/tests/ui/cross-crate/auxiliary/method-call-on-extern-fn-return-value.rs @@ -0,0 +1,4 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/51798 +#![crate_type = "lib"] + +pub fn vec() -> Vec { vec![] } diff --git a/tests/ui/issues/auxiliary/issue-2631-a.rs b/tests/ui/cross-crate/auxiliary/monomorphize-index-op-cross-crate.rs similarity index 81% rename from tests/ui/issues/auxiliary/issue-2631-a.rs rename to tests/ui/cross-crate/auxiliary/monomorphize-index-op-cross-crate.rs index 1e8211bfaa783..6ab538044fa5c 100644 --- a/tests/ui/issues/auxiliary/issue-2631-a.rs +++ b/tests/ui/cross-crate/auxiliary/monomorphize-index-op-cross-crate.rs @@ -1,3 +1,4 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/2631 #![crate_name="req"] #![crate_type = "lib"] diff --git a/tests/ui/issues/auxiliary/issue-29485.rs b/tests/ui/cross-crate/auxiliary/mut-ref-write-visible-after-unwind.rs similarity index 58% rename from tests/ui/issues/auxiliary/issue-29485.rs rename to tests/ui/cross-crate/auxiliary/mut-ref-write-visible-after-unwind.rs index 1e8891c51206f..2545f4f0c48cc 100644 --- a/tests/ui/issues/auxiliary/issue-29485.rs +++ b/tests/ui/cross-crate/auxiliary/mut-ref-write-visible-after-unwind.rs @@ -1,4 +1,5 @@ -#![crate_name="a"] +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/29265 +#![crate_name="mut_ref_write_visible_after_unwind"] #![crate_type = "lib"] pub struct X(pub u8); diff --git a/tests/ui/issues/auxiliary/issue-3136-a.rs b/tests/ui/cross-crate/auxiliary/nested-struct-in-polymorphic-impl-method.rs similarity index 76% rename from tests/ui/issues/auxiliary/issue-3136-a.rs rename to tests/ui/cross-crate/auxiliary/nested-struct-in-polymorphic-impl-method.rs index 22bb1c8f97709..24f7601b67125 100644 --- a/tests/ui/issues/auxiliary/issue-3136-a.rs +++ b/tests/ui/cross-crate/auxiliary/nested-struct-in-polymorphic-impl-method.rs @@ -1,3 +1,4 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/3136 #![crate_type = "lib"] trait x { diff --git a/tests/ui/issues/auxiliary/cgu_test_a.rs b/tests/ui/cross-crate/auxiliary/no-duplicate-symbols-with-codegen-units-cgu-test-a.rs similarity index 56% rename from tests/ui/issues/auxiliary/cgu_test_a.rs rename to tests/ui/cross-crate/auxiliary/no-duplicate-symbols-with-codegen-units-cgu-test-a.rs index 7998f1870b8fe..22618804fe629 100644 --- a/tests/ui/issues/auxiliary/cgu_test_a.rs +++ b/tests/ui/cross-crate/auxiliary/no-duplicate-symbols-with-codegen-units-cgu-test-a.rs @@ -1,7 +1,8 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/32518 //@ no-prefer-dynamic //@ compile-flags: -Ccodegen-units=2 --crate-type=lib -extern crate cgu_test; +extern crate no_duplicate_symbols_with_codegen_units_cgu_test as cgu_test; pub mod a { pub fn a() { diff --git a/tests/ui/issues/auxiliary/cgu_test_b.rs b/tests/ui/cross-crate/auxiliary/no-duplicate-symbols-with-codegen-units-cgu-test-b.rs similarity index 56% rename from tests/ui/issues/auxiliary/cgu_test_b.rs rename to tests/ui/cross-crate/auxiliary/no-duplicate-symbols-with-codegen-units-cgu-test-b.rs index 7998f1870b8fe..22618804fe629 100644 --- a/tests/ui/issues/auxiliary/cgu_test_b.rs +++ b/tests/ui/cross-crate/auxiliary/no-duplicate-symbols-with-codegen-units-cgu-test-b.rs @@ -1,7 +1,8 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/32518 //@ no-prefer-dynamic //@ compile-flags: -Ccodegen-units=2 --crate-type=lib -extern crate cgu_test; +extern crate no_duplicate_symbols_with_codegen_units_cgu_test as cgu_test; pub mod a { pub fn a() { diff --git a/tests/ui/issues/auxiliary/cgu_test.rs b/tests/ui/cross-crate/auxiliary/no-duplicate-symbols-with-codegen-units-cgu-test.rs similarity index 51% rename from tests/ui/issues/auxiliary/cgu_test.rs rename to tests/ui/cross-crate/auxiliary/no-duplicate-symbols-with-codegen-units-cgu-test.rs index 1103fcb1f0b28..73dd32b34ba8b 100644 --- a/tests/ui/issues/auxiliary/cgu_test.rs +++ b/tests/ui/cross-crate/auxiliary/no-duplicate-symbols-with-codegen-units-cgu-test.rs @@ -1,3 +1,4 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/32518 //@ no-prefer-dynamic //@ compile-flags: --crate-type=lib diff --git a/tests/ui/issues/auxiliary/issue-31702-1.rs b/tests/ui/cross-crate/auxiliary/optimized-closure-with-debug-info-cross-crate-1.rs similarity index 74% rename from tests/ui/issues/auxiliary/issue-31702-1.rs rename to tests/ui/cross-crate/auxiliary/optimized-closure-with-debug-info-cross-crate-1.rs index a48d0dc2c6447..b14ce0b0dc190 100644 --- a/tests/ui/issues/auxiliary/issue-31702-1.rs +++ b/tests/ui/cross-crate/auxiliary/optimized-closure-with-debug-info-cross-crate-1.rs @@ -1,3 +1,4 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/31702 #[derive(Copy)] pub struct U256(pub [u64; 4]); diff --git a/tests/ui/issues/auxiliary/issue-31702-2.rs b/tests/ui/cross-crate/auxiliary/optimized-closure-with-debug-info-cross-crate-2.rs similarity index 67% rename from tests/ui/issues/auxiliary/issue-31702-2.rs rename to tests/ui/cross-crate/auxiliary/optimized-closure-with-debug-info-cross-crate-2.rs index 16300b0f5d530..05da5e21824cd 100644 --- a/tests/ui/issues/auxiliary/issue-31702-2.rs +++ b/tests/ui/cross-crate/auxiliary/optimized-closure-with-debug-info-cross-crate-2.rs @@ -1,9 +1,10 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/31702 //@ compile-flags: -g -extern crate issue_31702_1; +extern crate optimized_closure_with_debug_info_cross_crate_1; use std::collections::HashMap; -use issue_31702_1::U256; +use optimized_closure_with_debug_info_cross_crate_1::U256; pub struct Ethash { engine_params: fn() -> Option<&'static Vec>, diff --git a/tests/ui/issues/auxiliary/issue-34796-aux.rs b/tests/ui/cross-crate/auxiliary/stable-hash-for-trait-object-type.rs similarity index 76% rename from tests/ui/issues/auxiliary/issue-34796-aux.rs rename to tests/ui/cross-crate/auxiliary/stable-hash-for-trait-object-type.rs index 0e91bb4bcdc1f..a3c278db38a60 100644 --- a/tests/ui/issues/auxiliary/issue-34796-aux.rs +++ b/tests/ui/cross-crate/auxiliary/stable-hash-for-trait-object-type.rs @@ -1,3 +1,4 @@ +//! Auxiliary crate for regression test of https://github.com/rust-lang/rust/issues/34796 #![crate_type = "lib"] pub trait Future { type Item; diff --git a/tests/ui/issues/auxiliary/issue-25467.rs b/tests/ui/cross-crate/auxiliary/trait-object-projection-bounds-with-interning-order.rs similarity index 76% rename from tests/ui/issues/auxiliary/issue-25467.rs rename to tests/ui/cross-crate/auxiliary/trait-object-projection-bounds-with-interning-order.rs index 16c2869dc75cc..eb58bb5d29d06 100644 --- a/tests/ui/issues/auxiliary/issue-25467.rs +++ b/tests/ui/cross-crate/auxiliary/trait-object-projection-bounds-with-interning-order.rs @@ -1,3 +1,4 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/25467 #![crate_type="lib"] pub trait Trait { diff --git a/tests/ui/issues/auxiliary/issue-2414-a.rs b/tests/ui/cross-crate/auxiliary/transitive-crate-dependency-with-trait-impl-a.rs similarity index 62% rename from tests/ui/issues/auxiliary/issue-2414-a.rs rename to tests/ui/cross-crate/auxiliary/transitive-crate-dependency-with-trait-impl-a.rs index b90ab32ddc4ad..58d79571f8d97 100644 --- a/tests/ui/issues/auxiliary/issue-2414-a.rs +++ b/tests/ui/cross-crate/auxiliary/transitive-crate-dependency-with-trait-impl-a.rs @@ -1,3 +1,4 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/2414 #![crate_name="a"] #![crate_type = "lib"] diff --git a/tests/ui/cross-crate/auxiliary/transitive-crate-dependency-with-trait-impl-b.rs b/tests/ui/cross-crate/auxiliary/transitive-crate-dependency-with-trait-impl-b.rs new file mode 100644 index 0000000000000..eddb36bc4d0fa --- /dev/null +++ b/tests/ui/cross-crate/auxiliary/transitive-crate-dependency-with-trait-impl-b.rs @@ -0,0 +1,5 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/2414 +#![crate_name="b"] +#![crate_type = "lib"] + +extern crate a; diff --git a/tests/ui/issues/auxiliary/issue-30123-aux.rs b/tests/ui/cross-crate/auxiliary/type-default-applied-in-cross-crate-method-lookup.rs similarity index 85% rename from tests/ui/issues/auxiliary/issue-30123-aux.rs rename to tests/ui/cross-crate/auxiliary/type-default-applied-in-cross-crate-method-lookup.rs index 07c743eb2aa34..68b9f6843ddbd 100644 --- a/tests/ui/issues/auxiliary/issue-30123-aux.rs +++ b/tests/ui/cross-crate/auxiliary/type-default-applied-in-cross-crate-method-lookup.rs @@ -1,3 +1,4 @@ +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/30123 use std::marker::PhantomData; pub struct Directed; diff --git a/tests/ui/cross-crate/const-fn-evaluated-cross-crate.rs b/tests/ui/cross-crate/const-fn-evaluated-cross-crate.rs new file mode 100644 index 0000000000000..cf0843f01ce8a --- /dev/null +++ b/tests/ui/cross-crate/const-fn-evaluated-cross-crate.rs @@ -0,0 +1,12 @@ +//@ run-pass +//@ aux-build:const-fn-evaluated-cross-crate.rs +//! Regression test for https://github.com/rust-lang/rust/issues/36954 +//! Cross crate const fn evaluation failed because the compiler's +//! internal argument lookup table used crate local ids that didn't +//! exist when evaluating a const fn from another crate. + +extern crate const_fn_evaluated_cross_crate as lib; + +fn main() { + let _ = lib::FOO; +} diff --git a/tests/ui/cross-crate/construct-extern-struct-with-destructor.rs b/tests/ui/cross-crate/construct-extern-struct-with-destructor.rs new file mode 100644 index 0000000000000..d916305bbc764 --- /dev/null +++ b/tests/ui/cross-crate/construct-extern-struct-with-destructor.rs @@ -0,0 +1,14 @@ +//@ run-pass +//@ aux-build:construct-extern-struct-with-destructor.rs + +//! Regression test for https://github.com/rust-lang/rust/issues/3012 +//! Guarantees that you can construct cross crate structs. + +extern crate construct_extern_struct_with_destructor as socketlib; + +use socketlib::socket; + +pub fn main() { + let fd: u32 = 1 as u32; + let _sock: Box<_> = Box::new(socket::socket_handle(fd)); +} diff --git a/tests/ui/cross-crate/cross-crate-static-reference-and-field-access.rs b/tests/ui/cross-crate/cross-crate-static-reference-and-field-access.rs new file mode 100644 index 0000000000000..25e52c153ba0e --- /dev/null +++ b/tests/ui/cross-crate/cross-crate-static-reference-and-field-access.rs @@ -0,0 +1,14 @@ +//@ aux-build:cross-crate-static-reference-and-field-access.rs +//@ check-pass + +//! Regression test for https://github.com/rust-lang/rust/issues/29265 +//! Exposed an bug where referencing a static variable from another crate +//! was causing an error. + +extern crate cross_crate_static_reference_and_field_access as lib; + +static _UNUSED: &'static lib::SomeType = &lib::SOME_VALUE; + +fn main() { + vec![0u8; lib::SOME_VALUE.some_member]; +} diff --git a/tests/ui/issues/issue-3979-xcrate.rs b/tests/ui/cross-crate/cross-crate-trait-inheritance-on-default-method.rs similarity index 55% rename from tests/ui/issues/issue-3979-xcrate.rs rename to tests/ui/cross-crate/cross-crate-trait-inheritance-on-default-method.rs index 7660405929bfb..3ff481d2c17e9 100644 --- a/tests/ui/issues/issue-3979-xcrate.rs +++ b/tests/ui/cross-crate/cross-crate-trait-inheritance-on-default-method.rs @@ -1,8 +1,10 @@ //@ run-pass #![allow(dead_code)] -//@ aux-build:issue-3979-traits.rs +//@ aux-build:cross-crate-trait-inheritance-on-default-method.rs +//! Regression test for https://github.com/rust-lang/rust/issues/3979 +//! Exposed a bug where external traits on a default method were failing to typecheck. -extern crate issue_3979_traits; +extern crate cross_crate_trait_inheritance_on_default_method as issue_3979_traits; use issue_3979_traits::{Positioned, Movable}; struct Point { x: isize, y: isize } diff --git a/tests/ui/cross-crate/cross-crate-type-alias-with-nested-destructors.rs b/tests/ui/cross-crate/cross-crate-type-alias-with-nested-destructors.rs new file mode 100644 index 0000000000000..c12dc04f5ab4a --- /dev/null +++ b/tests/ui/cross-crate/cross-crate-type-alias-with-nested-destructors.rs @@ -0,0 +1,11 @@ +//@ run-pass +//@ aux-build:cross-crate-type-alias-with-nested-destructors.rs + +//! Regression test for https://github.com/rust-lang/rust/issues/2526 + +#![allow(unused_imports)] + +extern crate cross_crate_type_alias_with_nested_destructors; +use cross_crate_type_alias_with_nested_destructors::*; + +pub fn main() {} diff --git a/tests/ui/issues/issue-38226.rs b/tests/ui/cross-crate/default-trait-method-reachable-through-trait-object.rs similarity index 71% rename from tests/ui/issues/issue-38226.rs rename to tests/ui/cross-crate/default-trait-method-reachable-through-trait-object.rs index d8bd9d64a7c60..a7683252757e8 100644 --- a/tests/ui/issues/issue-38226.rs +++ b/tests/ui/cross-crate/default-trait-method-reachable-through-trait-object.rs @@ -2,13 +2,13 @@ // This test makes sure that we don't run into a linker error because of the // middle::reachable pass missing trait methods with default impls. -//@ aux-build:issue-38226-aux.rs +//@ aux-build:default-trait-method-reachable-through-trait-object.rs // Need -Cno-prepopulate-passes to really disable inlining, otherwise the faulty // code gets optimized out: //@ compile-flags: -Cno-prepopulate-passes -Cpasses=name-anon-globals -extern crate issue_38226_aux; +extern crate default_trait_method_reachable_through_trait_object as issue_38226_aux; fn main() { issue_38226_aux::foo::<()>(); diff --git a/tests/ui/issues/issue-41053.rs b/tests/ui/cross-crate/extern-crate-and-impl-inside-method-body.rs similarity index 51% rename from tests/ui/issues/issue-41053.rs rename to tests/ui/cross-crate/extern-crate-and-impl-inside-method-body.rs index 42b0b008ce9b5..15ce563d575d9 100644 --- a/tests/ui/issues/issue-41053.rs +++ b/tests/ui/cross-crate/extern-crate-and-impl-inside-method-body.rs @@ -1,5 +1,10 @@ //@ run-pass -//@ aux-build:issue-41053.rs +//@ aux-build:extern-crate-and-impl-inside-method-body.rs + +//! Regression test for https://github.com/rust-lang/rust/issues/41053 +//! An extern crate declaration and trait impl referencing that crate +//! inside an impl method body triggered a borrow conflict in the +//! compiler's visible_parent_map. #![allow(non_local_definitions)] @@ -10,7 +15,7 @@ pub struct Foo; impl Iterator for Foo { type Item = Box; fn next(&mut self) -> Option> { - extern crate issue_41053; + extern crate extern_crate_and_impl_inside_method_body as issue_41053; impl crate::Trait for issue_41053::Test { fn foo(&self) {} } diff --git a/tests/ui/cross-crate/extern-generic-tuple-struct-construction.rs b/tests/ui/cross-crate/extern-generic-tuple-struct-construction.rs new file mode 100644 index 0000000000000..98d1fec370da9 --- /dev/null +++ b/tests/ui/cross-crate/extern-generic-tuple-struct-construction.rs @@ -0,0 +1,6 @@ +//@ run-pass +//@ aux-build:extern-generic-tuple-struct-construction.rs +//! Regression test for https://github.com/rust-lang/rust/issues/4545 + +extern crate extern_generic_tuple_struct_construction as somelib; +pub fn main() { somelib::mk::(); } diff --git a/tests/ui/cross-crate/extern-repr-enum-with-discriminant-cast.rs b/tests/ui/cross-crate/extern-repr-enum-with-discriminant-cast.rs new file mode 100644 index 0000000000000..96f345d002d86 --- /dev/null +++ b/tests/ui/cross-crate/extern-repr-enum-with-discriminant-cast.rs @@ -0,0 +1,15 @@ +//@ run-pass +#![allow(dead_code)] +//@ aux-build:extern-repr-enum-with-discriminant-cast.rs +//! Regression test for https://github.com/rust-lang/rust/issues/42007 +//! This test exposes a bug that happens because the Session LintStore is emptied when linting +//! The LintStore is emptied because the checker wants ownership as it wants to +//! mutate the pass objects and lint levels. +//! The fix was not taking ownership of the entire store just the lint levels and pass objects. +extern crate extern_repr_enum_with_discriminant_cast as issue_42007_s; + +enum I { + E(issue_42007_s::E), +} + +fn main() {} diff --git a/tests/ui/cross-crate/extern-trait-bound-with-array-associated-type.rs b/tests/ui/cross-crate/extern-trait-bound-with-array-associated-type.rs new file mode 100644 index 0000000000000..a0b5d0e876963 --- /dev/null +++ b/tests/ui/cross-crate/extern-trait-bound-with-array-associated-type.rs @@ -0,0 +1,15 @@ +//@ run-pass +#![allow(dead_code)] +//@ aux-build:extern-trait-bound-with-array-associated-type.rs +//! Regression test for https://github.com/rust-lang/rust/issues/48984 +//! This test exposes an error that occurs when a base trait has at +//! least one associated type, and the extending trait specifies the +//! associated type as an array of some kind. In order to trigger the +//! error, the extending trait must be defined in an external crate, and +//! used to constrain a generic type parameter. +extern crate extern_trait_bound_with_array_associated_type as issue48984aux; +use issue48984aux::Bar; + +fn do_thing() { } + +fn main() { } diff --git a/tests/ui/cross-crate/fn-declared-inside-closure-body-cross-crate.rs b/tests/ui/cross-crate/fn-declared-inside-closure-body-cross-crate.rs new file mode 100644 index 0000000000000..9d47358777c53 --- /dev/null +++ b/tests/ui/cross-crate/fn-declared-inside-closure-body-cross-crate.rs @@ -0,0 +1,13 @@ +//@ run-pass +//@ aux-build:fn-declared-inside-closure-body-cross-crate.rs + +//! Regression test for https://github.com/rust-lang/rust/issues/2723 + +extern crate fn_declared_inside_closure_body_cross_crate; +use fn_declared_inside_closure_body_cross_crate::f; + +pub fn main() { + unsafe { + f(vec![2]); + } +} diff --git a/tests/ui/cross-crate/fn-local-impl-returned-as-trait-object.rs b/tests/ui/cross-crate/fn-local-impl-returned-as-trait-object.rs new file mode 100644 index 0000000000000..0fc404784e22b --- /dev/null +++ b/tests/ui/cross-crate/fn-local-impl-returned-as-trait-object.rs @@ -0,0 +1,12 @@ +//@ run-pass +//@ aux-build:fn-local-impl-returned-as-trait-object.rs +//! Regression test for https://github.com/rust-lang/rust/issues/2380 +//! This test exposes a bug where a function that defines a trait impl inside its body +//! and returns it as a trait object failed because the reachability pass skipped nested +//! items in function bodies. + +extern crate a; + +pub fn main() { + a::f::<()>(); +} diff --git a/tests/ui/cross-crate/generic-fn-with-supertrait-bound-cross-crate.rs b/tests/ui/cross-crate/generic-fn-with-supertrait-bound-cross-crate.rs new file mode 100644 index 0000000000000..bce55b2140068 --- /dev/null +++ b/tests/ui/cross-crate/generic-fn-with-supertrait-bound-cross-crate.rs @@ -0,0 +1,11 @@ +//@ run-pass +#![allow(dead_code)] +//@ aux-build:generic-fn-with-supertrait-bound-cross-crate.rs + +//! Regression test for https://github.com/rust-lang/rust/issues/4208 +extern crate generic_fn_with_supertrait_bound_cross_crate as numeric; +use numeric::{sin, Angle}; + +fn foo>(theta: A) -> T { sin(&theta) } + +pub fn main() {} diff --git a/tests/ui/cross-crate/graceful-error-for-mistyped-assoc-const.rs b/tests/ui/cross-crate/graceful-error-for-mistyped-assoc-const.rs new file mode 100644 index 0000000000000..238fb6bf0e738 --- /dev/null +++ b/tests/ui/cross-crate/graceful-error-for-mistyped-assoc-const.rs @@ -0,0 +1,13 @@ +//@ aux-build:graceful-error-for-mistyped-assoc-const.rs +//! Regression test for https://github.com/rust-lang/rust/issues/41549 +//! Mismatched types on exernal associated constants used to ice, +//! this test confirms that it errors correctly. +extern crate graceful_error_for_mistyped_assoc_const as issue_41549; + +struct S; + +impl issue_41549::Trait for S { + const CONST: () = (); //~ ERROR incompatible type for trait +} + +fn main() {} diff --git a/tests/ui/issues/issue-41549.stderr b/tests/ui/cross-crate/graceful-error-for-mistyped-assoc-const.stderr similarity index 81% rename from tests/ui/issues/issue-41549.stderr rename to tests/ui/cross-crate/graceful-error-for-mistyped-assoc-const.stderr index 55be59684b55d..18b06462de7b6 100644 --- a/tests/ui/issues/issue-41549.stderr +++ b/tests/ui/cross-crate/graceful-error-for-mistyped-assoc-const.stderr @@ -1,5 +1,5 @@ error[E0326]: implemented const `CONST` has an incompatible type for trait - --> $DIR/issue-41549.rs:9:18 + --> $DIR/graceful-error-for-mistyped-assoc-const.rs:10:18 | LL | const CONST: () = (); | ^^ expected `u32`, found `()` diff --git a/tests/ui/cross-crate/impl-extern-trait-with-associated-type.rs b/tests/ui/cross-crate/impl-extern-trait-with-associated-type.rs new file mode 100644 index 0000000000000..c6905e9002b29 --- /dev/null +++ b/tests/ui/cross-crate/impl-extern-trait-with-associated-type.rs @@ -0,0 +1,16 @@ +//@ run-pass +#![allow(dead_code)] +//@ aux-build:impl-extern-trait-with-associated-type.rs +//! Regression test for https://github.com/rust-lang/rust/issues/20389 +//! This test confirms that code implementing a trait with an associated type from an external crate +//! runs. + +extern crate impl_extern_trait_with_associated_type; + +struct Foo; + +impl impl_extern_trait_with_associated_type::T for Foo { + type C = (); +} + +fn main() {} diff --git a/tests/ui/cross-crate/imported-struct-not-confused-with-variant.rs b/tests/ui/cross-crate/imported-struct-not-confused-with-variant.rs new file mode 100644 index 0000000000000..458fc32be0cea --- /dev/null +++ b/tests/ui/cross-crate/imported-struct-not-confused-with-variant.rs @@ -0,0 +1,12 @@ +//@ run-pass +//@ aux-build:imported-struct-not-confused-with-variant.rs + +//! Regression test for https://github.com/rust-lang/rust/issues/19293 +//! This test ensures that cross crate variants are properly namespaced under their enum or struct. + +extern crate imported_struct_not_confused_with_variant; +use imported_struct_not_confused_with_variant::{Foo, MyEnum}; + +fn main() { + MyEnum::Foo(Foo(5)); +} diff --git a/tests/ui/cross-crate/link-extern-crate-with-drop-type.rs b/tests/ui/cross-crate/link-extern-crate-with-drop-type.rs new file mode 100644 index 0000000000000..623a644dcbf9f --- /dev/null +++ b/tests/ui/cross-crate/link-extern-crate-with-drop-type.rs @@ -0,0 +1,11 @@ +//@ run-pass +//@ aux-build:link-extern-crate-with-drop-type.rs +//! Regression test for https://github.com/rust-lang/rust/issues/2170 +//! This test just verifies that linking against an external crate works without +//! a metadata failure. Apparently, having a Drop that calls another function is the trigger. + +extern crate link_extern_crate_with_drop_type; + +pub fn main() { + // let _ = issue_2170_lib::rsrc(2); +} diff --git a/tests/ui/cross-crate/macro-generated-module-path-resolution.rs b/tests/ui/cross-crate/macro-generated-module-path-resolution.rs new file mode 100644 index 0000000000000..f785c24a83623 --- /dev/null +++ b/tests/ui/cross-crate/macro-generated-module-path-resolution.rs @@ -0,0 +1,18 @@ +//@ run-pass +//@ aux-build:macro-generated-module-path-resolution.rs +//! Regression test for https://github.com/rust-lang/rust/issues/38190 +//! Non inline modules parsed as macro item fragments used the wrong +//! directory for file resolution, because the fragment parser didn't +//! inherit the correct directory from the macro invocation context. + +#[macro_use] +extern crate macro_generated_module_path_resolution as aux; + +mod auxiliary { + m!([ + #[path = "macro-generated-module-path-resolution"] + mod aux; + ]); +} + +fn main() {} diff --git a/tests/ui/cross-crate/method-call-on-extern-fn-return-value.rs b/tests/ui/cross-crate/method-call-on-extern-fn-return-value.rs new file mode 100644 index 0000000000000..26a24aeb8ca99 --- /dev/null +++ b/tests/ui/cross-crate/method-call-on-extern-fn-return-value.rs @@ -0,0 +1,18 @@ +//@ edition:2018 +//@ aux-build:method-call-on-extern-fn-return-value.rs +//@ check-pass +//! Regression test for https://github.com/rust-lang/rust/issues/51798 +//! Calling a method on a value returned from an external crate function +//! caused the privacy checker to panic when looking up the method's +//! type dependent definition. Requires 2018 edition. + +extern crate method_call_on_extern_fn_return_value as issue_51798; + +mod server { + fn f() { + let mut v = issue_51798::vec(); + v.clear(); + } +} + +fn main() {} diff --git a/tests/ui/issues/issue-2631-b.rs b/tests/ui/cross-crate/monomorphize-index-op-cross-crate.rs similarity index 72% rename from tests/ui/issues/issue-2631-b.rs rename to tests/ui/cross-crate/monomorphize-index-op-cross-crate.rs index fb2ecd74a6595..b915bbebf785b 100644 --- a/tests/ui/issues/issue-2631-b.rs +++ b/tests/ui/cross-crate/monomorphize-index-op-cross-crate.rs @@ -1,6 +1,8 @@ //@ run-pass -//@ aux-build:issue-2631-a.rs +//@ aux-build:monomorphize-index-op-cross-crate.rs + +//! Regression test for https://github.com/rust-lang/rust/issues/2631 extern crate req; diff --git a/tests/ui/cross-crate/mut-ref-write-visible-after-unwind.rs b/tests/ui/cross-crate/mut-ref-write-visible-after-unwind.rs new file mode 100644 index 0000000000000..2e3073286f0f6 --- /dev/null +++ b/tests/ui/cross-crate/mut-ref-write-visible-after-unwind.rs @@ -0,0 +1,19 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/29485 +//! Exposed an LLVM bug that caused rustc to panic. +//@ run-pass +//@ aux-build:mut-ref-write-visible-after-unwind.rs +//@ needs-unwind +//@ needs-threads +//@ ignore-backends: gcc + +extern crate mut_ref_write_visible_after_unwind as lib; + +fn main() { + let _ = std::thread::spawn(move || { + lib::f(&mut lib::X(0), g); + }).join(); +} + +fn g() { + panic!(); +} diff --git a/tests/ui/cross-crate/nested-struct-in-polymorphic-impl-method.rs b/tests/ui/cross-crate/nested-struct-in-polymorphic-impl-method.rs new file mode 100644 index 0000000000000..12d09cdc84440 --- /dev/null +++ b/tests/ui/cross-crate/nested-struct-in-polymorphic-impl-method.rs @@ -0,0 +1,8 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/3136 +//@ run-pass +//@ aux-build:nested-struct-in-polymorphic-impl-method.rs + + +extern crate nested_struct_in_polymorphic_impl_method; + +pub fn main() {} diff --git a/tests/ui/cross-crate/no-duplicate-symbols-with-codegen-units.rs b/tests/ui/cross-crate/no-duplicate-symbols-with-codegen-units.rs new file mode 100644 index 0000000000000..f54c89a9162c3 --- /dev/null +++ b/tests/ui/cross-crate/no-duplicate-symbols-with-codegen-units.rs @@ -0,0 +1,14 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/32518 +//@ run-pass +//@ no-prefer-dynamic +//@ aux-build:no-duplicate-symbols-with-codegen-units-cgu-test.rs +//@ aux-build:no-duplicate-symbols-with-codegen-units-cgu-test-a.rs +//@ aux-build:no-duplicate-symbols-with-codegen-units-cgu-test-b.rs + +extern crate no_duplicate_symbols_with_codegen_units_cgu_test_a as cgu_test_a; +extern crate no_duplicate_symbols_with_codegen_units_cgu_test_b as cgu_test_b; + +fn main() { + cgu_test_a::a::a(); + cgu_test_b::a::a(); +} diff --git a/tests/ui/cross-crate/optimized-closure-with-debug-info-cross-crate.rs b/tests/ui/cross-crate/optimized-closure-with-debug-info-cross-crate.rs new file mode 100644 index 0000000000000..f0b34bdd86f0a --- /dev/null +++ b/tests/ui/cross-crate/optimized-closure-with-debug-info-cross-crate.rs @@ -0,0 +1,11 @@ +//@ run-pass +//@ aux-build:optimized-closure-with-debug-info-cross-crate-1.rs +//@ aux-build:optimized-closure-with-debug-info-cross-crate-2.rs + +//! Regression test for https://github.com/rust-lang/rust/issues/31702 +// this test is actually entirely in the linked library crates + +extern crate optimized_closure_with_debug_info_cross_crate_1; +extern crate optimized_closure_with_debug_info_cross_crate_2; + +fn main() {} diff --git a/tests/ui/issues/issue-34796.rs b/tests/ui/cross-crate/stable-hash-for-trait-object-type.rs similarity index 79% rename from tests/ui/issues/issue-34796.rs rename to tests/ui/cross-crate/stable-hash-for-trait-object-type.rs index 1a417b3483068..725469e4e4f91 100644 --- a/tests/ui/issues/issue-34796.rs +++ b/tests/ui/cross-crate/stable-hash-for-trait-object-type.rs @@ -1,5 +1,6 @@ //@ run-pass #![allow(dead_code)] +// Regression test for https://github.com/rust-lang/rust/issues/34796 // This test case exposes conditions where the encoding of a trait object type // with projection predicates would differ between this crate and the upstream // crate, because the predicates were encoded in different order within each @@ -8,8 +9,8 @@ // the symbol name. // The fix was to make the order in which predicates get encoded stable. -//@ aux-build:issue-34796-aux.rs -extern crate issue_34796_aux; +//@ aux-build:stable-hash-for-trait-object-type.rs +extern crate stable_hash_for_trait_object_type as issue_34796_aux; fn mk() -> T { loop {} } diff --git a/tests/ui/cross-crate/trait-object-projection-bounds-with-interning-order.rs b/tests/ui/cross-crate/trait-object-projection-bounds-with-interning-order.rs new file mode 100644 index 0000000000000..44aff69126c2a --- /dev/null +++ b/tests/ui/cross-crate/trait-object-projection-bounds-with-interning-order.rs @@ -0,0 +1,14 @@ +//@ run-pass +#![allow(unused_variables)] +//@ aux-build:trait-object-projection-bounds-with-interning-order.rs + +//! Regression test for https://github.com/rust-lang/rust/issues/25467 + +pub type Issue25467BarT = (); +pub type Issue25467FooT = (); + +extern crate trait_object_projection_bounds_with_interning_order as aux; + +fn main() { + let o: aux::Object = None; +} diff --git a/tests/ui/cross-crate/transitive-crate-dependency-with-trait-impl.rs b/tests/ui/cross-crate/transitive-crate-dependency-with-trait-impl.rs new file mode 100644 index 0000000000000..8d3b15cfd86bb --- /dev/null +++ b/tests/ui/cross-crate/transitive-crate-dependency-with-trait-impl.rs @@ -0,0 +1,9 @@ +//@ run-pass +//@ aux-build:transitive-crate-dependency-with-trait-impl-a.rs +//@ aux-build:transitive-crate-dependency-with-trait-impl-b.rs + +//! Regression test for https://github.com/rust-lang/rust/issues/2414 + +extern crate b; + +pub fn main() {} diff --git a/tests/ui/cross-crate/type-default-applied-in-cross-crate-method-lookup.rs b/tests/ui/cross-crate/type-default-applied-in-cross-crate-method-lookup.rs new file mode 100644 index 0000000000000..b0b6f05610d50 --- /dev/null +++ b/tests/ui/cross-crate/type-default-applied-in-cross-crate-method-lookup.rs @@ -0,0 +1,10 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/30123 +//@ aux-build:type-default-applied-in-cross-crate-method-lookup.rs + +extern crate type_default_applied_in_cross_crate_method_lookup; +use type_default_applied_in_cross_crate_method_lookup::*; + +fn main() { + let ug = Graph::::new_undirected(); + //~^ ERROR no associated function or constant named `new_undirected` found +} diff --git a/tests/ui/cross-crate/type-default-applied-in-cross-crate-method-lookup.stderr b/tests/ui/cross-crate/type-default-applied-in-cross-crate-method-lookup.stderr new file mode 100644 index 0000000000000..c5c5f206fe071 --- /dev/null +++ b/tests/ui/cross-crate/type-default-applied-in-cross-crate-method-lookup.stderr @@ -0,0 +1,16 @@ +error[E0599]: no associated function or constant named `new_undirected` found for struct `type_default_applied_in_cross_crate_method_lookup::Graph` in the current scope + --> $DIR/type-default-applied-in-cross-crate-method-lookup.rs:8:33 + | +LL | let ug = Graph::::new_undirected(); + | ^^^^^^^^^^^^^^ associated function or constant not found in `type_default_applied_in_cross_crate_method_lookup::Graph` + | +note: if you're trying to build a new `type_default_applied_in_cross_crate_method_lookup::Graph`, consider using `type_default_applied_in_cross_crate_method_lookup::Graph::::new` which returns `type_default_applied_in_cross_crate_method_lookup::Graph<_, _>` + --> $DIR/auxiliary/type-default-applied-in-cross-crate-method-lookup.rs:15:5 + | +LL | pub fn new() -> Self { + | ^^^^^^^^^^^^^^^^^^^^ + = note: the associated function or constant was found for `type_default_applied_in_cross_crate_method_lookup::Graph` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/imports/ambiguous-14.rs b/tests/ui/imports/ambiguous-14.rs index ba2d7dc4e0166..b7203a2cb6fb4 100644 --- a/tests/ui/imports/ambiguous-14.rs +++ b/tests/ui/imports/ambiguous-14.rs @@ -22,5 +22,4 @@ mod g { fn main() { g::foo(); //~^ ERROR `foo` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } diff --git a/tests/ui/imports/ambiguous-14.stderr b/tests/ui/imports/ambiguous-14.stderr index 2ca10d2d6a848..327dd075945a4 100644 --- a/tests/ui/imports/ambiguous-14.stderr +++ b/tests/ui/imports/ambiguous-14.stderr @@ -1,4 +1,4 @@ -error: `foo` is ambiguous +error[E0659]: `foo` is ambiguous --> $DIR/ambiguous-14.rs:23:8 | LL | g::foo(); @@ -6,44 +6,18 @@ LL | g::foo(); | = note: ambiguous because of multiple glob imports of a name in the same module note: `foo` could refer to the function imported here - --> $DIR/ambiguous-14.rs:18:13 + --> $DIR/ambiguous-14.rs:13:13 | LL | pub use a::*; | ^^^^ = help: consider adding an explicit import of `foo` to disambiguate note: `foo` could also refer to the function imported here - --> $DIR/ambiguous-14.rs:19:13 + --> $DIR/ambiguous-14.rs:14:13 | -LL | pub use f::*; +LL | pub use b::*; | ^^^^ = help: consider adding an explicit import of `foo` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error -Future incompatibility report: Future breakage diagnostic: -error: `foo` is ambiguous - --> $DIR/ambiguous-14.rs:23:8 - | -LL | g::foo(); - | ^^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `foo` could refer to the function imported here - --> $DIR/ambiguous-14.rs:18:13 - | -LL | pub use a::*; - | ^^^^ - = help: consider adding an explicit import of `foo` to disambiguate -note: `foo` could also refer to the function imported here - --> $DIR/ambiguous-14.rs:19:13 - | -LL | pub use f::*; - | ^^^^ - = help: consider adding an explicit import of `foo` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-9.rs b/tests/ui/imports/ambiguous-9.rs index 58796031bf18f..0e60a2929c024 100644 --- a/tests/ui/imports/ambiguous-9.rs +++ b/tests/ui/imports/ambiguous-9.rs @@ -4,16 +4,16 @@ pub mod dsl { mod range { pub fn date_range() {} } - pub use self::range::*; //~ WARNING ambiguous glob re-exports + pub use self::range::*; use super::prelude::*; } pub mod prelude { mod t { - pub fn date_range() {} + pub fn date_range() {} } - pub use self::t::*; //~ WARNING ambiguous glob re-exports - pub use super::dsl::*; + pub use self::t::*; + pub use super::dsl::*; //~ WARNING ambiguous glob re-exports } use dsl::*; @@ -22,5 +22,4 @@ use prelude::*; fn main() { date_range(); //~^ ERROR `date_range` is ambiguous - //~| ERROR `date_range` is ambiguous } diff --git a/tests/ui/imports/ambiguous-9.stderr b/tests/ui/imports/ambiguous-9.stderr index b6e4c30a8d410..0ffbeb7c89509 100644 --- a/tests/ui/imports/ambiguous-9.stderr +++ b/tests/ui/imports/ambiguous-9.stderr @@ -6,56 +6,28 @@ LL | date_range(); | = note: ambiguous because of multiple glob imports of a name in the same module note: `date_range` could refer to the function imported here - --> $DIR/ambiguous-9.rs:19:5 + --> $DIR/ambiguous-9.rs:16:13 | -LL | use dsl::*; - | ^^^^^^ - = help: consider adding an explicit import of `date_range` to disambiguate -note: `date_range` could also refer to the function imported here - --> $DIR/ambiguous-9.rs:20:5 - | -LL | use prelude::*; - | ^^^^^^^^^^ - = help: consider adding an explicit import of `date_range` to disambiguate - -error[E0659]: `date_range` is ambiguous - --> $DIR/ambiguous-9.rs:23:5 - | -LL | date_range(); - | ^^^^^^^^^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `date_range` could refer to the function imported here - --> $DIR/ambiguous-9.rs:7:13 - | -LL | pub use self::range::*; - | ^^^^^^^^^^^^^^ +LL | pub use super::dsl::*; + | ^^^^^^^^^^^^^ = help: consider adding an explicit import of `date_range` to disambiguate note: `date_range` could also refer to the function imported here - --> $DIR/ambiguous-9.rs:8:9 + --> $DIR/ambiguous-9.rs:15:13 | -LL | use super::prelude::*; - | ^^^^^^^^^^^^^^^^^ +LL | pub use self::t::*; + | ^^^^^^^^^^ = help: consider adding an explicit import of `date_range` to disambiguate warning: ambiguous glob re-exports - --> $DIR/ambiguous-9.rs:7:13 - | -LL | pub use self::range::*; - | ^^^^^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here -LL | use super::prelude::*; - | ----------------- but the name `date_range` in the value namespace is also re-exported here - | - = note: `#[warn(ambiguous_glob_reexports)]` on by default - -warning: ambiguous glob re-exports - --> $DIR/ambiguous-9.rs:15:13 + --> $DIR/ambiguous-9.rs:16:13 | LL | pub use self::t::*; - | ^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here + | ---------- but the name `date_range` in the value namespace is also re-exported here LL | pub use super::dsl::*; - | ------------- but the name `date_range` in the value namespace is also re-exported here + | ^^^^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here + | + = note: `#[warn(ambiguous_glob_reexports)]` on by default -error: aborting due to 2 previous errors; 2 warnings emitted +error: aborting due to 1 previous error; 1 warning emitted For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/duplicate.rs b/tests/ui/imports/duplicate.rs index 0a652889ca8ad..be089dbf5a4af 100644 --- a/tests/ui/imports/duplicate.rs +++ b/tests/ui/imports/duplicate.rs @@ -35,7 +35,6 @@ fn main() { f::foo(); //~ ERROR `foo` is ambiguous g::foo(); //~^ ERROR `foo` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } mod ambiguous_module_errors { diff --git a/tests/ui/imports/duplicate.stderr b/tests/ui/imports/duplicate.stderr index f02d35b1d28ce..7bff44109e40b 100644 --- a/tests/ui/imports/duplicate.stderr +++ b/tests/ui/imports/duplicate.stderr @@ -9,20 +9,20 @@ LL | use crate::a::foo; = note: `foo` must be defined only once in the value namespace of this module error[E0659]: `foo` is ambiguous - --> $DIR/duplicate.rs:48:15 + --> $DIR/duplicate.rs:47:15 | LL | use self::foo::bar; | ^^^ ambiguous name | = note: ambiguous because of multiple glob imports of a name in the same module note: `foo` could refer to the module imported here - --> $DIR/duplicate.rs:45:9 + --> $DIR/duplicate.rs:44:9 | LL | use self::m1::*; | ^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate note: `foo` could also refer to the module imported here - --> $DIR/duplicate.rs:46:9 + --> $DIR/duplicate.rs:45:9 | LL | use self::m2::*; | ^^^^^^^^^^^ @@ -49,26 +49,6 @@ LL | pub use crate::b::*; = help: consider adding an explicit import of `foo` to disambiguate error[E0659]: `foo` is ambiguous - --> $DIR/duplicate.rs:51:9 - | -LL | foo::bar(); - | ^^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `foo` could refer to the module imported here - --> $DIR/duplicate.rs:45:9 - | -LL | use self::m1::*; - | ^^^^^^^^^^^ - = help: consider adding an explicit import of `foo` to disambiguate -note: `foo` could also refer to the module imported here - --> $DIR/duplicate.rs:46:9 - | -LL | use self::m2::*; - | ^^^^^^^^^^^ - = help: consider adding an explicit import of `foo` to disambiguate - -error: `foo` is ambiguous --> $DIR/duplicate.rs:36:8 | LL | g::foo(); @@ -76,46 +56,39 @@ LL | g::foo(); | = note: ambiguous because of multiple glob imports of a name in the same module note: `foo` could refer to the function imported here - --> $DIR/duplicate.rs:29:13 + --> $DIR/duplicate.rs:24:13 | LL | pub use crate::a::*; | ^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate note: `foo` could also refer to the function imported here - --> $DIR/duplicate.rs:30:13 + --> $DIR/duplicate.rs:25:13 | -LL | pub use crate::f::*; +LL | pub use crate::b::*; | ^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - -error: aborting due to 5 previous errors -Some errors have detailed explanations: E0252, E0659. -For more information about an error, try `rustc --explain E0252`. -Future incompatibility report: Future breakage diagnostic: -error: `foo` is ambiguous - --> $DIR/duplicate.rs:36:8 +error[E0659]: `foo` is ambiguous + --> $DIR/duplicate.rs:50:9 | -LL | g::foo(); - | ^^^ ambiguous name +LL | foo::bar(); + | ^^^ ambiguous name | = note: ambiguous because of multiple glob imports of a name in the same module -note: `foo` could refer to the function imported here - --> $DIR/duplicate.rs:29:13 +note: `foo` could refer to the module imported here + --> $DIR/duplicate.rs:44:9 | -LL | pub use crate::a::*; - | ^^^^^^^^^^^ +LL | use self::m1::*; + | ^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate -note: `foo` could also refer to the function imported here - --> $DIR/duplicate.rs:30:13 +note: `foo` could also refer to the module imported here + --> $DIR/duplicate.rs:45:9 | -LL | pub use crate::f::*; - | ^^^^^^^^^^^ +LL | use self::m2::*; + | ^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0252, E0659. +For more information about an error, try `rustc --explain E0252`. diff --git a/tests/ui/imports/import-loop-2.rs b/tests/ui/imports/import-loop-2.rs index 42f9a07fff389..af5c6509d38b6 100644 --- a/tests/ui/imports/import-loop-2.rs +++ b/tests/ui/imports/import-loop-2.rs @@ -1,9 +1,9 @@ mod a { - pub use crate::b::x; + pub use crate::b::x; //~ ERROR unresolved import `crate::b::x` } mod b { - pub use crate::a::x; //~ ERROR unresolved import `crate::a::x` + pub use crate::a::x; fn main() { let y = x; } } diff --git a/tests/ui/imports/import-loop-2.stderr b/tests/ui/imports/import-loop-2.stderr index 2ef40c4e21829..dfa7cf35eaac2 100644 --- a/tests/ui/imports/import-loop-2.stderr +++ b/tests/ui/imports/import-loop-2.stderr @@ -1,8 +1,8 @@ -error[E0432]: unresolved import `crate::a::x` - --> $DIR/import-loop-2.rs:6:13 +error[E0432]: unresolved import `crate::b::x` + --> $DIR/import-loop-2.rs:2:13 | -LL | pub use crate::a::x; - | ^^^^^^^^^^^ no `x` in `a` +LL | pub use crate::b::x; + | ^^^^^^^^^^^ no `x` in `b` error: aborting due to 1 previous error diff --git a/tests/ui/imports/import4.rs b/tests/ui/imports/import4.rs index f670cc06201c0..76a9887534c34 100644 --- a/tests/ui/imports/import4.rs +++ b/tests/ui/imports/import4.rs @@ -1,4 +1,4 @@ -mod a { pub use crate::b::foo; } -mod b { pub use crate::a::foo; } //~ ERROR unresolved import `crate::a::foo` +mod a { pub use crate::b::foo; } //~ ERROR unresolved import `crate::b::foo` +mod b { pub use crate::a::foo; } fn main() { println!("loop"); } diff --git a/tests/ui/imports/import4.stderr b/tests/ui/imports/import4.stderr index 4faa5f0520a9d..07fdc6a3d0ced 100644 --- a/tests/ui/imports/import4.stderr +++ b/tests/ui/imports/import4.stderr @@ -1,8 +1,8 @@ -error[E0432]: unresolved import `crate::a::foo` - --> $DIR/import4.rs:2:17 +error[E0432]: unresolved import `crate::b::foo` + --> $DIR/import4.rs:1:17 | -LL | mod b { pub use crate::a::foo; } - | ^^^^^^^^^^^^^ no `foo` in `a` +LL | mod a { pub use crate::b::foo; } + | ^^^^^^^^^^^^^ no `foo` in `b` error: aborting due to 1 previous error diff --git a/tests/ui/imports/same-res-ambigious.fail.stderr b/tests/ui/imports/same-res-ambigious.fail.stderr deleted file mode 100644 index dfd7c5a5f94e0..0000000000000 --- a/tests/ui/imports/same-res-ambigious.fail.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0603]: derive macro `Embed` is private - --> $DIR/same-res-ambigious.rs:8:28 - | -LL | #[derive(ambigious_extern::Embed)] - | ^^^^^ private derive macro - | -note: the derive macro `Embed` is defined here - --> $DIR/auxiliary/same-res-ambigious-extern-fail.rs:16:9 - | -LL | pub use RustEmbed as Embed; - | ^^^^^^^^^ -help: import `Embed` directly - | -LL - #[derive(ambigious_extern::Embed)] -LL + #[derive(same_res_ambigious_extern_macro::RustEmbed)] - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0603`. diff --git a/tests/ui/imports/same-res-ambigious.rs b/tests/ui/imports/same-res-ambigious.rs index b5c13a15b7c9c..0bfd10f18ada8 100644 --- a/tests/ui/imports/same-res-ambigious.rs +++ b/tests/ui/imports/same-res-ambigious.rs @@ -1,11 +1,11 @@ +//@ check-pass //@ edition: 2018 //@ revisions: fail pass -//@[pass] check-pass //@[pass] aux-crate: ambigious_extern=same-res-ambigious-extern.rs //@[fail] aux-crate: ambigious_extern=same-res-ambigious-extern-fail.rs // see https://github.com/rust-lang/rust/pull/147196 -#[derive(ambigious_extern::Embed)] //[fail]~ ERROR: derive macro `Embed` is private +#[derive(ambigious_extern::Embed)] struct Foo{} fn main(){} diff --git a/tests/ui/issues/auxiliary/issue-19293.rs b/tests/ui/issues/auxiliary/issue-19293.rs deleted file mode 100644 index 31359e86559dd..0000000000000 --- a/tests/ui/issues/auxiliary/issue-19293.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub struct Foo (pub isize); -pub enum MyEnum { - Foo(Foo), -} diff --git a/tests/ui/issues/auxiliary/issue-20389.rs b/tests/ui/issues/auxiliary/issue-20389.rs deleted file mode 100644 index ae6d44eeb7703..0000000000000 --- a/tests/ui/issues/auxiliary/issue-20389.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub trait T { - type C; - fn dummy(&self) { } -} diff --git a/tests/ui/issues/auxiliary/issue-2414-b.rs b/tests/ui/issues/auxiliary/issue-2414-b.rs deleted file mode 100644 index fc018349d80f1..0000000000000 --- a/tests/ui/issues/auxiliary/issue-2414-b.rs +++ /dev/null @@ -1,4 +0,0 @@ -#![crate_name="b"] -#![crate_type = "lib"] - -extern crate a; diff --git a/tests/ui/issues/auxiliary/issue-38190.rs b/tests/ui/issues/auxiliary/issue-38190.rs deleted file mode 100644 index 373e646ba2c39..0000000000000 --- a/tests/ui/issues/auxiliary/issue-38190.rs +++ /dev/null @@ -1,2 +0,0 @@ -#[macro_export] -macro_rules! m { ([$i:item]) => {} } diff --git a/tests/ui/issues/auxiliary/issue-41053.rs b/tests/ui/issues/auxiliary/issue-41053.rs deleted file mode 100644 index ae73c3e780fb3..0000000000000 --- a/tests/ui/issues/auxiliary/issue-41053.rs +++ /dev/null @@ -1 +0,0 @@ -pub struct Test; diff --git a/tests/ui/issues/auxiliary/issue-41549.rs b/tests/ui/issues/auxiliary/issue-41549.rs deleted file mode 100644 index b7bd375250f0b..0000000000000 --- a/tests/ui/issues/auxiliary/issue-41549.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub trait Trait { - const CONST: u32; -} diff --git a/tests/ui/issues/auxiliary/issue-42007-s.rs b/tests/ui/issues/auxiliary/issue-42007-s.rs deleted file mode 100644 index 95119a589c99d..0000000000000 --- a/tests/ui/issues/auxiliary/issue-42007-s.rs +++ /dev/null @@ -1,4 +0,0 @@ -#[repr(u8)] -pub enum E { - B = 1 as u8, -} diff --git a/tests/ui/issues/auxiliary/issue-4545.rs b/tests/ui/issues/auxiliary/issue-4545.rs deleted file mode 100644 index 2f60947507541..0000000000000 --- a/tests/ui/issues/auxiliary/issue-4545.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub struct S(Option); -pub fn mk() -> S { S(None) } diff --git a/tests/ui/issues/auxiliary/issue-48984-aux.rs b/tests/ui/issues/auxiliary/issue-48984-aux.rs deleted file mode 100644 index 7cc888cd4cb29..0000000000000 --- a/tests/ui/issues/auxiliary/issue-48984-aux.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![crate_type = "lib"] -#![crate_name = "issue48984aux"] - -pub trait Foo { type Item; } - -pub trait Bar: Foo { } diff --git a/tests/ui/issues/auxiliary/issue-51798.rs b/tests/ui/issues/auxiliary/issue-51798.rs deleted file mode 100644 index fef5213db9f7a..0000000000000 --- a/tests/ui/issues/auxiliary/issue-51798.rs +++ /dev/null @@ -1,3 +0,0 @@ -#![crate_type = "lib"] - -pub fn vec() -> Vec { vec![] } diff --git a/tests/ui/issues/issue-19293.rs b/tests/ui/issues/issue-19293.rs deleted file mode 100644 index 42effe303d036..0000000000000 --- a/tests/ui/issues/issue-19293.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ run-pass -//@ aux-build:issue-19293.rs - -extern crate issue_19293; -use issue_19293::{Foo, MyEnum}; - -fn main() { - MyEnum::Foo(Foo(5)); -} diff --git a/tests/ui/issues/issue-20389.rs b/tests/ui/issues/issue-20389.rs deleted file mode 100644 index e201663afc522..0000000000000 --- a/tests/ui/issues/issue-20389.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ run-pass -#![allow(dead_code)] -//@ aux-build:issue-20389.rs - - -extern crate issue_20389; - -struct Foo; - -impl issue_20389::T for Foo { - type C = (); -} - -fn main() {} diff --git a/tests/ui/issues/issue-2170-exe.rs b/tests/ui/issues/issue-2170-exe.rs deleted file mode 100644 index b66843d48cad6..0000000000000 --- a/tests/ui/issues/issue-2170-exe.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ run-pass -//@ aux-build:issue-2170-lib.rs - -extern crate issue_2170_lib; - -pub fn main() { - // let _ = issue_2170_lib::rsrc(2); -} diff --git a/tests/ui/issues/issue-2380-b.rs b/tests/ui/issues/issue-2380-b.rs deleted file mode 100644 index 503698f88c620..0000000000000 --- a/tests/ui/issues/issue-2380-b.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ run-pass -//@ aux-build:issue-2380.rs - - -extern crate a; - -pub fn main() { - a::f::<()>(); -} diff --git a/tests/ui/issues/issue-2414-c.rs b/tests/ui/issues/issue-2414-c.rs deleted file mode 100644 index ac75c5c51051c..0000000000000 --- a/tests/ui/issues/issue-2414-c.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ run-pass -//@ aux-build:issue-2414-a.rs -//@ aux-build:issue-2414-b.rs - - -extern crate b; - -pub fn main() {} diff --git a/tests/ui/issues/issue-2526-a.rs b/tests/ui/issues/issue-2526-a.rs deleted file mode 100644 index 379146d02b3de..0000000000000 --- a/tests/ui/issues/issue-2526-a.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass -//@ aux-build:issue-2526.rs - - -#![allow(unused_imports)] - -extern crate issue_2526; -use issue_2526::*; - -pub fn main() {} diff --git a/tests/ui/issues/issue-25467.rs b/tests/ui/issues/issue-25467.rs deleted file mode 100644 index 1ba5a0ef697a1..0000000000000 --- a/tests/ui/issues/issue-25467.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ run-pass -#![allow(unused_variables)] -//@ aux-build:issue-25467.rs - -pub type Issue25467BarT = (); -pub type Issue25467FooT = (); - -extern crate issue_25467 as aux; - -fn main() { - let o: aux::Object = None; -} diff --git a/tests/ui/issues/issue-2723-b.rs b/tests/ui/issues/issue-2723-b.rs deleted file mode 100644 index 731e521f26f89..0000000000000 --- a/tests/ui/issues/issue-2723-b.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass -//@ aux-build:issue-2723-a.rs - -extern crate issue_2723_a; -use issue_2723_a::f; - -pub fn main() { - unsafe { - f(vec![2]); - } -} diff --git a/tests/ui/issues/issue-29265.rs b/tests/ui/issues/issue-29265.rs deleted file mode 100644 index a3da9be3a3b65..0000000000000 --- a/tests/ui/issues/issue-29265.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ aux-build:issue-29265.rs -//@ check-pass - -extern crate issue_29265 as lib; - -static _UNUSED: &'static lib::SomeType = &lib::SOME_VALUE; - -fn main() { - vec![0u8; lib::SOME_VALUE.some_member]; -} diff --git a/tests/ui/issues/issue-29485.rs b/tests/ui/issues/issue-29485.rs deleted file mode 100644 index 843a684a85b5e..0000000000000 --- a/tests/ui/issues/issue-29485.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ run-pass -//@ aux-build:issue-29485.rs -//@ needs-unwind -//@ needs-threads -//@ ignore-backends: gcc - -extern crate a; - -fn main() { - let _ = std::thread::spawn(move || { - a::f(&mut a::X(0), g); - }).join(); -} - -fn g() { - panic!(); -} diff --git a/tests/ui/issues/issue-3012-2.rs b/tests/ui/issues/issue-3012-2.rs deleted file mode 100644 index fd090d5e7b50e..0000000000000 --- a/tests/ui/issues/issue-3012-2.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ run-pass -//@ aux-build:issue-3012-1.rs - - -extern crate socketlib; - -use socketlib::socket; - -pub fn main() { - let fd: u32 = 1 as u32; - let _sock: Box<_> = Box::new(socket::socket_handle(fd)); -} diff --git a/tests/ui/issues/issue-30123.rs b/tests/ui/issues/issue-30123.rs deleted file mode 100644 index 88fab44741f2e..0000000000000 --- a/tests/ui/issues/issue-30123.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ aux-build:issue-30123-aux.rs - -extern crate issue_30123_aux; -use issue_30123_aux::*; - -fn main() { - let ug = Graph::::new_undirected(); - //~^ ERROR no associated function or constant named `new_undirected` found -} diff --git a/tests/ui/issues/issue-30123.stderr b/tests/ui/issues/issue-30123.stderr deleted file mode 100644 index 1e2747407d1da..0000000000000 --- a/tests/ui/issues/issue-30123.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0599]: no associated function or constant named `new_undirected` found for struct `issue_30123_aux::Graph` in the current scope - --> $DIR/issue-30123.rs:7:33 - | -LL | let ug = Graph::::new_undirected(); - | ^^^^^^^^^^^^^^ associated function or constant not found in `issue_30123_aux::Graph` - | -note: if you're trying to build a new `issue_30123_aux::Graph`, consider using `issue_30123_aux::Graph::::new` which returns `issue_30123_aux::Graph<_, _>` - --> $DIR/auxiliary/issue-30123-aux.rs:14:5 - | -LL | pub fn new() -> Self { - | ^^^^^^^^^^^^^^^^^^^^ - = note: the associated function or constant was found for `issue_30123_aux::Graph` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/issues/issue-3136-b.rs b/tests/ui/issues/issue-3136-b.rs deleted file mode 100644 index bd6ea732643f1..0000000000000 --- a/tests/ui/issues/issue-3136-b.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass -//@ aux-build:issue-3136-a.rs - - -extern crate issue_3136_a; - -pub fn main() {} diff --git a/tests/ui/issues/issue-31702.rs b/tests/ui/issues/issue-31702.rs deleted file mode 100644 index 1cf01f7f04ecc..0000000000000 --- a/tests/ui/issues/issue-31702.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass -//@ aux-build:issue-31702-1.rs -//@ aux-build:issue-31702-2.rs - -// this test is actually entirely in the linked library crates - -extern crate issue_31702_1; -extern crate issue_31702_2; - -fn main() {} diff --git a/tests/ui/issues/issue-32518.rs b/tests/ui/issues/issue-32518.rs deleted file mode 100644 index 45a882850c009..0000000000000 --- a/tests/ui/issues/issue-32518.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ run-pass -//@ no-prefer-dynamic -//@ aux-build:cgu_test.rs -//@ aux-build:cgu_test_a.rs -//@ aux-build:cgu_test_b.rs - -extern crate cgu_test_a; -extern crate cgu_test_b; - -fn main() { - cgu_test_a::a::a(); - cgu_test_b::a::a(); -} diff --git a/tests/ui/issues/issue-36954.rs b/tests/ui/issues/issue-36954.rs deleted file mode 100644 index 411e99b603da4..0000000000000 --- a/tests/ui/issues/issue-36954.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ run-pass -//@ aux-build:issue-36954.rs - -extern crate issue_36954 as lib; - -fn main() { - let _ = lib::FOO; -} diff --git a/tests/ui/issues/issue-38190.rs b/tests/ui/issues/issue-38190.rs deleted file mode 100644 index 539d7f2ed3be4..0000000000000 --- a/tests/ui/issues/issue-38190.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ run-pass -//@ aux-build:issue-38190.rs - -#[macro_use] -extern crate issue_38190; - -mod auxiliary { - m!([ - #[path = "issue-38190.rs"] - mod issue_38190; - ]); -} - -fn main() {} diff --git a/tests/ui/issues/issue-41549.rs b/tests/ui/issues/issue-41549.rs deleted file mode 100644 index 8f57515415c6e..0000000000000 --- a/tests/ui/issues/issue-41549.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ aux-build:issue-41549.rs - - -extern crate issue_41549; - -struct S; - -impl issue_41549::Trait for S { - const CONST: () = (); //~ ERROR incompatible type for trait -} - -fn main() {} diff --git a/tests/ui/issues/issue-42007.rs b/tests/ui/issues/issue-42007.rs deleted file mode 100644 index b8ea7e871a736..0000000000000 --- a/tests/ui/issues/issue-42007.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass -#![allow(dead_code)] -//@ aux-build:issue-42007-s.rs - -extern crate issue_42007_s; - -enum I { - E(issue_42007_s::E), -} - -fn main() {} diff --git a/tests/ui/issues/issue-4208.rs b/tests/ui/issues/issue-4208.rs deleted file mode 100644 index 84938bea022d1..0000000000000 --- a/tests/ui/issues/issue-4208.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass -#![allow(dead_code)] -//@ aux-build:issue-4208-cc.rs - - -extern crate numeric; -use numeric::{sin, Angle}; - -fn foo>(theta: A) -> T { sin(&theta) } - -pub fn main() {} diff --git a/tests/ui/issues/issue-4545.rs b/tests/ui/issues/issue-4545.rs deleted file mode 100644 index dfb89136cbd22..0000000000000 --- a/tests/ui/issues/issue-4545.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ run-pass -//@ aux-build:issue-4545.rs - - -extern crate issue_4545 as somelib; -pub fn main() { somelib::mk::(); } diff --git a/tests/ui/issues/issue-48984.rs b/tests/ui/issues/issue-48984.rs deleted file mode 100644 index 0440789a480aa..0000000000000 --- a/tests/ui/issues/issue-48984.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ run-pass -#![allow(dead_code)] -//@ aux-build:issue-48984-aux.rs -extern crate issue48984aux; -use issue48984aux::Bar; - -fn do_thing() { } - -fn main() { } diff --git a/tests/ui/issues/issue-51798.rs b/tests/ui/issues/issue-51798.rs deleted file mode 100644 index f4d59f39952eb..0000000000000 --- a/tests/ui/issues/issue-51798.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ edition:2018 -//@ aux-build:issue-51798.rs -//@ check-pass - -extern crate issue_51798; - -mod server { - fn f() { - let mut v = issue_51798::vec(); - v.clear(); - } -} - -fn main() {} diff --git a/tests/ui/linking/auxiliary/duplicate-rlib-crate-name-precedence-1.rs b/tests/ui/linking/auxiliary/duplicate-rlib-crate-name-precedence-1.rs index 7b2bfbba12e6e..bac086ba0c054 100644 --- a/tests/ui/linking/auxiliary/duplicate-rlib-crate-name-precedence-1.rs +++ b/tests/ui/linking/auxiliary/duplicate-rlib-crate-name-precedence-1.rs @@ -1,5 +1,4 @@ -//! Auxiliary crate for . - +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/18913 //@ no-prefer-dynamic #![crate_type = "rlib"] diff --git a/tests/ui/linking/auxiliary/duplicate-rlib-crate-name-precedence-2.rs b/tests/ui/linking/auxiliary/duplicate-rlib-crate-name-precedence-2.rs index fc0d3d6ea4283..05dba52c6625e 100644 --- a/tests/ui/linking/auxiliary/duplicate-rlib-crate-name-precedence-2.rs +++ b/tests/ui/linking/auxiliary/duplicate-rlib-crate-name-precedence-2.rs @@ -1,5 +1,4 @@ -//! Auxiliary crate for . - +//! Auxiliary crate testing this issue https://github.com/rust-lang/rust/issues/18913 //@ no-prefer-dynamic #![crate_type = "rlib"] diff --git a/tests/ui/on-unimplemented/expected-comma-found-token.rs b/tests/ui/on-unimplemented/expected-comma-found-token.rs index d60ab3341fd6d..09c293f7eba78 100644 --- a/tests/ui/on-unimplemented/expected-comma-found-token.rs +++ b/tests/ui/on-unimplemented/expected-comma-found-token.rs @@ -4,7 +4,7 @@ #![feature(rustc_attrs)] #[rustc_on_unimplemented( - message="the message" - label="the label" //~ ERROR expected `,`, found `label` + message="the message" //~ ERROR attribute items not separated with `,` + label="the label" )] trait T {} diff --git a/tests/ui/on-unimplemented/expected-comma-found-token.stderr b/tests/ui/on-unimplemented/expected-comma-found-token.stderr index 2717100a1dc64..cdc80a4d9267c 100644 --- a/tests/ui/on-unimplemented/expected-comma-found-token.stderr +++ b/tests/ui/on-unimplemented/expected-comma-found-token.stderr @@ -1,10 +1,8 @@ -error: expected `,`, found `label` - --> $DIR/expected-comma-found-token.rs:8:5 +error: attribute items not separated with `,` + --> $DIR/expected-comma-found-token.rs:7:26 | LL | message="the message" - | - expected `,` -LL | label="the label" - | ^^^^^ unexpected token + | ^ help: try adding `,` here error: aborting due to 1 previous error diff --git a/tests/ui/privacy/privacy1.stderr b/tests/ui/privacy/privacy1.stderr index 5d1e003c703b4..22cc16b12af79 100644 --- a/tests/ui/privacy/privacy1.stderr +++ b/tests/ui/privacy/privacy1.stderr @@ -34,18 +34,6 @@ note: the module `baz` is defined here LL | mod baz { | ^^^^^^^ -error[E0603]: module `baz` is private - --> $DIR/privacy1.rs:148:18 - | -LL | use bar::baz; - | ^^^ private module - | -note: the module `baz` is defined here - --> $DIR/privacy1.rs:57:5 - | -LL | mod baz { - | ^^^^^^^ - error[E0603]: module `i` is private --> $DIR/privacy1.rs:172:20 | @@ -60,6 +48,18 @@ note: the module `i` is defined here LL | mod i { | ^^^^^ +error[E0603]: module `baz` is private + --> $DIR/privacy1.rs:148:18 + | +LL | use bar::baz; + | ^^^ private module + | +note: the module `baz` is defined here + --> $DIR/privacy1.rs:57:5 + | +LL | mod baz { + | ^^^^^^^ + error[E0603]: module `baz` is private --> $DIR/privacy1.rs:111:21 |