authorbors <bors@rust-lang.org> 2025-07-30 09:02:21 UTC
committerbors <bors@rust-lang.org> 2025-07-30 09:02:21 UTC
loge5e79f8bd428d0b8d26e8240d718b134ef297459
tree395771116faa1afd2896a964e9b81189fbe6790b
parent72716b134ac26b837703e46cbda99a453ae92c42
parent3682d8c1ce4379b9ad7d9da655f2fefee8bb86c3

Auto merge of #144673 - Zalathar:rollup-0kpeq3n, r=Zalathar

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: rollup

59 files changed, 737 insertions(+), 446 deletions(-)

compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs+1-1
......@@ -341,7 +341,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
341341 }
342342 }
343343 } 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);
345345 if info.tail_result_is_ignored {
346346 // #85581: If the first mutable borrow's scope contains
347347 // 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>(
969969 mir_def_id: LocalDefId,
970970 mut f: impl FnMut(ty::Region<'tcx>),
971971) {
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 };
975992
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() {
979994 if let ty::BoundVariableKind::Region(kind) = bound_var {
980995 let kind = ty::LateParamRegionKind::from_bound(ty::BoundVar::from_usize(idx), kind);
981996 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> {
13021302 None => ".clone()".to_string(),
13031303 };
13041304
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();
13061306
13071307 diag.span_suggestion_verbose(
13081308 span,
......@@ -1395,7 +1395,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13951395 .macro_backtrace()
13961396 .any(|x| matches!(x.kind, ExpnKind::Macro(MacroKind::Attr | MacroKind::Derive, ..)))
13971397 {
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);
13991402
14001403 let mut sugg = if self.precedence(expr) >= ExprPrecedence::Unambiguous {
14011404 vec![(span.shrink_to_hi(), ".into()".to_owned())]
......@@ -2062,7 +2065,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
20622065 None => sugg.to_string(),
20632066 };
20642067
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);
20662072 err.span_suggestion_verbose(span.shrink_to_hi(), msg, sugg, Applicability::HasPlaceholders);
20672073 true
20682074 }
compiler/rustc_lint/src/unused.rs+2-2
......@@ -185,7 +185,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
185185 let mut op_warned = false;
186186
187187 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);
189189 cx.emit_span_lint(
190190 UNUSED_MUST_USE,
191191 expr.span,
......@@ -511,7 +511,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
511511 );
512512 }
513513 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);
515515 cx.emit_span_lint(
516516 UNUSED_MUST_USE,
517517 span,
compiler/rustc_span/src/lib.rs+46-36
......@@ -716,12 +716,17 @@ impl Span {
716716 (!ctxt.is_root()).then(|| ctxt.outer_expn_data().call_site)
717717 }
718718
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`.
720720 ///
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`.
722725 /// If you need to extend the span, use [`find_ancestor_inside_same_ctxt`] instead,
723726 /// because joining spans with different syntax contexts can create unexpected results.
724727 ///
728 /// This is used to find the span of the macro call when a parent expr span, i.e. `outer`, is known.
729 ///
725730 /// [`find_ancestor_inside_same_ctxt`]: Self::find_ancestor_inside_same_ctxt
726731 pub fn find_ancestor_inside(mut self, outer: Span) -> Option<Span> {
727732 while !outer.contains(self) {
......@@ -730,8 +735,10 @@ impl Span {
730735 Some(self)
731736 }
732737
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`.
735742 ///
736743 /// Like [`find_ancestor_inside_same_ctxt`], but specifically for when spans might not
737744 /// overlap. Take care when using this, and prefer [`find_ancestor_inside`] or
......@@ -747,9 +754,12 @@ impl Span {
747754 Some(self)
748755 }
749756
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
751758 /// has the same [`SyntaxContext`] as `outer`.
752759 ///
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 ///
753763 /// This method is the combination of [`find_ancestor_inside`] and
754764 /// [`find_ancestor_in_same_ctxt`] and should be preferred when extending the returned span.
755765 /// If you do not need to modify the span, use [`find_ancestor_inside`] instead.
......@@ -763,43 +773,43 @@ impl Span {
763773 Some(self)
764774 }
765775
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.
768777 ///
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).
771780 ///
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.
778784 ///
779 /// macro_rules! inner {
780 /// ($x: expr) => {
781 /// format!("error: {}", $x)
782 /// //~^ ERROR mismatched types
783 /// }
784 /// }
785 /// # See also
785786 ///
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.
790797 ///
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()?;
801811 }
802 cur
812 Some(self)
803813 }
804814
805815 /// 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).
293293
294294- `no-auto-check-cfg` — disable auto check-cfg (only for `--check-cfg` tests)
295295- [`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
298296-[`forbid-output`](compiletest.md#incremental-tests) — incremental cfail rejects
299297 output pattern
300298- [`should-ice`](compiletest.md#incremental-tests) — incremental cfail should
......@@ -315,6 +313,17 @@ test suites that use those tools:
315313- `llvm-cov-flags` adds extra flags when running LLVM's `llvm-cov` tool.
316314 - Used by [coverage tests](compiletest.md#coverage-tests) in `coverage-run` mode.
317315
316### Tidy specific directives
317
318The following directives control how the [tidy script](../conventions.md#formatting)
319verifies 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.
318327
319328## Substitutions
320329
src/tools/compiletest/src/directives.rs+145-333
......@@ -12,6 +12,9 @@ use tracing::*;
1212use crate::common::{CodegenBackend, Config, Debugger, FailMode, PassMode, RunFailMode, TestMode};
1313use crate::debuggers::{extract_cdb_version, extract_gdb_version};
1414use crate::directives::auxiliary::{AuxProps, parse_and_update_aux};
15use crate::directives::directive_names::{
16 KNOWN_DIRECTIVE_NAMES, KNOWN_HTMLDOCCK_DIRECTIVE_NAMES, KNOWN_JSONDOCCK_DIRECTIVE_NAMES,
17};
1518use crate::directives::needs::CachedNeedsConditions;
1619use crate::errors::ErrorKind;
1720use crate::executor::{CollectedTestDesc, ShouldPanic};
......@@ -20,6 +23,7 @@ use crate::util::static_regex;
2023
2124pub(crate) mod auxiliary;
2225mod cfg;
26mod directive_names;
2327mod needs;
2428#[cfg(test)]
2529mod tests;
......@@ -59,9 +63,9 @@ impl EarlyProps {
5963 &mut poisoned,
6064 testfile,
6165 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);
6569 },
6670 );
6771
......@@ -351,7 +355,7 @@ impl TestProps {
351355 &mut poisoned,
352356 testfile,
353357 file,
354 &mut |directive @ DirectiveLine { raw_directive: ln, .. }| {
358 &mut |directive @ DirectiveLine { line_number, raw_directive: ln, .. }| {
355359 if !directive.applies_to_test_revision(test_revision) {
356360 return;
357361 }
......@@ -361,17 +365,28 @@ impl TestProps {
361365 config.push_name_value_directive(
362366 ln,
363367 ERROR_PATTERN,
368 testfile,
369 line_number,
364370 &mut self.error_patterns,
365371 |r| r,
366372 );
367373 config.push_name_value_directive(
368374 ln,
369375 REGEX_ERROR_PATTERN,
376 testfile,
377 line_number,
370378 &mut self.regex_error_patterns,
371379 |r| r,
372380 );
373381
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 );
375390
376391 fn split_flags(flags: &str) -> Vec<String> {
377392 // Individual flags can be single-quoted to preserve spaces; see
......@@ -386,7 +401,9 @@ impl TestProps {
386401 .collect::<Vec<_>>()
387402 }
388403
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 {
390407 let flags = split_flags(&flags);
391408 for flag in &flags {
392409 if flag == "--edition" || flag.starts_with("--edition=") {
......@@ -395,25 +412,40 @@ impl TestProps {
395412 }
396413 self.compile_flags.extend(flags);
397414 }
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 {
399424 panic!("`compiler-flags` directive should be spelled `compile-flags`");
400425 }
401426
402 if let Some(edition) = config.parse_edition(ln) {
427 if let Some(edition) = config.parse_edition(ln, testfile, line_number) {
403428 // The edition is added at the start, since flags from //@compile-flags must
404429 // be passed to rustc last.
405430 self.compile_flags.insert(0, format!("--edition={}", edition.trim()));
406431 has_edition = true;
407432 }
408433
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 );
410440
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 {
412444 self.run_flags.extend(split_flags(&flags));
413445 }
414446
415447 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);
417449 }
418450
419451 config.set_name_directive(ln, SHOULD_ICE, &mut self.should_ice);
......@@ -435,7 +467,9 @@ impl TestProps {
435467 );
436468 config.set_name_directive(ln, NO_PREFER_DYNAMIC, &mut self.no_prefer_dynamic);
437469
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 {
439473 self.pretty_mode = m;
440474 }
441475
......@@ -446,35 +480,45 @@ impl TestProps {
446480 );
447481
448482 // 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);
450484
451485 config.push_name_value_directive(
452486 ln,
453487 EXEC_ENV,
488 testfile,
489 line_number,
454490 &mut self.exec_env,
455491 Config::parse_env,
456492 );
457493 config.push_name_value_directive(
458494 ln,
459495 UNSET_EXEC_ENV,
496 testfile,
497 line_number,
460498 &mut self.unset_exec_env,
461499 |r| r.trim().to_owned(),
462500 );
463501 config.push_name_value_directive(
464502 ln,
465503 RUSTC_ENV,
504 testfile,
505 line_number,
466506 &mut self.rustc_env,
467507 Config::parse_env,
468508 );
469509 config.push_name_value_directive(
470510 ln,
471511 UNSET_RUSTC_ENV,
512 testfile,
513 line_number,
472514 &mut self.unset_rustc_env,
473515 |r| r.trim().to_owned(),
474516 );
475517 config.push_name_value_directive(
476518 ln,
477519 FORBID_OUTPUT,
520 testfile,
521 line_number,
478522 &mut self.forbid_output,
479523 |r| r,
480524 );
......@@ -510,7 +554,7 @@ impl TestProps {
510554 }
511555
512556 if let Some(code) = config
513 .parse_name_value_directive(ln, FAILURE_STATUS)
557 .parse_name_value_directive(ln, FAILURE_STATUS, testfile, line_number)
514558 .and_then(|code| code.trim().parse::<i32>().ok())
515559 {
516560 self.failure_status = Some(code);
......@@ -531,6 +575,8 @@ impl TestProps {
531575 config.set_name_value_directive(
532576 ln,
533577 ASSEMBLY_OUTPUT,
578 testfile,
579 line_number,
534580 &mut self.assembly_output,
535581 |r| r.trim().to_string(),
536582 );
......@@ -543,7 +589,9 @@ impl TestProps {
543589
544590 // Unlike the other `name_value_directive`s this needs to be handled manually,
545591 // 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 {
547595 let known_bug = known_bug.trim();
548596 if known_bug == "unknown"
549597 || known_bug.split(',').all(|issue_ref| {
......@@ -571,16 +619,25 @@ impl TestProps {
571619 config.set_name_value_directive(
572620 ln,
573621 TEST_MIR_PASS,
622 testfile,
623 line_number,
574624 &mut self.mir_unit_test,
575625 |s| s.trim().to_string(),
576626 );
577627 config.set_name_directive(ln, REMAP_SRC_BASE, &mut self.remap_src_base);
578628
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 {
580632 self.llvm_cov_flags.extend(split_flags(&flags));
581633 }
582634
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 ) {
584641 self.filecheck_flags.extend(split_flags(&flags));
585642 }
586643
......@@ -588,9 +645,12 @@ impl TestProps {
588645
589646 self.update_add_core_stubs(ln, config);
590647
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 ) {
594654 self.dont_require_annotations
595655 .insert(ErrorKind::expect_from_user_str(err_kind.trim()));
596656 }
......@@ -769,296 +829,6 @@ fn line_directive<'line>(
769829 Some(DirectiveLine { line_number, revision, raw_directive })
770830}
771831
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.
775const 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
1040const 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
1059const KNOWN_JSONDOCCK_DIRECTIVE_NAMES: &[&str] =
1060 &["count", "!count", "has", "!has", "is", "!is", "ismany", "!ismany", "set", "!set"];
1061
1062832/// The (partly) broken-down contents of a line containing a test directive,
1063833/// which [`iter_directives`] passes to its callback function.
1064834///
......@@ -1206,6 +976,7 @@ impl Config {
1206976 fn parse_and_update_revisions(
1207977 &self,
1208978 testfile: &Utf8Path,
979 line_number: usize,
1209980 line: &str,
1210981 existing: &mut Vec<String>,
1211982 ) {
......@@ -1219,7 +990,8 @@ impl Config {
1219990 const FILECHECK_FORBIDDEN_REVISION_NAMES: [&str; 9] =
1220991 ["CHECK", "COM", "NEXT", "SAME", "EMPTY", "NOT", "COUNT", "DAG", "LABEL"];
1221992
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 {
1223995 if self.mode == TestMode::RunMake {
1224996 panic!("`run-make` tests do not support revisions: {}", testfile);
1225997 }
......@@ -1264,8 +1036,13 @@ impl Config {
12641036 (name.to_owned(), value.to_owned())
12651037 }
12661038
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) {
12691046 Some(Utf8PathBuf::from(&s))
12701047 } else if self.parse_name_directive(line, "pp-exact") {
12711048 testfile.file_name().map(Utf8PathBuf::from)
......@@ -1306,19 +1083,31 @@ impl Config {
13061083 line.starts_with("no-") && self.parse_name_directive(&line[3..], directive)
13071084 }
13081085
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> {
13101093 let colon = directive.len();
13111094 if line.starts_with(directive) && line.as_bytes().get(colon) == Some(&b':') {
13121095 let value = line[(colon + 1)..].to_owned();
13131096 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)
13151104 } else {
13161105 None
13171106 }
13181107 }
13191108
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)
13221111 }
13231112
13241113 fn set_name_directive(&self, line: &str, directive: &str, value: &mut bool) {
......@@ -1340,11 +1129,14 @@ impl Config {
13401129 &self,
13411130 line: &str,
13421131 directive: &str,
1132 testfile: &Utf8Path,
1133 line_number: usize,
13431134 value: &mut Option<T>,
13441135 parse: impl FnOnce(String) -> T,
13451136 ) {
13461137 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);
13481140 }
13491141 }
13501142
......@@ -1352,10 +1144,14 @@ impl Config {
13521144 &self,
13531145 line: &str,
13541146 directive: &str,
1147 testfile: &Utf8Path,
1148 line_number: usize,
13551149 values: &mut Vec<T>,
13561150 parse: impl FnOnce(String) -> T,
13571151 ) {
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 {
13591155 values.push(value);
13601156 }
13611157 }
......@@ -1672,9 +1468,9 @@ pub(crate) fn make_test_description<R: Read>(
16721468 decision!(cfg::handle_ignore(config, ln));
16731469 decision!(cfg::handle_only(config, ln));
16741470 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));
16781474 decision!(ignore_cdb(config, ln));
16791475 decision!(ignore_gdb(config, ln));
16801476 decision!(ignore_lldb(config, ln));
......@@ -1801,8 +1597,15 @@ fn ignore_lldb(config: &Config, line: &str) -> IgnoreDecision {
18011597 IgnoreDecision::Continue
18021598}
18031599
1804fn ignore_backends(config: &Config, path: &Utf8Path, line: &str) -> IgnoreDecision {
1805 if let Some(backends_to_ignore) = config.parse_name_value_directive(line, "ignore-backends") {
1600fn 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 {
18061609 for backend in backends_to_ignore.split_whitespace().map(|backend| {
18071610 match CodegenBackend::try_from(backend) {
18081611 Ok(backend) => backend,
......@@ -1821,8 +1624,15 @@ fn ignore_backends(config: &Config, path: &Utf8Path, line: &str) -> IgnoreDecisi
18211624 IgnoreDecision::Continue
18221625}
18231626
1824fn needs_backends(config: &Config, path: &Utf8Path, line: &str) -> IgnoreDecision {
1825 if let Some(needed_backends) = config.parse_name_value_directive(line, "needs-backends") {
1627fn 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 {
18261636 if !needed_backends
18271637 .split_whitespace()
18281638 .map(|backend| match CodegenBackend::try_from(backend) {
......@@ -1844,9 +1654,9 @@ fn needs_backends(config: &Config, path: &Utf8Path, line: &str) -> IgnoreDecisio
18441654 IgnoreDecision::Continue
18451655}
18461656
1847fn ignore_llvm(config: &Config, path: &Utf8Path, line: &str) -> IgnoreDecision {
1657fn ignore_llvm(config: &Config, path: &Utf8Path, line: &str, line_number: usize) -> IgnoreDecision {
18481658 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)
18501660 {
18511661 let components: HashSet<_> = config.llvm_components.split_whitespace().collect();
18521662 if let Some(missing_component) = needed_components
......@@ -1867,7 +1677,9 @@ fn ignore_llvm(config: &Config, path: &Utf8Path, line: &str) -> IgnoreDecision {
18671677 if let Some(actual_version) = &config.llvm_version {
18681678 // Note that these `min` versions will check for not just major versions.
18691679
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 {
18711683 let min_version = extract_llvm_version(&version_string);
18721684 // Ignore if actual version is smaller than the minimum required version.
18731685 if *actual_version < min_version {
......@@ -1878,7 +1690,7 @@ fn ignore_llvm(config: &Config, path: &Utf8Path, line: &str) -> IgnoreDecision {
18781690 };
18791691 }
18801692 } 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)
18821694 {
18831695 let max_version = extract_llvm_version(&version_string);
18841696 // 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 {
18921704 };
18931705 }
18941706 } 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)
18961708 {
18971709 let min_version = extract_llvm_version(&version_string);
18981710 // Ignore if using system LLVM and actual version
......@@ -1905,7 +1717,7 @@ fn ignore_llvm(config: &Config, path: &Utf8Path, line: &str) -> IgnoreDecision {
19051717 };
19061718 }
19071719 } 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)
19091721 {
19101722 // Syntax is: "ignore-llvm-version: <version1> [- <version2>]"
19111723 let (v_min, v_max) =
......@@ -1931,7 +1743,7 @@ fn ignore_llvm(config: &Config, path: &Utf8Path, line: &str) -> IgnoreDecision {
19311743 }
19321744 }
19331745 } 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)
19351747 {
19361748 // Syntax is "exact-llvm-major-version: <version>"
19371749 let version = extract_llvm_version(&version_string);
src/tools/compiletest/src/directives/auxiliary.rs+34-7
......@@ -3,6 +3,8 @@
33
44use std::iter;
55
6use camino::Utf8Path;
7
68use super::directives::{AUX_BIN, AUX_BUILD, AUX_CODEGEN_BACKEND, AUX_CRATE, PROC_MACRO};
79use crate::common::Config;
810
......@@ -41,17 +43,42 @@ impl AuxProps {
4143
4244/// If the given test directive line contains an `aux-*` directive, parse it
4345/// and update [`AuxProps`] accordingly.
44pub(super) fn parse_and_update_aux(config: &Config, ln: &str, aux: &mut AuxProps) {
46pub(super) fn parse_and_update_aux(
47 config: &Config,
48 ln: &str,
49 testfile: &Utf8Path,
50 line_number: usize,
51 aux: &mut AuxProps,
52) {
4553 if !(ln.starts_with("aux-") || ln.starts_with("proc-macro")) {
4654 return;
4755 }
4856
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 {
5582 aux.codegen_backend = Some(r.trim().to_owned());
5683 }
5784}
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.
4pub(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
269pub(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
288pub(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 {
4747 continue;
4848 };
4949
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 {
5153 commands.push(command);
5254 }
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 {
5458 check_lines.push((line_no, pattern));
5559 }
5660 }
src/tools/tidy/src/style.rs+5-2
......@@ -519,8 +519,11 @@ pub fn check(path: &Path, bad: &mut bool) {
519519 .any(|directive| matches!(directive, Directive::Ignore(_)));
520520 let has_alphabetical_directive = line.contains("tidy-alphabetical-start")
521521 || 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;
524527 if contains_potential_directive && (!has_recognized_directive) {
525528 err("Unrecognized tidy directive")
526529 }
src/tools/tidy/src/target_specific_tests.rs+51-10
......@@ -12,12 +12,16 @@ const COMPILE_FLAGS_HEADER: &str = "compile-flags:";
1212
1313#[derive(Default, Debug)]
1414struct RevisionInfo<'a> {
15 target_arch: Option<&'a str>,
15 target_arch: Option<Option<&'a str>>,
1616 llvm_components: Option<Vec<&'a str>>,
1717}
1818
1919pub fn check(tests_path: &Path, bad: &mut bool) {
2020 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
2125 let file = entry.path().display();
2226 let mut header_map = BTreeMap::new();
2327 iter_header(content, &mut |HeaderLine { revision, directive, .. }| {
......@@ -34,10 +38,11 @@ pub fn check(tests_path: &Path, bad: &mut bool) {
3438 && let Some((_, v)) = compile_flags.split_once("--target")
3539 {
3640 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));
4146 } else {
4247 eprintln!("{file}: seems to have a malformed --target value");
4348 *bad = true;
......@@ -54,9 +59,11 @@ pub fn check(tests_path: &Path, bad: &mut bool) {
5459 let rev = rev.unwrap_or("[unspecified]");
5560 match (target_arch, llvm_components) {
5661 (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);
5865 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"
6067 );
6168 *bad = true;
6269 }
......@@ -66,11 +73,45 @@ pub fn check(tests_path: &Path, bad: &mut bool) {
6673 );
6774 *bad = true;
6875 }
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 }
7286 }
7387 }
7488 }
7589 });
7690}
91
92fn 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 @@
33//@ add-core-stubs
44//@ revisions:x86_64 i686 aarch64 arm riscv
55//@[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
77//@[i686] compile-flags: --target i686-unknown-linux-musl
8//@[i686] needs-llvm-components: aarch64 arm riscv
8//@[i686] needs-llvm-components: x86
99//@[aarch64] compile-flags: --target aarch64-unknown-none
10//@[aarch64] needs-llvm-components: aarch64 arm riscv
10//@[aarch64] needs-llvm-components: aarch64
1111//@[arm] compile-flags: --target armv7r-none-eabi
12//@[arm] needs-llvm-components: aarch64 arm riscv
12//@[arm] needs-llvm-components: arm
1313//@[riscv] compile-flags: --target riscv64gc-unknown-none-elf
14//@[riscv] needs-llvm-components: aarch64 arm riscv
14//@[riscv] needs-llvm-components: riscv
1515//@ compile-flags: -C no-prepopulate-passes
1616
1717#![crate_type = "lib"]
tests/codegen-llvm/cast-target-abi.rs+1-1
......@@ -4,7 +4,7 @@
44//@ compile-flags: -Copt-level=3 -Cno-prepopulate-passes -Zlint-llvm-ir
55
66//@[aarch64] compile-flags: --target aarch64-unknown-linux-gnu
7//@[aarch64] needs-llvm-components: arm
7//@[aarch64] needs-llvm-components: aarch64
88//@[loongarch64] compile-flags: --target loongarch64-unknown-linux-gnu
99//@[loongarch64] needs-llvm-components: loongarch
1010//@[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu
tests/codegen-llvm/cf-protection.rs+1-1
......@@ -3,7 +3,7 @@
33//@ add-core-stubs
44//@ revisions: undefined none branch return full
55//@ needs-llvm-components: x86
6//@ [undefined] compile-flags:
6// [undefined] no extra compile-flags
77//@ [none] compile-flags: -Z cf-protection=none
88//@ [branch] compile-flags: -Z cf-protection=branch
99//@ [return] compile-flags: -Z cf-protection=return
tests/codegen-llvm/codemodels.rs+1-1
......@@ -1,7 +1,7 @@
11//@ only-x86_64
22
33//@ revisions: NOMODEL MODEL-SMALL MODEL-KERNEL MODEL-MEDIUM MODEL-LARGE
4//@[NOMODEL] compile-flags:
4// [NOMODEL] no compile-flags
55//@[MODEL-SMALL] compile-flags: -C code-model=small
66//@[MODEL-KERNEL] compile-flags: -C code-model=kernel
77//@[MODEL-MEDIUM] compile-flags: -C code-model=medium
tests/codegen-llvm/ehcontguard_disabled.rs-2
......@@ -1,5 +1,3 @@
1//@ compile-flags:
2
31#![crate_type = "lib"]
42
53// A basic test function.
tests/codegen-llvm/naked-fn/naked-functions.rs+1-1
......@@ -8,7 +8,7 @@
88//@[win_i686] compile-flags: --target i686-pc-windows-gnu
99//@[win_i686] needs-llvm-components: x86
1010//@[macos] compile-flags: --target aarch64-apple-darwin
11//@[macos] needs-llvm-components: arm
11//@[macos] needs-llvm-components: aarch64
1212//@[thumb] compile-flags: --target thumbv7em-none-eabi
1313//@[thumb] needs-llvm-components: arm
1414
tests/codegen-llvm/sanitizer/address-sanitizer-globals-tracking.rs+3-3
......@@ -19,9 +19,9 @@
1919//@ only-linux
2020//
2121//@ 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
2525
2626#![crate_type = "staticlib"]
2727
tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-attr-no-sanitize.rs+1-1
......@@ -5,7 +5,7 @@
55//@ [aarch64] compile-flags: --target aarch64-unknown-none
66//@ [aarch64] needs-llvm-components: aarch64
77//@ [x86_64] compile-flags: --target x86_64-unknown-none
8//@ [x86_64] needs-llvm-components:
8//@ [x86_64] needs-llvm-components: x86
99//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0
1010
1111#![crate_type = "lib"]
tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs+1-1
......@@ -5,7 +5,7 @@
55//@ [aarch64] compile-flags: --target aarch64-unknown-none
66//@ [aarch64] needs-llvm-components: aarch64
77//@ [x86_64] compile-flags: --target x86_64-unknown-none
8//@ [x86_64] needs-llvm-components:
8//@ [x86_64] needs-llvm-components: x86
99//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-generalize-pointers
1010
1111#![crate_type = "lib"]
tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs+1-1
......@@ -5,7 +5,7 @@
55//@ [aarch64] compile-flags: --target aarch64-unknown-none
66//@ [aarch64] needs-llvm-components: aarch64
77//@ [x86_64] compile-flags: --target x86_64-unknown-none
8//@ [x86_64] needs-llvm-components:
8//@ [x86_64] needs-llvm-components: x86
99//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers
1010
1111#![crate_type = "lib"]
tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs+1-1
......@@ -5,7 +5,7 @@
55//@ [aarch64] compile-flags: --target aarch64-unknown-none
66//@ [aarch64] needs-llvm-components: aarch64
77//@ [x86_64] compile-flags: --target x86_64-unknown-none
8//@ [x86_64] needs-llvm-components:
8//@ [x86_64] needs-llvm-components: x86
99//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers
1010
1111#![crate_type = "lib"]
tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi.rs+1-1
......@@ -5,7 +5,7 @@
55//@ [aarch64] compile-flags: --target aarch64-unknown-none
66//@ [aarch64] needs-llvm-components: aarch64
77//@ [x86_64] compile-flags: --target x86_64-unknown-none
8//@ [x86_64] needs-llvm-components:
8//@ [x86_64] needs-llvm-components: x86
99//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0
1010
1111#![crate_type = "lib"]
tests/codegen-llvm/sanitizer/kcfi/emit-kcfi-operand-bundle.rs+1-1
......@@ -5,7 +5,7 @@
55//@ [aarch64] compile-flags: --target aarch64-unknown-none
66//@ [aarch64] needs-llvm-components: aarch64
77//@ [x86_64] compile-flags: --target x86_64-unknown-none
8//@ [x86_64] needs-llvm-components:
8//@ [x86_64] needs-llvm-components: x86
99//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0
1010
1111#![crate_type = "lib"]
tests/codegen-llvm/sanitizer/kcfi/emit-type-metadata-trait-objects.rs+1-1
......@@ -5,7 +5,7 @@
55//@ [aarch64] compile-flags: --target aarch64-unknown-none
66//@ [aarch64] needs-llvm-components: aarch64
77//@ [x86_64] compile-flags: --target x86_64-unknown-none
8//@ [x86_64] needs-llvm-components:
8//@ [x86_64] needs-llvm-components: x86
99//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0
1010
1111#![crate_type = "lib"]
tests/codegen-llvm/sanitizer/memory-track-origins.rs+1-1
......@@ -5,7 +5,7 @@
55//@ revisions:MSAN-0 MSAN-1 MSAN-2 MSAN-1-LTO MSAN-2-LTO
66//
77//@ compile-flags: -Zsanitizer=memory -Ctarget-feature=-crt-static
8//@[MSAN-0] compile-flags:
8// [MSAN-0] no extra compile-flags
99//@[MSAN-1] compile-flags: -Zsanitizer-memory-track-origins=1
1010//@[MSAN-2] compile-flags: -Zsanitizer-memory-track-origins
1111//@[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 @@
66// but ub-checks are explicitly disabled.
77
88//@ revisions: DEBUG NOCHECKS
9//@ [DEBUG] compile-flags:
9// [DEBUG] no extra compile-flags
1010//@ [NOCHECKS] compile-flags: -Zub-checks=no
1111//@ compile-flags: -Copt-level=3 -Cdebug-assertions=yes
1212
tests/debuginfo/unsized.rs-1
......@@ -37,7 +37,6 @@
3737// cdb-check: [...] vtable : 0x[...] [Type: unsigned [...]int[...] (*)[4]]
3838
3939// cdb-command:dx _box
40// cdb-check:
4140// cdb-check:_box [Type: alloc::boxed::Box<unsized::Foo<dyn$<core::fmt::Debug> >,alloc::alloc::Global>]
4241// cdb-check:[+0x000] pointer : 0x[...] [Type: unsized::Foo<dyn$<core::fmt::Debug> > *]
4342// cdb-check:[...] vtable : 0x[...] [Type: unsigned [...]int[...] (*)[4]]
tests/run-make/link-cfg/rmake.rs+1
......@@ -12,6 +12,7 @@
1212
1313//@ ignore-cross-compile
1414// Reason: the compiled binary is executed
15//@ needs-llvm-components: x86
1516
1617use run_make_support::{bare_rustc, build_native_dynamic_lib, build_native_static_lib, run, rustc};
1718
tests/run-make/mismatching-target-triples/rmake.rs+1
......@@ -4,6 +4,7 @@
44// now replaced by a clearer normal error message. This test checks that this aforementioned
55// error message is used.
66// See https://github.com/rust-lang/rust/issues/10814
7//@ needs-llvm-components: x86
78
89use run_make_support::rustc;
910
tests/run-make/musl-default-linking/rmake.rs+1
......@@ -4,6 +4,7 @@ use run_make_support::{rustc, serde_json};
44// Per https://github.com/rust-lang/compiler-team/issues/422,
55// we should be trying to move these targets to dynamically link
66// musl libc by default.
7//@ needs-llvm-components: aarch64 arm mips powerpc riscv systemz x86
78static LEGACY_STATIC_LINKING_TARGETS: &[&'static str] = &[
89 "aarch64-unknown-linux-musl",
910 "arm-unknown-linux-musleabi",
tests/run-make/rustdoc-target-spec-json-path/rmake.rs+1
......@@ -1,4 +1,5 @@
11// Test that rustdoc will properly canonicalize the target spec json path just like rustc.
2//@ needs-llvm-components: x86
23
34use run_make_support::{cwd, rustc, rustdoc};
45
tests/run-make/target-specs/rmake.rs+1
......@@ -4,6 +4,7 @@
44// with the target flag's bundle of new features to check that compilation either succeeds while
55// using them correctly, or fails with the right error message when using them improperly.
66// See https://github.com/rust-lang/rust/pull/16156
7//@ needs-llvm-components: x86
78
89use run_make_support::{diff, rfs, rustc};
910
tests/ui/README.md-4
......@@ -654,10 +654,6 @@ Tests on range patterns where one of the bounds is not a direct value.
654654
655655Tests for the standard library collection [`std::collections::HashMap`](https://doc.rust-lang.org/std/collections/struct.HashMap.html).
656656
657## `tests/ui/hello_world/`
658
659Tests that the basic hello-world program is not somehow broken.
660
661657## `tests/ui/higher-ranked/`
662658
663659Tests 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
3fn 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
10fn needs_static_lifetime<T: 'static>(obj: T) {}
11
12fn main() {}
tests/ui/borrowck/liberated-region-from-outer-closure.stderr created+17
......@@ -0,0 +1,17 @@
1error[E0310]: the parameter type `T` may not live long enough
2 --> $DIR/liberated-region-from-outer-closure.rs:5:17
3 |
4LL | 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 |
10help: consider adding an explicit lifetime bound
11 |
12LL | fn example<T: Copy + 'static>(x: T) -> impl FnMut(&mut ()) {
13 | +++++++++
14
15error: aborting due to 1 previous error
16
17For more information about this error, try `rustc --explain E0310`.
tests/ui/errors/remap-path-prefix-sysroot.rs+1-1
......@@ -2,7 +2,7 @@
22//@ compile-flags: -g -Ztranslate-remapped-path-to-local-path=yes
33//@ [with-remap]compile-flags: --remap-path-prefix={{rust-src-base}}=remapped
44//@ [with-remap]compile-flags: --remap-path-prefix={{src-base}}=remapped-tests-ui
5//@ [without-remap]compile-flags:
5// [without-remap] no extra compile-flags
66
77// The $SRC_DIR*.rs:LL:COL normalisation doesn't kick in automatically
88// as the remapped revision will not begin with $SRC_DIR_REAL,
tests/ui/errors/wrong-target-spec.rs+1
......@@ -2,6 +2,7 @@
22// checks that such invalid target specs are rejected by the compiler.
33// See https://github.com/rust-lang/rust/issues/33329
44
5// ignore-tidy-target-specific-tests
56//@ needs-llvm-components: x86
67//@ compile-flags: --target x86_64_unknown-linux-musl
78
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
5fn main() {
6 println!("Hello, world!");
7}
tests/ui/linkage-attr/unstable-flavor.rs+2-2
......@@ -4,9 +4,9 @@
44//
55//@ revisions: bpf ptx
66//@ [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
88//@ [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
1010
1111#![feature(no_core)]
1212#![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);
99 for<Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&'^0 mut &'^1 i32, &'^2 i32)),
1010 (),
1111 ]
12 = note: late-bound region is '?1
13 = note: late-bound region is '?2
14 = note: late-bound region is '?3
1215
1316error: lifetime may not live long enough
1417 --> $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);
99 for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&'^0 mut &'^1 i32, &'^1 i32)),
1010 (),
1111 ]
12 = note: late-bound region is '?1
13 = note: late-bound region is '?2
1214
1315note: no external requirements
1416 --> $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| {
99 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>)),
1010 (),
1111 ]
12 = note: late-bound region is '?7
13 = note: late-bound region is '?8
1214 = note: late-bound region is '?4
1315 = note: late-bound region is '?5
1416 = 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
99 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>)),
1010 (),
1111 ]
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
1218 = note: late-bound region is '?3
1319 = note: late-bound region is '?4
1420 = 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| {
99 for<Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 u32>, std::cell::Cell<&'^0 u32>)),
1010 (),
1111 ]
12 = note: late-bound region is '?2
1213
1314error[E0521]: borrowed data escapes outside of closure
1415 --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:22:9
......@@ -43,6 +44,7 @@ LL | foo(cell, |cell_a, cell_x| {
4344 for<Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 u32>, std::cell::Cell<&'^0 u32>)),
4445 (),
4546 ]
47 = note: late-bound region is '?2
4648 = note: number of external vids: 2
4749 = note: where '?1: '?0
4850
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| {
99 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>)),
1010 (),
1111 ]
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
1217 = note: late-bound region is '?2
1318 = note: late-bound region is '?3
1419 = 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
99 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>)),
1010 (),
1111 ]
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
1218 = note: late-bound region is '?3
1319 = note: late-bound region is '?4
1420 = 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| {
99 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>)),
1010 (),
1111 ]
12 = note: late-bound region is '?5
13 = note: late-bound region is '?6
1214 = note: late-bound region is '?3
1315 = note: late-bound region is '?4
1416 = 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| {
99 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>)),
1010 (),
1111 ]
12 = note: late-bound region is '?4
13 = note: late-bound region is '?5
1214 = note: late-bound region is '?3
1315 = note: number of external vids: 4
1416 = 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| {
99 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>)),
1010 (),
1111 ]
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
1217 = note: late-bound region is '?2
1318 = note: late-bound region is '?3
1419
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
99 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>)),
1010 (),
1111 ]
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
1218 = note: late-bound region is '?3
1319 = note: late-bound region is '?4
1420
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`
99 for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&'^0 i32, &'^1 i32)) -> &'^0 i32,
1010 (),
1111 ]
12 = note: late-bound region is '?1
13 = note: late-bound region is '?2
1214
1315error: lifetime may not live long enough
1416 --> $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));
99 for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'?1 &'^0 ()>>, &'^1 T)),
1010 (),
1111 ]
12 = note: late-bound region is '?2
13 = note: late-bound region is '?3
1214 = note: number of external vids: 2
1315 = note: where T: '?1
1416
......@@ -31,6 +33,8 @@ LL | twice(cell, value, |a, b| invoke(a, b));
3133 for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'?1 &'^0 ()>>, &'^1 T)),
3234 (),
3335 ]
36 = note: late-bound region is '?3
37 = note: late-bound region is '?4
3438 = note: late-bound region is '?2
3539 = note: number of external vids: 3
3640 = note: where T: '?1
tests/ui/target_modifiers/defaults_check.rs+1-1
......@@ -6,7 +6,7 @@
66//@ needs-llvm-components: x86
77
88//@ revisions: ok ok_explicit error
9//@[ok] compile-flags:
9// [ok] no extra compile-flags
1010//@[ok_explicit] compile-flags: -Zreg-struct-return=false
1111//@[error] compile-flags: -Zreg-struct-return=true
1212//@[ok] check-pass
tests/ui/target_modifiers/incompatible_fixedx18.rs+1-1
......@@ -5,7 +5,7 @@
55//@ revisions:allow_match allow_mismatch error_generated
66//@[allow_match] compile-flags: -Zfixed-x18
77//@[allow_mismatch] compile-flags: -Cunsafe-allow-abi-mismatch=fixed-x18
8//@[error_generated] compile-flags:
8// [error_generated] no extra compile-flags
99//@[allow_mismatch] check-pass
1010//@[allow_match] check-pass
1111
tests/ui/target_modifiers/incompatible_regparm.rs+1-1
......@@ -5,7 +5,7 @@
55//@ revisions:allow_regparm_mismatch allow_no_value error_generated
66//@[allow_regparm_mismatch] compile-flags: -Cunsafe-allow-abi-mismatch=regparm
77//@[allow_no_value] compile-flags: -Cunsafe-allow-abi-mismatch
8//@[error_generated] compile-flags:
8// [error_generated] no extra compile-flags
99//@[allow_regparm_mismatch] check-pass
1010
1111#![feature(no_core)]
tests/ui/target_modifiers/no_value_bool.rs+1-1
......@@ -8,7 +8,7 @@
88//@ revisions: ok ok_explicit error error_explicit
99//@[ok] compile-flags: -Zreg-struct-return
1010//@[ok_explicit] compile-flags: -Zreg-struct-return=true
11//@[error] compile-flags:
11// [error] no extra compile-flags
1212//@[error_explicit] compile-flags: -Zreg-struct-return=false
1313//@[ok] check-pass
1414//@[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
5fn main() {
6 println!("Hello, world!");
7}