rust/tests/ui
bors 5b20c45999 Auto merge of #128849 - estebank:issue-89143, r=jackh726
Tweak detection of multiple crate versions to be more encompassing

Previously, we only emitted the additional context if the type was in the same crate as the trait that appeared multiple times in the dependency tree. Now, we look at all traits looking for two with the same name in different crates with the same crate number, and we are more flexible looking for the types involved. This will work even if the type that implements the wrong trait version is from a different crate entirely.

```
error[E0277]: the trait bound `CustomErrorHandler: ErrorHandler` is not satisfied because the trait comes from a different crate version
 --> src/main.rs:5:17
  |
5 |     cnb_runtime(CustomErrorHandler {});
  |                 ^^^^^^^^^^^^^^^^^^^^^ the trait `ErrorHandler` is not implemented for `CustomErrorHandler`
  |
note: there are multiple different versions of crate `c` in the dependency graph
 --> /home/gh-estebank/testcase-rustc-crate-version-mismatch/c-v0.2/src/lib.rs:1:1
  |
1 | pub trait ErrorHandler {}
  | ^^^^^^^^^^^^^^^^^^^^^^ this is the required trait
  |
 ::: src/main.rs:1:5
  |
1 | use b::CustomErrorHandler;
  |     - one version of crate `c` is used here, as a dependency of crate `b`
2 | use c::cnb_runtime;
  |     - one version of crate `c` is used here, as a direct dependency of the current crate
  |
 ::: /home/gh-estebank/testcase-rustc-crate-version-mismatch/b/src/lib.rs:1:1
  |
1 | pub struct CustomErrorHandler {}
  | ----------------------------- this type doesn't implement the required trait
  |
 ::: /home/gh-estebank/testcase-rustc-crate-version-mismatch/c-v0.1/src/lib.rs:1:1
  |
1 | pub trait ErrorHandler {}
  | ---------------------- this is the found trait
  = note: two types coming from two different versions of the same crate are different types even if they look the same
  = help: you can use `cargo tree` to explore your dependency tree
```

Fix #89143.
2024-11-08 00:34:48 +00:00
..
abi
alloc-error
allocator
annotate-snippet
anon-params
argfile
argument-suggestions
array-slice-vec
asm Basic inline assembly support for SPARC and SPARC64 2024-11-07 21:19:03 +09:00
associated-consts
associated-inherent-types
associated-item
associated-type-bounds
associated-types
async-await
attributes
auto-traits
autodiff
autoref-autoderef
auxiliary
backtrace
bench
binding
binop
blind
block-result
borrowck
box
btreemap
builtin-superkinds
c-variadic
cast
cfg
check-cfg Rollup merge of #132077 - alexcrichton:wide-arithmetic, r=jieyouxu 2024-11-05 23:43:57 +01:00
closure_context
closure-expected-type
closures Auto merge of #132580 - compiler-errors:globs, r=Noratrieb 2024-11-05 08:30:56 +00:00
cmse-nonsecure
codegen
codemap_tests
coercion
coherence
coinduction
command
compare-method
compiletest-self-test
conditional-compilation
confuse-field-and-method
const_prop
const-generics
const-ptr
consts Rollup merge of #132571 - RalfJung:const_eval_select_macro, r=oli-obk 2024-11-05 20:10:52 +01:00
coroutine Add --diagnostic-width to some tests failing after 1a0c502183 2024-11-06 20:02:42 +01:00
coverage-attr
crate-loading
cross
cross-crate
custom_test_frameworks
cycle-trait
debuginfo
definition-reachable
delegation
dep-graph
deprecation
deref-patterns
derived-errors
derives Rollup merge of #131153 - VulnBandit:copy_impl_vuln, r=compiler-errors 2024-11-04 20:40:44 -08:00
deriving
dest-prop
destructuring-assignment
diagnostic_namespace
diagnostic-flags
diagnostic-width
did_you_mean
directory_ownership
disallowed-deconstructing
dollar-crate
drop
drop-bounds
dropck Tweak E0320 overflow error wording 2024-11-05 21:54:45 +00:00
dst
duplicate
dyn-compatibility
dyn-drop
dyn-keyword
dyn-star
dynamically-sized-types
editions
empty
entry-point
enum
enum-discriminant
env-macro
error-codes Rollup merge of #132025 - duncpro:E0027, r=compiler-errors 2024-11-04 20:40:45 -08:00
error-emitter
errors
explicit
explicit-tail-calls
expr
extern
extern-flag
feature-gates
ffi-attrs
float
fmt
fn
fn-main
for
for-loop-while
foreign
fuel
fully-qualified-type
function-pointer
functional-struct-update
functions-closures
generic-associated-types
generic-const-items
generics
half-open-range-patterns
hashmap
hello_world
higher-ranked
hygiene
illegal-sized-bound
impl-header-lifetime-elision
impl-trait Add --diagnostic-width to some tests failing after 1a0c502183 2024-11-06 20:02:42 +01:00
implied-bounds
imports
include-macros
incoherent-inherent-impls
indexing
inference
infinite
inherent-impls-overlap-check
inline-const
instrument-coverage
instrument-xray
interior-mutability
internal
internal-lints
intrinsics most const intrinsics don't need an explicit rustc_const_unstable any more 2024-11-04 23:27:46 +01:00
invalid
invalid-compile-flags Rollup merge of #132259 - mrkajetanp:branch-protection-pauth-lr, r=davidtwco 2024-11-05 20:10:49 +01:00
invalid-module-declaration
invalid-self-argument
io-checks
issues
iterators
json
keyword
kindck
label
lang-items
late-bound-lifetimes
layout
lazy-type-alias
lazy-type-alias-impl-trait
let-else
lexer
lifetimes
limits
linkage-attr
lint
liveness
loops
lowering
lto
lub-glb
macro_backtrace
macros
malformed
manual
marker_trait_attr
match
meta
methods
mir
mir-dataflow
mismatched_types
missing
missing_non_modrs_mod
missing-trait-bounds
modules
modules_and_files_visibility
moves
mut
namespace
native-library-link-flags
never_type
nll
no_std
non_modrs_mods
non_modrs_mods_and_inline_mods
not-panic
numbers-arithmetic
numeric
object-lifetime
obsolete-in-place
offset-of
on-unimplemented
operator-recovery
or-patterns
overloaded
packed
panic-handler
panic-runtime
panics
parallel-rustc
parser
patchable-function-entry
pattern
pin-macro
polymorphization
precondition-checks
print_type_sizes
print-request
privacy
proc-macro
process
process-termination
ptr_ops
pub
qualified
query-system
range
raw-ref-op
reachable
recursion Tweak E0320 overflow error wording 2024-11-05 21:54:45 +00:00
recursion_limit
regions
repeat-expr
repr remove support for extern-block const intrinsics 2024-11-04 23:27:45 +01:00
reserved
resolve
return
rfcs Rollup merge of #132303 - nyurik:non-exhaustive-err, r=compiler-errors 2024-11-04 20:40:45 -08:00
rmeta
runtime
rust-2018
rust-2021
rust-2024
rustc-env
rustdoc
sanitizer
self
sepcomp
shadowed
shell-argfiles
simd
single-use-lifetime
sized
span
specialization
stability-attribute remove support for extern-block const intrinsics 2024-11-04 23:27:45 +01:00
stable-mir-print
stack-protector
static
statics
stats
std
stdlib-unit-tests
str
structs
structs-enums
suggestions Auto merge of #132404 - makai410:suggest-swap-lhs-rhs, r=fee1-dead 2024-11-06 11:49:52 +00:00
svh
symbol-mangling-version
symbol-names
sync
target-feature Auto merge of #129884 - RalfJung:forbidden-target-features, r=workingjubilee 2024-11-05 16:25:45 +00:00
test-attrs
thir-print
thread-local
threads-sendsync
tool-attributes
track-diagnostics
trait-bounds
traits
transmutability
transmute
treat-err-as-bug
trivial-bounds
try-block
try-trait
tuple
type
type-alias
type-alias-enum-variants
type-alias-impl-trait
type-inference
typeck fix test 2024-11-07 20:56:36 +00:00
typeof
ufcs
unboxed-closures
underscore-imports
underscore-lifetime
uniform-paths
uninhabited
union
unknown-unstable-lints
unop
unpretty
unresolved
unsafe
unsized
unsized-locals
unused-crate-deps
unwind-abis
use
variance
variants
version
warnings
wasm
wf
where-clauses
while
windows-subsystem
zero-sized
.gitattributes
alias-uninit-value.rs
allow-non-lint-warnings.rs
anonymous-higher-ranked-lifetime.rs
anonymous-higher-ranked-lifetime.stderr
artificial-block.rs
as-precedence.rs
assign-assign.rs
assign-imm-local-twice.rs
assign-imm-local-twice.stderr
assoc-lang-items.rs
assoc-lang-items.stderr
assoc-oddities-3.rs
associated-path-shl.rs
associated-path-shl.stderr
atomic-from-mut-not-available.rs
atomic-from-mut-not-available.stderr
attempted-access-non-fatal.rs
attempted-access-non-fatal.stderr
attr-bad-crate-attr.rs
attr-bad-crate-attr.stderr
attr-shebang.rs
attr-start.rs
attr-usage-inline.rs
attr-usage-inline.stderr
attrs-resolution-errors.rs
attrs-resolution-errors.stderr
attrs-resolution.rs
augmented-assignments-feature-gate-cross.rs
augmented-assignments-rpass.rs
augmented-assignments.rs
augmented-assignments.stderr
auto-instantiate.rs
auto-ref-slice-plus-ref.rs
auto-ref-slice-plus-ref.stderr
autoderef-full-lval.rs
autoderef-full-lval.stderr
bare-fn-implements-fn-mut.rs
bare-static-string.rs
big-literals.rs
bind-by-move.rs
bitwise.rs
bogus-tag.rs
bogus-tag.stderr
borrow-by-val-method-receiver.rs
bounds-lifetime.rs
bounds-lifetime.stderr
break-diverging-value.rs
break-diverging-value.stderr
builtin-clone-unwind.rs
can-copy-pod.rs
cancel-clean-via-immediate-rvalue-ref.rs
cannot-mutate-captured-non-mut-var.rs
cannot-mutate-captured-non-mut-var.stderr
capture1.rs
capture1.stderr
catch-unwind-bang.rs
cenum_impl_drop_cast.rs
cenum_impl_drop_cast.stderr
cfguard-run.rs
char.rs
class-cast-to-trait.rs
class-cast-to-trait.stderr
class-method-missing.rs
class-method-missing.stderr
cleanup-rvalue-for-scope.rs
cleanup-rvalue-scopes-cf.rs
cleanup-rvalue-scopes-cf.stderr
cleanup-rvalue-scopes.rs
cleanup-rvalue-temp-during-incomplete-alloc.rs
cleanup-shortcircuit.rs
close-over-big-then-small-data.rs
command-line-diagnostics.rs
command-line-diagnostics.stderr
complex.rs
conservative_impl_trait.rs
conservative_impl_trait.stderr
constructor-lifetime-args.rs
constructor-lifetime-args.stderr
copy-a-resource.rs
copy-a-resource.stderr
crate-leading-sep.rs
crate-method-reexport-grrrrrrr.rs
crate-name-attr-used.rs
crate-name-mismatch.rs
crate-name-mismatch.stderr
custom_attribute.rs
custom_attribute.stderr
custom-attribute-multisegment.rs
custom-attribute-multisegment.stderr
custom-test-frameworks-simple.rs
deduplicate-diagnostics.deduplicate.stderr
deduplicate-diagnostics.duplicate.stderr
deduplicate-diagnostics.rs
deep.rs
default-method-parsing.rs
default-method-simple.rs
defaults-well-formedness.rs
deprecation-in-force-unstable.rs
deref-non-pointer.rs
deref-non-pointer.stderr
deref-rc.rs
deref.rs
derive-uninhabited-enum-38885.rs
derive-uninhabited-enum-38885.stderr
destructure-trait-ref.rs
destructure-trait-ref.stderr
diverging-fallback-method-chain.rs
diverging-fallback-option.rs
diverging-fn-tail-35849.rs
diverging-fn-tail-35849.stderr
double-ref.rs
double-type-import.rs
double-type-import.stderr
dupe-first-attr.rs
duplicate_entry_error.rs
duplicate_entry_error.stderr
duplicate-label-E0381-issue-129274.rs
duplicate-label-E0381-issue-129274.stderr
early-ret-binop-add.rs
elide-errors-on-mismatched-tuple.rs
elide-errors-on-mismatched-tuple.stderr
elided-test.rs
elided-test.stderr
else-if.rs
empty-allocation-non-null.rs
empty-allocation-rvalue-non-null.rs
empty-type-parameter-list.rs
empty-type-parameter-list.stderr
error-festival.rs
error-festival.stderr
error-should-say-copy-not-pod.rs
error-should-say-copy-not-pod.stderr
exclusive-drop-and-copy.rs
exclusive-drop-and-copy.stderr
explain.rs
explain.stdout
explicit-i-suffix.rs
explore-issue-38412.rs
explore-issue-38412.stderr
ext-expand-inner-exprs.rs
ext-nonexistent.rs
ext-nonexistent.stderr
fact.rs
fail-simple.rs
fail-simple.stderr
filter-block-view-items.rs
format-no-std.rs
fun-indirect-call.rs
future-incompatible-lint-group.rs
future-incompatible-lint-group.stderr
global-scope.rs
hello.rs
illegal-ufcs-drop.fixed
illegal-ufcs-drop.rs
illegal-ufcs-drop.stderr
impl-inherent-non-conflict.rs
impl-not-adjacent-to-type.rs
impl-privacy-xc-1.rs
impl-unused-rps-in-assoc-type.rs
impl-unused-rps-in-assoc-type.stderr
impl-unused-tps-inherent.rs
impl-unused-tps-inherent.stderr
impl-unused-tps.rs
impl-unused-tps.stderr
implicit-method-bind.rs
implicit-method-bind.stderr
inline-disallow-on-variant.rs
inline-disallow-on-variant.stderr
inlined-main.rs
inner-attrs-on-impl.rs
inner-module.rs
inner-static-type-parameter.rs
inner-static-type-parameter.stderr
inner-static.rs
integral-indexing.rs
integral-indexing.stderr
integral-variable-unification-error.rs
integral-variable-unification-error.stderr
invalid_crate_type_syntax.rs
invalid_crate_type_syntax.stderr
invalid_dispatch_from_dyn_impls.rs
invalid_dispatch_from_dyn_impls.stderr
issue-11881.rs
issue-13560.rs
issue-15924.rs
issue-16822.rs
issue-18502.rs
issue-24106.rs
issue-76387-llvm-miscompile.rs
issues-71798.rs
issues-71798.stderr
item-name-overload.rs
kinds-in-metadata.rs
kinds-of-primitive-impl.rs
kinds-of-primitive-impl.stderr
last-use-in-block.rs
last-use-in-cap-clause.rs
last-use-is-capture.rs
lazy-and-or.rs
lexical-scopes.rs
lexical-scopes.stderr
lexical-scoping.rs
link-section.rs
list.rs
log-err-phi.rs
log-knows-the-names-of-variants.rs
log-poly.rs
logging-only-prints-once.rs
loud_ui.rs
max-min-classes.rs
maximal_mir_to_hir_coverage.rs
maybe-bounds.rs
maybe-bounds.stderr
method-output-diff-issue-127263.rs
method-output-diff-issue-127263.stderr
minus-string.rs
minus-string.stderr
missing_debug_impls.rs
missing_debug_impls.stderr
mod-subitem-as-enum-variant.rs
mod-subitem-as-enum-variant.stderr
monomorphize-abi-alignment.rs
msvc-data-only.rs
msvc-opt-minsize.rs
multibyte.rs
multiline-comment.rs
mut-function-arguments.rs
mutual-recursion-group.rs
myriad-closures.rs
nested-block-comment.rs
nested-cfg-attrs.rs
nested-cfg-attrs.stderr
nested-class.rs
nested-ty-params.rs
nested-ty-params.stderr
new-impl-syntax.rs
new-import-syntax.rs
new-style-constants.rs
new-unicode-escapes.rs
newlambdas.rs
newtype-polymorphic.rs
newtype.rs
no_crate_type.rs
no_crate_type.stderr
no_send-enum.rs
no_send-enum.stderr
no_send-rc.rs
no_send-rc.stderr
no_share-enum.rs
no_share-enum.stderr
no_share-struct.rs
no_share-struct.stderr
no-capture-arc.rs
no-capture-arc.stderr
no-core-1.rs
no-core-2.rs
no-link-unknown-crate.rs
no-link-unknown-crate.stderr
no-reuse-move-arc.rs
no-reuse-move-arc.stderr
no-send-res-ports.rs
no-send-res-ports.stderr
no-warn-on-field-replace-issue-34101.rs
noexporttypeexe.rs
noexporttypeexe.stderr
non-constant-expr-for-arr-len.rs
non-constant-expr-for-arr-len.stderr
non-copyable-void.rs
non-copyable-void.stderr
non-fmt-panic.fixed
non-fmt-panic.rs
non-fmt-panic.stderr
noncopyable-class.rs
noncopyable-class.stderr
nonscalar-cast.fixed
nonscalar-cast.rs
nonscalar-cast.stderr
not-clone-closure.rs Add --diagnostic-width to some tests failing after 1a0c502183 2024-11-06 20:02:42 +01:00
not-clone-closure.stderr Add --diagnostic-width to some tests failing after 1a0c502183 2024-11-06 20:02:42 +01:00
not-copy-closure.rs
not-copy-closure.stderr
not-enough-arguments.rs
not-enough-arguments.stderr
nul-characters.rs
nullable-pointer-iotareduction.rs
nullable-pointer-size.rs
object-pointer-types.rs
object-pointer-types.stderr
objects-coerce-freeze-borrored.rs
occurs-check-2.rs
occurs-check-2.stderr
occurs-check-3.rs
occurs-check-3.stderr
occurs-check.rs
occurs-check.stderr
once-cant-call-twice-on-heap.rs
once-cant-call-twice-on-heap.stderr
oom_unwind.rs
op-assign-builtins-by-ref.rs
opeq.rs
opt-in-copy.rs
opt-in-copy.stderr
optimization-remark.rs
out-pointer-aliasing.rs
output-slot-variants.rs
over-constrained-vregs.rs
panic_implementation-closures.rs
panic-while-printing.rs
paren-span.rs
paren-span.stderr
partialeq_help.rs
partialeq_help.stderr
path-lookahead.fixed
path-lookahead.rs
path-lookahead.stderr
path.rs
paths-containing-nul.rs
phantom-auto-trait.rs
phantom-auto-trait.stderr
point-to-type-err-cause-on-impl-trait-return-2.rs
point-to-type-err-cause-on-impl-trait-return-2.stderr
pptypedef.rs
pptypedef.stderr
primitive-binop-lhs-mut.rs
print-calling-conventions.rs
print-calling-conventions.stdout
print-stdout-eprint-stderr.rs
project-cache-issue-31849.rs
ptr-coercion-rpass.rs
ptr-coercion.rs
ptr-coercion.stderr
query-visibility.rs
raw-str.rs
README.md
realloc-16687.rs
reassign-ref-mut.rs
reassign-ref-mut.stderr
reexport-test-harness-main.rs
removing-extern-crate.fixed
removing-extern-crate.rs
removing-extern-crate.stderr
resource-assign-is-not-copy.rs
resource-destruct.rs
rustc-error.rs
rustc-error.stderr
seq-args.rs
seq-args.stderr
shadow-bool.rs
shadowed-use-visibility.rs
short-error-format.rs
short-error-format.stderr
sized-borrowed-pointer.rs
sized-cycle-note.rs
sized-cycle-note.stderr
sized-owned-pointer.rs
sse2.rs
stable-addr-of.rs
std-uncopyable-atomics.rs
std-uncopyable-atomics.stderr
stdio-is-blocking.rs
string-box-error.rs
struct-ctor-mangling.rs
super-at-top-level.rs
super-at-top-level.stderr
super.rs
svh-add-nothing.rs
swap-1.rs
swap-overlapping.rs
switched-expectations.rs
switched-expectations.stderr
syntax-extension-minor.rs
tag-type-args.rs
tag-type-args.stderr
tag-variant-cast-non-nullary.fixed
tag-variant-cast-non-nullary.rs
tag-variant-cast-non-nullary.stderr
tail-call-arg-leak.rs
tail-cps.rs
tail-typeck.rs
tail-typeck.stderr
trailing-comma.rs
trait-method-number-parameters.rs
trait-method-number-parameters.stderr
transmute-equal-assoc-types.rs
transmute-non-immediate-to-immediate.rs
trivial_casts-rpass.rs
trivial_casts-rpass.stderr
try-from-int-error-partial-eq.rs
try-operator-hygiene.rs
try-operator.rs
tydesc-name.rs
type_length_limit.polonius.stderr
type_length_limit.rs
type_length_limit.stderr
type-id-higher-rank-2.rs
type-namespace.rs
type-param-constraints.rs
type-param.rs
type-ptr.rs
type-use-i1-versus-i8.rs
typeid-intrinsic.rs
typestate-multi-decl.rs
unconstrained-none.rs
unconstrained-none.stderr
unconstrained-ref.rs
unconstrained-ref.stderr
underscore-ident-matcher.rs
underscore-ident-matcher.stderr
underscore-lifetimes.rs
underscore-method-after-integer.rs
unevaluated_fixed_size_array_len.rs
unevaluated_fixed_size_array_len.stderr
uninit-empty-types.rs
unit.rs
unknown-language-item.rs
unknown-language-item.stderr
unknown-llvm-arg.rs
unknown-llvm-arg.stderr
unnamed_argument_mode.rs
unreachable-code-1.rs
unreachable-code.rs
unsigned-literal-negation.rs
unsigned-literal-negation.stderr
unused-move-capture.rs
unused-move.rs
unwind-no-uwtable.rs
use-import-export.rs
use-keyword-2.rs
use-module-level-int-consts.rs
use-nested-groups.rs
used.rs
used.stderr
usize-generic-argument-parent.rs
usize-generic-argument-parent.stderr
utf8_idents.rs
utf8-bom.rs
wait-forked-but-failed-child.rs
walk-struct-literal-with.rs
walk-struct-literal-with.stderr
weak-new-uninhabited-issue-48493.rs
weird-exit-code.rs
weird-exprs.rs
write-fmt-errors.rs
writing-to-immutable-vec.rs
writing-to-immutable-vec.stderr
wrong-hashset-issue-42918.rs

UI Tests

This folder contains rustc's UI tests.

Test Directives (Headers)

Typically, a UI test will have some test directives / headers which are special comments that tell compiletest how to build and intepret a test.

As part of an on-going effort to rewrite compiletest (see https://github.com/rust-lang/compiler-team/issues/536), a major change proposal to change legacy compiletest-style headers // <directive> to ui_test-style headers //@ <directive> was accepted (see https://github.com/rust-lang/compiler-team/issues/512.

An example directive is ignore-test. In legacy compiletest style, the header would be written as

// ignore-test

but in ui_test style, the header would be written as

//@ ignore-test

compiletest is changed to accept only //@ directives for UI tests (currently), and will reject and report an error if it encounters any comments // <content> that may be parsed as an legacy compiletest-style test header. To fix this, you should migrate to the ui_test-style header //@ <content>.