| author | bors <bors@rust-lang.org> 2025-07-30 09:02:21 UTC |
| committer | bors <bors@rust-lang.org> 2025-07-30 09:02:21 UTC |
| log | e5e79f8bd428d0b8d26e8240d718b134ef297459 |
| tree | 395771116faa1afd2896a964e9b81189fbe6790b |
| parent | 72716b134ac26b837703e46cbda99a453ae92c42 |
| parent | 3682d8c1ce4379b9ad7d9da655f2fefee8bb86c3 |
Rollup of 6 pull requests
Successful merges:
- rust-lang/rust#144042 (Verify llvm-needs-components are not empty and match the --target value)
- rust-lang/rust#144268 (Add method `find_ancestor_not_from_macro` and `find_ancestor_not_from_extern_macro` to supersede `find_oldest_ancestor_in_same_ctxt`)
- rust-lang/rust#144411 (Remove `hello_world` directory)
- rust-lang/rust#144662 (compiletest: Move directive names back into a separate file)
- rust-lang/rust#144666 (Make sure to account for the right item universal regions in borrowck)
- rust-lang/rust#144668 ([test][run-make] add needs-llvm-components)
r? `@ghost`
`@rustbot` modify labels: rollup59 files changed, 737 insertions(+), 446 deletions(-)
compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs+1-1| ... | ... | @@ -341,7 +341,7 @@ impl<'tcx> BorrowExplanation<'tcx> { |
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | } else if let LocalInfo::BlockTailTemp(info) = local_decl.local_info() { |
| 344 | let sp = info.span.find_oldest_ancestor_in_same_ctxt(); | |
| 344 | let sp = info.span.find_ancestor_not_from_macro().unwrap_or(info.span); | |
| 345 | 345 | if info.tail_result_is_ignored { |
| 346 | 346 | // #85581: If the first mutable borrow's scope contains |
| 347 | 347 | // the second borrow, this suggestion isn't helpful. |
compiler/rustc_borrowck/src/universal_regions.rs+21-6| ... | ... | @@ -969,13 +969,28 @@ fn for_each_late_bound_region_in_item<'tcx>( |
| 969 | 969 | mir_def_id: LocalDefId, |
| 970 | 970 | mut f: impl FnMut(ty::Region<'tcx>), |
| 971 | 971 | ) { |
| 972 | if !tcx.def_kind(mir_def_id).is_fn_like() { | |
| 973 | return; | |
| 974 | } | |
| 972 | let bound_vars = match tcx.def_kind(mir_def_id) { | |
| 973 | DefKind::Fn | DefKind::AssocFn => { | |
| 974 | tcx.late_bound_vars(tcx.local_def_id_to_hir_id(mir_def_id)) | |
| 975 | } | |
| 976 | // We extract the bound vars from the deduced closure signature, since we may have | |
| 977 | // only deduced that a param in the closure signature is late-bound from a constraint | |
| 978 | // that we discover during typeck. | |
| 979 | DefKind::Closure => { | |
| 980 | let ty = tcx.type_of(mir_def_id).instantiate_identity(); | |
| 981 | match *ty.kind() { | |
| 982 | ty::Closure(_, args) => args.as_closure().sig().bound_vars(), | |
| 983 | ty::CoroutineClosure(_, args) => { | |
| 984 | args.as_coroutine_closure().coroutine_closure_sig().bound_vars() | |
| 985 | } | |
| 986 | ty::Coroutine(_, _) | ty::Error(_) => return, | |
| 987 | _ => unreachable!("unexpected type for closure: {ty}"), | |
| 988 | } | |
| 989 | } | |
| 990 | _ => return, | |
| 991 | }; | |
| 975 | 992 | |
| 976 | for (idx, bound_var) in | |
| 977 | tcx.late_bound_vars(tcx.local_def_id_to_hir_id(mir_def_id)).iter().enumerate() | |
| 978 | { | |
| 993 | for (idx, bound_var) in bound_vars.iter().enumerate() { | |
| 979 | 994 | if let ty::BoundVariableKind::Region(kind) = bound_var { |
| 980 | 995 | let kind = ty::LateParamRegionKind::from_bound(ty::BoundVar::from_usize(idx), kind); |
| 981 | 996 | let liberated_region = ty::Region::new_late_param(tcx, mir_def_id.to_def_id(), kind); |
compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs+9-3| ... | ... | @@ -1302,7 +1302,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1302 | 1302 | None => ".clone()".to_string(), |
| 1303 | 1303 | }; |
| 1304 | 1304 | |
| 1305 | let span = expr.span.find_oldest_ancestor_in_same_ctxt().shrink_to_hi(); | |
| 1305 | let span = expr.span.find_ancestor_not_from_macro().unwrap_or(expr.span).shrink_to_hi(); | |
| 1306 | 1306 | |
| 1307 | 1307 | diag.span_suggestion_verbose( |
| 1308 | 1308 | span, |
| ... | ... | @@ -1395,7 +1395,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1395 | 1395 | .macro_backtrace() |
| 1396 | 1396 | .any(|x| matches!(x.kind, ExpnKind::Macro(MacroKind::Attr | MacroKind::Derive, ..))) |
| 1397 | 1397 | { |
| 1398 | let span = expr.span.find_oldest_ancestor_in_same_ctxt(); | |
| 1398 | let span = expr | |
| 1399 | .span | |
| 1400 | .find_ancestor_not_from_extern_macro(&self.tcx.sess.source_map()) | |
| 1401 | .unwrap_or(expr.span); | |
| 1399 | 1402 | |
| 1400 | 1403 | let mut sugg = if self.precedence(expr) >= ExprPrecedence::Unambiguous { |
| 1401 | 1404 | vec![(span.shrink_to_hi(), ".into()".to_owned())] |
| ... | ... | @@ -2062,7 +2065,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 2062 | 2065 | None => sugg.to_string(), |
| 2063 | 2066 | }; |
| 2064 | 2067 | |
| 2065 | let span = expr.span.find_oldest_ancestor_in_same_ctxt(); | |
| 2068 | let span = expr | |
| 2069 | .span | |
| 2070 | .find_ancestor_not_from_extern_macro(&self.tcx.sess.source_map()) | |
| 2071 | .unwrap_or(expr.span); | |
| 2066 | 2072 | err.span_suggestion_verbose(span.shrink_to_hi(), msg, sugg, Applicability::HasPlaceholders); |
| 2067 | 2073 | true |
| 2068 | 2074 | } |
compiler/rustc_lint/src/unused.rs+2-2| ... | ... | @@ -185,7 +185,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { |
| 185 | 185 | let mut op_warned = false; |
| 186 | 186 | |
| 187 | 187 | if let Some(must_use_op) = must_use_op { |
| 188 | let span = expr.span.find_oldest_ancestor_in_same_ctxt(); | |
| 188 | let span = expr.span.find_ancestor_not_from_macro().unwrap_or(expr.span); | |
| 189 | 189 | cx.emit_span_lint( |
| 190 | 190 | UNUSED_MUST_USE, |
| 191 | 191 | expr.span, |
| ... | ... | @@ -511,7 +511,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { |
| 511 | 511 | ); |
| 512 | 512 | } |
| 513 | 513 | MustUsePath::Def(span, def_id, reason) => { |
| 514 | let span = span.find_oldest_ancestor_in_same_ctxt(); | |
| 514 | let span = span.find_ancestor_not_from_macro().unwrap_or(*span); | |
| 515 | 515 | cx.emit_span_lint( |
| 516 | 516 | UNUSED_MUST_USE, |
| 517 | 517 | span, |
compiler/rustc_span/src/lib.rs+46-36| ... | ... | @@ -716,12 +716,17 @@ impl Span { |
| 716 | 716 | (!ctxt.is_root()).then(|| ctxt.outer_expn_data().call_site) |
| 717 | 717 | } |
| 718 | 718 | |
| 719 | /// Walk down the expansion ancestors to find a span that's contained within `outer`. | |
| 719 | /// Find the first ancestor span that's contained within `outer`. | |
| 720 | 720 | /// |
| 721 | /// The span returned by this method may have a different [`SyntaxContext`] as `outer`. | |
| 721 | /// This method traverses the macro expansion ancestors until it finds the first span | |
| 722 | /// that's contained within `outer`. | |
| 723 | /// | |
| 724 | /// The span returned by this method may have a different [`SyntaxContext`] than `outer`. | |
| 722 | 725 | /// If you need to extend the span, use [`find_ancestor_inside_same_ctxt`] instead, |
| 723 | 726 | /// because joining spans with different syntax contexts can create unexpected results. |
| 724 | 727 | /// |
| 728 | /// This is used to find the span of the macro call when a parent expr span, i.e. `outer`, is known. | |
| 729 | /// | |
| 725 | 730 | /// [`find_ancestor_inside_same_ctxt`]: Self::find_ancestor_inside_same_ctxt |
| 726 | 731 | pub fn find_ancestor_inside(mut self, outer: Span) -> Option<Span> { |
| 727 | 732 | while !outer.contains(self) { |
| ... | ... | @@ -730,8 +735,10 @@ impl Span { |
| 730 | 735 | Some(self) |
| 731 | 736 | } |
| 732 | 737 | |
| 733 | /// Walk down the expansion ancestors to find a span with the same [`SyntaxContext`] as | |
| 734 | /// `other`. | |
| 738 | /// Find the first ancestor span with the same [`SyntaxContext`] as `other`. | |
| 739 | /// | |
| 740 | /// This method traverses the macro expansion ancestors until it finds a span | |
| 741 | /// that has the same [`SyntaxContext`] as `other`. | |
| 735 | 742 | /// |
| 736 | 743 | /// Like [`find_ancestor_inside_same_ctxt`], but specifically for when spans might not |
| 737 | 744 | /// overlap. Take care when using this, and prefer [`find_ancestor_inside`] or |
| ... | ... | @@ -747,9 +754,12 @@ impl Span { |
| 747 | 754 | Some(self) |
| 748 | 755 | } |
| 749 | 756 | |
| 750 | /// Walk down the expansion ancestors to find a span that's contained within `outer` and | |
| 757 | /// Find the first ancestor span that's contained within `outer` and | |
| 751 | 758 | /// has the same [`SyntaxContext`] as `outer`. |
| 752 | 759 | /// |
| 760 | /// This method traverses the macro expansion ancestors until it finds a span | |
| 761 | /// that is both contained within `outer` and has the same [`SyntaxContext`] as `outer`. | |
| 762 | /// | |
| 753 | 763 | /// This method is the combination of [`find_ancestor_inside`] and |
| 754 | 764 | /// [`find_ancestor_in_same_ctxt`] and should be preferred when extending the returned span. |
| 755 | 765 | /// If you do not need to modify the span, use [`find_ancestor_inside`] instead. |
| ... | ... | @@ -763,43 +773,43 @@ impl Span { |
| 763 | 773 | Some(self) |
| 764 | 774 | } |
| 765 | 775 | |
| 766 | /// Recursively walk down the expansion ancestors to find the oldest ancestor span with the same | |
| 767 | /// [`SyntaxContext`] the initial span. | |
| 776 | /// Find the first ancestor span that does not come from an external macro. | |
| 768 | 777 | /// |
| 769 | /// This method is suitable for peeling through *local* macro expansions to find the "innermost" | |
| 770 | /// span that is still local and shares the same [`SyntaxContext`]. For example, given | |
| 778 | /// This method traverses the macro expansion ancestors until it finds a span | |
| 779 | /// that is either from user-written code or from a local macro (defined in the current crate). | |
| 771 | 780 | /// |
| 772 | /// ```ignore (illustrative example, contains type error) | |
| 773 | /// macro_rules! outer { | |
| 774 | /// ($x: expr) => { | |
| 775 | /// inner!($x) | |
| 776 | /// } | |
| 777 | /// } | |
| 781 | /// External macros are those defined in dependencies or the standard library. | |
| 782 | /// This method is useful for reporting errors in user-controllable code and avoiding | |
| 783 | /// diagnostics inside external macros. | |
| 778 | 784 | /// |
| 779 | /// macro_rules! inner { | |
| 780 | /// ($x: expr) => { | |
| 781 | /// format!("error: {}", $x) | |
| 782 | /// //~^ ERROR mismatched types | |
| 783 | /// } | |
| 784 | /// } | |
| 785 | /// # See also | |
| 785 | 786 | /// |
| 786 | /// fn bar(x: &str) -> Result<(), Box<dyn std::error::Error>> { | |
| 787 | /// Err(outer!(x)) | |
| 788 | /// } | |
| 789 | /// ``` | |
| 787 | /// - [`Self::find_ancestor_not_from_macro`] | |
| 788 | /// - [`Self::in_external_macro`] | |
| 789 | pub fn find_ancestor_not_from_extern_macro(mut self, sm: &SourceMap) -> Option<Span> { | |
| 790 | while self.in_external_macro(sm) { | |
| 791 | self = self.parent_callsite()?; | |
| 792 | } | |
| 793 | Some(self) | |
| 794 | } | |
| 795 | ||
| 796 | /// Find the first ancestor span that does not come from any macro expansion. | |
| 790 | 797 | /// |
| 791 | /// if provided the initial span of `outer!(x)` inside `bar`, this method will recurse | |
| 792 | /// the parent callsites until we reach `format!("error: {}", $x)`, at which point it is the | |
| 793 | /// oldest ancestor span that is both still local and shares the same [`SyntaxContext`] as the | |
| 794 | /// initial span. | |
| 795 | pub fn find_oldest_ancestor_in_same_ctxt(self) -> Span { | |
| 796 | let mut cur = self; | |
| 797 | while cur.eq_ctxt(self) | |
| 798 | && let Some(parent_callsite) = cur.parent_callsite() | |
| 799 | { | |
| 800 | cur = parent_callsite; | |
| 798 | /// This method traverses the macro expansion ancestors until it finds a span | |
| 799 | /// that originates from user-written code rather than any macro-generated code. | |
| 800 | /// | |
| 801 | /// This method is useful for reporting errors at the exact location users wrote code | |
| 802 | /// and providing suggestions at directly editable locations. | |
| 803 | /// | |
| 804 | /// # See also | |
| 805 | /// | |
| 806 | /// - [`Self::find_ancestor_not_from_extern_macro`] | |
| 807 | /// - [`Span::from_expansion`] | |
| 808 | pub fn find_ancestor_not_from_macro(mut self) -> Option<Span> { | |
| 809 | while self.from_expansion() { | |
| 810 | self = self.parent_callsite()?; | |
| 801 | 811 | } |
| 802 | cur | |
| 812 | Some(self) | |
| 803 | 813 | } |
| 804 | 814 | |
| 805 | 815 | /// Edition of the crate from which this span came. |
src/doc/rustc-dev-guide/src/tests/directives.md+11-2| ... | ... | @@ -293,8 +293,6 @@ See [Pretty-printer](compiletest.md#pretty-printer-tests). |
| 293 | 293 | |
| 294 | 294 | - `no-auto-check-cfg` — disable auto check-cfg (only for `--check-cfg` tests) |
| 295 | 295 | - [`revisions`](compiletest.md#revisions) — compile multiple times |
| 296 | - [`unused-revision-names`](compiletest.md#ignoring-unused-revision-names) - | |
| 297 | suppress tidy checks for mentioning unknown revision names | |
| 298 | 296 | -[`forbid-output`](compiletest.md#incremental-tests) — incremental cfail rejects |
| 299 | 297 | output pattern |
| 300 | 298 | - [`should-ice`](compiletest.md#incremental-tests) — incremental cfail should |
| ... | ... | @@ -315,6 +313,17 @@ test suites that use those tools: |
| 315 | 313 | - `llvm-cov-flags` adds extra flags when running LLVM's `llvm-cov` tool. |
| 316 | 314 | - Used by [coverage tests](compiletest.md#coverage-tests) in `coverage-run` mode. |
| 317 | 315 | |
| 316 | ### Tidy specific directives | |
| 317 | ||
| 318 | The following directives control how the [tidy script](../conventions.md#formatting) | |
| 319 | verifies tests. | |
| 320 | ||
| 321 | - `ignore-tidy-target-specific-tests` disables checking that the appropriate | |
| 322 | LLVM component is required (via a `needs-llvm-components` directive) when a | |
| 323 | test is compiled for a specific target (via the `--target` flag in a | |
| 324 | `compile-flag` directive). | |
| 325 | - [`unused-revision-names`](compiletest.md#ignoring-unused-revision-names) - | |
| 326 | suppress tidy checks for mentioning unknown revision names. | |
| 318 | 327 | |
| 319 | 328 | ## Substitutions |
| 320 | 329 |
src/tools/compiletest/src/directives.rs+145-333| ... | ... | @@ -12,6 +12,9 @@ use tracing::*; |
| 12 | 12 | use crate::common::{CodegenBackend, Config, Debugger, FailMode, PassMode, RunFailMode, TestMode}; |
| 13 | 13 | use crate::debuggers::{extract_cdb_version, extract_gdb_version}; |
| 14 | 14 | use crate::directives::auxiliary::{AuxProps, parse_and_update_aux}; |
| 15 | use crate::directives::directive_names::{ | |
| 16 | KNOWN_DIRECTIVE_NAMES, KNOWN_HTMLDOCCK_DIRECTIVE_NAMES, KNOWN_JSONDOCCK_DIRECTIVE_NAMES, | |
| 17 | }; | |
| 15 | 18 | use crate::directives::needs::CachedNeedsConditions; |
| 16 | 19 | use crate::errors::ErrorKind; |
| 17 | 20 | use crate::executor::{CollectedTestDesc, ShouldPanic}; |
| ... | ... | @@ -20,6 +23,7 @@ use crate::util::static_regex; |
| 20 | 23 | |
| 21 | 24 | pub(crate) mod auxiliary; |
| 22 | 25 | mod cfg; |
| 26 | mod directive_names; | |
| 23 | 27 | mod needs; |
| 24 | 28 | #[cfg(test)] |
| 25 | 29 | mod tests; |
| ... | ... | @@ -59,9 +63,9 @@ impl EarlyProps { |
| 59 | 63 | &mut poisoned, |
| 60 | 64 | testfile, |
| 61 | 65 | rdr, |
| 62 | &mut |DirectiveLine { raw_directive: ln, .. }| { | |
| 63 | parse_and_update_aux(config, ln, &mut props.aux); | |
| 64 | config.parse_and_update_revisions(testfile, ln, &mut props.revisions); | |
| 66 | &mut |DirectiveLine { line_number, raw_directive: ln, .. }| { | |
| 67 | parse_and_update_aux(config, ln, testfile, line_number, &mut props.aux); | |
| 68 | config.parse_and_update_revisions(testfile, line_number, ln, &mut props.revisions); | |
| 65 | 69 | }, |
| 66 | 70 | ); |
| 67 | 71 | |
| ... | ... | @@ -351,7 +355,7 @@ impl TestProps { |
| 351 | 355 | &mut poisoned, |
| 352 | 356 | testfile, |
| 353 | 357 | file, |
| 354 | &mut |directive @ DirectiveLine { raw_directive: ln, .. }| { | |
| 358 | &mut |directive @ DirectiveLine { line_number, raw_directive: ln, .. }| { | |
| 355 | 359 | if !directive.applies_to_test_revision(test_revision) { |
| 356 | 360 | return; |
| 357 | 361 | } |
| ... | ... | @@ -361,17 +365,28 @@ impl TestProps { |
| 361 | 365 | config.push_name_value_directive( |
| 362 | 366 | ln, |
| 363 | 367 | ERROR_PATTERN, |
| 368 | testfile, | |
| 369 | line_number, | |
| 364 | 370 | &mut self.error_patterns, |
| 365 | 371 | |r| r, |
| 366 | 372 | ); |
| 367 | 373 | config.push_name_value_directive( |
| 368 | 374 | ln, |
| 369 | 375 | REGEX_ERROR_PATTERN, |
| 376 | testfile, | |
| 377 | line_number, | |
| 370 | 378 | &mut self.regex_error_patterns, |
| 371 | 379 | |r| r, |
| 372 | 380 | ); |
| 373 | 381 | |
| 374 | config.push_name_value_directive(ln, DOC_FLAGS, &mut self.doc_flags, |r| r); | |
| 382 | config.push_name_value_directive( | |
| 383 | ln, | |
| 384 | DOC_FLAGS, | |
| 385 | testfile, | |
| 386 | line_number, | |
| 387 | &mut self.doc_flags, | |
| 388 | |r| r, | |
| 389 | ); | |
| 375 | 390 | |
| 376 | 391 | fn split_flags(flags: &str) -> Vec<String> { |
| 377 | 392 | // Individual flags can be single-quoted to preserve spaces; see |
| ... | ... | @@ -386,7 +401,9 @@ impl TestProps { |
| 386 | 401 | .collect::<Vec<_>>() |
| 387 | 402 | } |
| 388 | 403 | |
| 389 | if let Some(flags) = config.parse_name_value_directive(ln, COMPILE_FLAGS) { | |
| 404 | if let Some(flags) = | |
| 405 | config.parse_name_value_directive(ln, COMPILE_FLAGS, testfile, line_number) | |
| 406 | { | |
| 390 | 407 | let flags = split_flags(&flags); |
| 391 | 408 | for flag in &flags { |
| 392 | 409 | if flag == "--edition" || flag.starts_with("--edition=") { |
| ... | ... | @@ -395,25 +412,40 @@ impl TestProps { |
| 395 | 412 | } |
| 396 | 413 | self.compile_flags.extend(flags); |
| 397 | 414 | } |
| 398 | if config.parse_name_value_directive(ln, INCORRECT_COMPILER_FLAGS).is_some() { | |
| 415 | if config | |
| 416 | .parse_name_value_directive( | |
| 417 | ln, | |
| 418 | INCORRECT_COMPILER_FLAGS, | |
| 419 | testfile, | |
| 420 | line_number, | |
| 421 | ) | |
| 422 | .is_some() | |
| 423 | { | |
| 399 | 424 | panic!("`compiler-flags` directive should be spelled `compile-flags`"); |
| 400 | 425 | } |
| 401 | 426 | |
| 402 | if let Some(edition) = config.parse_edition(ln) { | |
| 427 | if let Some(edition) = config.parse_edition(ln, testfile, line_number) { | |
| 403 | 428 | // The edition is added at the start, since flags from //@compile-flags must |
| 404 | 429 | // be passed to rustc last. |
| 405 | 430 | self.compile_flags.insert(0, format!("--edition={}", edition.trim())); |
| 406 | 431 | has_edition = true; |
| 407 | 432 | } |
| 408 | 433 | |
| 409 | config.parse_and_update_revisions(testfile, ln, &mut self.revisions); | |
| 434 | config.parse_and_update_revisions( | |
| 435 | testfile, | |
| 436 | line_number, | |
| 437 | ln, | |
| 438 | &mut self.revisions, | |
| 439 | ); | |
| 410 | 440 | |
| 411 | if let Some(flags) = config.parse_name_value_directive(ln, RUN_FLAGS) { | |
| 441 | if let Some(flags) = | |
| 442 | config.parse_name_value_directive(ln, RUN_FLAGS, testfile, line_number) | |
| 443 | { | |
| 412 | 444 | self.run_flags.extend(split_flags(&flags)); |
| 413 | 445 | } |
| 414 | 446 | |
| 415 | 447 | if self.pp_exact.is_none() { |
| 416 | self.pp_exact = config.parse_pp_exact(ln, testfile); | |
| 448 | self.pp_exact = config.parse_pp_exact(ln, testfile, line_number); | |
| 417 | 449 | } |
| 418 | 450 | |
| 419 | 451 | config.set_name_directive(ln, SHOULD_ICE, &mut self.should_ice); |
| ... | ... | @@ -435,7 +467,9 @@ impl TestProps { |
| 435 | 467 | ); |
| 436 | 468 | config.set_name_directive(ln, NO_PREFER_DYNAMIC, &mut self.no_prefer_dynamic); |
| 437 | 469 | |
| 438 | if let Some(m) = config.parse_name_value_directive(ln, PRETTY_MODE) { | |
| 470 | if let Some(m) = | |
| 471 | config.parse_name_value_directive(ln, PRETTY_MODE, testfile, line_number) | |
| 472 | { | |
| 439 | 473 | self.pretty_mode = m; |
| 440 | 474 | } |
| 441 | 475 | |
| ... | ... | @@ -446,35 +480,45 @@ impl TestProps { |
| 446 | 480 | ); |
| 447 | 481 | |
| 448 | 482 | // Call a helper method to deal with aux-related directives. |
| 449 | parse_and_update_aux(config, ln, &mut self.aux); | |
| 483 | parse_and_update_aux(config, ln, testfile, line_number, &mut self.aux); | |
| 450 | 484 | |
| 451 | 485 | config.push_name_value_directive( |
| 452 | 486 | ln, |
| 453 | 487 | EXEC_ENV, |
| 488 | testfile, | |
| 489 | line_number, | |
| 454 | 490 | &mut self.exec_env, |
| 455 | 491 | Config::parse_env, |
| 456 | 492 | ); |
| 457 | 493 | config.push_name_value_directive( |
| 458 | 494 | ln, |
| 459 | 495 | UNSET_EXEC_ENV, |
| 496 | testfile, | |
| 497 | line_number, | |
| 460 | 498 | &mut self.unset_exec_env, |
| 461 | 499 | |r| r.trim().to_owned(), |
| 462 | 500 | ); |
| 463 | 501 | config.push_name_value_directive( |
| 464 | 502 | ln, |
| 465 | 503 | RUSTC_ENV, |
| 504 | testfile, | |
| 505 | line_number, | |
| 466 | 506 | &mut self.rustc_env, |
| 467 | 507 | Config::parse_env, |
| 468 | 508 | ); |
| 469 | 509 | config.push_name_value_directive( |
| 470 | 510 | ln, |
| 471 | 511 | UNSET_RUSTC_ENV, |
| 512 | testfile, | |
| 513 | line_number, | |
| 472 | 514 | &mut self.unset_rustc_env, |
| 473 | 515 | |r| r.trim().to_owned(), |
| 474 | 516 | ); |
| 475 | 517 | config.push_name_value_directive( |
| 476 | 518 | ln, |
| 477 | 519 | FORBID_OUTPUT, |
| 520 | testfile, | |
| 521 | line_number, | |
| 478 | 522 | &mut self.forbid_output, |
| 479 | 523 | |r| r, |
| 480 | 524 | ); |
| ... | ... | @@ -510,7 +554,7 @@ impl TestProps { |
| 510 | 554 | } |
| 511 | 555 | |
| 512 | 556 | if let Some(code) = config |
| 513 | .parse_name_value_directive(ln, FAILURE_STATUS) | |
| 557 | .parse_name_value_directive(ln, FAILURE_STATUS, testfile, line_number) | |
| 514 | 558 | .and_then(|code| code.trim().parse::<i32>().ok()) |
| 515 | 559 | { |
| 516 | 560 | self.failure_status = Some(code); |
| ... | ... | @@ -531,6 +575,8 @@ impl TestProps { |
| 531 | 575 | config.set_name_value_directive( |
| 532 | 576 | ln, |
| 533 | 577 | ASSEMBLY_OUTPUT, |
| 578 | testfile, | |
| 579 | line_number, | |
| 534 | 580 | &mut self.assembly_output, |
| 535 | 581 | |r| r.trim().to_string(), |
| 536 | 582 | ); |
| ... | ... | @@ -543,7 +589,9 @@ impl TestProps { |
| 543 | 589 | |
| 544 | 590 | // Unlike the other `name_value_directive`s this needs to be handled manually, |
| 545 | 591 | // because it sets a `bool` flag. |
| 546 | if let Some(known_bug) = config.parse_name_value_directive(ln, KNOWN_BUG) { | |
| 592 | if let Some(known_bug) = | |
| 593 | config.parse_name_value_directive(ln, KNOWN_BUG, testfile, line_number) | |
| 594 | { | |
| 547 | 595 | let known_bug = known_bug.trim(); |
| 548 | 596 | if known_bug == "unknown" |
| 549 | 597 | || known_bug.split(',').all(|issue_ref| { |
| ... | ... | @@ -571,16 +619,25 @@ impl TestProps { |
| 571 | 619 | config.set_name_value_directive( |
| 572 | 620 | ln, |
| 573 | 621 | TEST_MIR_PASS, |
| 622 | testfile, | |
| 623 | line_number, | |
| 574 | 624 | &mut self.mir_unit_test, |
| 575 | 625 | |s| s.trim().to_string(), |
| 576 | 626 | ); |
| 577 | 627 | config.set_name_directive(ln, REMAP_SRC_BASE, &mut self.remap_src_base); |
| 578 | 628 | |
| 579 | if let Some(flags) = config.parse_name_value_directive(ln, LLVM_COV_FLAGS) { | |
| 629 | if let Some(flags) = | |
| 630 | config.parse_name_value_directive(ln, LLVM_COV_FLAGS, testfile, line_number) | |
| 631 | { | |
| 580 | 632 | self.llvm_cov_flags.extend(split_flags(&flags)); |
| 581 | 633 | } |
| 582 | 634 | |
| 583 | if let Some(flags) = config.parse_name_value_directive(ln, FILECHECK_FLAGS) { | |
| 635 | if let Some(flags) = config.parse_name_value_directive( | |
| 636 | ln, | |
| 637 | FILECHECK_FLAGS, | |
| 638 | testfile, | |
| 639 | line_number, | |
| 640 | ) { | |
| 584 | 641 | self.filecheck_flags.extend(split_flags(&flags)); |
| 585 | 642 | } |
| 586 | 643 | |
| ... | ... | @@ -588,9 +645,12 @@ impl TestProps { |
| 588 | 645 | |
| 589 | 646 | self.update_add_core_stubs(ln, config); |
| 590 | 647 | |
| 591 | if let Some(err_kind) = | |
| 592 | config.parse_name_value_directive(ln, DONT_REQUIRE_ANNOTATIONS) | |
| 593 | { | |
| 648 | if let Some(err_kind) = config.parse_name_value_directive( | |
| 649 | ln, | |
| 650 | DONT_REQUIRE_ANNOTATIONS, | |
| 651 | testfile, | |
| 652 | line_number, | |
| 653 | ) { | |
| 594 | 654 | self.dont_require_annotations |
| 595 | 655 | .insert(ErrorKind::expect_from_user_str(err_kind.trim())); |
| 596 | 656 | } |
| ... | ... | @@ -769,296 +829,6 @@ fn line_directive<'line>( |
| 769 | 829 | Some(DirectiveLine { line_number, revision, raw_directive }) |
| 770 | 830 | } |
| 771 | 831 | |
| 772 | /// This was originally generated by collecting directives from ui tests and then extracting their | |
| 773 | /// directive names. This is **not** an exhaustive list of all possible directives. Instead, this is | |
| 774 | /// a best-effort approximation for diagnostics. Add new directives to this list when needed. | |
| 775 | const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ | |
| 776 | // tidy-alphabetical-start | |
| 777 | "add-core-stubs", | |
| 778 | "assembly-output", | |
| 779 | "aux-bin", | |
| 780 | "aux-build", | |
| 781 | "aux-codegen-backend", | |
| 782 | "aux-crate", | |
| 783 | "build-aux-docs", | |
| 784 | "build-fail", | |
| 785 | "build-pass", | |
| 786 | "check-fail", | |
| 787 | "check-pass", | |
| 788 | "check-run-results", | |
| 789 | "check-stdout", | |
| 790 | "check-test-line-numbers-match", | |
| 791 | "compile-flags", | |
| 792 | "doc-flags", | |
| 793 | "dont-check-compiler-stderr", | |
| 794 | "dont-check-compiler-stdout", | |
| 795 | "dont-check-failure-status", | |
| 796 | "dont-require-annotations", | |
| 797 | "edition", | |
| 798 | "error-pattern", | |
| 799 | "exact-llvm-major-version", | |
| 800 | "exec-env", | |
| 801 | "failure-status", | |
| 802 | "filecheck-flags", | |
| 803 | "forbid-output", | |
| 804 | "force-host", | |
| 805 | "ignore-16bit", | |
| 806 | "ignore-32bit", | |
| 807 | "ignore-64bit", | |
| 808 | "ignore-aarch64", | |
| 809 | "ignore-aarch64-pc-windows-msvc", | |
| 810 | "ignore-aarch64-unknown-linux-gnu", | |
| 811 | "ignore-aix", | |
| 812 | "ignore-android", | |
| 813 | "ignore-apple", | |
| 814 | "ignore-arm", | |
| 815 | "ignore-arm-unknown-linux-gnueabi", | |
| 816 | "ignore-arm-unknown-linux-gnueabihf", | |
| 817 | "ignore-arm-unknown-linux-musleabi", | |
| 818 | "ignore-arm-unknown-linux-musleabihf", | |
| 819 | "ignore-auxiliary", | |
| 820 | "ignore-avr", | |
| 821 | "ignore-backends", | |
| 822 | "ignore-beta", | |
| 823 | "ignore-cdb", | |
| 824 | "ignore-compare-mode-next-solver", | |
| 825 | "ignore-compare-mode-polonius", | |
| 826 | "ignore-coverage-map", | |
| 827 | "ignore-coverage-run", | |
| 828 | "ignore-cross-compile", | |
| 829 | "ignore-eabi", | |
| 830 | "ignore-elf", | |
| 831 | "ignore-emscripten", | |
| 832 | "ignore-endian-big", | |
| 833 | "ignore-enzyme", | |
| 834 | "ignore-freebsd", | |
| 835 | "ignore-fuchsia", | |
| 836 | "ignore-gdb", | |
| 837 | "ignore-gdb-version", | |
| 838 | "ignore-gnu", | |
| 839 | "ignore-haiku", | |
| 840 | "ignore-horizon", | |
| 841 | "ignore-i686-pc-windows-gnu", | |
| 842 | "ignore-i686-pc-windows-msvc", | |
| 843 | "ignore-illumos", | |
| 844 | "ignore-ios", | |
| 845 | "ignore-linux", | |
| 846 | "ignore-lldb", | |
| 847 | "ignore-llvm-version", | |
| 848 | "ignore-loongarch32", | |
| 849 | "ignore-loongarch64", | |
| 850 | "ignore-macabi", | |
| 851 | "ignore-macos", | |
| 852 | "ignore-msp430", | |
| 853 | "ignore-msvc", | |
| 854 | "ignore-musl", | |
| 855 | "ignore-netbsd", | |
| 856 | "ignore-nightly", | |
| 857 | "ignore-none", | |
| 858 | "ignore-nto", | |
| 859 | "ignore-nvptx64", | |
| 860 | "ignore-nvptx64-nvidia-cuda", | |
| 861 | "ignore-openbsd", | |
| 862 | "ignore-pass", | |
| 863 | "ignore-powerpc", | |
| 864 | "ignore-powerpc64", | |
| 865 | "ignore-remote", | |
| 866 | "ignore-riscv64", | |
| 867 | "ignore-rustc-debug-assertions", | |
| 868 | "ignore-rustc_abi-x86-sse2", | |
| 869 | "ignore-s390x", | |
| 870 | "ignore-sgx", | |
| 871 | "ignore-sparc64", | |
| 872 | "ignore-spirv", | |
| 873 | "ignore-stable", | |
| 874 | "ignore-stage1", | |
| 875 | "ignore-stage2", | |
| 876 | "ignore-std-debug-assertions", | |
| 877 | "ignore-test", | |
| 878 | "ignore-thumb", | |
| 879 | "ignore-thumbv8m.base-none-eabi", | |
| 880 | "ignore-thumbv8m.main-none-eabi", | |
| 881 | "ignore-tvos", | |
| 882 | "ignore-unix", | |
| 883 | "ignore-unknown", | |
| 884 | "ignore-uwp", | |
| 885 | "ignore-visionos", | |
| 886 | "ignore-vxworks", | |
| 887 | "ignore-wasi", | |
| 888 | "ignore-wasm", | |
| 889 | "ignore-wasm32", | |
| 890 | "ignore-wasm32-bare", | |
| 891 | "ignore-wasm64", | |
| 892 | "ignore-watchos", | |
| 893 | "ignore-windows", | |
| 894 | "ignore-windows-gnu", | |
| 895 | "ignore-windows-msvc", | |
| 896 | "ignore-x32", | |
| 897 | "ignore-x86", | |
| 898 | "ignore-x86_64", | |
| 899 | "ignore-x86_64-apple-darwin", | |
| 900 | "ignore-x86_64-pc-windows-gnu", | |
| 901 | "ignore-x86_64-unknown-linux-gnu", | |
| 902 | "incremental", | |
| 903 | "known-bug", | |
| 904 | "llvm-cov-flags", | |
| 905 | "max-llvm-major-version", | |
| 906 | "min-cdb-version", | |
| 907 | "min-gdb-version", | |
| 908 | "min-lldb-version", | |
| 909 | "min-llvm-version", | |
| 910 | "min-system-llvm-version", | |
| 911 | "needs-asm-support", | |
| 912 | "needs-backends", | |
| 913 | "needs-crate-type", | |
| 914 | "needs-deterministic-layouts", | |
| 915 | "needs-dlltool", | |
| 916 | "needs-dynamic-linking", | |
| 917 | "needs-enzyme", | |
| 918 | "needs-force-clang-based-tests", | |
| 919 | "needs-git-hash", | |
| 920 | "needs-llvm-components", | |
| 921 | "needs-llvm-zstd", | |
| 922 | "needs-profiler-runtime", | |
| 923 | "needs-relocation-model-pic", | |
| 924 | "needs-run-enabled", | |
| 925 | "needs-rust-lld", | |
| 926 | "needs-rustc-debug-assertions", | |
| 927 | "needs-sanitizer-address", | |
| 928 | "needs-sanitizer-cfi", | |
| 929 | "needs-sanitizer-dataflow", | |
| 930 | "needs-sanitizer-hwaddress", | |
| 931 | "needs-sanitizer-kcfi", | |
| 932 | "needs-sanitizer-leak", | |
| 933 | "needs-sanitizer-memory", | |
| 934 | "needs-sanitizer-memtag", | |
| 935 | "needs-sanitizer-safestack", | |
| 936 | "needs-sanitizer-shadow-call-stack", | |
| 937 | "needs-sanitizer-support", | |
| 938 | "needs-sanitizer-thread", | |
| 939 | "needs-std-debug-assertions", | |
| 940 | "needs-subprocess", | |
| 941 | "needs-symlink", | |
| 942 | "needs-target-has-atomic", | |
| 943 | "needs-target-std", | |
| 944 | "needs-threads", | |
| 945 | "needs-unwind", | |
| 946 | "needs-wasmtime", | |
| 947 | "needs-xray", | |
| 948 | "no-auto-check-cfg", | |
| 949 | "no-prefer-dynamic", | |
| 950 | "normalize-stderr", | |
| 951 | "normalize-stderr-32bit", | |
| 952 | "normalize-stderr-64bit", | |
| 953 | "normalize-stdout", | |
| 954 | "only-16bit", | |
| 955 | "only-32bit", | |
| 956 | "only-64bit", | |
| 957 | "only-aarch64", | |
| 958 | "only-aarch64-apple-darwin", | |
| 959 | "only-aarch64-unknown-linux-gnu", | |
| 960 | "only-apple", | |
| 961 | "only-arm", | |
| 962 | "only-avr", | |
| 963 | "only-beta", | |
| 964 | "only-bpf", | |
| 965 | "only-cdb", | |
| 966 | "only-dist", | |
| 967 | "only-elf", | |
| 968 | "only-emscripten", | |
| 969 | "only-gnu", | |
| 970 | "only-i686-pc-windows-gnu", | |
| 971 | "only-i686-pc-windows-msvc", | |
| 972 | "only-i686-unknown-linux-gnu", | |
| 973 | "only-ios", | |
| 974 | "only-linux", | |
| 975 | "only-loongarch32", | |
| 976 | "only-loongarch64", | |
| 977 | "only-loongarch64-unknown-linux-gnu", | |
| 978 | "only-macos", | |
| 979 | "only-mips", | |
| 980 | "only-mips64", | |
| 981 | "only-msp430", | |
| 982 | "only-msvc", | |
| 983 | "only-musl", | |
| 984 | "only-nightly", | |
| 985 | "only-nvptx64", | |
| 986 | "only-powerpc", | |
| 987 | "only-riscv64", | |
| 988 | "only-rustc_abi-x86-sse2", | |
| 989 | "only-s390x", | |
| 990 | "only-sparc", | |
| 991 | "only-sparc64", | |
| 992 | "only-stable", | |
| 993 | "only-thumb", | |
| 994 | "only-tvos", | |
| 995 | "only-uefi", | |
| 996 | "only-unix", | |
| 997 | "only-visionos", | |
| 998 | "only-wasm32", | |
| 999 | "only-wasm32-bare", | |
| 1000 | "only-wasm32-wasip1", | |
| 1001 | "only-watchos", | |
| 1002 | "only-windows", | |
| 1003 | "only-windows-gnu", | |
| 1004 | "only-windows-msvc", | |
| 1005 | "only-x86", | |
| 1006 | "only-x86_64", | |
| 1007 | "only-x86_64-apple-darwin", | |
| 1008 | "only-x86_64-fortanix-unknown-sgx", | |
| 1009 | "only-x86_64-pc-windows-gnu", | |
| 1010 | "only-x86_64-pc-windows-msvc", | |
| 1011 | "only-x86_64-unknown-linux-gnu", | |
| 1012 | "pp-exact", | |
| 1013 | "pretty-compare-only", | |
| 1014 | "pretty-mode", | |
| 1015 | "proc-macro", | |
| 1016 | "reference", | |
| 1017 | "regex-error-pattern", | |
| 1018 | "remap-src-base", | |
| 1019 | "revisions", | |
| 1020 | "run-crash", | |
| 1021 | "run-fail", | |
| 1022 | "run-fail-or-crash", | |
| 1023 | "run-flags", | |
| 1024 | "run-pass", | |
| 1025 | "run-rustfix", | |
| 1026 | "rustc-env", | |
| 1027 | "rustfix-only-machine-applicable", | |
| 1028 | "should-fail", | |
| 1029 | "should-ice", | |
| 1030 | "stderr-per-bitwidth", | |
| 1031 | "test-mir-pass", | |
| 1032 | "unique-doc-out-dir", | |
| 1033 | "unset-exec-env", | |
| 1034 | "unset-rustc-env", | |
| 1035 | // Used by the tidy check `unknown_revision`. | |
| 1036 | "unused-revision-names", | |
| 1037 | // tidy-alphabetical-end | |
| 1038 | ]; | |
| 1039 | ||
| 1040 | const KNOWN_HTMLDOCCK_DIRECTIVE_NAMES: &[&str] = &[ | |
| 1041 | "count", | |
| 1042 | "!count", | |
| 1043 | "files", | |
| 1044 | "!files", | |
| 1045 | "has", | |
| 1046 | "!has", | |
| 1047 | "has-dir", | |
| 1048 | "!has-dir", | |
| 1049 | "hasraw", | |
| 1050 | "!hasraw", | |
| 1051 | "matches", | |
| 1052 | "!matches", | |
| 1053 | "matchesraw", | |
| 1054 | "!matchesraw", | |
| 1055 | "snapshot", | |
| 1056 | "!snapshot", | |
| 1057 | ]; | |
| 1058 | ||
| 1059 | const KNOWN_JSONDOCCK_DIRECTIVE_NAMES: &[&str] = | |
| 1060 | &["count", "!count", "has", "!has", "is", "!is", "ismany", "!ismany", "set", "!set"]; | |
| 1061 | ||
| 1062 | 832 | /// The (partly) broken-down contents of a line containing a test directive, |
| 1063 | 833 | /// which [`iter_directives`] passes to its callback function. |
| 1064 | 834 | /// |
| ... | ... | @@ -1206,6 +976,7 @@ impl Config { |
| 1206 | 976 | fn parse_and_update_revisions( |
| 1207 | 977 | &self, |
| 1208 | 978 | testfile: &Utf8Path, |
| 979 | line_number: usize, | |
| 1209 | 980 | line: &str, |
| 1210 | 981 | existing: &mut Vec<String>, |
| 1211 | 982 | ) { |
| ... | ... | @@ -1219,7 +990,8 @@ impl Config { |
| 1219 | 990 | const FILECHECK_FORBIDDEN_REVISION_NAMES: [&str; 9] = |
| 1220 | 991 | ["CHECK", "COM", "NEXT", "SAME", "EMPTY", "NOT", "COUNT", "DAG", "LABEL"]; |
| 1221 | 992 | |
| 1222 | if let Some(raw) = self.parse_name_value_directive(line, "revisions") { | |
| 993 | if let Some(raw) = self.parse_name_value_directive(line, "revisions", testfile, line_number) | |
| 994 | { | |
| 1223 | 995 | if self.mode == TestMode::RunMake { |
| 1224 | 996 | panic!("`run-make` tests do not support revisions: {}", testfile); |
| 1225 | 997 | } |
| ... | ... | @@ -1264,8 +1036,13 @@ impl Config { |
| 1264 | 1036 | (name.to_owned(), value.to_owned()) |
| 1265 | 1037 | } |
| 1266 | 1038 | |
| 1267 | fn parse_pp_exact(&self, line: &str, testfile: &Utf8Path) -> Option<Utf8PathBuf> { | |
| 1268 | if let Some(s) = self.parse_name_value_directive(line, "pp-exact") { | |
| 1039 | fn parse_pp_exact( | |
| 1040 | &self, | |
| 1041 | line: &str, | |
| 1042 | testfile: &Utf8Path, | |
| 1043 | line_number: usize, | |
| 1044 | ) -> Option<Utf8PathBuf> { | |
| 1045 | if let Some(s) = self.parse_name_value_directive(line, "pp-exact", testfile, line_number) { | |
| 1269 | 1046 | Some(Utf8PathBuf::from(&s)) |
| 1270 | 1047 | } else if self.parse_name_directive(line, "pp-exact") { |
| 1271 | 1048 | testfile.file_name().map(Utf8PathBuf::from) |
| ... | ... | @@ -1306,19 +1083,31 @@ impl Config { |
| 1306 | 1083 | line.starts_with("no-") && self.parse_name_directive(&line[3..], directive) |
| 1307 | 1084 | } |
| 1308 | 1085 | |
| 1309 | pub fn parse_name_value_directive(&self, line: &str, directive: &str) -> Option<String> { | |
| 1086 | pub fn parse_name_value_directive( | |
| 1087 | &self, | |
| 1088 | line: &str, | |
| 1089 | directive: &str, | |
| 1090 | testfile: &Utf8Path, | |
| 1091 | line_number: usize, | |
| 1092 | ) -> Option<String> { | |
| 1310 | 1093 | let colon = directive.len(); |
| 1311 | 1094 | if line.starts_with(directive) && line.as_bytes().get(colon) == Some(&b':') { |
| 1312 | 1095 | let value = line[(colon + 1)..].to_owned(); |
| 1313 | 1096 | debug!("{}: {}", directive, value); |
| 1314 | Some(expand_variables(value, self)) | |
| 1097 | let value = expand_variables(value, self); | |
| 1098 | if value.is_empty() { | |
| 1099 | error!("{testfile}:{line_number}: empty value for directive `{directive}`"); | |
| 1100 | help!("expected syntax is: `{directive}: value`"); | |
| 1101 | panic!("empty directive value detected"); | |
| 1102 | } | |
| 1103 | Some(value) | |
| 1315 | 1104 | } else { |
| 1316 | 1105 | None |
| 1317 | 1106 | } |
| 1318 | 1107 | } |
| 1319 | 1108 | |
| 1320 | fn parse_edition(&self, line: &str) -> Option<String> { | |
| 1321 | self.parse_name_value_directive(line, "edition") | |
| 1109 | fn parse_edition(&self, line: &str, testfile: &Utf8Path, line_number: usize) -> Option<String> { | |
| 1110 | self.parse_name_value_directive(line, "edition", testfile, line_number) | |
| 1322 | 1111 | } |
| 1323 | 1112 | |
| 1324 | 1113 | fn set_name_directive(&self, line: &str, directive: &str, value: &mut bool) { |
| ... | ... | @@ -1340,11 +1129,14 @@ impl Config { |
| 1340 | 1129 | &self, |
| 1341 | 1130 | line: &str, |
| 1342 | 1131 | directive: &str, |
| 1132 | testfile: &Utf8Path, | |
| 1133 | line_number: usize, | |
| 1343 | 1134 | value: &mut Option<T>, |
| 1344 | 1135 | parse: impl FnOnce(String) -> T, |
| 1345 | 1136 | ) { |
| 1346 | 1137 | if value.is_none() { |
| 1347 | *value = self.parse_name_value_directive(line, directive).map(parse); | |
| 1138 | *value = | |
| 1139 | self.parse_name_value_directive(line, directive, testfile, line_number).map(parse); | |
| 1348 | 1140 | } |
| 1349 | 1141 | } |
| 1350 | 1142 | |
| ... | ... | @@ -1352,10 +1144,14 @@ impl Config { |
| 1352 | 1144 | &self, |
| 1353 | 1145 | line: &str, |
| 1354 | 1146 | directive: &str, |
| 1147 | testfile: &Utf8Path, | |
| 1148 | line_number: usize, | |
| 1355 | 1149 | values: &mut Vec<T>, |
| 1356 | 1150 | parse: impl FnOnce(String) -> T, |
| 1357 | 1151 | ) { |
| 1358 | if let Some(value) = self.parse_name_value_directive(line, directive).map(parse) { | |
| 1152 | if let Some(value) = | |
| 1153 | self.parse_name_value_directive(line, directive, testfile, line_number).map(parse) | |
| 1154 | { | |
| 1359 | 1155 | values.push(value); |
| 1360 | 1156 | } |
| 1361 | 1157 | } |
| ... | ... | @@ -1672,9 +1468,9 @@ pub(crate) fn make_test_description<R: Read>( |
| 1672 | 1468 | decision!(cfg::handle_ignore(config, ln)); |
| 1673 | 1469 | decision!(cfg::handle_only(config, ln)); |
| 1674 | 1470 | decision!(needs::handle_needs(&cache.needs, config, ln)); |
| 1675 | decision!(ignore_llvm(config, path, ln)); | |
| 1676 | decision!(ignore_backends(config, path, ln)); | |
| 1677 | decision!(needs_backends(config, path, ln)); | |
| 1471 | decision!(ignore_llvm(config, path, ln, line_number)); | |
| 1472 | decision!(ignore_backends(config, path, ln, line_number)); | |
| 1473 | decision!(needs_backends(config, path, ln, line_number)); | |
| 1678 | 1474 | decision!(ignore_cdb(config, ln)); |
| 1679 | 1475 | decision!(ignore_gdb(config, ln)); |
| 1680 | 1476 | decision!(ignore_lldb(config, ln)); |
| ... | ... | @@ -1801,8 +1597,15 @@ fn ignore_lldb(config: &Config, line: &str) -> IgnoreDecision { |
| 1801 | 1597 | IgnoreDecision::Continue |
| 1802 | 1598 | } |
| 1803 | 1599 | |
| 1804 | fn ignore_backends(config: &Config, path: &Utf8Path, line: &str) -> IgnoreDecision { | |
| 1805 | if let Some(backends_to_ignore) = config.parse_name_value_directive(line, "ignore-backends") { | |
| 1600 | fn ignore_backends( | |
| 1601 | config: &Config, | |
| 1602 | path: &Utf8Path, | |
| 1603 | line: &str, | |
| 1604 | line_number: usize, | |
| 1605 | ) -> IgnoreDecision { | |
| 1606 | if let Some(backends_to_ignore) = | |
| 1607 | config.parse_name_value_directive(line, "ignore-backends", path, line_number) | |
| 1608 | { | |
| 1806 | 1609 | for backend in backends_to_ignore.split_whitespace().map(|backend| { |
| 1807 | 1610 | match CodegenBackend::try_from(backend) { |
| 1808 | 1611 | Ok(backend) => backend, |
| ... | ... | @@ -1821,8 +1624,15 @@ fn ignore_backends(config: &Config, path: &Utf8Path, line: &str) -> IgnoreDecisi |
| 1821 | 1624 | IgnoreDecision::Continue |
| 1822 | 1625 | } |
| 1823 | 1626 | |
| 1824 | fn needs_backends(config: &Config, path: &Utf8Path, line: &str) -> IgnoreDecision { | |
| 1825 | if let Some(needed_backends) = config.parse_name_value_directive(line, "needs-backends") { | |
| 1627 | fn needs_backends( | |
| 1628 | config: &Config, | |
| 1629 | path: &Utf8Path, | |
| 1630 | line: &str, | |
| 1631 | line_number: usize, | |
| 1632 | ) -> IgnoreDecision { | |
| 1633 | if let Some(needed_backends) = | |
| 1634 | config.parse_name_value_directive(line, "needs-backends", path, line_number) | |
| 1635 | { | |
| 1826 | 1636 | if !needed_backends |
| 1827 | 1637 | .split_whitespace() |
| 1828 | 1638 | .map(|backend| match CodegenBackend::try_from(backend) { |
| ... | ... | @@ -1844,9 +1654,9 @@ fn needs_backends(config: &Config, path: &Utf8Path, line: &str) -> IgnoreDecisio |
| 1844 | 1654 | IgnoreDecision::Continue |
| 1845 | 1655 | } |
| 1846 | 1656 | |
| 1847 | fn ignore_llvm(config: &Config, path: &Utf8Path, line: &str) -> IgnoreDecision { | |
| 1657 | fn ignore_llvm(config: &Config, path: &Utf8Path, line: &str, line_number: usize) -> IgnoreDecision { | |
| 1848 | 1658 | if let Some(needed_components) = |
| 1849 | config.parse_name_value_directive(line, "needs-llvm-components") | |
| 1659 | config.parse_name_value_directive(line, "needs-llvm-components", path, line_number) | |
| 1850 | 1660 | { |
| 1851 | 1661 | let components: HashSet<_> = config.llvm_components.split_whitespace().collect(); |
| 1852 | 1662 | if let Some(missing_component) = needed_components |
| ... | ... | @@ -1867,7 +1677,9 @@ fn ignore_llvm(config: &Config, path: &Utf8Path, line: &str) -> IgnoreDecision { |
| 1867 | 1677 | if let Some(actual_version) = &config.llvm_version { |
| 1868 | 1678 | // Note that these `min` versions will check for not just major versions. |
| 1869 | 1679 | |
| 1870 | if let Some(version_string) = config.parse_name_value_directive(line, "min-llvm-version") { | |
| 1680 | if let Some(version_string) = | |
| 1681 | config.parse_name_value_directive(line, "min-llvm-version", path, line_number) | |
| 1682 | { | |
| 1871 | 1683 | let min_version = extract_llvm_version(&version_string); |
| 1872 | 1684 | // Ignore if actual version is smaller than the minimum required version. |
| 1873 | 1685 | if *actual_version < min_version { |
| ... | ... | @@ -1878,7 +1690,7 @@ fn ignore_llvm(config: &Config, path: &Utf8Path, line: &str) -> IgnoreDecision { |
| 1878 | 1690 | }; |
| 1879 | 1691 | } |
| 1880 | 1692 | } else if let Some(version_string) = |
| 1881 | config.parse_name_value_directive(line, "max-llvm-major-version") | |
| 1693 | config.parse_name_value_directive(line, "max-llvm-major-version", path, line_number) | |
| 1882 | 1694 | { |
| 1883 | 1695 | let max_version = extract_llvm_version(&version_string); |
| 1884 | 1696 | // Ignore if actual major version is larger than the maximum required major version. |
| ... | ... | @@ -1892,7 +1704,7 @@ fn ignore_llvm(config: &Config, path: &Utf8Path, line: &str) -> IgnoreDecision { |
| 1892 | 1704 | }; |
| 1893 | 1705 | } |
| 1894 | 1706 | } else if let Some(version_string) = |
| 1895 | config.parse_name_value_directive(line, "min-system-llvm-version") | |
| 1707 | config.parse_name_value_directive(line, "min-system-llvm-version", path, line_number) | |
| 1896 | 1708 | { |
| 1897 | 1709 | let min_version = extract_llvm_version(&version_string); |
| 1898 | 1710 | // Ignore if using system LLVM and actual version |
| ... | ... | @@ -1905,7 +1717,7 @@ fn ignore_llvm(config: &Config, path: &Utf8Path, line: &str) -> IgnoreDecision { |
| 1905 | 1717 | }; |
| 1906 | 1718 | } |
| 1907 | 1719 | } else if let Some(version_range) = |
| 1908 | config.parse_name_value_directive(line, "ignore-llvm-version") | |
| 1720 | config.parse_name_value_directive(line, "ignore-llvm-version", path, line_number) | |
| 1909 | 1721 | { |
| 1910 | 1722 | // Syntax is: "ignore-llvm-version: <version1> [- <version2>]" |
| 1911 | 1723 | let (v_min, v_max) = |
| ... | ... | @@ -1931,7 +1743,7 @@ fn ignore_llvm(config: &Config, path: &Utf8Path, line: &str) -> IgnoreDecision { |
| 1931 | 1743 | } |
| 1932 | 1744 | } |
| 1933 | 1745 | } else if let Some(version_string) = |
| 1934 | config.parse_name_value_directive(line, "exact-llvm-major-version") | |
| 1746 | config.parse_name_value_directive(line, "exact-llvm-major-version", path, line_number) | |
| 1935 | 1747 | { |
| 1936 | 1748 | // Syntax is "exact-llvm-major-version: <version>" |
| 1937 | 1749 | let version = extract_llvm_version(&version_string); |
src/tools/compiletest/src/directives/auxiliary.rs+34-7| ... | ... | @@ -3,6 +3,8 @@ |
| 3 | 3 | |
| 4 | 4 | use std::iter; |
| 5 | 5 | |
| 6 | use camino::Utf8Path; | |
| 7 | ||
| 6 | 8 | use super::directives::{AUX_BIN, AUX_BUILD, AUX_CODEGEN_BACKEND, AUX_CRATE, PROC_MACRO}; |
| 7 | 9 | use crate::common::Config; |
| 8 | 10 | |
| ... | ... | @@ -41,17 +43,42 @@ impl AuxProps { |
| 41 | 43 | |
| 42 | 44 | /// If the given test directive line contains an `aux-*` directive, parse it |
| 43 | 45 | /// and update [`AuxProps`] accordingly. |
| 44 | pub(super) fn parse_and_update_aux(config: &Config, ln: &str, aux: &mut AuxProps) { | |
| 46 | pub(super) fn parse_and_update_aux( | |
| 47 | config: &Config, | |
| 48 | ln: &str, | |
| 49 | testfile: &Utf8Path, | |
| 50 | line_number: usize, | |
| 51 | aux: &mut AuxProps, | |
| 52 | ) { | |
| 45 | 53 | if !(ln.starts_with("aux-") || ln.starts_with("proc-macro")) { |
| 46 | 54 | return; |
| 47 | 55 | } |
| 48 | 56 | |
| 49 | config.push_name_value_directive(ln, AUX_BUILD, &mut aux.builds, |r| r.trim().to_string()); | |
| 50 | config.push_name_value_directive(ln, AUX_BIN, &mut aux.bins, |r| r.trim().to_string()); | |
| 51 | config.push_name_value_directive(ln, AUX_CRATE, &mut aux.crates, parse_aux_crate); | |
| 52 | config | |
| 53 | .push_name_value_directive(ln, PROC_MACRO, &mut aux.proc_macros, |r| r.trim().to_string()); | |
| 54 | if let Some(r) = config.parse_name_value_directive(ln, AUX_CODEGEN_BACKEND) { | |
| 57 | config.push_name_value_directive(ln, AUX_BUILD, testfile, line_number, &mut aux.builds, |r| { | |
| 58 | r.trim().to_string() | |
| 59 | }); | |
| 60 | config.push_name_value_directive(ln, AUX_BIN, testfile, line_number, &mut aux.bins, |r| { | |
| 61 | r.trim().to_string() | |
| 62 | }); | |
| 63 | config.push_name_value_directive( | |
| 64 | ln, | |
| 65 | AUX_CRATE, | |
| 66 | testfile, | |
| 67 | line_number, | |
| 68 | &mut aux.crates, | |
| 69 | parse_aux_crate, | |
| 70 | ); | |
| 71 | config.push_name_value_directive( | |
| 72 | ln, | |
| 73 | PROC_MACRO, | |
| 74 | testfile, | |
| 75 | line_number, | |
| 76 | &mut aux.proc_macros, | |
| 77 | |r| r.trim().to_string(), | |
| 78 | ); | |
| 79 | if let Some(r) = | |
| 80 | config.parse_name_value_directive(ln, AUX_CODEGEN_BACKEND, testfile, line_number) | |
| 81 | { | |
| 55 | 82 | aux.codegen_backend = Some(r.trim().to_owned()); |
| 56 | 83 | } |
| 57 | 84 | } |
src/tools/compiletest/src/directives/directive_names.rs created+289| ... | ... | @@ -0,0 +1,289 @@ |
| 1 | /// This was originally generated by collecting directives from ui tests and then extracting their | |
| 2 | /// directive names. This is **not** an exhaustive list of all possible directives. Instead, this is | |
| 3 | /// a best-effort approximation for diagnostics. Add new directives to this list when needed. | |
| 4 | pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ | |
| 5 | // tidy-alphabetical-start | |
| 6 | "add-core-stubs", | |
| 7 | "assembly-output", | |
| 8 | "aux-bin", | |
| 9 | "aux-build", | |
| 10 | "aux-codegen-backend", | |
| 11 | "aux-crate", | |
| 12 | "build-aux-docs", | |
| 13 | "build-fail", | |
| 14 | "build-pass", | |
| 15 | "check-fail", | |
| 16 | "check-pass", | |
| 17 | "check-run-results", | |
| 18 | "check-stdout", | |
| 19 | "check-test-line-numbers-match", | |
| 20 | "compile-flags", | |
| 21 | "doc-flags", | |
| 22 | "dont-check-compiler-stderr", | |
| 23 | "dont-check-compiler-stdout", | |
| 24 | "dont-check-failure-status", | |
| 25 | "dont-require-annotations", | |
| 26 | "edition", | |
| 27 | "error-pattern", | |
| 28 | "exact-llvm-major-version", | |
| 29 | "exec-env", | |
| 30 | "failure-status", | |
| 31 | "filecheck-flags", | |
| 32 | "forbid-output", | |
| 33 | "force-host", | |
| 34 | "ignore-16bit", | |
| 35 | "ignore-32bit", | |
| 36 | "ignore-64bit", | |
| 37 | "ignore-aarch64", | |
| 38 | "ignore-aarch64-pc-windows-msvc", | |
| 39 | "ignore-aarch64-unknown-linux-gnu", | |
| 40 | "ignore-aix", | |
| 41 | "ignore-android", | |
| 42 | "ignore-apple", | |
| 43 | "ignore-arm", | |
| 44 | "ignore-arm-unknown-linux-gnueabi", | |
| 45 | "ignore-arm-unknown-linux-gnueabihf", | |
| 46 | "ignore-arm-unknown-linux-musleabi", | |
| 47 | "ignore-arm-unknown-linux-musleabihf", | |
| 48 | "ignore-auxiliary", | |
| 49 | "ignore-avr", | |
| 50 | "ignore-backends", | |
| 51 | "ignore-beta", | |
| 52 | "ignore-cdb", | |
| 53 | "ignore-compare-mode-next-solver", | |
| 54 | "ignore-compare-mode-polonius", | |
| 55 | "ignore-coverage-map", | |
| 56 | "ignore-coverage-run", | |
| 57 | "ignore-cross-compile", | |
| 58 | "ignore-eabi", | |
| 59 | "ignore-elf", | |
| 60 | "ignore-emscripten", | |
| 61 | "ignore-endian-big", | |
| 62 | "ignore-enzyme", | |
| 63 | "ignore-freebsd", | |
| 64 | "ignore-fuchsia", | |
| 65 | "ignore-gdb", | |
| 66 | "ignore-gdb-version", | |
| 67 | "ignore-gnu", | |
| 68 | "ignore-haiku", | |
| 69 | "ignore-horizon", | |
| 70 | "ignore-i686-pc-windows-gnu", | |
| 71 | "ignore-i686-pc-windows-msvc", | |
| 72 | "ignore-illumos", | |
| 73 | "ignore-ios", | |
| 74 | "ignore-linux", | |
| 75 | "ignore-lldb", | |
| 76 | "ignore-llvm-version", | |
| 77 | "ignore-loongarch32", | |
| 78 | "ignore-loongarch64", | |
| 79 | "ignore-macabi", | |
| 80 | "ignore-macos", | |
| 81 | "ignore-msp430", | |
| 82 | "ignore-msvc", | |
| 83 | "ignore-musl", | |
| 84 | "ignore-netbsd", | |
| 85 | "ignore-nightly", | |
| 86 | "ignore-none", | |
| 87 | "ignore-nto", | |
| 88 | "ignore-nvptx64", | |
| 89 | "ignore-nvptx64-nvidia-cuda", | |
| 90 | "ignore-openbsd", | |
| 91 | "ignore-pass", | |
| 92 | "ignore-powerpc", | |
| 93 | "ignore-powerpc64", | |
| 94 | "ignore-remote", | |
| 95 | "ignore-riscv64", | |
| 96 | "ignore-rustc-debug-assertions", | |
| 97 | "ignore-rustc_abi-x86-sse2", | |
| 98 | "ignore-s390x", | |
| 99 | "ignore-sgx", | |
| 100 | "ignore-sparc64", | |
| 101 | "ignore-spirv", | |
| 102 | "ignore-stable", | |
| 103 | "ignore-stage1", | |
| 104 | "ignore-stage2", | |
| 105 | "ignore-std-debug-assertions", | |
| 106 | "ignore-test", | |
| 107 | "ignore-thumb", | |
| 108 | "ignore-thumbv8m.base-none-eabi", | |
| 109 | "ignore-thumbv8m.main-none-eabi", | |
| 110 | "ignore-tvos", | |
| 111 | "ignore-unix", | |
| 112 | "ignore-unknown", | |
| 113 | "ignore-uwp", | |
| 114 | "ignore-visionos", | |
| 115 | "ignore-vxworks", | |
| 116 | "ignore-wasi", | |
| 117 | "ignore-wasm", | |
| 118 | "ignore-wasm32", | |
| 119 | "ignore-wasm32-bare", | |
| 120 | "ignore-wasm64", | |
| 121 | "ignore-watchos", | |
| 122 | "ignore-windows", | |
| 123 | "ignore-windows-gnu", | |
| 124 | "ignore-windows-msvc", | |
| 125 | "ignore-x32", | |
| 126 | "ignore-x86", | |
| 127 | "ignore-x86_64", | |
| 128 | "ignore-x86_64-apple-darwin", | |
| 129 | "ignore-x86_64-pc-windows-gnu", | |
| 130 | "ignore-x86_64-unknown-linux-gnu", | |
| 131 | "incremental", | |
| 132 | "known-bug", | |
| 133 | "llvm-cov-flags", | |
| 134 | "max-llvm-major-version", | |
| 135 | "min-cdb-version", | |
| 136 | "min-gdb-version", | |
| 137 | "min-lldb-version", | |
| 138 | "min-llvm-version", | |
| 139 | "min-system-llvm-version", | |
| 140 | "needs-asm-support", | |
| 141 | "needs-backends", | |
| 142 | "needs-crate-type", | |
| 143 | "needs-deterministic-layouts", | |
| 144 | "needs-dlltool", | |
| 145 | "needs-dynamic-linking", | |
| 146 | "needs-enzyme", | |
| 147 | "needs-force-clang-based-tests", | |
| 148 | "needs-git-hash", | |
| 149 | "needs-llvm-components", | |
| 150 | "needs-llvm-zstd", | |
| 151 | "needs-profiler-runtime", | |
| 152 | "needs-relocation-model-pic", | |
| 153 | "needs-run-enabled", | |
| 154 | "needs-rust-lld", | |
| 155 | "needs-rustc-debug-assertions", | |
| 156 | "needs-sanitizer-address", | |
| 157 | "needs-sanitizer-cfi", | |
| 158 | "needs-sanitizer-dataflow", | |
| 159 | "needs-sanitizer-hwaddress", | |
| 160 | "needs-sanitizer-kcfi", | |
| 161 | "needs-sanitizer-leak", | |
| 162 | "needs-sanitizer-memory", | |
| 163 | "needs-sanitizer-memtag", | |
| 164 | "needs-sanitizer-safestack", | |
| 165 | "needs-sanitizer-shadow-call-stack", | |
| 166 | "needs-sanitizer-support", | |
| 167 | "needs-sanitizer-thread", | |
| 168 | "needs-std-debug-assertions", | |
| 169 | "needs-subprocess", | |
| 170 | "needs-symlink", | |
| 171 | "needs-target-has-atomic", | |
| 172 | "needs-target-std", | |
| 173 | "needs-threads", | |
| 174 | "needs-unwind", | |
| 175 | "needs-wasmtime", | |
| 176 | "needs-xray", | |
| 177 | "no-auto-check-cfg", | |
| 178 | "no-prefer-dynamic", | |
| 179 | "normalize-stderr", | |
| 180 | "normalize-stderr-32bit", | |
| 181 | "normalize-stderr-64bit", | |
| 182 | "normalize-stdout", | |
| 183 | "only-16bit", | |
| 184 | "only-32bit", | |
| 185 | "only-64bit", | |
| 186 | "only-aarch64", | |
| 187 | "only-aarch64-apple-darwin", | |
| 188 | "only-aarch64-unknown-linux-gnu", | |
| 189 | "only-apple", | |
| 190 | "only-arm", | |
| 191 | "only-avr", | |
| 192 | "only-beta", | |
| 193 | "only-bpf", | |
| 194 | "only-cdb", | |
| 195 | "only-dist", | |
| 196 | "only-elf", | |
| 197 | "only-emscripten", | |
| 198 | "only-gnu", | |
| 199 | "only-i686-pc-windows-gnu", | |
| 200 | "only-i686-pc-windows-msvc", | |
| 201 | "only-i686-unknown-linux-gnu", | |
| 202 | "only-ios", | |
| 203 | "only-linux", | |
| 204 | "only-loongarch32", | |
| 205 | "only-loongarch64", | |
| 206 | "only-loongarch64-unknown-linux-gnu", | |
| 207 | "only-macos", | |
| 208 | "only-mips", | |
| 209 | "only-mips64", | |
| 210 | "only-msp430", | |
| 211 | "only-msvc", | |
| 212 | "only-musl", | |
| 213 | "only-nightly", | |
| 214 | "only-nvptx64", | |
| 215 | "only-powerpc", | |
| 216 | "only-riscv64", | |
| 217 | "only-rustc_abi-x86-sse2", | |
| 218 | "only-s390x", | |
| 219 | "only-sparc", | |
| 220 | "only-sparc64", | |
| 221 | "only-stable", | |
| 222 | "only-thumb", | |
| 223 | "only-tvos", | |
| 224 | "only-uefi", | |
| 225 | "only-unix", | |
| 226 | "only-visionos", | |
| 227 | "only-wasm32", | |
| 228 | "only-wasm32-bare", | |
| 229 | "only-wasm32-wasip1", | |
| 230 | "only-watchos", | |
| 231 | "only-windows", | |
| 232 | "only-windows-gnu", | |
| 233 | "only-windows-msvc", | |
| 234 | "only-x86", | |
| 235 | "only-x86_64", | |
| 236 | "only-x86_64-apple-darwin", | |
| 237 | "only-x86_64-fortanix-unknown-sgx", | |
| 238 | "only-x86_64-pc-windows-gnu", | |
| 239 | "only-x86_64-pc-windows-msvc", | |
| 240 | "only-x86_64-unknown-linux-gnu", | |
| 241 | "pp-exact", | |
| 242 | "pretty-compare-only", | |
| 243 | "pretty-mode", | |
| 244 | "proc-macro", | |
| 245 | "reference", | |
| 246 | "regex-error-pattern", | |
| 247 | "remap-src-base", | |
| 248 | "revisions", | |
| 249 | "run-crash", | |
| 250 | "run-fail", | |
| 251 | "run-fail-or-crash", | |
| 252 | "run-flags", | |
| 253 | "run-pass", | |
| 254 | "run-rustfix", | |
| 255 | "rustc-env", | |
| 256 | "rustfix-only-machine-applicable", | |
| 257 | "should-fail", | |
| 258 | "should-ice", | |
| 259 | "stderr-per-bitwidth", | |
| 260 | "test-mir-pass", | |
| 261 | "unique-doc-out-dir", | |
| 262 | "unset-exec-env", | |
| 263 | "unset-rustc-env", | |
| 264 | // Used by the tidy check `unknown_revision`. | |
| 265 | "unused-revision-names", | |
| 266 | // tidy-alphabetical-end | |
| 267 | ]; | |
| 268 | ||
| 269 | pub(crate) const KNOWN_HTMLDOCCK_DIRECTIVE_NAMES: &[&str] = &[ | |
| 270 | "count", | |
| 271 | "!count", | |
| 272 | "files", | |
| 273 | "!files", | |
| 274 | "has", | |
| 275 | "!has", | |
| 276 | "has-dir", | |
| 277 | "!has-dir", | |
| 278 | "hasraw", | |
| 279 | "!hasraw", | |
| 280 | "matches", | |
| 281 | "!matches", | |
| 282 | "matchesraw", | |
| 283 | "!matchesraw", | |
| 284 | "snapshot", | |
| 285 | "!snapshot", | |
| 286 | ]; | |
| 287 | ||
| 288 | pub(crate) const KNOWN_JSONDOCCK_DIRECTIVE_NAMES: &[&str] = | |
| 289 | &["count", "!count", "has", "!has", "is", "!is", "ismany", "!ismany", "set", "!set"]; |
src/tools/compiletest/src/runtest/debugger.rs+6-2| ... | ... | @@ -47,10 +47,14 @@ impl DebuggerCommands { |
| 47 | 47 | continue; |
| 48 | 48 | }; |
| 49 | 49 | |
| 50 | if let Some(command) = config.parse_name_value_directive(&line, &command_directive) { | |
| 50 | if let Some(command) = | |
| 51 | config.parse_name_value_directive(&line, &command_directive, file, line_no) | |
| 52 | { | |
| 51 | 53 | commands.push(command); |
| 52 | 54 | } |
| 53 | if let Some(pattern) = config.parse_name_value_directive(&line, &check_directive) { | |
| 55 | if let Some(pattern) = | |
| 56 | config.parse_name_value_directive(&line, &check_directive, file, line_no) | |
| 57 | { | |
| 54 | 58 | check_lines.push((line_no, pattern)); |
| 55 | 59 | } |
| 56 | 60 | } |
src/tools/tidy/src/style.rs+5-2| ... | ... | @@ -519,8 +519,11 @@ pub fn check(path: &Path, bad: &mut bool) { |
| 519 | 519 | .any(|directive| matches!(directive, Directive::Ignore(_))); |
| 520 | 520 | let has_alphabetical_directive = line.contains("tidy-alphabetical-start") |
| 521 | 521 | || line.contains("tidy-alphabetical-end"); |
| 522 | let has_recognized_directive = | |
| 523 | has_recognized_ignore_directive || has_alphabetical_directive; | |
| 522 | let has_other_tidy_ignore_directive = | |
| 523 | line.contains("ignore-tidy-target-specific-tests"); | |
| 524 | let has_recognized_directive = has_recognized_ignore_directive | |
| 525 | || has_alphabetical_directive | |
| 526 | || has_other_tidy_ignore_directive; | |
| 524 | 527 | if contains_potential_directive && (!has_recognized_directive) { |
| 525 | 528 | err("Unrecognized tidy directive") |
| 526 | 529 | } |
src/tools/tidy/src/target_specific_tests.rs+51-10| ... | ... | @@ -12,12 +12,16 @@ const COMPILE_FLAGS_HEADER: &str = "compile-flags:"; |
| 12 | 12 | |
| 13 | 13 | #[derive(Default, Debug)] |
| 14 | 14 | struct RevisionInfo<'a> { |
| 15 | target_arch: Option<&'a str>, | |
| 15 | target_arch: Option<Option<&'a str>>, | |
| 16 | 16 | llvm_components: Option<Vec<&'a str>>, |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | pub fn check(tests_path: &Path, bad: &mut bool) { |
| 20 | 20 | crate::walk::walk(tests_path, |path, _is_dir| filter_not_rust(path), &mut |entry, content| { |
| 21 | if content.contains("// ignore-tidy-target-specific-tests") { | |
| 22 | return; | |
| 23 | } | |
| 24 | ||
| 21 | 25 | let file = entry.path().display(); |
| 22 | 26 | let mut header_map = BTreeMap::new(); |
| 23 | 27 | iter_header(content, &mut |HeaderLine { revision, directive, .. }| { |
| ... | ... | @@ -34,10 +38,11 @@ pub fn check(tests_path: &Path, bad: &mut bool) { |
| 34 | 38 | && let Some((_, v)) = compile_flags.split_once("--target") |
| 35 | 39 | { |
| 36 | 40 | let v = v.trim_start_matches([' ', '=']); |
| 37 | let v = if v == "{{target}}" { Some((v, v)) } else { v.split_once("-") }; | |
| 38 | if let Some((arch, _)) = v { | |
| 39 | let info = header_map.entry(revision).or_insert(RevisionInfo::default()); | |
| 40 | info.target_arch.replace(arch); | |
| 41 | let info = header_map.entry(revision).or_insert(RevisionInfo::default()); | |
| 42 | if v.starts_with("{{") { | |
| 43 | info.target_arch.replace(None); | |
| 44 | } else if let Some((arch, _)) = v.split_once("-") { | |
| 45 | info.target_arch.replace(Some(arch)); | |
| 41 | 46 | } else { |
| 42 | 47 | eprintln!("{file}: seems to have a malformed --target value"); |
| 43 | 48 | *bad = true; |
| ... | ... | @@ -54,9 +59,11 @@ pub fn check(tests_path: &Path, bad: &mut bool) { |
| 54 | 59 | let rev = rev.unwrap_or("[unspecified]"); |
| 55 | 60 | match (target_arch, llvm_components) { |
| 56 | 61 | (None, None) => {} |
| 57 | (Some(_), None) => { | |
| 62 | (Some(target_arch), None) => { | |
| 63 | let llvm_component = | |
| 64 | target_arch.map_or_else(|| "<arch>".to_string(), arch_to_llvm_component); | |
| 58 | 65 | eprintln!( |
| 59 | "{file}: revision {rev} should specify `{LLVM_COMPONENTS_HEADER}` as it has `--target` set" | |
| 66 | "{file}: revision {rev} should specify `{LLVM_COMPONENTS_HEADER} {llvm_component}` as it has `--target` set" | |
| 60 | 67 | ); |
| 61 | 68 | *bad = true; |
| 62 | 69 | } |
| ... | ... | @@ -66,11 +73,45 @@ pub fn check(tests_path: &Path, bad: &mut bool) { |
| 66 | 73 | ); |
| 67 | 74 | *bad = true; |
| 68 | 75 | } |
| 69 | (Some(_), Some(_)) => { | |
| 70 | // FIXME: check specified components against the target architectures we | |
| 71 | // gathered. | |
| 76 | (Some(target_arch), Some(llvm_components)) => { | |
| 77 | if let Some(target_arch) = target_arch { | |
| 78 | let llvm_component = arch_to_llvm_component(target_arch); | |
| 79 | if !llvm_components.contains(&llvm_component.as_str()) { | |
| 80 | eprintln!( | |
| 81 | "{file}: revision {rev} should specify `{LLVM_COMPONENTS_HEADER} {llvm_component}` as it has `--target` set" | |
| 82 | ); | |
| 83 | *bad = true; | |
| 84 | } | |
| 85 | } | |
| 72 | 86 | } |
| 73 | 87 | } |
| 74 | 88 | } |
| 75 | 89 | }); |
| 76 | 90 | } |
| 91 | ||
| 92 | fn arch_to_llvm_component(arch: &str) -> String { | |
| 93 | // NOTE: This is an *approximate* mapping of Rust's `--target` architecture to LLVM component | |
| 94 | // names. It is not intended to be an authoritative source, but rather a best-effort that's good | |
| 95 | // enough for the purpose of this tidy check. | |
| 96 | match arch { | |
| 97 | "amdgcn" => "amdgpu".into(), | |
| 98 | "aarch64_be" | "arm64_32" | "arm64e" | "arm64ec" => "aarch64".into(), | |
| 99 | "i386" | "i586" | "i686" | "x86" | "x86_64" | "x86_64h" => "x86".into(), | |
| 100 | "loongarch32" | "loongarch64" => "loongarch".into(), | |
| 101 | "nvptx64" => "nvptx".into(), | |
| 102 | "s390x" => "systemz".into(), | |
| 103 | "sparc64" | "sparcv9" => "sparc".into(), | |
| 104 | "wasm32" | "wasm32v1" | "wasm64" => "webassembly".into(), | |
| 105 | _ if arch.starts_with("armeb") | |
| 106 | || arch.starts_with("armv") | |
| 107 | || arch.starts_with("thumbv") => | |
| 108 | { | |
| 109 | "arm".into() | |
| 110 | } | |
| 111 | _ if arch.starts_with("bpfe") => "bpf".into(), | |
| 112 | _ if arch.starts_with("mips") => "mips".into(), | |
| 113 | _ if arch.starts_with("powerpc") => "powerpc".into(), | |
| 114 | _ if arch.starts_with("riscv") => "riscv".into(), | |
| 115 | _ => arch.to_ascii_lowercase(), | |
| 116 | } | |
| 117 | } |
tests/codegen-llvm/abi-efiapi.rs+5-5| ... | ... | @@ -3,15 +3,15 @@ |
| 3 | 3 | //@ add-core-stubs |
| 4 | 4 | //@ revisions:x86_64 i686 aarch64 arm riscv |
| 5 | 5 | //@[x86_64] compile-flags: --target x86_64-unknown-uefi |
| 6 | //@[x86_64] needs-llvm-components: aarch64 arm riscv | |
| 6 | //@[x86_64] needs-llvm-components: x86 | |
| 7 | 7 | //@[i686] compile-flags: --target i686-unknown-linux-musl |
| 8 | //@[i686] needs-llvm-components: aarch64 arm riscv | |
| 8 | //@[i686] needs-llvm-components: x86 | |
| 9 | 9 | //@[aarch64] compile-flags: --target aarch64-unknown-none |
| 10 | //@[aarch64] needs-llvm-components: aarch64 arm riscv | |
| 10 | //@[aarch64] needs-llvm-components: aarch64 | |
| 11 | 11 | //@[arm] compile-flags: --target armv7r-none-eabi |
| 12 | //@[arm] needs-llvm-components: aarch64 arm riscv | |
| 12 | //@[arm] needs-llvm-components: arm | |
| 13 | 13 | //@[riscv] compile-flags: --target riscv64gc-unknown-none-elf |
| 14 | //@[riscv] needs-llvm-components: aarch64 arm riscv | |
| 14 | //@[riscv] needs-llvm-components: riscv | |
| 15 | 15 | //@ compile-flags: -C no-prepopulate-passes |
| 16 | 16 | |
| 17 | 17 | #![crate_type = "lib"] |
tests/codegen-llvm/cast-target-abi.rs+1-1| ... | ... | @@ -4,7 +4,7 @@ |
| 4 | 4 | //@ compile-flags: -Copt-level=3 -Cno-prepopulate-passes -Zlint-llvm-ir |
| 5 | 5 | |
| 6 | 6 | //@[aarch64] compile-flags: --target aarch64-unknown-linux-gnu |
| 7 | //@[aarch64] needs-llvm-components: arm | |
| 7 | //@[aarch64] needs-llvm-components: aarch64 | |
| 8 | 8 | //@[loongarch64] compile-flags: --target loongarch64-unknown-linux-gnu |
| 9 | 9 | //@[loongarch64] needs-llvm-components: loongarch |
| 10 | 10 | //@[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu |
tests/codegen-llvm/cf-protection.rs+1-1| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | //@ add-core-stubs |
| 4 | 4 | //@ revisions: undefined none branch return full |
| 5 | 5 | //@ needs-llvm-components: x86 |
| 6 | //@ [undefined] compile-flags: | |
| 6 | // [undefined] no extra compile-flags | |
| 7 | 7 | //@ [none] compile-flags: -Z cf-protection=none |
| 8 | 8 | //@ [branch] compile-flags: -Z cf-protection=branch |
| 9 | 9 | //@ [return] compile-flags: -Z cf-protection=return |
tests/codegen-llvm/codemodels.rs+1-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | //@ only-x86_64 |
| 2 | 2 | |
| 3 | 3 | //@ revisions: NOMODEL MODEL-SMALL MODEL-KERNEL MODEL-MEDIUM MODEL-LARGE |
| 4 | //@[NOMODEL] compile-flags: | |
| 4 | // [NOMODEL] no compile-flags | |
| 5 | 5 | //@[MODEL-SMALL] compile-flags: -C code-model=small |
| 6 | 6 | //@[MODEL-KERNEL] compile-flags: -C code-model=kernel |
| 7 | 7 | //@[MODEL-MEDIUM] compile-flags: -C code-model=medium |
tests/codegen-llvm/ehcontguard_disabled.rs-2| ... | ... | @@ -1,5 +1,3 @@ |
| 1 | //@ compile-flags: | |
| 2 | ||
| 3 | 1 | #![crate_type = "lib"] |
| 4 | 2 | |
| 5 | 3 | // A basic test function. |
tests/codegen-llvm/naked-fn/naked-functions.rs+1-1| ... | ... | @@ -8,7 +8,7 @@ |
| 8 | 8 | //@[win_i686] compile-flags: --target i686-pc-windows-gnu |
| 9 | 9 | //@[win_i686] needs-llvm-components: x86 |
| 10 | 10 | //@[macos] compile-flags: --target aarch64-apple-darwin |
| 11 | //@[macos] needs-llvm-components: arm | |
| 11 | //@[macos] needs-llvm-components: aarch64 | |
| 12 | 12 | //@[thumb] compile-flags: --target thumbv7em-none-eabi |
| 13 | 13 | //@[thumb] needs-llvm-components: arm |
| 14 | 14 |
tests/codegen-llvm/sanitizer/address-sanitizer-globals-tracking.rs+3-3| ... | ... | @@ -19,9 +19,9 @@ |
| 19 | 19 | //@ only-linux |
| 20 | 20 | // |
| 21 | 21 | //@ revisions:ASAN ASAN-FAT-LTO |
| 22 | //@ compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static | |
| 23 | //@[ASAN] compile-flags: | |
| 24 | //@[ASAN-FAT-LTO] compile-flags: -Cprefer-dynamic=false -Clto=fat | |
| 22 | //@ compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static | |
| 23 | // [ASAN] no extra compile-flags | |
| 24 | //@[ASAN-FAT-LTO] compile-flags: -Cprefer-dynamic=false -Clto=fat | |
| 25 | 25 | |
| 26 | 26 | #![crate_type = "staticlib"] |
| 27 | 27 |
tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-attr-no-sanitize.rs+1-1| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | //@ [aarch64] compile-flags: --target aarch64-unknown-none |
| 6 | 6 | //@ [aarch64] needs-llvm-components: aarch64 |
| 7 | 7 | //@ [x86_64] compile-flags: --target x86_64-unknown-none |
| 8 | //@ [x86_64] needs-llvm-components: | |
| 8 | //@ [x86_64] needs-llvm-components: x86 | |
| 9 | 9 | //@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 |
| 10 | 10 | |
| 11 | 11 | #![crate_type = "lib"] |
tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs+1-1| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | //@ [aarch64] compile-flags: --target aarch64-unknown-none |
| 6 | 6 | //@ [aarch64] needs-llvm-components: aarch64 |
| 7 | 7 | //@ [x86_64] compile-flags: --target x86_64-unknown-none |
| 8 | //@ [x86_64] needs-llvm-components: | |
| 8 | //@ [x86_64] needs-llvm-components: x86 | |
| 9 | 9 | //@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-generalize-pointers |
| 10 | 10 | |
| 11 | 11 | #![crate_type = "lib"] |
tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs+1-1| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | //@ [aarch64] compile-flags: --target aarch64-unknown-none |
| 6 | 6 | //@ [aarch64] needs-llvm-components: aarch64 |
| 7 | 7 | //@ [x86_64] compile-flags: --target x86_64-unknown-none |
| 8 | //@ [x86_64] needs-llvm-components: | |
| 8 | //@ [x86_64] needs-llvm-components: x86 | |
| 9 | 9 | //@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers |
| 10 | 10 | |
| 11 | 11 | #![crate_type = "lib"] |
tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs+1-1| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | //@ [aarch64] compile-flags: --target aarch64-unknown-none |
| 6 | 6 | //@ [aarch64] needs-llvm-components: aarch64 |
| 7 | 7 | //@ [x86_64] compile-flags: --target x86_64-unknown-none |
| 8 | //@ [x86_64] needs-llvm-components: | |
| 8 | //@ [x86_64] needs-llvm-components: x86 | |
| 9 | 9 | //@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers |
| 10 | 10 | |
| 11 | 11 | #![crate_type = "lib"] |
tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi.rs+1-1| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | //@ [aarch64] compile-flags: --target aarch64-unknown-none |
| 6 | 6 | //@ [aarch64] needs-llvm-components: aarch64 |
| 7 | 7 | //@ [x86_64] compile-flags: --target x86_64-unknown-none |
| 8 | //@ [x86_64] needs-llvm-components: | |
| 8 | //@ [x86_64] needs-llvm-components: x86 | |
| 9 | 9 | //@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 |
| 10 | 10 | |
| 11 | 11 | #![crate_type = "lib"] |
tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle.rs+1-1| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | //@ [aarch64] compile-flags: --target aarch64-unknown-none |
| 6 | 6 | //@ [aarch64] needs-llvm-components: aarch64 |
| 7 | 7 | //@ [x86_64] compile-flags: --target x86_64-unknown-none |
| 8 | //@ [x86_64] needs-llvm-components: | |
| 8 | //@ [x86_64] needs-llvm-components: x86 | |
| 9 | 9 | //@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 |
| 10 | 10 | |
| 11 | 11 | #![crate_type = "lib"] |
tests/codegen-llvm/sanitizer/kcfi/emit-type-metadata-trait-objects.rs+1-1| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | //@ [aarch64] compile-flags: --target aarch64-unknown-none |
| 6 | 6 | //@ [aarch64] needs-llvm-components: aarch64 |
| 7 | 7 | //@ [x86_64] compile-flags: --target x86_64-unknown-none |
| 8 | //@ [x86_64] needs-llvm-components: | |
| 8 | //@ [x86_64] needs-llvm-components: x86 | |
| 9 | 9 | //@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 |
| 10 | 10 | |
| 11 | 11 | #![crate_type = "lib"] |
tests/codegen-llvm/sanitizer/memory-track-origins.rs+1-1| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | //@ revisions:MSAN-0 MSAN-1 MSAN-2 MSAN-1-LTO MSAN-2-LTO |
| 6 | 6 | // |
| 7 | 7 | //@ compile-flags: -Zsanitizer=memory -Ctarget-feature=-crt-static |
| 8 | //@[MSAN-0] compile-flags: | |
| 8 | // [MSAN-0] no extra compile-flags | |
| 9 | 9 | //@[MSAN-1] compile-flags: -Zsanitizer-memory-track-origins=1 |
| 10 | 10 | //@[MSAN-2] compile-flags: -Zsanitizer-memory-track-origins |
| 11 | 11 | //@[MSAN-1-LTO] compile-flags: -Zsanitizer-memory-track-origins=1 -C lto=fat |
tests/codegen-llvm/ub-checks.rs+1-1| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | // but ub-checks are explicitly disabled. |
| 7 | 7 | |
| 8 | 8 | //@ revisions: DEBUG NOCHECKS |
| 9 | //@ [DEBUG] compile-flags: | |
| 9 | // [DEBUG] no extra compile-flags | |
| 10 | 10 | //@ [NOCHECKS] compile-flags: -Zub-checks=no |
| 11 | 11 | //@ compile-flags: -Copt-level=3 -Cdebug-assertions=yes |
| 12 | 12 |
tests/debuginfo/unsized.rs-1| ... | ... | @@ -37,7 +37,6 @@ |
| 37 | 37 | // cdb-check: [...] vtable : 0x[...] [Type: unsigned [...]int[...] (*)[4]] |
| 38 | 38 | |
| 39 | 39 | // cdb-command:dx _box |
| 40 | // cdb-check: | |
| 41 | 40 | // cdb-check:_box [Type: alloc::boxed::Box<unsized::Foo<dyn$<core::fmt::Debug> >,alloc::alloc::Global>] |
| 42 | 41 | // cdb-check:[+0x000] pointer : 0x[...] [Type: unsized::Foo<dyn$<core::fmt::Debug> > *] |
| 43 | 42 | // cdb-check:[...] vtable : 0x[...] [Type: unsigned [...]int[...] (*)[4]] |
tests/run-make/link-cfg/rmake.rs+1| ... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | |
| 13 | 13 | //@ ignore-cross-compile |
| 14 | 14 | // Reason: the compiled binary is executed |
| 15 | //@ needs-llvm-components: x86 | |
| 15 | 16 | |
| 16 | 17 | use run_make_support::{bare_rustc, build_native_dynamic_lib, build_native_static_lib, run, rustc}; |
| 17 | 18 |
tests/run-make/mismatching-target-triples/rmake.rs+1| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | // now replaced by a clearer normal error message. This test checks that this aforementioned |
| 5 | 5 | // error message is used. |
| 6 | 6 | // See https://github.com/rust-lang/rust/issues/10814 |
| 7 | //@ needs-llvm-components: x86 | |
| 7 | 8 | |
| 8 | 9 | use run_make_support::rustc; |
| 9 | 10 |
tests/run-make/musl-default-linking/rmake.rs+1| ... | ... | @@ -4,6 +4,7 @@ use run_make_support::{rustc, serde_json}; |
| 4 | 4 | // Per https://github.com/rust-lang/compiler-team/issues/422, |
| 5 | 5 | // we should be trying to move these targets to dynamically link |
| 6 | 6 | // musl libc by default. |
| 7 | //@ needs-llvm-components: aarch64 arm mips powerpc riscv systemz x86 | |
| 7 | 8 | static LEGACY_STATIC_LINKING_TARGETS: &[&'static str] = &[ |
| 8 | 9 | "aarch64-unknown-linux-musl", |
| 9 | 10 | "arm-unknown-linux-musleabi", |
tests/run-make/rustdoc-target-spec-json-path/rmake.rs+1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | // Test that rustdoc will properly canonicalize the target spec json path just like rustc. |
| 2 | //@ needs-llvm-components: x86 | |
| 2 | 3 | |
| 3 | 4 | use run_make_support::{cwd, rustc, rustdoc}; |
| 4 | 5 |
tests/run-make/target-specs/rmake.rs+1| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | // with the target flag's bundle of new features to check that compilation either succeeds while |
| 5 | 5 | // using them correctly, or fails with the right error message when using them improperly. |
| 6 | 6 | // See https://github.com/rust-lang/rust/pull/16156 |
| 7 | //@ needs-llvm-components: x86 | |
| 7 | 8 | |
| 8 | 9 | use run_make_support::{diff, rfs, rustc}; |
| 9 | 10 |
tests/ui/README.md-4| ... | ... | @@ -654,10 +654,6 @@ Tests on range patterns where one of the bounds is not a direct value. |
| 654 | 654 | |
| 655 | 655 | Tests for the standard library collection [`std::collections::HashMap`](https://doc.rust-lang.org/std/collections/struct.HashMap.html). |
| 656 | 656 | |
| 657 | ## `tests/ui/hello_world/` | |
| 658 | ||
| 659 | Tests that the basic hello-world program is not somehow broken. | |
| 660 | ||
| 661 | 657 | ## `tests/ui/higher-ranked/` |
| 662 | 658 | |
| 663 | 659 | Tests for higher-ranked trait bounds. |
tests/ui/borrowck/liberated-region-from-outer-closure.rs created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | // Regression test for <https://github.com/rust-lang/rust/issues/144608>. | |
| 2 | ||
| 3 | fn example<T: Copy>(x: T) -> impl FnMut(&mut ()) { | |
| 4 | move |_: &mut ()| { | |
| 5 | move || needs_static_lifetime(x); | |
| 6 | //~^ ERROR the parameter type `T` may not live long enough | |
| 7 | } | |
| 8 | } | |
| 9 | ||
| 10 | fn needs_static_lifetime<T: 'static>(obj: T) {} | |
| 11 | ||
| 12 | fn main() {} |
tests/ui/borrowck/liberated-region-from-outer-closure.stderr created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | error[E0310]: the parameter type `T` may not live long enough | |
| 2 | --> $DIR/liberated-region-from-outer-closure.rs:5:17 | |
| 3 | | | |
| 4 | LL | move || needs_static_lifetime(x); | |
| 5 | | ^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 6 | | | | |
| 7 | | the parameter type `T` must be valid for the static lifetime... | |
| 8 | | ...so that the type `T` will meet its required lifetime bounds | |
| 9 | | | |
| 10 | help: consider adding an explicit lifetime bound | |
| 11 | | | |
| 12 | LL | fn example<T: Copy + 'static>(x: T) -> impl FnMut(&mut ()) { | |
| 13 | | +++++++++ | |
| 14 | ||
| 15 | error: aborting due to 1 previous error | |
| 16 | ||
| 17 | For more information about this error, try `rustc --explain E0310`. |
tests/ui/errors/remap-path-prefix-sysroot.rs+1-1| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | //@ compile-flags: -g -Ztranslate-remapped-path-to-local-path=yes |
| 3 | 3 | //@ [with-remap]compile-flags: --remap-path-prefix={{rust-src-base}}=remapped |
| 4 | 4 | //@ [with-remap]compile-flags: --remap-path-prefix={{src-base}}=remapped-tests-ui |
| 5 | //@ [without-remap]compile-flags: | |
| 5 | // [without-remap] no extra compile-flags | |
| 6 | 6 | |
| 7 | 7 | // The $SRC_DIR*.rs:LL:COL normalisation doesn't kick in automatically |
| 8 | 8 | // as the remapped revision will not begin with $SRC_DIR_REAL, |
tests/ui/errors/wrong-target-spec.rs+1| ... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 | // checks that such invalid target specs are rejected by the compiler. |
| 3 | 3 | // See https://github.com/rust-lang/rust/issues/33329 |
| 4 | 4 | |
| 5 | // ignore-tidy-target-specific-tests | |
| 5 | 6 | //@ needs-llvm-components: x86 |
| 6 | 7 | //@ compile-flags: --target x86_64_unknown-linux-musl |
| 7 | 8 |
tests/ui/hello_world/main.rs deleted-7| ... | ... | @@ -1,7 +0,0 @@ |
| 1 | //@ build-pass | |
| 2 | ||
| 3 | // Test that compiling hello world succeeds with no output of any kind. | |
| 4 | ||
| 5 | fn main() { | |
| 6 | println!("Hello, world!"); | |
| 7 | } |
tests/ui/linkage-attr/unstable-flavor.rs+2-2| ... | ... | @@ -4,9 +4,9 @@ |
| 4 | 4 | // |
| 5 | 5 | //@ revisions: bpf ptx |
| 6 | 6 | //@ [bpf] compile-flags: --target=bpfel-unknown-none -C linker-flavor=bpf --crate-type=rlib |
| 7 | //@ [bpf] needs-llvm-components: | |
| 7 | //@ [bpf] needs-llvm-components: bpf | |
| 8 | 8 | //@ [ptx] compile-flags: --target=nvptx64-nvidia-cuda -C linker-flavor=ptx --crate-type=rlib |
| 9 | //@ [ptx] needs-llvm-components: | |
| 9 | //@ [ptx] needs-llvm-components: nvptx | |
| 10 | 10 | |
| 11 | 11 | #![feature(no_core)] |
| 12 | 12 | #![no_core] |
tests/ui/nll/closure-requirements/escape-argument-callee.stderr+3| ... | ... | @@ -9,6 +9,9 @@ LL | let mut closure = expect_sig(|p, y| *p = y); |
| 9 | 9 | for<Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&'^0 mut &'^1 i32, &'^2 i32)), |
| 10 | 10 | (), |
| 11 | 11 | ] |
| 12 | = note: late-bound region is '?1 | |
| 13 | = note: late-bound region is '?2 | |
| 14 | = note: late-bound region is '?3 | |
| 12 | 15 | |
| 13 | 16 | error: lifetime may not live long enough |
| 14 | 17 | --> $DIR/escape-argument-callee.rs:26:45 |
tests/ui/nll/closure-requirements/escape-argument.stderr+2| ... | ... | @@ -9,6 +9,8 @@ LL | let mut closure = expect_sig(|p, y| *p = y); |
| 9 | 9 | for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&'^0 mut &'^1 i32, &'^1 i32)), |
| 10 | 10 | (), |
| 11 | 11 | ] |
| 12 | = note: late-bound region is '?1 | |
| 13 | = note: late-bound region is '?2 | |
| 12 | 14 | |
| 13 | 15 | note: no external requirements |
| 14 | 16 | --> $DIR/escape-argument.rs:20:1 |
tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr+2| ... | ... | @@ -9,6 +9,8 @@ LL | |_outlives1, _outlives2, _outlives3, x, y| { |
| 9 | 9 | for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 &'^0 u32>, std::cell::Cell<&'?2 &'^0 u32>, std::cell::Cell<&'^1 &'?3 u32>, std::cell::Cell<&'^0 u32>, std::cell::Cell<&'^1 u32>)), |
| 10 | 10 | (), |
| 11 | 11 | ] |
| 12 | = note: late-bound region is '?7 | |
| 13 | = note: late-bound region is '?8 | |
| 12 | 14 | = note: late-bound region is '?4 |
| 13 | 15 | = note: late-bound region is '?5 |
| 14 | 16 | = note: late-bound region is '?6 |
tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr+6| ... | ... | @@ -9,6 +9,12 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y |
| 9 | 9 | for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&'^0 std::cell::Cell<&'?1 &'^1 u32>, &'^2 std::cell::Cell<&'^3 &'?2 u32>, &'^4 std::cell::Cell<&'^1 u32>, &'^5 std::cell::Cell<&'^3 u32>)), |
| 10 | 10 | (), |
| 11 | 11 | ] |
| 12 | = note: late-bound region is '?5 | |
| 13 | = note: late-bound region is '?6 | |
| 14 | = note: late-bound region is '?7 | |
| 15 | = note: late-bound region is '?8 | |
| 16 | = note: late-bound region is '?9 | |
| 17 | = note: late-bound region is '?10 | |
| 12 | 18 | = note: late-bound region is '?3 |
| 13 | 19 | = note: late-bound region is '?4 |
| 14 | 20 | = note: number of external vids: 5 |
tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr+2| ... | ... | @@ -9,6 +9,7 @@ LL | foo(cell, |cell_a, cell_x| { |
| 9 | 9 | for<Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 u32>, std::cell::Cell<&'^0 u32>)), |
| 10 | 10 | (), |
| 11 | 11 | ] |
| 12 | = note: late-bound region is '?2 | |
| 12 | 13 | |
| 13 | 14 | error[E0521]: borrowed data escapes outside of closure |
| 14 | 15 | --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:22:9 |
| ... | ... | @@ -43,6 +44,7 @@ LL | foo(cell, |cell_a, cell_x| { |
| 43 | 44 | for<Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 u32>, std::cell::Cell<&'^0 u32>)), |
| 44 | 45 | (), |
| 45 | 46 | ] |
| 47 | = note: late-bound region is '?2 | |
| 46 | 48 | = note: number of external vids: 2 |
| 47 | 49 | = note: where '?1: '?0 |
| 48 | 50 |
tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr+5| ... | ... | @@ -9,6 +9,11 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { |
| 9 | 9 | for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&'^0 std::cell::Cell<&'?1 &'^1 u32>, &'^2 std::cell::Cell<&'^1 u32>, &'^3 std::cell::Cell<&'^4 u32>)), |
| 10 | 10 | (), |
| 11 | 11 | ] |
| 12 | = note: late-bound region is '?4 | |
| 13 | = note: late-bound region is '?5 | |
| 14 | = note: late-bound region is '?6 | |
| 15 | = note: late-bound region is '?7 | |
| 16 | = note: late-bound region is '?8 | |
| 12 | 17 | = note: late-bound region is '?2 |
| 13 | 18 | = note: late-bound region is '?3 |
| 14 | 19 | = note: number of external vids: 4 |
tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr+6| ... | ... | @@ -9,6 +9,12 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y |
| 9 | 9 | for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&'^0 std::cell::Cell<&'?1 &'^1 u32>, &'^2 std::cell::Cell<&'?2 &'^3 u32>, &'^4 std::cell::Cell<&'^1 u32>, &'^5 std::cell::Cell<&'^3 u32>)), |
| 10 | 10 | (), |
| 11 | 11 | ] |
| 12 | = note: late-bound region is '?5 | |
| 13 | = note: late-bound region is '?6 | |
| 14 | = note: late-bound region is '?7 | |
| 15 | = note: late-bound region is '?8 | |
| 16 | = note: late-bound region is '?9 | |
| 17 | = note: late-bound region is '?10 | |
| 12 | 18 | = note: late-bound region is '?3 |
| 13 | 19 | = note: late-bound region is '?4 |
| 14 | 20 | = note: number of external vids: 5 |
tests/ui/nll/closure-requirements/propagate-approximated-val.stderr+2| ... | ... | @@ -9,6 +9,8 @@ LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| { |
| 9 | 9 | for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 &'^0 u32>, std::cell::Cell<&'^1 &'?2 u32>, std::cell::Cell<&'^0 u32>, std::cell::Cell<&'^1 u32>)), |
| 10 | 10 | (), |
| 11 | 11 | ] |
| 12 | = note: late-bound region is '?5 | |
| 13 | = note: late-bound region is '?6 | |
| 12 | 14 | = note: late-bound region is '?3 |
| 13 | 15 | = note: late-bound region is '?4 |
| 14 | 16 | = note: number of external vids: 5 |
tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr+2| ... | ... | @@ -9,6 +9,8 @@ LL | |_outlives1, _outlives2, x, y| { |
| 9 | 9 | for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 &'^0 u32>, std::cell::Cell<&'^1 &'?2 u32>, std::cell::Cell<&'^0 u32>, std::cell::Cell<&'^1 u32>)), |
| 10 | 10 | (), |
| 11 | 11 | ] |
| 12 | = note: late-bound region is '?4 | |
| 13 | = note: late-bound region is '?5 | |
| 12 | 14 | = note: late-bound region is '?3 |
| 13 | 15 | = note: number of external vids: 4 |
| 14 | 16 | = note: where '?1: '?2 |
tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr+5| ... | ... | @@ -9,6 +9,11 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { |
| 9 | 9 | for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&'^0 std::cell::Cell<&'^1 &'?1 u32>, &'^2 std::cell::Cell<&'^3 u32>, &'^4 std::cell::Cell<&'^1 u32>)), |
| 10 | 10 | (), |
| 11 | 11 | ] |
| 12 | = note: late-bound region is '?4 | |
| 13 | = note: late-bound region is '?5 | |
| 14 | = note: late-bound region is '?6 | |
| 15 | = note: late-bound region is '?7 | |
| 16 | = note: late-bound region is '?8 | |
| 12 | 17 | = note: late-bound region is '?2 |
| 13 | 18 | = note: late-bound region is '?3 |
| 14 | 19 |
tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr+6| ... | ... | @@ -9,6 +9,12 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y |
| 9 | 9 | for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&'^0 std::cell::Cell<&'^1 &'?1 u32>, &'^2 std::cell::Cell<&'^3 &'?2 u32>, &'^4 std::cell::Cell<&'^1 u32>, &'^5 std::cell::Cell<&'^3 u32>)), |
| 10 | 10 | (), |
| 11 | 11 | ] |
| 12 | = note: late-bound region is '?5 | |
| 13 | = note: late-bound region is '?6 | |
| 14 | = note: late-bound region is '?7 | |
| 15 | = note: late-bound region is '?8 | |
| 16 | = note: late-bound region is '?9 | |
| 17 | = note: late-bound region is '?10 | |
| 12 | 18 | = note: late-bound region is '?3 |
| 13 | 19 | = note: late-bound region is '?4 |
| 14 | 20 |
tests/ui/nll/closure-requirements/return-wrong-bound-region.stderr+2| ... | ... | @@ -9,6 +9,8 @@ LL | expect_sig(|a, b| b); // ought to return `a` |
| 9 | 9 | for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&'^0 i32, &'^1 i32)) -> &'^0 i32, |
| 10 | 10 | (), |
| 11 | 11 | ] |
| 12 | = note: late-bound region is '?1 | |
| 13 | = note: late-bound region is '?2 | |
| 12 | 14 | |
| 13 | 15 | error: lifetime may not live long enough |
| 14 | 16 | --> $DIR/return-wrong-bound-region.rs:11:23 |
tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr+4| ... | ... | @@ -9,6 +9,8 @@ LL | twice(cell, value, |a, b| invoke(a, b)); |
| 9 | 9 | for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'?1 &'^0 ()>>, &'^1 T)), |
| 10 | 10 | (), |
| 11 | 11 | ] |
| 12 | = note: late-bound region is '?2 | |
| 13 | = note: late-bound region is '?3 | |
| 12 | 14 | = note: number of external vids: 2 |
| 13 | 15 | = note: where T: '?1 |
| 14 | 16 | |
| ... | ... | @@ -31,6 +33,8 @@ LL | twice(cell, value, |a, b| invoke(a, b)); |
| 31 | 33 | for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'?1 &'^0 ()>>, &'^1 T)), |
| 32 | 34 | (), |
| 33 | 35 | ] |
| 36 | = note: late-bound region is '?3 | |
| 37 | = note: late-bound region is '?4 | |
| 34 | 38 | = note: late-bound region is '?2 |
| 35 | 39 | = note: number of external vids: 3 |
| 36 | 40 | = note: where T: '?1 |
tests/ui/target_modifiers/defaults_check.rs+1-1| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | //@ needs-llvm-components: x86 |
| 7 | 7 | |
| 8 | 8 | //@ revisions: ok ok_explicit error |
| 9 | //@[ok] compile-flags: | |
| 9 | // [ok] no extra compile-flags | |
| 10 | 10 | //@[ok_explicit] compile-flags: -Zreg-struct-return=false |
| 11 | 11 | //@[error] compile-flags: -Zreg-struct-return=true |
| 12 | 12 | //@[ok] check-pass |
tests/ui/target_modifiers/incompatible_fixedx18.rs+1-1| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | //@ revisions:allow_match allow_mismatch error_generated |
| 6 | 6 | //@[allow_match] compile-flags: -Zfixed-x18 |
| 7 | 7 | //@[allow_mismatch] compile-flags: -Cunsafe-allow-abi-mismatch=fixed-x18 |
| 8 | //@[error_generated] compile-flags: | |
| 8 | // [error_generated] no extra compile-flags | |
| 9 | 9 | //@[allow_mismatch] check-pass |
| 10 | 10 | //@[allow_match] check-pass |
| 11 | 11 |
tests/ui/target_modifiers/incompatible_regparm.rs+1-1| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | //@ revisions:allow_regparm_mismatch allow_no_value error_generated |
| 6 | 6 | //@[allow_regparm_mismatch] compile-flags: -Cunsafe-allow-abi-mismatch=regparm |
| 7 | 7 | //@[allow_no_value] compile-flags: -Cunsafe-allow-abi-mismatch |
| 8 | //@[error_generated] compile-flags: | |
| 8 | // [error_generated] no extra compile-flags | |
| 9 | 9 | //@[allow_regparm_mismatch] check-pass |
| 10 | 10 | |
| 11 | 11 | #![feature(no_core)] |
tests/ui/target_modifiers/no_value_bool.rs+1-1| ... | ... | @@ -8,7 +8,7 @@ |
| 8 | 8 | //@ revisions: ok ok_explicit error error_explicit |
| 9 | 9 | //@[ok] compile-flags: -Zreg-struct-return |
| 10 | 10 | //@[ok_explicit] compile-flags: -Zreg-struct-return=true |
| 11 | //@[error] compile-flags: | |
| 11 | // [error] no extra compile-flags | |
| 12 | 12 | //@[error_explicit] compile-flags: -Zreg-struct-return=false |
| 13 | 13 | //@[ok] check-pass |
| 14 | 14 | //@[ok_explicit] check-pass |
tests/ui/warnings/hello-world.rs created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | //@ build-pass | |
| 2 | ||
| 3 | // Test that compiling hello world succeeds with no output of any kind. | |
| 4 | ||
| 5 | fn main() { | |
| 6 | println!("Hello, world!"); | |
| 7 | } |