| author | bors <bors@rust-lang.org> 2026-01-20 14:42:53 UTC |
| committer | bors <bors@rust-lang.org> 2026-01-20 14:42:53 UTC |
| log | 5c49c4f7c8393c861b849441d27f5d40e0f1e33b |
| tree | 2520d2a97b074878a50401806b89ac9e5fa05de7 |
| parent | fffc4fcf96b30bc838551de5104d74f82400b35b |
| parent | 83ce00e35eb310973b0407388c56ed677fa3dc04 |
Rollup of 6 pull requests
Successful merges:
- rust-lang/rust#147611 (Stabilize `-Zremap-path-scope`)
- rust-lang/rust#149058 (FCW Lint when using an ambiguously glob imported trait)
- rust-lang/rust#149644 (Create x86_64-unknown-linux-gnuasan target which enables ASAN by default)
- rust-lang/rust#150524 (Test that -Zbuild-std=core works on a variety of profiles)
- rust-lang/rust#151394 (Fix typos: 'occured' -> 'occurred' and 'non_existant' -> 'non_existent')
- rust-lang/rust#151396 (`rustc_queries!`: Don't push the `(cache)` modifier twice)
r? @ghost67 files changed, 880 insertions(+), 140 deletions(-)
Cargo.lock+1| ... | ... | @@ -3337,6 +3337,7 @@ dependencies = [ |
| 3337 | 3337 | "rustdoc-json-types", |
| 3338 | 3338 | "serde_json", |
| 3339 | 3339 | "similar", |
| 3340 | "tempfile", | |
| 3340 | 3341 | "wasmparser 0.236.1", |
| 3341 | 3342 | ] |
| 3342 | 3343 |
compiler/rustc_hir/src/hir.rs+5| ... | ... | @@ -4615,6 +4615,11 @@ pub struct Upvar { |
| 4615 | 4615 | pub struct TraitCandidate { |
| 4616 | 4616 | pub def_id: DefId, |
| 4617 | 4617 | pub import_ids: SmallVec<[LocalDefId; 1]>, |
| 4618 | // Indicates whether this trait candidate is ambiguously glob imported | |
| 4619 | // in it's scope. Related to the AMBIGUOUS_GLOB_IMPORTED_TRAITS lint. | |
| 4620 | // If this is set to true and the trait is used as a result of method lookup, this | |
| 4621 | // lint is thrown. | |
| 4622 | pub lint_ambiguous: bool, | |
| 4618 | 4623 | } |
| 4619 | 4624 | |
| 4620 | 4625 | #[derive(Copy, Clone, Debug, HashStable_Generic)] |
compiler/rustc_hir_typeck/src/method/confirm.rs+27-2| ... | ... | @@ -1,3 +1,4 @@ |
| 1 | use std::fmt::Debug; | |
| 1 | 2 | use std::ops::Deref; |
| 2 | 3 | |
| 3 | 4 | use rustc_hir as hir; |
| ... | ... | @@ -12,7 +13,9 @@ use rustc_hir_analysis::hir_ty_lowering::{ |
| 12 | 13 | use rustc_infer::infer::{ |
| 13 | 14 | BoundRegionConversionTime, DefineOpaqueTypes, InferOk, RegionVariableOrigin, |
| 14 | 15 | }; |
| 15 | use rustc_lint::builtin::RESOLVING_TO_ITEMS_SHADOWING_SUPERTRAIT_ITEMS; | |
| 16 | use rustc_lint::builtin::{ | |
| 17 | AMBIGUOUS_GLOB_IMPORTED_TRAITS, RESOLVING_TO_ITEMS_SHADOWING_SUPERTRAIT_ITEMS, | |
| 18 | }; | |
| 16 | 19 | use rustc_middle::traits::ObligationCauseCode; |
| 17 | 20 | use rustc_middle::ty::adjustment::{ |
| 18 | 21 | Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, PointerCoercion, |
| ... | ... | @@ -149,6 +152,9 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { |
| 149 | 152 | // Lint when an item is shadowing a supertrait item. |
| 150 | 153 | self.lint_shadowed_supertrait_items(pick, segment); |
| 151 | 154 | |
| 155 | // Lint when a trait is ambiguously imported | |
| 156 | self.lint_ambiguously_glob_imported_traits(pick, segment); | |
| 157 | ||
| 152 | 158 | // Add any trait/regions obligations specified on the method's type parameters. |
| 153 | 159 | // We won't add these if we encountered an illegal sized bound, so that we can use |
| 154 | 160 | // a custom error in that case. |
| ... | ... | @@ -322,7 +328,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { |
| 322 | 328 | }) |
| 323 | 329 | } |
| 324 | 330 | |
| 325 | probe::TraitPick => { | |
| 331 | probe::TraitPick(_) => { | |
| 326 | 332 | let trait_def_id = pick.item.container_id(self.tcx); |
| 327 | 333 | |
| 328 | 334 | // Make a trait reference `$0 : Trait<$1...$n>` |
| ... | ... | @@ -719,6 +725,25 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { |
| 719 | 725 | ); |
| 720 | 726 | } |
| 721 | 727 | |
| 728 | fn lint_ambiguously_glob_imported_traits( | |
| 729 | &self, | |
| 730 | pick: &probe::Pick<'_>, | |
| 731 | segment: &hir::PathSegment<'tcx>, | |
| 732 | ) { | |
| 733 | if pick.kind != probe::PickKind::TraitPick(true) { | |
| 734 | return; | |
| 735 | } | |
| 736 | let trait_name = self.tcx.item_name(pick.item.container_id(self.tcx)); | |
| 737 | let import_span = self.tcx.hir_span_if_local(pick.import_ids[0].to_def_id()).unwrap(); | |
| 738 | ||
| 739 | self.tcx.node_lint(AMBIGUOUS_GLOB_IMPORTED_TRAITS, segment.hir_id, |diag| { | |
| 740 | diag.primary_message(format!("Use of ambiguously glob imported trait `{trait_name}`")) | |
| 741 | .span(segment.ident.span) | |
| 742 | .span_label(import_span, format!("`{trait_name}` imported ambiguously here")) | |
| 743 | .help(format!("Import `{trait_name}` explicitly")); | |
| 744 | }); | |
| 745 | } | |
| 746 | ||
| 722 | 747 | fn upcast( |
| 723 | 748 | &mut self, |
| 724 | 749 | source_trait_ref: ty::PolyTraitRef<'tcx>, |
compiler/rustc_hir_typeck/src/method/probe.rs+34-12| ... | ... | @@ -106,7 +106,7 @@ pub(crate) struct Candidate<'tcx> { |
| 106 | 106 | pub(crate) enum CandidateKind<'tcx> { |
| 107 | 107 | InherentImplCandidate { impl_def_id: DefId, receiver_steps: usize }, |
| 108 | 108 | ObjectCandidate(ty::PolyTraitRef<'tcx>), |
| 109 | TraitCandidate(ty::PolyTraitRef<'tcx>), | |
| 109 | TraitCandidate(ty::PolyTraitRef<'tcx>, bool /* lint_ambiguous */), | |
| 110 | 110 | WhereClauseCandidate(ty::PolyTraitRef<'tcx>), |
| 111 | 111 | } |
| 112 | 112 | |
| ... | ... | @@ -235,7 +235,10 @@ pub(crate) struct Pick<'tcx> { |
| 235 | 235 | pub(crate) enum PickKind<'tcx> { |
| 236 | 236 | InherentImplPick, |
| 237 | 237 | ObjectPick, |
| 238 | TraitPick, | |
| 238 | TraitPick( | |
| 239 | // Is Ambiguously Imported | |
| 240 | bool, | |
| 241 | ), | |
| 239 | 242 | WhereClausePick( |
| 240 | 243 | // Trait |
| 241 | 244 | ty::PolyTraitRef<'tcx>, |
| ... | ... | @@ -560,7 +563,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 560 | 563 | probe_cx.push_candidate( |
| 561 | 564 | Candidate { |
| 562 | 565 | item, |
| 563 | kind: CandidateKind::TraitCandidate(ty::Binder::dummy(trait_ref)), | |
| 566 | kind: CandidateKind::TraitCandidate( | |
| 567 | ty::Binder::dummy(trait_ref), | |
| 568 | false, | |
| 569 | ), | |
| 564 | 570 | import_ids: smallvec![], |
| 565 | 571 | }, |
| 566 | 572 | false, |
| ... | ... | @@ -1018,6 +1024,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { |
| 1018 | 1024 | self.assemble_extension_candidates_for_trait( |
| 1019 | 1025 | &trait_candidate.import_ids, |
| 1020 | 1026 | trait_did, |
| 1027 | trait_candidate.lint_ambiguous, | |
| 1021 | 1028 | ); |
| 1022 | 1029 | } |
| 1023 | 1030 | } |
| ... | ... | @@ -1029,7 +1036,11 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { |
| 1029 | 1036 | let mut duplicates = FxHashSet::default(); |
| 1030 | 1037 | for trait_info in suggest::all_traits(self.tcx) { |
| 1031 | 1038 | if duplicates.insert(trait_info.def_id) { |
| 1032 | self.assemble_extension_candidates_for_trait(&smallvec![], trait_info.def_id); | |
| 1039 | self.assemble_extension_candidates_for_trait( | |
| 1040 | &smallvec![], | |
| 1041 | trait_info.def_id, | |
| 1042 | false, | |
| 1043 | ); | |
| 1033 | 1044 | } |
| 1034 | 1045 | } |
| 1035 | 1046 | } |
| ... | ... | @@ -1055,6 +1066,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { |
| 1055 | 1066 | &mut self, |
| 1056 | 1067 | import_ids: &SmallVec<[LocalDefId; 1]>, |
| 1057 | 1068 | trait_def_id: DefId, |
| 1069 | lint_ambiguous: bool, | |
| 1058 | 1070 | ) { |
| 1059 | 1071 | let trait_args = self.fresh_args_for_item(self.span, trait_def_id); |
| 1060 | 1072 | let trait_ref = ty::TraitRef::new_from_args(self.tcx, trait_def_id, trait_args); |
| ... | ... | @@ -1076,7 +1088,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { |
| 1076 | 1088 | Candidate { |
| 1077 | 1089 | item, |
| 1078 | 1090 | import_ids: import_ids.clone(), |
| 1079 | kind: TraitCandidate(bound_trait_ref), | |
| 1091 | kind: TraitCandidate(bound_trait_ref, lint_ambiguous), | |
| 1080 | 1092 | }, |
| 1081 | 1093 | false, |
| 1082 | 1094 | ); |
| ... | ... | @@ -1099,7 +1111,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { |
| 1099 | 1111 | Candidate { |
| 1100 | 1112 | item, |
| 1101 | 1113 | import_ids: import_ids.clone(), |
| 1102 | kind: TraitCandidate(ty::Binder::dummy(trait_ref)), | |
| 1114 | kind: TraitCandidate(ty::Binder::dummy(trait_ref), lint_ambiguous), | |
| 1103 | 1115 | }, |
| 1104 | 1116 | false, |
| 1105 | 1117 | ); |
| ... | ... | @@ -1842,7 +1854,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { |
| 1842 | 1854 | ObjectCandidate(_) | WhereClauseCandidate(_) => { |
| 1843 | 1855 | CandidateSource::Trait(candidate.item.container_id(self.tcx)) |
| 1844 | 1856 | } |
| 1845 | TraitCandidate(trait_ref) => self.probe(|_| { | |
| 1857 | TraitCandidate(trait_ref, _) => self.probe(|_| { | |
| 1846 | 1858 | let trait_ref = self.instantiate_binder_with_fresh_vars( |
| 1847 | 1859 | self.span, |
| 1848 | 1860 | BoundRegionConversionTime::FnCall, |
| ... | ... | @@ -1872,7 +1884,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { |
| 1872 | 1884 | fn candidate_source_from_pick(&self, pick: &Pick<'tcx>) -> CandidateSource { |
| 1873 | 1885 | match pick.kind { |
| 1874 | 1886 | InherentImplPick => CandidateSource::Impl(pick.item.container_id(self.tcx)), |
| 1875 | ObjectPick | WhereClausePick(_) | TraitPick => { | |
| 1887 | ObjectPick | WhereClausePick(_) | TraitPick(_) => { | |
| 1876 | 1888 | CandidateSource::Trait(pick.item.container_id(self.tcx)) |
| 1877 | 1889 | } |
| 1878 | 1890 | } |
| ... | ... | @@ -1948,7 +1960,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { |
| 1948 | 1960 | impl_bounds, |
| 1949 | 1961 | )); |
| 1950 | 1962 | } |
| 1951 | TraitCandidate(poly_trait_ref) => { | |
| 1963 | TraitCandidate(poly_trait_ref, _) => { | |
| 1952 | 1964 | // Some trait methods are excluded for arrays before 2021. |
| 1953 | 1965 | // (`array.into_iter()` wants a slice iterator for compatibility.) |
| 1954 | 1966 | if let Some(method_name) = self.method_name { |
| ... | ... | @@ -2274,11 +2286,16 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { |
| 2274 | 2286 | } |
| 2275 | 2287 | } |
| 2276 | 2288 | |
| 2289 | let lint_ambiguous = match probes[0].0.kind { | |
| 2290 | TraitCandidate(_, lint) => lint, | |
| 2291 | _ => false, | |
| 2292 | }; | |
| 2293 | ||
| 2277 | 2294 | // FIXME: check the return type here somehow. |
| 2278 | 2295 | // If so, just use this trait and call it a day. |
| 2279 | 2296 | Some(Pick { |
| 2280 | 2297 | item: probes[0].0.item, |
| 2281 | kind: TraitPick, | |
| 2298 | kind: TraitPick(lint_ambiguous), | |
| 2282 | 2299 | import_ids: probes[0].0.import_ids.clone(), |
| 2283 | 2300 | autoderefs: 0, |
| 2284 | 2301 | autoref_or_ptr_adjustment: None, |
| ... | ... | @@ -2348,9 +2365,14 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { |
| 2348 | 2365 | } |
| 2349 | 2366 | } |
| 2350 | 2367 | |
| 2368 | let lint_ambiguous = match probes[0].0.kind { | |
| 2369 | TraitCandidate(_, lint) => lint, | |
| 2370 | _ => false, | |
| 2371 | }; | |
| 2372 | ||
| 2351 | 2373 | Some(Pick { |
| 2352 | 2374 | item: child_candidate.item, |
| 2353 | kind: TraitPick, | |
| 2375 | kind: TraitPick(lint_ambiguous), | |
| 2354 | 2376 | import_ids: child_candidate.import_ids.clone(), |
| 2355 | 2377 | autoderefs: 0, |
| 2356 | 2378 | autoref_or_ptr_adjustment: None, |
| ... | ... | @@ -2613,7 +2635,7 @@ impl<'tcx> Candidate<'tcx> { |
| 2613 | 2635 | kind: match self.kind { |
| 2614 | 2636 | InherentImplCandidate { .. } => InherentImplPick, |
| 2615 | 2637 | ObjectCandidate(_) => ObjectPick, |
| 2616 | TraitCandidate(_) => TraitPick, | |
| 2638 | TraitCandidate(_, lint_ambiguous) => TraitPick(lint_ambiguous), | |
| 2617 | 2639 | WhereClauseCandidate(trait_ref) => { |
| 2618 | 2640 | // Only trait derived from where-clauses should |
| 2619 | 2641 | // appear here, so they should not contain any |
compiler/rustc_lint_defs/src/builtin.rs+55| ... | ... | @@ -17,6 +17,7 @@ declare_lint_pass! { |
| 17 | 17 | AARCH64_SOFTFLOAT_NEON, |
| 18 | 18 | ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE, |
| 19 | 19 | AMBIGUOUS_ASSOCIATED_ITEMS, |
| 20 | AMBIGUOUS_GLOB_IMPORTED_TRAITS, | |
| 20 | 21 | AMBIGUOUS_GLOB_IMPORTS, |
| 21 | 22 | AMBIGUOUS_GLOB_REEXPORTS, |
| 22 | 23 | AMBIGUOUS_PANIC_IMPORTS, |
| ... | ... | @@ -4473,6 +4474,60 @@ declare_lint! { |
| 4473 | 4474 | }; |
| 4474 | 4475 | } |
| 4475 | 4476 | |
| 4477 | declare_lint! { | |
| 4478 | /// The `ambiguous_glob_imported_traits` lint reports uses of traits that are | |
| 4479 | /// imported ambiguously via glob imports. Previously, this was not enforced | |
| 4480 | /// due to a bug in rustc. | |
| 4481 | /// | |
| 4482 | /// ### Example | |
| 4483 | /// | |
| 4484 | /// ```rust,compile_fail | |
| 4485 | /// #![deny(ambiguous_glob_imported_traits)] | |
| 4486 | /// mod m1 { | |
| 4487 | /// pub trait Trait { | |
| 4488 | /// fn method1(&self) {} | |
| 4489 | /// } | |
| 4490 | /// impl Trait for u8 {} | |
| 4491 | /// } | |
| 4492 | /// mod m2 { | |
| 4493 | /// pub trait Trait { | |
| 4494 | /// fn method2(&self) {} | |
| 4495 | /// } | |
| 4496 | /// impl Trait for u8 {} | |
| 4497 | /// } | |
| 4498 | /// | |
| 4499 | /// fn main() { | |
| 4500 | /// use m1::*; | |
| 4501 | /// use m2::*; | |
| 4502 | /// 0u8.method1(); | |
| 4503 | /// 0u8.method2(); | |
| 4504 | /// } | |
| 4505 | /// ``` | |
| 4506 | /// | |
| 4507 | /// {{produces}} | |
| 4508 | /// | |
| 4509 | /// ### Explanation | |
| 4510 | /// | |
| 4511 | /// When multiple traits with the same name are brought into scope through glob imports, | |
| 4512 | /// one trait becomes the "primary" one while the others are shadowed. Methods from the | |
| 4513 | /// shadowed traits (e.g. `method2`) become inaccessible, while methods from the "primary" | |
| 4514 | /// trait (e.g. `method1`) still resolve. Ideally, none of the ambiguous traits would be in scope, | |
| 4515 | /// but we have to allow this for now because of backwards compatibility. | |
| 4516 | /// This lint reports uses of these "primary" traits that are ambiguous. | |
| 4517 | /// | |
| 4518 | /// This is a [future-incompatible] lint to transition this to a | |
| 4519 | /// hard error in the future. | |
| 4520 | /// | |
| 4521 | /// [future-incompatible]: ../index.md#future-incompatible-lints | |
| 4522 | pub AMBIGUOUS_GLOB_IMPORTED_TRAITS, | |
| 4523 | Warn, | |
| 4524 | "detects uses of ambiguously glob imported traits", | |
| 4525 | @future_incompatible = FutureIncompatibleInfo { | |
| 4526 | reason: fcw!(FutureReleaseError #147992), | |
| 4527 | report_in_deps: false, | |
| 4528 | }; | |
| 4529 | } | |
| 4530 | ||
| 4476 | 4531 | declare_lint! { |
| 4477 | 4532 | /// The `ambiguous_panic_imports` lint detects ambiguous core and std panic imports, but |
| 4478 | 4533 | /// previously didn't do that due to `#[macro_use]` prelude macro import. |
compiler/rustc_macros/src/query.rs-3| ... | ... | @@ -378,9 +378,6 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream { |
| 378 | 378 | return_result_from_ensure_ok, |
| 379 | 379 | ); |
| 380 | 380 | |
| 381 | if modifiers.cache.is_some() { | |
| 382 | attributes.push(quote! { (cache) }); | |
| 383 | } | |
| 384 | 381 | // Pass on the cache modifier |
| 385 | 382 | if modifiers.cache.is_some() { |
| 386 | 383 | attributes.push(quote! { (cache) }); |
compiler/rustc_resolve/src/lib.rs+27-5| ... | ... | @@ -622,7 +622,18 @@ struct ModuleData<'ra> { |
| 622 | 622 | globs: CmRefCell<Vec<Import<'ra>>>, |
| 623 | 623 | |
| 624 | 624 | /// Used to memoize the traits in this module for faster searches through all traits in scope. |
| 625 | traits: CmRefCell<Option<Box<[(Macros20NormalizedIdent, Decl<'ra>, Option<Module<'ra>>)]>>>, | |
| 625 | traits: CmRefCell< | |
| 626 | Option< | |
| 627 | Box< | |
| 628 | [( | |
| 629 | Macros20NormalizedIdent, | |
| 630 | Decl<'ra>, | |
| 631 | Option<Module<'ra>>, | |
| 632 | bool, /* lint ambiguous */ | |
| 633 | )], | |
| 634 | >, | |
| 635 | >, | |
| 636 | >, | |
| 626 | 637 | |
| 627 | 638 | /// Span of the module itself. Used for error reporting. |
| 628 | 639 | span: Span, |
| ... | ... | @@ -719,7 +730,12 @@ impl<'ra> Module<'ra> { |
| 719 | 730 | return; |
| 720 | 731 | } |
| 721 | 732 | if let Res::Def(DefKind::Trait | DefKind::TraitAlias, def_id) = binding.res() { |
| 722 | collected_traits.push((name, binding, r.as_ref().get_module(def_id))) | |
| 733 | collected_traits.push(( | |
| 734 | name, | |
| 735 | binding, | |
| 736 | r.as_ref().get_module(def_id), | |
| 737 | binding.is_ambiguity_recursive(), | |
| 738 | )); | |
| 723 | 739 | } |
| 724 | 740 | }); |
| 725 | 741 | *traits = Some(collected_traits.into_boxed_slice()); |
| ... | ... | @@ -1877,7 +1893,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 1877 | 1893 | if let Some(module) = current_trait { |
| 1878 | 1894 | if self.trait_may_have_item(Some(module), assoc_item) { |
| 1879 | 1895 | let def_id = module.def_id(); |
| 1880 | found_traits.push(TraitCandidate { def_id, import_ids: smallvec![] }); | |
| 1896 | found_traits.push(TraitCandidate { | |
| 1897 | def_id, | |
| 1898 | import_ids: smallvec![], | |
| 1899 | lint_ambiguous: false, | |
| 1900 | }); | |
| 1881 | 1901 | } |
| 1882 | 1902 | } |
| 1883 | 1903 | |
| ... | ... | @@ -1915,11 +1935,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 1915 | 1935 | ) { |
| 1916 | 1936 | module.ensure_traits(self); |
| 1917 | 1937 | let traits = module.traits.borrow(); |
| 1918 | for &(trait_name, trait_binding, trait_module) in traits.as_ref().unwrap().iter() { | |
| 1938 | for &(trait_name, trait_binding, trait_module, lint_ambiguous) in | |
| 1939 | traits.as_ref().unwrap().iter() | |
| 1940 | { | |
| 1919 | 1941 | if self.trait_may_have_item(trait_module, assoc_item) { |
| 1920 | 1942 | let def_id = trait_binding.res().def_id(); |
| 1921 | 1943 | let import_ids = self.find_transitive_imports(&trait_binding.kind, trait_name.0); |
| 1922 | found_traits.push(TraitCandidate { def_id, import_ids }); | |
| 1944 | found_traits.push(TraitCandidate { def_id, import_ids, lint_ambiguous }); | |
| 1923 | 1945 | } |
| 1924 | 1946 | } |
| 1925 | 1947 | } |
compiler/rustc_session/src/config.rs+42-6| ... | ... | @@ -22,7 +22,9 @@ use rustc_hashes::Hash64; |
| 22 | 22 | use rustc_macros::{BlobDecodable, Decodable, Encodable, HashStable_Generic}; |
| 23 | 23 | use rustc_span::edition::{DEFAULT_EDITION, EDITION_NAME_LIST, Edition, LATEST_STABLE_EDITION}; |
| 24 | 24 | use rustc_span::source_map::FilePathMapping; |
| 25 | use rustc_span::{FileName, RealFileName, SourceFileHashAlgorithm, Symbol, sym}; | |
| 25 | use rustc_span::{ | |
| 26 | FileName, RealFileName, RemapPathScopeComponents, SourceFileHashAlgorithm, Symbol, sym, | |
| 27 | }; | |
| 26 | 28 | use rustc_target::spec::{ |
| 27 | 29 | FramePointer, LinkSelfContainedComponents, LinkerFeatures, PanicStrategy, SplitDebuginfo, |
| 28 | 30 | Target, TargetTuple, |
| ... | ... | @@ -1317,6 +1319,29 @@ impl OutputFilenames { |
| 1317 | 1319 | } |
| 1318 | 1320 | } |
| 1319 | 1321 | |
| 1322 | pub(crate) fn parse_remap_path_scope( | |
| 1323 | early_dcx: &EarlyDiagCtxt, | |
| 1324 | matches: &getopts::Matches, | |
| 1325 | ) -> RemapPathScopeComponents { | |
| 1326 | if let Some(v) = matches.opt_str("remap-path-scope") { | |
| 1327 | let mut slot = RemapPathScopeComponents::empty(); | |
| 1328 | for s in v.split(',') { | |
| 1329 | slot |= match s { | |
| 1330 | "macro" => RemapPathScopeComponents::MACRO, | |
| 1331 | "diagnostics" => RemapPathScopeComponents::DIAGNOSTICS, | |
| 1332 | "debuginfo" => RemapPathScopeComponents::DEBUGINFO, | |
| 1333 | "coverage" => RemapPathScopeComponents::COVERAGE, | |
| 1334 | "object" => RemapPathScopeComponents::OBJECT, | |
| 1335 | "all" => RemapPathScopeComponents::all(), | |
| 1336 | _ => early_dcx.early_fatal("argument for `--remap-path-scope` must be a comma separated list of scopes: `macro`, `diagnostics`, `debuginfo`, `coverage`, `object`, `all`"), | |
| 1337 | } | |
| 1338 | } | |
| 1339 | slot | |
| 1340 | } else { | |
| 1341 | RemapPathScopeComponents::all() | |
| 1342 | } | |
| 1343 | } | |
| 1344 | ||
| 1320 | 1345 | #[derive(Clone, Debug)] |
| 1321 | 1346 | pub struct Sysroot { |
| 1322 | 1347 | pub explicit: Option<PathBuf>, |
| ... | ... | @@ -1353,9 +1378,9 @@ pub fn host_tuple() -> &'static str { |
| 1353 | 1378 | |
| 1354 | 1379 | fn file_path_mapping( |
| 1355 | 1380 | remap_path_prefix: Vec<(PathBuf, PathBuf)>, |
| 1356 | unstable_opts: &UnstableOptions, | |
| 1381 | remap_path_scope: RemapPathScopeComponents, | |
| 1357 | 1382 | ) -> FilePathMapping { |
| 1358 | FilePathMapping::new(remap_path_prefix.clone(), unstable_opts.remap_path_scope) | |
| 1383 | FilePathMapping::new(remap_path_prefix.clone(), remap_path_scope) | |
| 1359 | 1384 | } |
| 1360 | 1385 | |
| 1361 | 1386 | impl Default for Options { |
| ... | ... | @@ -1367,7 +1392,7 @@ impl Default for Options { |
| 1367 | 1392 | // to create a default working directory. |
| 1368 | 1393 | let working_dir = { |
| 1369 | 1394 | let working_dir = std::env::current_dir().unwrap(); |
| 1370 | let file_mapping = file_path_mapping(Vec::new(), &unstable_opts); | |
| 1395 | let file_mapping = file_path_mapping(Vec::new(), RemapPathScopeComponents::empty()); | |
| 1371 | 1396 | file_mapping.to_real_filename(&RealFileName::empty(), &working_dir) |
| 1372 | 1397 | }; |
| 1373 | 1398 | |
| ... | ... | @@ -1402,6 +1427,7 @@ impl Default for Options { |
| 1402 | 1427 | cli_forced_codegen_units: None, |
| 1403 | 1428 | cli_forced_local_thinlto_off: false, |
| 1404 | 1429 | remap_path_prefix: Vec::new(), |
| 1430 | remap_path_scope: RemapPathScopeComponents::all(), | |
| 1405 | 1431 | real_rust_source_base_dir: None, |
| 1406 | 1432 | real_rustc_dev_source_base_dir: None, |
| 1407 | 1433 | edition: DEFAULT_EDITION, |
| ... | ... | @@ -1428,7 +1454,7 @@ impl Options { |
| 1428 | 1454 | } |
| 1429 | 1455 | |
| 1430 | 1456 | pub fn file_path_mapping(&self) -> FilePathMapping { |
| 1431 | file_path_mapping(self.remap_path_prefix.clone(), &self.unstable_opts) | |
| 1457 | file_path_mapping(self.remap_path_prefix.clone(), self.remap_path_scope) | |
| 1432 | 1458 | } |
| 1433 | 1459 | |
| 1434 | 1460 | /// Returns `true` if there will be an output file generated. |
| ... | ... | @@ -1866,6 +1892,14 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> { |
| 1866 | 1892 | "Remap source names in all output (compiler messages and output files)", |
| 1867 | 1893 | "<FROM>=<TO>", |
| 1868 | 1894 | ), |
| 1895 | opt( | |
| 1896 | Stable, | |
| 1897 | Opt, | |
| 1898 | "", | |
| 1899 | "remap-path-scope", | |
| 1900 | "Defines which scopes of paths should be remapped by `--remap-path-prefix`", | |
| 1901 | "<macro,diagnostics,debuginfo,coverage,object,all>", | |
| 1902 | ), | |
| 1869 | 1903 | opt(Unstable, Multi, "", "env-set", "Inject an environment variable", "<VAR>=<VALUE>"), |
| 1870 | 1904 | ]; |
| 1871 | 1905 | options.extend(verbose_only.into_iter().map(|mut opt| { |
| ... | ... | @@ -2669,6 +2703,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M |
| 2669 | 2703 | let externs = parse_externs(early_dcx, matches, &unstable_opts); |
| 2670 | 2704 | |
| 2671 | 2705 | let remap_path_prefix = parse_remap_path_prefix(early_dcx, matches, &unstable_opts); |
| 2706 | let remap_path_scope = parse_remap_path_scope(early_dcx, matches); | |
| 2672 | 2707 | |
| 2673 | 2708 | let pretty = parse_pretty(early_dcx, &unstable_opts); |
| 2674 | 2709 | |
| ... | ... | @@ -2735,7 +2770,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M |
| 2735 | 2770 | early_dcx.early_fatal(format!("Current directory is invalid: {e}")); |
| 2736 | 2771 | }); |
| 2737 | 2772 | |
| 2738 | let file_mapping = file_path_mapping(remap_path_prefix.clone(), &unstable_opts); | |
| 2773 | let file_mapping = file_path_mapping(remap_path_prefix.clone(), remap_path_scope); | |
| 2739 | 2774 | file_mapping.to_real_filename(&RealFileName::empty(), &working_dir) |
| 2740 | 2775 | }; |
| 2741 | 2776 | |
| ... | ... | @@ -2772,6 +2807,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M |
| 2772 | 2807 | cli_forced_codegen_units: codegen_units, |
| 2773 | 2808 | cli_forced_local_thinlto_off: disable_local_thinlto, |
| 2774 | 2809 | remap_path_prefix, |
| 2810 | remap_path_scope, | |
| 2775 | 2811 | real_rust_source_base_dir, |
| 2776 | 2812 | real_rustc_dev_source_base_dir, |
| 2777 | 2813 | edition, |
compiler/rustc_session/src/options.rs+2-26| ... | ... | @@ -454,6 +454,8 @@ top_level_options!( |
| 454 | 454 | |
| 455 | 455 | /// Remap source path prefixes in all output (messages, object files, debug, etc.). |
| 456 | 456 | remap_path_prefix: Vec<(PathBuf, PathBuf)> [TRACKED_NO_CRATE_HASH], |
| 457 | /// Defines which scopes of paths should be remapped by `--remap-path-prefix`. | |
| 458 | remap_path_scope: RemapPathScopeComponents [TRACKED_NO_CRATE_HASH], | |
| 457 | 459 | |
| 458 | 460 | /// Base directory containing the `library/` directory for the Rust standard library. |
| 459 | 461 | /// Right now it's always `$sysroot/lib/rustlib/src/rust` |
| ... | ... | @@ -872,7 +874,6 @@ mod desc { |
| 872 | 874 | pub(crate) const parse_branch_protection: &str = "a `,` separated combination of `bti`, `gcs`, `pac-ret`, (optionally with `pc`, `b-key`, `leaf` if `pac-ret` is set)"; |
| 873 | 875 | pub(crate) const parse_proc_macro_execution_strategy: &str = |
| 874 | 876 | "one of supported execution strategies (`same-thread`, or `cross-thread`)"; |
| 875 | pub(crate) const parse_remap_path_scope: &str = "comma separated list of scopes: `macro`, `diagnostics`, `debuginfo`, `coverage`, `object`, `all`"; | |
| 876 | 877 | pub(crate) const parse_inlining_threshold: &str = |
| 877 | 878 | "either a boolean (`yes`, `no`, `on`, `off`, etc), or a non-negative number"; |
| 878 | 879 | pub(crate) const parse_llvm_module_flag: &str = "<key>:<type>:<value>:<behavior>. Type must currently be `u32`. Behavior should be one of (`error`, `warning`, `require`, `override`, `append`, `appendunique`, `max`, `min`)"; |
| ... | ... | @@ -1737,29 +1738,6 @@ pub mod parse { |
| 1737 | 1738 | true |
| 1738 | 1739 | } |
| 1739 | 1740 | |
| 1740 | pub(crate) fn parse_remap_path_scope( | |
| 1741 | slot: &mut RemapPathScopeComponents, | |
| 1742 | v: Option<&str>, | |
| 1743 | ) -> bool { | |
| 1744 | if let Some(v) = v { | |
| 1745 | *slot = RemapPathScopeComponents::empty(); | |
| 1746 | for s in v.split(',') { | |
| 1747 | *slot |= match s { | |
| 1748 | "macro" => RemapPathScopeComponents::MACRO, | |
| 1749 | "diagnostics" => RemapPathScopeComponents::DIAGNOSTICS, | |
| 1750 | "debuginfo" => RemapPathScopeComponents::DEBUGINFO, | |
| 1751 | "coverage" => RemapPathScopeComponents::COVERAGE, | |
| 1752 | "object" => RemapPathScopeComponents::OBJECT, | |
| 1753 | "all" => RemapPathScopeComponents::all(), | |
| 1754 | _ => return false, | |
| 1755 | } | |
| 1756 | } | |
| 1757 | true | |
| 1758 | } else { | |
| 1759 | false | |
| 1760 | } | |
| 1761 | } | |
| 1762 | ||
| 1763 | 1741 | pub(crate) fn parse_relocation_model(slot: &mut Option<RelocModel>, v: Option<&str>) -> bool { |
| 1764 | 1742 | match v.and_then(|s| RelocModel::from_str(s).ok()) { |
| 1765 | 1743 | Some(relocation_model) => *slot = Some(relocation_model), |
| ... | ... | @@ -2614,8 +2592,6 @@ options! { |
| 2614 | 2592 | "whether ELF relocations can be relaxed"), |
| 2615 | 2593 | remap_cwd_prefix: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED], |
| 2616 | 2594 | "remap paths under the current working directory to this path prefix"), |
| 2617 | remap_path_scope: RemapPathScopeComponents = (RemapPathScopeComponents::all(), parse_remap_path_scope, [TRACKED], | |
| 2618 | "remap path scope (default: all)"), | |
| 2619 | 2595 | remark_dir: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED], |
| 2620 | 2596 | "directory into which to write optimization remarks (if not specified, they will be \ |
| 2621 | 2597 | written to standard error output)"), |
compiler/rustc_target/src/spec/mod.rs+2| ... | ... | @@ -1801,6 +1801,8 @@ supported_targets! { |
| 1801 | 1801 | ("x86_64-lynx-lynxos178", x86_64_lynx_lynxos178), |
| 1802 | 1802 | |
| 1803 | 1803 | ("x86_64-pc-cygwin", x86_64_pc_cygwin), |
| 1804 | ||
| 1805 | ("x86_64-unknown-linux-gnuasan", x86_64_unknown_linux_gnuasan), | |
| 1804 | 1806 | } |
| 1805 | 1807 | |
| 1806 | 1808 | /// Cow-Vec-Str: Cow<'static, [Cow<'static, str>]> |
compiler/rustc_target/src/spec/targets/i586_unknown_redox.rs+1-1| ... | ... | @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { |
| 11 | 11 | |
| 12 | 12 | Target { |
| 13 | 13 | llvm_target: "i586-unknown-redox".into(), |
| 14 | metadata: TargetMetadata { description: None, tier: None, host_tools: None, std: None }, | |
| 14 | metadata: TargetMetadata { description: None, tier: Some(3), host_tools: None, std: None }, | |
| 15 | 15 | pointer_width: 32, |
| 16 | 16 | data_layout: |
| 17 | 17 | "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:32-n8:16:32-S128" |
compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnuasan.rs created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | use crate::spec::{SanitizerSet, Target, TargetMetadata}; | |
| 2 | ||
| 3 | pub(crate) fn target() -> Target { | |
| 4 | let mut base = super::x86_64_unknown_linux_gnu::target(); | |
| 5 | base.metadata = TargetMetadata { | |
| 6 | description: Some( | |
| 7 | "64-bit Linux (kernel 3.2+, glibc 2.17+) with ASAN enabled by default".into(), | |
| 8 | ), | |
| 9 | tier: Some(2), | |
| 10 | host_tools: Some(false), | |
| 11 | std: Some(true), | |
| 12 | }; | |
| 13 | base.supported_sanitizers = SanitizerSet::ADDRESS; | |
| 14 | base.default_sanitizers = SanitizerSet::ADDRESS; | |
| 15 | base | |
| 16 | } |
compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_none.rs+1-1| ... | ... | @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target { |
| 15 | 15 | llvm_target: "x86_64-unknown-linux-none".into(), |
| 16 | 16 | metadata: TargetMetadata { |
| 17 | 17 | description: None, |
| 18 | tier: None, | |
| 18 | tier: Some(3), | |
| 19 | 19 | host_tools: None, |
| 20 | 20 | std: Some(false), |
| 21 | 21 | }, |
compiler/rustc_target/src/spec/targets/xtensa_esp32_espidf.rs+1-1| ... | ... | @@ -9,7 +9,7 @@ pub(crate) fn target() -> Target { |
| 9 | 9 | pointer_width: 32, |
| 10 | 10 | data_layout: "e-m:e-p:32:32-v1:8:8-i64:64-i128:128-n32".into(), |
| 11 | 11 | arch: Arch::Xtensa, |
| 12 | metadata: TargetMetadata { description: None, tier: None, host_tools: None, std: None }, | |
| 12 | metadata: TargetMetadata { description: None, tier: Some(3), host_tools: None, std: None }, | |
| 13 | 13 | |
| 14 | 14 | options: TargetOptions { |
| 15 | 15 | endian: Endian::Little, |
compiler/rustc_target/src/spec/targets/xtensa_esp32s2_espidf.rs+1-1| ... | ... | @@ -9,7 +9,7 @@ pub(crate) fn target() -> Target { |
| 9 | 9 | pointer_width: 32, |
| 10 | 10 | data_layout: "e-m:e-p:32:32-v1:8:8-i64:64-i128:128-n32".into(), |
| 11 | 11 | arch: Arch::Xtensa, |
| 12 | metadata: TargetMetadata { description: None, tier: None, host_tools: None, std: None }, | |
| 12 | metadata: TargetMetadata { description: None, tier: Some(3), host_tools: None, std: None }, | |
| 13 | 13 | |
| 14 | 14 | options: TargetOptions { |
| 15 | 15 | endian: Endian::Little, |
compiler/rustc_target/src/spec/targets/xtensa_esp32s3_espidf.rs+1-1| ... | ... | @@ -9,7 +9,7 @@ pub(crate) fn target() -> Target { |
| 9 | 9 | pointer_width: 32, |
| 10 | 10 | data_layout: "e-m:e-p:32:32-v1:8:8-i64:64-i128:128-n32".into(), |
| 11 | 11 | arch: Arch::Xtensa, |
| 12 | metadata: TargetMetadata { description: None, tier: None, host_tools: None, std: None }, | |
| 12 | metadata: TargetMetadata { description: None, tier: Some(3), host_tools: None, std: None }, | |
| 13 | 13 | |
| 14 | 14 | options: TargetOptions { |
| 15 | 15 | endian: Endian::Little, |
src/bootstrap/mk/Makefile.in+5| ... | ... | @@ -53,6 +53,11 @@ check-aux: |
| 53 | 53 | 		src/tools/cargotest \ |
| 54 | 54 | 		src/tools/test-float-parse \ |
| 55 | 55 | 		$(BOOTSTRAP_ARGS) |
| 56 | 	# The build-std suite is off by default because it is uncommonly slow | |
| 57 | 	# and memory-hungry. | |
| 58 | 	$(Q)$(BOOTSTRAP) test --stage 2 \ | |
| 59 | 		build-std \ | |
| 60 | 		$(BOOTSTRAP_ARGS) | |
| 56 | 61 | 	# Run standard library tests in Miri. |
| 57 | 62 | 	$(Q)MIRIFLAGS="-Zmiri-strict-provenance" \ |
| 58 | 63 | 		$(BOOTSTRAP) miri --stage 2 \ |
src/bootstrap/src/core/build_steps/llvm.rs+1| ... | ... | @@ -1515,6 +1515,7 @@ fn supported_sanitizers( |
| 1515 | 1515 | "x86_64", |
| 1516 | 1516 | &["asan", "dfsan", "lsan", "msan", "safestack", "tsan", "rtsan"], |
| 1517 | 1517 | ), |
| 1518 | "x86_64-unknown-linux-gnuasan" => common_libs("linux", "x86_64", &["asan"]), | |
| 1518 | 1519 | "x86_64-unknown-linux-musl" => { |
| 1519 | 1520 | common_libs("linux", "x86_64", &["asan", "lsan", "msan", "tsan"]) |
| 1520 | 1521 | } |
src/bootstrap/src/core/build_steps/test.rs+7-1| ... | ... | @@ -1625,6 +1625,12 @@ test!(RunMakeCargo { |
| 1625 | 1625 | suite: "run-make-cargo", |
| 1626 | 1626 | default: true |
| 1627 | 1627 | }); |
| 1628 | test!(BuildStd { | |
| 1629 | path: "tests/build-std", | |
| 1630 | mode: CompiletestMode::RunMake, | |
| 1631 | suite: "build-std", | |
| 1632 | default: false | |
| 1633 | }); | |
| 1628 | 1634 | |
| 1629 | 1635 | test!(AssemblyLlvm { |
| 1630 | 1636 | path: "tests/assembly-llvm", |
| ... | ... | @@ -1948,7 +1954,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the |
| 1948 | 1954 | let stage0_rustc_path = builder.compiler(0, test_compiler.host); |
| 1949 | 1955 | cmd.arg("--stage0-rustc-path").arg(builder.rustc(stage0_rustc_path)); |
| 1950 | 1956 | |
| 1951 | if suite == "run-make-cargo" { | |
| 1957 | if matches!(suite, "run-make-cargo" | "build-std") { | |
| 1952 | 1958 | let cargo_path = if test_compiler.stage == 0 { |
| 1953 | 1959 | // If we're using `--stage 0`, we should provide the bootstrap cargo. |
| 1954 | 1960 | builder.initial_cargo.clone() |
src/bootstrap/src/core/builder/cli_paths.rs+1| ... | ... | @@ -20,6 +20,7 @@ pub(crate) const PATH_REMAP: &[(&str, &[&str])] = &[ |
| 20 | 20 | &[ |
| 21 | 21 | // tidy-alphabetical-start |
| 22 | 22 | "tests/assembly-llvm", |
| 23 | "tests/build-std", | |
| 23 | 24 | "tests/codegen-llvm", |
| 24 | 25 | "tests/codegen-units", |
| 25 | 26 | "tests/coverage", |
src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tests.snap+3| ... | ... | @@ -5,6 +5,9 @@ expression: test tests |
| 5 | 5 | [Test] test::AssemblyLlvm |
| 6 | 6 | targets: [aarch64-unknown-linux-gnu] |
| 7 | 7 | - Suite(test::tests/assembly-llvm) |
| 8 | [Test] test::BuildStd | |
| 9 | targets: [aarch64-unknown-linux-gnu] | |
| 10 | - Suite(test::tests/build-std) | |
| 8 | 11 | [Test] test::CodegenLlvm |
| 9 | 12 | targets: [aarch64-unknown-linux-gnu] |
| 10 | 13 | - Suite(test::tests/codegen-llvm) |
src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tests_skip_coverage.snap+3| ... | ... | @@ -5,6 +5,9 @@ expression: test tests --skip=coverage |
| 5 | 5 | [Test] test::AssemblyLlvm |
| 6 | 6 | targets: [aarch64-unknown-linux-gnu] |
| 7 | 7 | - Suite(test::tests/assembly-llvm) |
| 8 | [Test] test::BuildStd | |
| 9 | targets: [aarch64-unknown-linux-gnu] | |
| 10 | - Suite(test::tests/build-std) | |
| 8 | 11 | [Test] test::CodegenLlvm |
| 9 | 12 | targets: [aarch64-unknown-linux-gnu] |
| 10 | 13 | - Suite(test::tests/codegen-llvm) |
src/bootstrap/src/core/builder/mod.rs+1| ... | ... | @@ -927,6 +927,7 @@ impl<'a> Builder<'a> { |
| 927 | 927 | test::CollectLicenseMetadata, |
| 928 | 928 | test::RunMake, |
| 929 | 929 | test::RunMakeCargo, |
| 930 | test::BuildStd, | |
| 930 | 931 | ), |
| 931 | 932 | Kind::Miri => describe!(test::Crate), |
| 932 | 933 | Kind::Bench => describe!(test::Crate, test::CrateLibrustc, test::CrateRustdoc), |
src/bootstrap/src/core/builder/tests.rs+2-2| ... | ... | @@ -2077,7 +2077,7 @@ mod snapshot { |
| 2077 | 2077 | let ctx = TestCtx::new(); |
| 2078 | 2078 | insta::assert_snapshot!( |
| 2079 | 2079 | prepare_test_config(&ctx) |
| 2080 | .render_steps(), @r" | |
| 2080 | .render_steps(), @" | |
| 2081 | 2081 | [build] rustc 0 <host> -> Tidy 1 <host> |
| 2082 | 2082 | [test] tidy <> |
| 2083 | 2083 | [build] rustdoc 0 <host> |
| ... | ... | @@ -2255,7 +2255,7 @@ mod snapshot { |
| 2255 | 2255 | insta::assert_snapshot!( |
| 2256 | 2256 | prepare_test_config(&ctx) |
| 2257 | 2257 | .stage(2) |
| 2258 | .render_steps(), @r" | |
| 2258 | .render_steps(), @" | |
| 2259 | 2259 | [build] rustc 0 <host> -> Tidy 1 <host> |
| 2260 | 2260 | [test] tidy <> |
| 2261 | 2261 | [build] rustdoc 0 <host> |
src/bootstrap/src/core/sanity.rs+1| ... | ... | @@ -38,6 +38,7 @@ pub struct Finder { |
| 38 | 38 | const STAGE0_MISSING_TARGETS: &[&str] = &[ |
| 39 | 39 | // just a dummy comment so the list doesn't get onelined |
| 40 | 40 | "riscv64im-unknown-none-elf", |
| 41 | "x86_64-unknown-linux-gnuasan", | |
| 41 | 42 | ]; |
| 42 | 43 | |
| 43 | 44 | /// Minimum version threshold for libstdc++ required when using prebuilt LLVM |
src/doc/rustc-dev-guide/src/tests/compiletest.md+10| ... | ... | @@ -78,6 +78,10 @@ The following test suites are available, with links for more information: |
| 78 | 78 | |
| 79 | 79 | [`run-make`](#run-make-tests) are general purpose tests using Rust programs. |
| 80 | 80 | |
| 81 | ### The build-std test suite | |
| 82 | ||
| 83 | [`build-std`](#build-std-tests) test that -Zbuild-std works. | |
| 84 | ||
| 81 | 85 | ### Rustdoc test suites |
| 82 | 86 | |
| 83 | 87 | | Test suite | Purpose | |
| ... | ... | @@ -429,6 +433,12 @@ use cases that require testing in-tree `cargo` in conjunction with in-tree `rust |
| 429 | 433 | The `run-make` test suite does not have access to in-tree `cargo` (so it can be the |
| 430 | 434 | faster-to-iterate test suite). |
| 431 | 435 | |
| 436 | ### `build-std` tests | |
| 437 | ||
| 438 | The tests in [`tests/build-std`] check that `-Zbuild-std` works. This is currently | |
| 439 | just a run-make test suite with a single recipe. The recipe generates test cases | |
| 440 | and runs them in parallel. | |
| 441 | ||
| 432 | 442 | #### Using Rust recipes |
| 433 | 443 | |
| 434 | 444 | Each test should be in a separate directory with a `rmake.rs` Rust program, |
src/doc/rustc/src/SUMMARY.md+1| ... | ... | @@ -151,5 +151,6 @@ |
| 151 | 151 | - [x86_64-pc-cygwin](platform-support/x86_64-pc-cygwin.md) |
| 152 | 152 | - [x86_64-unknown-linux-none](platform-support/x86_64-unknown-linux-none.md) |
| 153 | 153 | - [x86_64-unknown-none](platform-support/x86_64-unknown-none.md) |
| 154 | - [x86_64-unknown-linux-gnuasan](platform-support/x86_64-unknown-linux-gnuasan.md) | |
| 154 | 155 | - [xtensa-\*-none-elf](platform-support/xtensa.md) |
| 155 | 156 | - [\*-nuttx-\*](platform-support/nuttx.md) |
src/doc/rustc/src/command-line-arguments.md+8| ... | ... | @@ -428,6 +428,14 @@ specified multiple times. |
| 428 | 428 | Refer to the [Remap source paths](remap-source-paths.md) section of this book for |
| 429 | 429 | further details and explanation. |
| 430 | 430 | |
| 431 | <a id="option-remap-path-scope"></a> | |
| 432 | ## `--remap-path-scope`: remap source paths in output | |
| 433 | ||
| 434 | Defines which scopes of paths should be remapped by `--remap-path-prefix`. | |
| 435 | ||
| 436 | Refer to the [Remap source paths](remap-source-paths.md) section of this book for | |
| 437 | further details and explanation. | |
| 438 | ||
| 431 | 439 | <a id="option-json"></a> |
| 432 | 440 | ## `--json`: configure json messages printed by the compiler |
| 433 | 441 |
src/doc/rustc/src/platform-support.md+1| ... | ... | @@ -206,6 +206,7 @@ target | std | notes |
| 206 | 206 | [`x86_64-apple-ios-macabi`](platform-support/apple-ios-macabi.md) | ✓ | Mac Catalyst on x86_64 |
| 207 | 207 | [`x86_64-fortanix-unknown-sgx`](platform-support/x86_64-fortanix-unknown-sgx.md) | ✓ | [Fortanix ABI] for 64-bit Intel SGX |
| 208 | 208 | [`x86_64-linux-android`](platform-support/android.md) | ✓ | 64-bit x86 Android |
| 209 | [`x86_64-unknown-linux-gnuasan`](platform-support/x86_64-unknown-linux-gnuasan.md) | ✓ | 64-bit Linux (kernel 3.2+, glibc 2.17+) with ASAN enabled by default | |
| 209 | 210 | [`x86_64-unknown-fuchsia`](platform-support/fuchsia.md) | ✓ | 64-bit x86 Fuchsia |
| 210 | 211 | `x86_64-unknown-linux-gnux32` | ✓ | 64-bit Linux (x32 ABI) (kernel 4.15+, glibc 2.27) |
| 211 | 212 | [`x86_64-unknown-none`](platform-support/x86_64-unknown-none.md) | * | Freestanding/bare-metal x86_64, softfloat |
src/doc/rustc/src/platform-support/x86_64-unknown-linux-gnuasan.md created+56| ... | ... | @@ -0,0 +1,56 @@ |
| 1 | # `x86_64-unknown-linux-gnuasan` | |
| 2 | ||
| 3 | **Tier: 2** | |
| 4 | ||
| 5 | Target mirroring `x86_64-unknown-linux-gnu` with AddressSanitizer enabled by | |
| 6 | default. | |
| 7 | The goal of this target is to allow shipping ASAN-instrumented standard | |
| 8 | libraries through rustup, enabling a fully instrumented binary without requiring | |
| 9 | nightly features (build-std). | |
| 10 | Once build-std stabilizes, this target is no longer needed and will be removed. | |
| 11 | ||
| 12 | ## Target maintainers | |
| 13 | ||
| 14 | - [@jakos-sec](https://github.com/jakos-sec) | |
| 15 | - [@1c3t3a](https://github.com/1c3t3a) | |
| 16 | - [@rust-lang/project-exploit-mitigations][project-exploit-mitigations] | |
| 17 | ||
| 18 | ## Requirements | |
| 19 | ||
| 20 | The target is for cross-compilation only. Host tools are not supported, since | |
| 21 | there is no need to have the host tools instrumented with ASAN. std is fully | |
| 22 | supported. | |
| 23 | ||
| 24 | In all other aspects the target is equivalent to `x86_64-unknown-linux-gnu`. | |
| 25 | ||
| 26 | ## Building the target | |
| 27 | ||
| 28 | The target can be built by enabling it for a rustc build: | |
| 29 | ||
| 30 | ```toml | |
| 31 | [build] | |
| 32 | target = ["x86_64-unknown-linux-gnuasan"] | |
| 33 | ``` | |
| 34 | ||
| 35 | ## Building Rust programs | |
| 36 | ||
| 37 | Rust programs can be compiled by adding this target via rustup: | |
| 38 | ||
| 39 | ```sh | |
| 40 | $ rustup target add x86_64-unknown-linux-gnuasan | |
| 41 | ``` | |
| 42 | ||
| 43 | and then compiling with the target: | |
| 44 | ||
| 45 | ```sh | |
| 46 | $ rustc foo.rs --target x86_64-unknown-linux-gnuasan | |
| 47 | ``` | |
| 48 | ||
| 49 | ## Testing | |
| 50 | ||
| 51 | Created binaries will run on Linux without any external requirements. | |
| 52 | ||
| 53 | ## Cross-compilation toolchains and C code | |
| 54 | ||
| 55 | The target supports C code and should use the same toolchain target as | |
| 56 | `x86_64-unknown-linux-gnu`. |
src/doc/rustc/src/remap-source-paths.md+26-1| ... | ... | @@ -6,7 +6,7 @@ output, including compiler diagnostics, debugging information, macro expansions, |
| 6 | 6 | This is useful for normalizing build products, for example, by removing the current directory |
| 7 | 7 | out of the paths emitted into object files. |
| 8 | 8 | |
| 9 | The remapping is done via the `--remap-path-prefix` option. | |
| 9 | The remapping is done via the `--remap-path-prefix` flag and can be customized via the `--remap-path-scope` flag. | |
| 10 | 10 | |
| 11 | 11 | ## `--remap-path-prefix` |
| 12 | 12 | |
| ... | ... | @@ -39,6 +39,31 @@ rustc --remap-path-prefix "/home/user/project=/redacted" |
| 39 | 39 | |
| 40 | 40 | This example replaces all occurrences of `/home/user/project` in emitted paths with `/redacted`. |
| 41 | 41 | |
| 42 | ## `--remap-path-scope` | |
| 43 | ||
| 44 | Defines which scopes of paths should be remapped by `--remap-path-prefix`. | |
| 45 | ||
| 46 | This flag accepts a comma-separated list of values and may be specified multiple times, in which case the scopes are aggregated together. | |
| 47 | ||
| 48 | The valid scopes are: | |
| 49 | ||
| 50 | - `macro` - apply remappings to the expansion of `std::file!()` macro. This is where paths in embedded panic messages come from | |
| 51 | - `diagnostics` - apply remappings to printed compiler diagnostics | |
| 52 | - `debuginfo` - apply remappings to debug information | |
| 53 | - `coverage` - apply remappings to coverage information | |
| 54 | - `object` - apply remappings to all paths in compiled executables or libraries, but not elsewhere. Currently an alias for `macro,coverage,debuginfo`. | |
| 55 | - `all` (default) - an alias for all of the above, also equivalent to supplying only `--remap-path-prefix` without `--remap-path-scope`. | |
| 56 | ||
| 57 | The scopes accepted by `--remap-path-scope` are not exhaustive - new scopes may be added in future releases for eventual stabilisation. | |
| 58 | This implies that the `all` scope can correspond to different scopes between releases. | |
| 59 | ||
| 60 | ### Example | |
| 61 | ||
| 62 | ```sh | |
| 63 | # With `object` scope only the build outputs will be remapped, the diagnostics won't be remapped. | |
| 64 | rustc --remap-path-prefix=$(PWD)=/remapped --remap-path-scope=object main.rs | |
| 65 | ``` | |
| 66 | ||
| 42 | 67 | ## Caveats and Limitations |
| 43 | 68 | |
| 44 | 69 | ### Paths generated by linkers |
src/doc/unstable-book/src/compiler-flags/remap-path-scope.md deleted-23| ... | ... | @@ -1,23 +0,0 @@ |
| 1 | # `remap-path-scope` | |
| 2 | ||
| 3 | The tracking issue for this feature is: [#111540](https://github.com/rust-lang/rust/issues/111540). | |
| 4 | ||
| 5 | ------------------------ | |
| 6 | ||
| 7 | When the `--remap-path-prefix` option is passed to rustc, source path prefixes in all output will be affected by default. | |
| 8 | The `--remap-path-scope` argument can be used in conjunction with `--remap-path-prefix` to determine paths in which output context should be affected. | |
| 9 | This flag accepts a comma-separated list of values and may be specified multiple times, in which case the scopes are aggregated together. The valid scopes are: | |
| 10 | ||
| 11 | - `macro` - apply remappings to the expansion of `std::file!()` macro. This is where paths in embedded panic messages come from | |
| 12 | - `diagnostics` - apply remappings to printed compiler diagnostics | |
| 13 | - `debuginfo` - apply remappings to debug information | |
| 14 | - `coverage` - apply remappings to coverage information | |
| 15 | - `object` - apply remappings to all paths in compiled executables or libraries, but not elsewhere. Currently an alias for `macro,debuginfo`. | |
| 16 | - `all` - an alias for all of the above, also equivalent to supplying only `--remap-path-prefix` without `--remap-path-scope`. | |
| 17 | ||
| 18 | ## Example | |
| 19 | ```sh | |
| 20 | # This would produce an absolute path to main.rs in build outputs of | |
| 21 | # "./main.rs". | |
| 22 | rustc --remap-path-prefix=$(PWD)=/remapped -Zremap-path-scope=object main.rs | |
| 23 | ``` |
src/tools/compiletest/src/common.rs+1| ... | ... | @@ -77,6 +77,7 @@ string_enum! { |
| 77 | 77 | RustdocUi => "rustdoc-ui", |
| 78 | 78 | Ui => "ui", |
| 79 | 79 | UiFullDeps => "ui-fulldeps", |
| 80 | BuildStd => "build-std", | |
| 80 | 81 | } |
| 81 | 82 | } |
| 82 | 83 |
src/tools/compiletest/src/runtest/run_make.rs+2-2| ... | ... | @@ -190,8 +190,8 @@ impl TestCx<'_> { |
| 190 | 190 | // through a specific CI runner). |
| 191 | 191 | .env("LLVM_COMPONENTS", &self.config.llvm_components); |
| 192 | 192 | |
| 193 | // Only `run-make-cargo` test suite gets an in-tree `cargo`, not `run-make`. | |
| 194 | if self.config.suite == TestSuite::RunMakeCargo { | |
| 193 | // The `run-make-cargo` and `build-std` suites need an in-tree `cargo`, `run-make` does not. | |
| 194 | if matches!(self.config.suite, TestSuite::RunMakeCargo | TestSuite::BuildStd) { | |
| 195 | 195 | cmd.env( |
| 196 | 196 | "CARGO", |
| 197 | 197 | self.config.cargo_path.as_ref().expect("cargo must be built and made available"), |
src/tools/llvm-bitcode-linker/src/linker.rs+3-3| ... | ... | @@ -68,7 +68,7 @@ impl Session { |
| 68 | 68 | .arg("-o") |
| 69 | 69 | .arg(&self.link_path) |
| 70 | 70 | .output() |
| 71 | .context("An error occured when calling llvm-link. Make sure the llvm-tools component is installed.")?; | |
| 71 | .context("An error occurred when calling llvm-link. Make sure the llvm-tools component is installed.")?; | |
| 72 | 72 | |
| 73 | 73 | if !llvm_link_output.status.success() { |
| 74 | 74 | tracing::error!( |
| ... | ... | @@ -115,7 +115,7 @@ impl Session { |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | let opt_output = opt_cmd.output().context( |
| 118 | "An error occured when calling opt. Make sure the llvm-tools component is installed.", | |
| 118 | "An error occurred when calling opt. Make sure the llvm-tools component is installed.", | |
| 119 | 119 | )?; |
| 120 | 120 | |
| 121 | 121 | if !opt_output.status.success() { |
| ... | ... | @@ -149,7 +149,7 @@ impl Session { |
| 149 | 149 | .arg(&self.opt_path) |
| 150 | 150 | .arg("-o").arg(&self.out_path) |
| 151 | 151 | .output() |
| 152 | .context("An error occured when calling llc. Make sure the llvm-tools component is installed.")?; | |
| 152 | .context("An error occurred when calling llc. Make sure the llvm-tools component is installed.")?; | |
| 153 | 153 | |
| 154 | 154 | if !lcc_output.status.success() { |
| 155 | 155 | tracing::error!( |
src/tools/miri/genmc-sys/cpp/include/MiriInterface.hpp+1-1| ... | ... | @@ -79,7 +79,7 @@ struct MiriGenmcShim : private GenMCDriver { |
| 79 | 79 | void handle_execution_start(); |
| 80 | 80 | // This function must be called at the end of any execution, even if an error was found |
| 81 | 81 | // during the execution. |
| 82 | // Returns `null`, or a string containing an error message if an error occured. | |
| 82 | // Returns `null`, or a string containing an error message if an error occurred. | |
| 83 | 83 | std::unique_ptr<std::string> handle_execution_end(); |
| 84 | 84 | |
| 85 | 85 | /***** Functions for handling events encountered during program execution. *****/ |
src/tools/miri/genmc-sys/src/lib.rs+1-1| ... | ... | @@ -379,7 +379,7 @@ mod ffi { |
| 379 | 379 | /// This function must be called at the start of any execution, before any events are reported to GenMC. |
| 380 | 380 | fn handle_execution_start(self: Pin<&mut MiriGenmcShim>); |
| 381 | 381 | /// This function must be called at the end of any execution, even if an error was found during the execution. |
| 382 | /// Returns `null`, or a string containing an error message if an error occured. | |
| 382 | /// Returns `null`, or a string containing an error message if an error occurred. | |
| 383 | 383 | fn handle_execution_end(self: Pin<&mut MiriGenmcShim>) -> UniquePtr<CxxString>; |
| 384 | 384 | |
| 385 | 385 | /***** Functions for handling events encountered during program execution. *****/ |
src/tools/miri/src/concurrency/genmc/mod.rs+1-1| ... | ... | @@ -220,7 +220,7 @@ impl GenmcCtx { |
| 220 | 220 | /// Don't call this function if an error was found. |
| 221 | 221 | /// |
| 222 | 222 | /// GenMC detects certain errors only when the execution ends. |
| 223 | /// If an error occured, a string containing a short error description is returned. | |
| 223 | /// If an error occurred, a string containing a short error description is returned. | |
| 224 | 224 | /// |
| 225 | 225 | /// GenMC currently doesn't return an error in all cases immediately when one happens. |
| 226 | 226 | /// This function will also check for those, and return their error description. |
src/tools/run-make-support/Cargo.toml+1| ... | ... | @@ -17,6 +17,7 @@ object = "0.37" |
| 17 | 17 | regex = "1.11" |
| 18 | 18 | serde_json = "1.0" |
| 19 | 19 | similar = "2.7" |
| 20 | tempfile = "3" | |
| 20 | 21 | wasmparser = { version = "0.236", default-features = false, features = ["std", "features", "validate"] } |
| 21 | 22 | # tidy-alphabetical-end |
| 22 | 23 |
src/tools/run-make-support/src/command.rs+13| ... | ... | @@ -46,6 +46,8 @@ pub struct Command { |
| 46 | 46 | // Emulate linear type semantics. |
| 47 | 47 | drop_bomb: DropBomb, |
| 48 | 48 | already_executed: bool, |
| 49 | ||
| 50 | context: String, | |
| 49 | 51 | } |
| 50 | 52 | |
| 51 | 53 | impl Command { |
| ... | ... | @@ -60,6 +62,7 @@ impl Command { |
| 60 | 62 | stdout: None, |
| 61 | 63 | stderr: None, |
| 62 | 64 | already_executed: false, |
| 65 | context: String::new(), | |
| 63 | 66 | } |
| 64 | 67 | } |
| 65 | 68 | |
| ... | ... | @@ -69,6 +72,16 @@ impl Command { |
| 69 | 72 | self.cmd |
| 70 | 73 | } |
| 71 | 74 | |
| 75 | pub(crate) fn get_context(&self) -> &str { | |
| 76 | &self.context | |
| 77 | } | |
| 78 | ||
| 79 | /// Appends context to the command, to provide a better error message if the command fails. | |
| 80 | pub fn context(&mut self, ctx: &str) -> &mut Self { | |
| 81 | self.context.push_str(&format!("{ctx}\n")); | |
| 82 | self | |
| 83 | } | |
| 84 | ||
| 72 | 85 | /// Specify a stdin input buffer. This is a convenience helper, |
| 73 | 86 | pub fn stdin_buf<I: AsRef<[u8]>>(&mut self, input: I) -> &mut Self { |
| 74 | 87 | self.stdin_buf = Some(input.as_ref().to_vec().into_boxed_slice()); |
src/tools/run-make-support/src/lib.rs+3-1| ... | ... | @@ -34,7 +34,9 @@ pub mod rfs { |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | // Re-exports of third-party library crates. |
| 37 | pub use {bstr, gimli, libc, object, regex, rustdoc_json_types, serde_json, similar, wasmparser}; | |
| 37 | pub use { | |
| 38 | bstr, gimli, libc, object, regex, rustdoc_json_types, serde_json, similar, tempfile, wasmparser, | |
| 39 | }; | |
| 38 | 40 | |
| 39 | 41 | // Helpers for building names of output artifacts that are potentially target-specific. |
| 40 | 42 | pub use crate::artifact_names::{ |
src/tools/run-make-support/src/util.rs+3| ... | ... | @@ -21,6 +21,9 @@ pub(crate) fn handle_failed_output( |
| 21 | 21 | eprintln!("output status: `{}`", output.status()); |
| 22 | 22 | eprintln!("=== STDOUT ===\n{}\n\n", output.stdout_utf8()); |
| 23 | 23 | eprintln!("=== STDERR ===\n{}\n\n", output.stderr_utf8()); |
| 24 | if !cmd.get_context().is_empty() { | |
| 25 | eprintln!("Context:\n{}", cmd.get_context()); | |
| 26 | } | |
| 24 | 27 | std::process::exit(1) |
| 25 | 28 | } |
| 26 | 29 |
src/tools/tidy/src/diagnostics.rs+1-1| ... | ... | @@ -213,7 +213,7 @@ impl RunningCheck { |
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | /// Has an error already occured for this check? | |
| 216 | /// Has an error already occurred for this check? | |
| 217 | 217 | pub fn is_bad(&self) -> bool { |
| 218 | 218 | self.bad |
| 219 | 219 | } |
tests/assembly-llvm/targets/targets-elf.rs+3| ... | ... | @@ -673,6 +673,9 @@ |
| 673 | 673 | //@ revisions: x86_64_unknown_linux_gnux32 |
| 674 | 674 | //@ [x86_64_unknown_linux_gnux32] compile-flags: --target x86_64-unknown-linux-gnux32 |
| 675 | 675 | //@ [x86_64_unknown_linux_gnux32] needs-llvm-components: x86 |
| 676 | //@ revisions: x86_64_unknown_linux_gnuasan | |
| 677 | //@ [x86_64_unknown_linux_gnuasan] compile-flags: --target x86_64-unknown-linux-gnuasan | |
| 678 | //@ [x86_64_unknown_linux_gnuasan] needs-llvm-components: x86 | |
| 676 | 679 | //@ revisions: x86_64_unknown_linux_musl |
| 677 | 680 | //@ [x86_64_unknown_linux_musl] compile-flags: --target x86_64-unknown-linux-musl |
| 678 | 681 | //@ [x86_64_unknown_linux_musl] needs-llvm-components: x86 |
tests/build-std/configurations/rmake.rs created+131| ... | ... | @@ -0,0 +1,131 @@ |
| 1 | // This test ensures we are able to compile -Zbuild-std=core under a variety of profiles. | |
| 2 | // Currently, it tests that we can compile to all Tier 1 targets, and it does this by checking what | |
| 3 | // the tier metadata in target-spec JSON. This means that all in-tree targets must have a tier set. | |
| 4 | ||
| 5 | #![deny(warnings)] | |
| 6 | ||
| 7 | use std::collections::HashMap; | |
| 8 | use std::sync::{Arc, Mutex}; | |
| 9 | use std::thread; | |
| 10 | ||
| 11 | use run_make_support::serde_json::{self, Value}; | |
| 12 | use run_make_support::tempfile::TempDir; | |
| 13 | use run_make_support::{cargo, rfs, rustc}; | |
| 14 | ||
| 15 | #[derive(Clone)] | |
| 16 | struct Task { | |
| 17 | target: String, | |
| 18 | opt_level: u8, | |
| 19 | debug: u8, | |
| 20 | panic: &'static str, | |
| 21 | } | |
| 22 | ||
| 23 | fn manifest(task: &Task) -> String { | |
| 24 | let Task { opt_level, debug, panic, target: _ } = task; | |
| 25 | format!( | |
| 26 | r#"[package] | |
| 27 | name = "scratch" | |
| 28 | version = "0.1.0" | |
| 29 | edition = "2024" | |
| 30 | ||
| 31 | [lib] | |
| 32 | path = "lib.rs" | |
| 33 | ||
| 34 | [profile.release] | |
| 35 | opt-level = {opt_level} | |
| 36 | debug = {debug} | |
| 37 | panic = "{panic}" | |
| 38 | "# | |
| 39 | ) | |
| 40 | } | |
| 41 | ||
| 42 | fn main() { | |
| 43 | let mut targets = Vec::new(); | |
| 44 | let all_targets = | |
| 45 | rustc().args(&["--print=all-target-specs-json", "-Zunstable-options"]).run().stdout_utf8(); | |
| 46 | let all_targets: HashMap<String, Value> = serde_json::from_str(&all_targets).unwrap(); | |
| 47 | for (target, spec) in all_targets { | |
| 48 | let metadata = spec.as_object().unwrap()["metadata"].as_object().unwrap(); | |
| 49 | let tier = metadata["tier"] | |
| 50 | .as_u64() | |
| 51 | .expect(&format!("Target {} is missing tier metadata", target)); | |
| 52 | if tier == 1 { | |
| 53 | targets.push(target); | |
| 54 | } | |
| 55 | } | |
| 56 | ||
| 57 | let mut tasks = Vec::new(); | |
| 58 | ||
| 59 | // Testing every combination of compiler flags is infeasible. So we are making some attempt to | |
| 60 | // choose combinations that will tend to run into problems. | |
| 61 | // | |
| 62 | // The particular combination of settings below is tuned to look for problems generating the | |
| 63 | // code for compiler-builtins. | |
| 64 | // We only exercise opt-level 0 and 3 to exercise mir-opt-level 1 and 2. | |
| 65 | // We only exercise debug 0 and 2 because level 2 turns off some MIR optimizations. | |
| 66 | // We only test abort and immediate-abort because abort vs unwind doesn't change MIR much at | |
| 67 | // all. but immediate-abort does. | |
| 68 | // | |
| 69 | // Currently this only tests that we can compile the tier 1 targets. But since we are using | |
| 70 | // -Zbuild-std=core, we could have any list of targets. | |
| 71 | ||
| 72 | for opt_level in [0, 3] { | |
| 73 | for debug in [0, 2] { | |
| 74 | for panic in ["abort", "immediate-abort"] { | |
| 75 | for target in &targets { | |
| 76 | tasks.push(Task { target: target.clone(), opt_level, debug, panic }); | |
| 77 | } | |
| 78 | } | |
| 79 | } | |
| 80 | } | |
| 81 | ||
| 82 | let tasks = Arc::new(Mutex::new(tasks)); | |
| 83 | let mut threads = Vec::new(); | |
| 84 | ||
| 85 | // Try to obey the -j argument passed to bootstrap, otherwise fall back to using all the system | |
| 86 | // resouces. This test can be rather memory-hungry (~1 GB/thread); if it causes trouble in | |
| 87 | // practice do not hesitate to limit its parallelism. | |
| 88 | for _ in 0..run_make_support::env::jobs() { | |
| 89 | let tasks = Arc::clone(&tasks); | |
| 90 | let handle = thread::spawn(move || { | |
| 91 | loop { | |
| 92 | let maybe_task = tasks.lock().unwrap().pop(); | |
| 93 | if let Some(task) = maybe_task { | |
| 94 | test(task); | |
| 95 | } else { | |
| 96 | break; | |
| 97 | } | |
| 98 | } | |
| 99 | }); | |
| 100 | threads.push(handle); | |
| 101 | } | |
| 102 | ||
| 103 | for t in threads { | |
| 104 | t.join().unwrap(); | |
| 105 | } | |
| 106 | } | |
| 107 | ||
| 108 | fn test(task: Task) { | |
| 109 | let dir = TempDir::new().unwrap(); | |
| 110 | ||
| 111 | let manifest = manifest(&task); | |
| 112 | rfs::write(dir.path().join("Cargo.toml"), &manifest); | |
| 113 | rfs::write(dir.path().join("lib.rs"), "#![no_std]"); | |
| 114 | ||
| 115 | let mut args = vec!["build", "--release", "-Zbuild-std=core", "--target", &task.target, "-j1"]; | |
| 116 | if task.panic == "immediate-abort" { | |
| 117 | args.push("-Zpanic-immediate-abort"); | |
| 118 | } | |
| 119 | cargo() | |
| 120 | .current_dir(dir.path()) | |
| 121 | .args(&args) | |
| 122 | .env("RUSTC_BOOTSTRAP", "1") | |
| 123 | // Visual Studio 2022 requires that the LIB env var be set so it can | |
| 124 | // find the Windows SDK. | |
| 125 | .env("LIB", std::env::var("LIB").unwrap_or_default()) | |
| 126 | .context(&format!( | |
| 127 | "build-std for target `{}` failed with the following Cargo.toml:\n\n{manifest}", | |
| 128 | task.target | |
| 129 | )) | |
| 130 | .run(); | |
| 131 | } |
tests/coverage/remap-path-prefix.rs+3-3| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | //@ revisions: with_remap with_coverage_scope with_object_scope with_macro_scope |
| 11 | 11 | //@ compile-flags: --remap-path-prefix={{src-base}}=remapped |
| 12 | 12 | // |
| 13 | //@[with_coverage_scope] compile-flags: -Zremap-path-scope=coverage | |
| 14 | //@[with_object_scope] compile-flags: -Zremap-path-scope=object | |
| 15 | //@[with_macro_scope] compile-flags: -Zremap-path-scope=macro | |
| 13 | //@[with_coverage_scope] compile-flags: --remap-path-scope=coverage | |
| 14 | //@[with_object_scope] compile-flags: --remap-path-scope=object | |
| 15 | //@[with_macro_scope] compile-flags: --remap-path-scope=macro | |
| 16 | 16 | |
| 17 | 17 | fn main() {} |
tests/coverage/remap-path-prefix.with_macro_scope.coverage+3-3| ... | ... | @@ -10,9 +10,9 @@ |
| 10 | 10 | LL| |//@ revisions: with_remap with_coverage_scope with_object_scope with_macro_scope |
| 11 | 11 | LL| |//@ compile-flags: --remap-path-prefix={{src-base}}=remapped |
| 12 | 12 | LL| |// |
| 13 | LL| |//@[with_coverage_scope] compile-flags: -Zremap-path-scope=coverage | |
| 14 | LL| |//@[with_object_scope] compile-flags: -Zremap-path-scope=object | |
| 15 | LL| |//@[with_macro_scope] compile-flags: -Zremap-path-scope=macro | |
| 13 | LL| |//@[with_coverage_scope] compile-flags: --remap-path-scope=coverage | |
| 14 | LL| |//@[with_object_scope] compile-flags: --remap-path-scope=object | |
| 15 | LL| |//@[with_macro_scope] compile-flags: --remap-path-scope=macro | |
| 16 | 16 | LL| | |
| 17 | 17 | LL| 1|fn main() {} |
| 18 | 18 |
tests/run-make/remap-path-prefix-consts/rmake.rs+2-2| ... | ... | @@ -97,7 +97,7 @@ fn main() { |
| 97 | 97 | location_caller |
| 98 | 98 | .crate_type("lib") |
| 99 | 99 | .remap_path_prefix(cwd(), "/remapped") |
| 100 | .arg("-Zremap-path-scope=object") | |
| 100 | .arg("--remap-path-scope=object") | |
| 101 | 101 | .input(cwd().join("location-caller.rs")); |
| 102 | 102 | location_caller.run(); |
| 103 | 103 | |
| ... | ... | @@ -105,7 +105,7 @@ fn main() { |
| 105 | 105 | runner |
| 106 | 106 | .crate_type("bin") |
| 107 | 107 | .remap_path_prefix(cwd(), "/remapped") |
| 108 | .arg("-Zremap-path-scope=diagnostics") | |
| 108 | .arg("--remap-path-scope=diagnostics") | |
| 109 | 109 | .input(cwd().join("runner.rs")) |
| 110 | 110 | .output(&runner_bin); |
| 111 | 111 | runner.run(); |
tests/run-make/remap-path-prefix-dwarf/rmake.rs+4-4| ... | ... | @@ -105,7 +105,7 @@ fn check_dwarf_deps(scope: &str, dwarf_test: DwarfDump) { |
| 105 | 105 | let mut rustc_sm = rustc(); |
| 106 | 106 | rustc_sm.input(cwd().join("src/some_value.rs")); |
| 107 | 107 | rustc_sm.arg("-Cdebuginfo=2"); |
| 108 | rustc_sm.arg(format!("-Zremap-path-scope={}", scope)); | |
| 108 | rustc_sm.arg(format!("--remap-path-scope={}", scope)); | |
| 109 | 109 | rustc_sm.arg("--remap-path-prefix"); |
| 110 | 110 | rustc_sm.arg(format!("{}=/REMAPPED", cwd().display())); |
| 111 | 111 | rustc_sm.arg("-Csplit-debuginfo=off"); |
| ... | ... | @@ -117,7 +117,7 @@ fn check_dwarf_deps(scope: &str, dwarf_test: DwarfDump) { |
| 117 | 117 | rustc_pv.input(cwd().join("src/print_value.rs")); |
| 118 | 118 | rustc_pv.output(&print_value_rlib); |
| 119 | 119 | rustc_pv.arg("-Cdebuginfo=2"); |
| 120 | rustc_pv.arg(format!("-Zremap-path-scope={}", scope)); | |
| 120 | rustc_pv.arg(format!("--remap-path-scope={}", scope)); | |
| 121 | 121 | rustc_pv.arg("--remap-path-prefix"); |
| 122 | 122 | rustc_pv.arg(format!("{}=/REMAPPED", cwd().display())); |
| 123 | 123 | rustc_pv.arg("-Csplit-debuginfo=off"); |
| ... | ... | @@ -158,8 +158,8 @@ fn check_dwarf(test: DwarfTest) { |
| 158 | 158 | rustc.arg("-Cdebuginfo=2"); |
| 159 | 159 | if let Some(scope) = test.scope { |
| 160 | 160 | match scope { |
| 161 | ScopeType::Object => rustc.arg("-Zremap-path-scope=object"), | |
| 162 | ScopeType::Diagnostics => rustc.arg("-Zremap-path-scope=diagnostics"), | |
| 161 | ScopeType::Object => rustc.arg("--remap-path-scope=object"), | |
| 162 | ScopeType::Diagnostics => rustc.arg("--remap-path-scope=diagnostics"), | |
| 163 | 163 | }; |
| 164 | 164 | if is_darwin() { |
| 165 | 165 | rustc.arg("-Csplit-debuginfo=off"); |
tests/run-make/remap-path-prefix/rmake.rs+3-3| ... | ... | @@ -38,9 +38,9 @@ fn main() { |
| 38 | 38 | rmeta_contains("/the/aux/lib.rs"); |
| 39 | 39 | rmeta_not_contains("auxiliary"); |
| 40 | 40 | |
| 41 | out_object.arg("-Zremap-path-scope=object"); | |
| 42 | out_macro.arg("-Zremap-path-scope=macro"); | |
| 43 | out_diagobj.arg("-Zremap-path-scope=diagnostics,object"); | |
| 41 | out_object.arg("--remap-path-scope=object"); | |
| 42 | out_macro.arg("--remap-path-scope=macro"); | |
| 43 | out_diagobj.arg("--remap-path-scope=diagnostics,object"); | |
| 44 | 44 | if is_darwin() { |
| 45 | 45 | out_object.arg("-Csplit-debuginfo=off"); |
| 46 | 46 | out_macro.arg("-Csplit-debuginfo=off"); |
tests/run-make/rustc-help/help-v.diff+4-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | @@ -65,10 +65,28 @@ | |
| 1 | @@ -65,10 +65,31 @@ | |
| 2 | 2 | Set a codegen option |
| 3 | 3 | -V, --version Print version info and exit |
| 4 | 4 | -v, --verbose Use verbose output |
| ... | ... | @@ -20,6 +20,9 @@ |
| 20 | 20 | + --remap-path-prefix <FROM>=<TO> |
| 21 | 21 | + Remap source names in all output (compiler messages |
| 22 | 22 | + and output files) |
| 23 | + --remap-path-scope <macro,diagnostics,debuginfo,coverage,object,all> | |
| 24 | + Defines which scopes of paths should be remapped by | |
| 25 | + `--remap-path-prefix` | |
| 23 | 26 | + @path Read newline separated options from `path` |
| 24 | 27 | |
| 25 | 28 | Additional help: |
tests/run-make/rustc-help/help-v.stdout+3| ... | ... | @@ -83,6 +83,9 @@ Options: |
| 83 | 83 | --remap-path-prefix <FROM>=<TO> |
| 84 | 84 | Remap source names in all output (compiler messages |
| 85 | 85 | and output files) |
| 86 | --remap-path-scope <macro,diagnostics,debuginfo,coverage,object,all> | |
| 87 | Defines which scopes of paths should be remapped by | |
| 88 | `--remap-path-prefix` | |
| 86 | 89 | @path Read newline separated options from `path` |
| 87 | 90 | |
| 88 | 91 | Additional help: |
tests/run-make/split-debuginfo/rmake.rs+6-7| ... | ... | @@ -171,8 +171,7 @@ enum RemapPathPrefix { |
| 171 | 171 | Unspecified, |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | /// `-Zremap-path-scope`. See | |
| 175 | /// <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/remap-path-scope.html#remap-path-scope>. | |
| 174 | /// `--remap-path-scope` | |
| 176 | 175 | #[derive(Debug, Clone)] |
| 177 | 176 | enum RemapPathScope { |
| 178 | 177 | /// Comma-separated list of remap scopes: `macro`, `diagnostics`, `debuginfo`, `object`, `all`. |
| ... | ... | @@ -921,7 +920,7 @@ mod shared_linux_other_tests { |
| 921 | 920 | .debuginfo(level.cli_value()) |
| 922 | 921 | .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) |
| 923 | 922 | .remap_path_prefix(cwd(), remapped_prefix) |
| 924 | .arg(format!("-Zremap-path-scope={scope}")) | |
| 923 | .arg(format!("--remap-path-scope={scope}")) | |
| 925 | 924 | .run(); |
| 926 | 925 | let found_files = cwd_filenames(); |
| 927 | 926 | FileAssertions { expected_files: BTreeSet::from(["foo", "foo.dwp"]) } |
| ... | ... | @@ -950,7 +949,7 @@ mod shared_linux_other_tests { |
| 950 | 949 | .debuginfo(level.cli_value()) |
| 951 | 950 | .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) |
| 952 | 951 | .remap_path_prefix(cwd(), remapped_prefix) |
| 953 | .arg(format!("-Zremap-path-scope={scope}")) | |
| 952 | .arg(format!("--remap-path-scope={scope}")) | |
| 954 | 953 | .run(); |
| 955 | 954 | let found_files = cwd_filenames(); |
| 956 | 955 | FileAssertions { expected_files: BTreeSet::from(["foo", "foo.dwp"]) } |
| ... | ... | @@ -1202,7 +1201,7 @@ mod shared_linux_other_tests { |
| 1202 | 1201 | .debuginfo(level.cli_value()) |
| 1203 | 1202 | .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) |
| 1204 | 1203 | .remap_path_prefix(cwd(), remapped_prefix) |
| 1205 | .arg(format!("-Zremap-path-scope={scope}")) | |
| 1204 | .arg(format!("--remap-path-scope={scope}")) | |
| 1206 | 1205 | .run(); |
| 1207 | 1206 | |
| 1208 | 1207 | let found_files = cwd_filenames(); |
| ... | ... | @@ -1242,7 +1241,7 @@ mod shared_linux_other_tests { |
| 1242 | 1241 | .debuginfo(level.cli_value()) |
| 1243 | 1242 | .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) |
| 1244 | 1243 | .remap_path_prefix(cwd(), remapped_prefix) |
| 1245 | .arg(format!("-Zremap-path-scope={scope}")) | |
| 1244 | .arg(format!("--remap-path-scope={scope}")) | |
| 1246 | 1245 | .run(); |
| 1247 | 1246 | |
| 1248 | 1247 | let found_files = cwd_filenames(); |
| ... | ... | @@ -1356,7 +1355,7 @@ fn main() { |
| 1356 | 1355 | // NOTE: these combinations are not exhaustive, because while porting to rmake.rs initially I |
| 1357 | 1356 | // tried to preserve the existing test behavior closely. Notably, no attempt was made to |
| 1358 | 1357 | // exhaustively cover all cases in the 6-fold Cartesian product of `{,-Csplit=debuginfo=...}` x |
| 1359 | // `{,-Cdebuginfo=...}` x `{,--remap-path-prefix}` x `{,-Zremap-path-scope=...}` x | |
| 1358 | // `{,-Cdebuginfo=...}` x `{,--remap-path-prefix}` x `{,--remap-path-scope=...}` x | |
| 1360 | 1359 | // `{,-Zsplit-dwarf-kind=...}` x `{,-Clinker-plugin-lto}`. If you really want to, you can |
| 1361 | 1360 | // identify which combination isn't exercised with a 6-layers nested for loop iterating through |
| 1362 | 1361 | // each of the cli flag enum variants. |
tests/rustdoc-html/intra-doc/deps.rs+3-3| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | //@ compile-flags: --extern-html-root-url=empty=https://empty.example/ |
| 7 | 7 | // This one is to ensure that we don't link to any item we see which has |
| 8 | 8 | // an external html root URL unless it actually exists. |
| 9 | //@ compile-flags: --extern-html-root-url=non_existant=https://non-existant.example/ | |
| 9 | //@ compile-flags: --extern-html-root-url=non_existent=https://non-existent.example/ | |
| 10 | 10 | //@ aux-build: empty.rs |
| 11 | 11 | |
| 12 | 12 | #![crate_name = "foo"] |
| ... | ... | @@ -14,10 +14,10 @@ |
| 14 | 14 | |
| 15 | 15 | //@ has 'foo/index.html' |
| 16 | 16 | //@ has - '//a[@href="https://empty.example/empty/index.html"]' 'empty' |
| 17 | // There should only be one intra doc links, we should not link `non_existant`. | |
| 17 | // There should only be one intra doc links, we should not link `non_existent`. | |
| 18 | 18 | //@ count - '//*[@class="docblock"]//a' 1 |
| 19 | 19 | //! [`empty`] |
| 20 | 20 | //! |
| 21 | //! [`non_existant`] | |
| 21 | //! [`non_existent`] | |
| 22 | 22 | |
| 23 | 23 | extern crate empty; |
tests/ui/errors/auxiliary/file-debuginfo.rs+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | //@ compile-flags: --remap-path-prefix={{src-base}}=remapped |
| 2 | //@ compile-flags: -Zremap-path-scope=debuginfo | |
| 2 | //@ compile-flags: --remap-path-scope=debuginfo | |
| 3 | 3 | |
| 4 | 4 | #[macro_export] |
| 5 | 5 | macro_rules! my_file { |
tests/ui/errors/auxiliary/file-diag.rs+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | //@ compile-flags: --remap-path-prefix={{src-base}}=remapped |
| 2 | //@ compile-flags: -Zremap-path-scope=diagnostics | |
| 2 | //@ compile-flags: --remap-path-scope=diagnostics | |
| 3 | 3 | |
| 4 | 4 | #[macro_export] |
| 5 | 5 | macro_rules! my_file { |
tests/ui/errors/auxiliary/file-macro.rs+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | //@ compile-flags: --remap-path-prefix={{src-base}}=remapped |
| 2 | //@ compile-flags: -Zremap-path-scope=macro | |
| 2 | //@ compile-flags: --remap-path-scope=macro | |
| 3 | 3 | |
| 4 | 4 | #[macro_export] |
| 5 | 5 | macro_rules! my_file { |
tests/ui/errors/auxiliary/trait-debuginfo.rs+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | 1 | //@ compile-flags: --remap-path-prefix={{src-base}}=remapped |
| 2 | //@ compile-flags: -Zremap-path-scope=debuginfo | |
| 2 | //@ compile-flags: --remap-path-scope=debuginfo | |
| 3 | 3 | |
| 4 | 4 | pub trait Trait: std::fmt::Display {} |
tests/ui/errors/auxiliary/trait-diag.rs+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | 1 | //@ compile-flags: --remap-path-prefix={{src-base}}=remapped |
| 2 | //@ compile-flags: -Zremap-path-scope=diagnostics | |
| 2 | //@ compile-flags: --remap-path-scope=diagnostics | |
| 3 | 3 | |
| 4 | 4 | pub trait Trait: std::fmt::Display {} |
tests/ui/errors/auxiliary/trait-macro.rs+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | 1 | //@ compile-flags: --remap-path-prefix={{src-base}}=remapped |
| 2 | //@ compile-flags: -Zremap-path-scope=macro | |
| 2 | //@ compile-flags: --remap-path-scope=macro | |
| 3 | 3 | |
| 4 | 4 | pub trait Trait: std::fmt::Display {} |
tests/ui/errors/remap-path-prefix-diagnostics.rs+5-5| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | // This test exercises `-Zremap-path-scope`, diagnostics printing paths and dependency. | |
| 1 | // This test exercises `--remap-path-scope`, diagnostics printing paths and dependency. | |
| 2 | 2 | // |
| 3 | 3 | // We test different combinations with/without remap in deps, with/without remap in this |
| 4 | 4 | // crate but always in deps and always here but never in deps. |
| ... | ... | @@ -12,10 +12,10 @@ |
| 12 | 12 | //@[with-debuginfo-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped |
| 13 | 13 | //@[not-diag-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped |
| 14 | 14 | |
| 15 | //@[with-diag-in-deps] compile-flags: -Zremap-path-scope=diagnostics | |
| 16 | //@[with-macro-in-deps] compile-flags: -Zremap-path-scope=macro | |
| 17 | //@[with-debuginfo-in-deps] compile-flags: -Zremap-path-scope=debuginfo | |
| 18 | //@[not-diag-in-deps] compile-flags: -Zremap-path-scope=diagnostics | |
| 15 | //@[with-diag-in-deps] compile-flags: --remap-path-scope=diagnostics | |
| 16 | //@[with-macro-in-deps] compile-flags: --remap-path-scope=macro | |
| 17 | //@[with-debuginfo-in-deps] compile-flags: --remap-path-scope=debuginfo | |
| 18 | //@[not-diag-in-deps] compile-flags: --remap-path-scope=diagnostics | |
| 19 | 19 | |
| 20 | 20 | //@[with-diag-in-deps] aux-build:trait-diag.rs |
| 21 | 21 | //@[with-macro-in-deps] aux-build:trait-macro.rs |
tests/ui/errors/remap-path-prefix-macro.rs+5-5| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | // This test exercises `-Zremap-path-scope`, macros (like file!()) and dependency. | |
| 1 | // This test exercises `--remap-path-scope`, macros (like file!()) and dependency. | |
| 2 | 2 | // |
| 3 | 3 | // We test different combinations with/without remap in deps, with/without remap in |
| 4 | 4 | // this crate but always in deps and always here but never in deps. |
| ... | ... | @@ -15,10 +15,10 @@ |
| 15 | 15 | //@[with-debuginfo-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped |
| 16 | 16 | //@[not-macro-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped |
| 17 | 17 | |
| 18 | //@[with-diag-in-deps] compile-flags: -Zremap-path-scope=diagnostics | |
| 19 | //@[with-macro-in-deps] compile-flags: -Zremap-path-scope=macro | |
| 20 | //@[with-debuginfo-in-deps] compile-flags: -Zremap-path-scope=debuginfo | |
| 21 | //@[not-macro-in-deps] compile-flags: -Zremap-path-scope=macro | |
| 18 | //@[with-diag-in-deps] compile-flags: --remap-path-scope=diagnostics | |
| 19 | //@[with-macro-in-deps] compile-flags: --remap-path-scope=macro | |
| 20 | //@[with-debuginfo-in-deps] compile-flags: --remap-path-scope=debuginfo | |
| 21 | //@[not-macro-in-deps] compile-flags: --remap-path-scope=macro | |
| 22 | 22 | |
| 23 | 23 | //@[with-diag-in-deps] aux-build:file-diag.rs |
| 24 | 24 | //@[with-macro-in-deps] aux-build:file-macro.rs |
tests/ui/errors/remap-path-prefix.rs+2-2| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | //@ revisions: normal with-diagnostic-scope without-diagnostic-scope |
| 2 | 2 | //@ compile-flags: --remap-path-prefix={{src-base}}=remapped |
| 3 | //@ [with-diagnostic-scope]compile-flags: -Zremap-path-scope=diagnostics | |
| 4 | //@ [without-diagnostic-scope]compile-flags: -Zremap-path-scope=object | |
| 3 | //@ [with-diagnostic-scope]compile-flags: --remap-path-scope=diagnostics | |
| 4 | //@ [without-diagnostic-scope]compile-flags: --remap-path-scope=object | |
| 5 | 5 | // Manually remap, so the remapped path remains in .stderr file. |
| 6 | 6 | |
| 7 | 7 | // The remapped paths are not normalized by compiletest. |
tests/ui/imports/ambiguous-trait-in-scope.rs created+84| ... | ... | @@ -0,0 +1,84 @@ |
| 1 | //@ edition:2018 | |
| 2 | //@ aux-crate:external=ambiguous-trait-reexport.rs | |
| 3 | ||
| 4 | mod m1 { | |
| 5 | pub trait Trait { | |
| 6 | fn method1(&self) {} | |
| 7 | } | |
| 8 | impl Trait for u8 {} | |
| 9 | } | |
| 10 | mod m2 { | |
| 11 | pub trait Trait { | |
| 12 | fn method2(&self) {} | |
| 13 | } | |
| 14 | impl Trait for u8 {} | |
| 15 | } | |
| 16 | mod m1_reexport { | |
| 17 | pub use crate::m1::Trait; | |
| 18 | } | |
| 19 | mod m2_reexport { | |
| 20 | pub use crate::m2::Trait; | |
| 21 | } | |
| 22 | ||
| 23 | mod ambig_reexport { | |
| 24 | pub use crate::m1::*; | |
| 25 | pub use crate::m2::*; | |
| 26 | } | |
| 27 | ||
| 28 | fn test1() { | |
| 29 | // Create an ambiguous import for `Trait` in one order | |
| 30 | use m1::*; | |
| 31 | use m2::*; | |
| 32 | 0u8.method1(); //~ WARNING Use of ambiguously glob imported trait `Trait` [ambiguous_glob_imported_traits] | |
| 33 | //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 34 | 0u8.method2(); //~ ERROR: no method named `method2` found for type `u8` in the current scope | |
| 35 | } | |
| 36 | ||
| 37 | fn test2() { | |
| 38 | // Create an ambiguous import for `Trait` in another order | |
| 39 | use m2::*; | |
| 40 | use m1::*; | |
| 41 | 0u8.method1(); //~ ERROR: no method named `method1` found for type `u8` in the current scope | |
| 42 | 0u8.method2(); //~ WARNING Use of ambiguously glob imported trait `Trait` [ambiguous_glob_imported_traits] | |
| 43 | //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 44 | } | |
| 45 | ||
| 46 | fn test_indirect_reexport() { | |
| 47 | use m1_reexport::*; | |
| 48 | use m2_reexport::*; | |
| 49 | 0u8.method1(); //~ WARNING Use of ambiguously glob imported trait `Trait` [ambiguous_glob_imported_traits] | |
| 50 | //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 51 | 0u8.method2(); //~ ERROR: no method named `method2` found for type `u8` in the current scope | |
| 52 | } | |
| 53 | ||
| 54 | fn test_ambig_reexport() { | |
| 55 | use ambig_reexport::*; | |
| 56 | 0u8.method1(); //~ WARNING Use of ambiguously glob imported trait `Trait` [ambiguous_glob_imported_traits] | |
| 57 | //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 58 | 0u8.method2(); //~ ERROR: no method named `method2` found for type `u8` in the current scope | |
| 59 | } | |
| 60 | ||
| 61 | fn test_external() { | |
| 62 | use external::m1::*; | |
| 63 | use external::m2::*; | |
| 64 | 0u8.method1(); //~ WARNING Use of ambiguously glob imported trait `Trait` [ambiguous_glob_imported_traits] | |
| 65 | //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 66 | 0u8.method2(); //~ ERROR: no method named `method2` found for type `u8` in the current scope | |
| 67 | } | |
| 68 | ||
| 69 | fn test_external_indirect_reexport() { | |
| 70 | use external::m1_reexport::*; | |
| 71 | use external::m2_reexport::*; | |
| 72 | 0u8.method1(); //~ WARNING Use of ambiguously glob imported trait `Trait` [ambiguous_glob_imported_traits] | |
| 73 | //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 74 | 0u8.method2(); //~ ERROR: no method named `method2` found for type `u8` in the current scope | |
| 75 | } | |
| 76 | ||
| 77 | fn test_external_ambig_reexport() { | |
| 78 | use external::ambig_reexport::*; | |
| 79 | 0u8.method1(); //~ WARNING Use of ambiguously glob imported trait `Trait` [ambiguous_glob_imported_traits] | |
| 80 | //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 81 | 0u8.method2(); //~ ERROR: no method named `method2` found for type `u8` in the current scope | |
| 82 | } | |
| 83 | ||
| 84 | fn main() {} |
tests/ui/imports/ambiguous-trait-in-scope.stderr created+191| ... | ... | @@ -0,0 +1,191 @@ |
| 1 | warning: Use of ambiguously glob imported trait `Trait` | |
| 2 | --> $DIR/ambiguous-trait-in-scope.rs:32:9 | |
| 3 | | | |
| 4 | LL | use m1::*; | |
| 5 | | -- `Trait` imported ambiguously here | |
| 6 | LL | use m2::*; | |
| 7 | LL | 0u8.method1(); | |
| 8 | | ^^^^^^^ | |
| 9 | | | |
| 10 | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 11 | = note: for more information, see issue #147992 <https://github.com/rust-lang/rust/issues/147992> | |
| 12 | = help: Import `Trait` explicitly | |
| 13 | = note: `#[warn(ambiguous_glob_imported_traits)]` (part of `#[warn(future_incompatible)]`) on by default | |
| 14 | ||
| 15 | error[E0599]: no method named `method2` found for type `u8` in the current scope | |
| 16 | --> $DIR/ambiguous-trait-in-scope.rs:34:9 | |
| 17 | | | |
| 18 | LL | 0u8.method2(); | |
| 19 | | ^^^^^^^ method not found in `u8` | |
| 20 | | | |
| 21 | = help: items from traits can only be used if the trait is in scope | |
| 22 | help: the following traits which provide `method2` are implemented but not in scope; perhaps you want to import one of them | |
| 23 | | | |
| 24 | LL + use ambiguous_trait_reexport::m2::Trait; | |
| 25 | | | |
| 26 | LL + use crate::m2::Trait; | |
| 27 | | | |
| 28 | ||
| 29 | error[E0599]: no method named `method1` found for type `u8` in the current scope | |
| 30 | --> $DIR/ambiguous-trait-in-scope.rs:41:9 | |
| 31 | | | |
| 32 | LL | 0u8.method1(); | |
| 33 | | ^^^^^^^ method not found in `u8` | |
| 34 | | | |
| 35 | = help: items from traits can only be used if the trait is in scope | |
| 36 | help: the following traits which provide `method1` are implemented but not in scope; perhaps you want to import one of them | |
| 37 | | | |
| 38 | LL + use ambiguous_trait_reexport::m1::Trait; | |
| 39 | | | |
| 40 | LL + use crate::m1::Trait; | |
| 41 | | | |
| 42 | ||
| 43 | warning: Use of ambiguously glob imported trait `Trait` | |
| 44 | --> $DIR/ambiguous-trait-in-scope.rs:42:9 | |
| 45 | | | |
| 46 | LL | use m2::*; | |
| 47 | | -- `Trait` imported ambiguously here | |
| 48 | ... | |
| 49 | LL | 0u8.method2(); | |
| 50 | | ^^^^^^^ | |
| 51 | | | |
| 52 | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 53 | = note: for more information, see issue #147992 <https://github.com/rust-lang/rust/issues/147992> | |
| 54 | = help: Import `Trait` explicitly | |
| 55 | ||
| 56 | warning: Use of ambiguously glob imported trait `Trait` | |
| 57 | --> $DIR/ambiguous-trait-in-scope.rs:49:9 | |
| 58 | | | |
| 59 | LL | use m1_reexport::*; | |
| 60 | | ----------- `Trait` imported ambiguously here | |
| 61 | LL | use m2_reexport::*; | |
| 62 | LL | 0u8.method1(); | |
| 63 | | ^^^^^^^ | |
| 64 | | | |
| 65 | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 66 | = note: for more information, see issue #147992 <https://github.com/rust-lang/rust/issues/147992> | |
| 67 | = help: Import `Trait` explicitly | |
| 68 | ||
| 69 | error[E0599]: no method named `method2` found for type `u8` in the current scope | |
| 70 | --> $DIR/ambiguous-trait-in-scope.rs:51:9 | |
| 71 | | | |
| 72 | LL | 0u8.method2(); | |
| 73 | | ^^^^^^^ method not found in `u8` | |
| 74 | | | |
| 75 | = help: items from traits can only be used if the trait is in scope | |
| 76 | help: the following traits which provide `method2` are implemented but not in scope; perhaps you want to import one of them | |
| 77 | | | |
| 78 | LL + use ambiguous_trait_reexport::m2::Trait; | |
| 79 | | | |
| 80 | LL + use crate::m2::Trait; | |
| 81 | | | |
| 82 | ||
| 83 | warning: Use of ambiguously glob imported trait `Trait` | |
| 84 | --> $DIR/ambiguous-trait-in-scope.rs:56:9 | |
| 85 | | | |
| 86 | LL | use ambig_reexport::*; | |
| 87 | | -------------- `Trait` imported ambiguously here | |
| 88 | LL | 0u8.method1(); | |
| 89 | | ^^^^^^^ | |
| 90 | | | |
| 91 | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 92 | = note: for more information, see issue #147992 <https://github.com/rust-lang/rust/issues/147992> | |
| 93 | = help: Import `Trait` explicitly | |
| 94 | ||
| 95 | error[E0599]: no method named `method2` found for type `u8` in the current scope | |
| 96 | --> $DIR/ambiguous-trait-in-scope.rs:58:9 | |
| 97 | | | |
| 98 | LL | 0u8.method2(); | |
| 99 | | ^^^^^^^ method not found in `u8` | |
| 100 | | | |
| 101 | = help: items from traits can only be used if the trait is in scope | |
| 102 | help: the following traits which provide `method2` are implemented but not in scope; perhaps you want to import one of them | |
| 103 | | | |
| 104 | LL + use ambiguous_trait_reexport::m2::Trait; | |
| 105 | | | |
| 106 | LL + use crate::m2::Trait; | |
| 107 | | | |
| 108 | ||
| 109 | warning: Use of ambiguously glob imported trait `Trait` | |
| 110 | --> $DIR/ambiguous-trait-in-scope.rs:64:9 | |
| 111 | | | |
| 112 | LL | use external::m1::*; | |
| 113 | | ------------ `Trait` imported ambiguously here | |
| 114 | LL | use external::m2::*; | |
| 115 | LL | 0u8.method1(); | |
| 116 | | ^^^^^^^ | |
| 117 | | | |
| 118 | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 119 | = note: for more information, see issue #147992 <https://github.com/rust-lang/rust/issues/147992> | |
| 120 | = help: Import `Trait` explicitly | |
| 121 | ||
| 122 | error[E0599]: no method named `method2` found for type `u8` in the current scope | |
| 123 | --> $DIR/ambiguous-trait-in-scope.rs:66:9 | |
| 124 | | | |
| 125 | LL | 0u8.method2(); | |
| 126 | | ^^^^^^^ method not found in `u8` | |
| 127 | | | |
| 128 | = help: items from traits can only be used if the trait is in scope | |
| 129 | help: the following traits which provide `method2` are implemented but not in scope; perhaps you want to import one of them | |
| 130 | | | |
| 131 | LL + use ambiguous_trait_reexport::m2::Trait; | |
| 132 | | | |
| 133 | LL + use crate::m2::Trait; | |
| 134 | | | |
| 135 | ||
| 136 | warning: Use of ambiguously glob imported trait `Trait` | |
| 137 | --> $DIR/ambiguous-trait-in-scope.rs:72:9 | |
| 138 | | | |
| 139 | LL | use external::m1_reexport::*; | |
| 140 | | --------------------- `Trait` imported ambiguously here | |
| 141 | LL | use external::m2_reexport::*; | |
| 142 | LL | 0u8.method1(); | |
| 143 | | ^^^^^^^ | |
| 144 | | | |
| 145 | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 146 | = note: for more information, see issue #147992 <https://github.com/rust-lang/rust/issues/147992> | |
| 147 | = help: Import `Trait` explicitly | |
| 148 | ||
| 149 | error[E0599]: no method named `method2` found for type `u8` in the current scope | |
| 150 | --> $DIR/ambiguous-trait-in-scope.rs:74:9 | |
| 151 | | | |
| 152 | LL | 0u8.method2(); | |
| 153 | | ^^^^^^^ method not found in `u8` | |
| 154 | | | |
| 155 | = help: items from traits can only be used if the trait is in scope | |
| 156 | help: the following traits which provide `method2` are implemented but not in scope; perhaps you want to import one of them | |
| 157 | | | |
| 158 | LL + use ambiguous_trait_reexport::m2::Trait; | |
| 159 | | | |
| 160 | LL + use crate::m2::Trait; | |
| 161 | | | |
| 162 | ||
| 163 | warning: Use of ambiguously glob imported trait `Trait` | |
| 164 | --> $DIR/ambiguous-trait-in-scope.rs:79:9 | |
| 165 | | | |
| 166 | LL | use external::ambig_reexport::*; | |
| 167 | | ------------------------ `Trait` imported ambiguously here | |
| 168 | LL | 0u8.method1(); | |
| 169 | | ^^^^^^^ | |
| 170 | | | |
| 171 | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 172 | = note: for more information, see issue #147992 <https://github.com/rust-lang/rust/issues/147992> | |
| 173 | = help: Import `Trait` explicitly | |
| 174 | ||
| 175 | error[E0599]: no method named `method2` found for type `u8` in the current scope | |
| 176 | --> $DIR/ambiguous-trait-in-scope.rs:81:9 | |
| 177 | | | |
| 178 | LL | 0u8.method2(); | |
| 179 | | ^^^^^^^ method not found in `u8` | |
| 180 | | | |
| 181 | = help: items from traits can only be used if the trait is in scope | |
| 182 | help: the following traits which provide `method2` are implemented but not in scope; perhaps you want to import one of them | |
| 183 | | | |
| 184 | LL + use ambiguous_trait_reexport::m2::Trait; | |
| 185 | | | |
| 186 | LL + use crate::m2::Trait; | |
| 187 | | | |
| 188 | ||
| 189 | error: aborting due to 7 previous errors; 7 warnings emitted | |
| 190 | ||
| 191 | For more information about this error, try `rustc --explain E0599`. |
tests/ui/imports/auxiliary/ambiguous-trait-reexport.rs created+23| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | pub mod m1 { | |
| 2 | pub trait Trait { | |
| 3 | fn method1(&self) {} | |
| 4 | } | |
| 5 | impl Trait for u8 {} | |
| 6 | } | |
| 7 | pub mod m2 { | |
| 8 | pub trait Trait { | |
| 9 | fn method2(&self) {} | |
| 10 | } | |
| 11 | impl Trait for u8 {} | |
| 12 | } | |
| 13 | pub mod m1_reexport { | |
| 14 | pub use crate::m1::Trait; | |
| 15 | } | |
| 16 | pub mod m2_reexport { | |
| 17 | pub use crate::m2::Trait; | |
| 18 | } | |
| 19 | ||
| 20 | pub mod ambig_reexport { | |
| 21 | pub use crate::m1::*; | |
| 22 | pub use crate::m2::*; | |
| 23 | } |
tests/ui/imports/no-ambiguous-trait-lint-on-redundant-import.rs created+27| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | //@ check-pass | |
| 2 | // The AMBIGUOUS_GLOB_IMPORTED_TRAITS lint is reported on uses of traits that are | |
| 3 | // ambiguously glob imported. This test checks that we don't report this lint | |
| 4 | // when the same trait is glob imported multiple times. | |
| 5 | ||
| 6 | mod t { | |
| 7 | pub trait Trait { | |
| 8 | fn method(&self) {} | |
| 9 | } | |
| 10 | ||
| 11 | impl Trait for i8 {} | |
| 12 | } | |
| 13 | ||
| 14 | mod m1 { | |
| 15 | pub use t::Trait; | |
| 16 | } | |
| 17 | ||
| 18 | mod m2 { | |
| 19 | pub use t::Trait; | |
| 20 | } | |
| 21 | ||
| 22 | use m1::*; | |
| 23 | use m2::*; | |
| 24 | ||
| 25 | fn main() { | |
| 26 | 0i8.method(); | |
| 27 | } |