|
| 1 | +//! Test that private dependencies of `std` that live in the sysroot do not reach through to |
| 2 | +//! diagnostics. |
| 3 | +//! |
| 4 | +//! This test would be more robust if we could patch the sysroot with an "evil" crate that |
| 5 | +//! provided known types that we control; however, this would effectively require rebuilding |
| 6 | +//! `std` (or patching crate metadata). So, this test relies on what is currently public API |
| 7 | +//! of `std`'s dependencies, but may not be robust against dependency upgrades/changes. |
| 8 | +
|
| 9 | +//@ only-unix Windows sysroots seem to not expose this dependency |
| 10 | +//@ revisions: default rustc_private_enabled |
| 11 | + |
| 12 | +// Enabling `rustc_private` should `std`'s dependencies accessible, so they should show up |
| 13 | +// in diagnostics. NB: not all diagnostics are affected by this. |
| 14 | +#![cfg_attr(rustc_private_enabled, feature(rustc_private))] |
| 15 | +#![crate_type = "lib"] |
| 16 | + |
| 17 | +trait Trait { type Bar; } |
| 18 | + |
| 19 | +// Attempt to get a suggestion for `gimli::read::op::EvaluationStoreage`, which should not be |
| 20 | +// present in diagnostics (it is a dependency of the compiler). |
| 21 | +type AssociatedTy = dyn Trait<ExpressionStack = i32, Bar = i32>; |
| 22 | +//~^ ERROR associated type `ExpressionStack` not found |
| 23 | +//~| NOTE there is an associated type `ExpressionStack` in the trait `gimli::read::op::EvaluationStorage` |
| 24 | + |
| 25 | +// Attempt to get a suggestion for `hashbrown::Equivalent` |
| 26 | +trait Trait2<K>: Equivalent<K> {} |
| 27 | +//~^ ERROR cannot find trait |
| 28 | +//~| NOTE not found |
| 29 | + |
| 30 | +// Attempt to get a suggestion for `hashbrown::Equivalent::equivalent` |
| 31 | +fn trait_member<T>(val: &T, key: &K) -> bool { |
| 32 | + //~^ ERROR cannot find type `K` |
| 33 | + //~| NOTE similarly named |
| 34 | + val.equivalent(key) |
| 35 | +} |
| 36 | + |
| 37 | +// Attempt to get a suggestion for `memchr::memchr2` |
| 38 | +fn free_function(buf: &[u8]) -> Option<usize> { |
| 39 | + memchr2(b'a', b'b', buf) |
| 40 | + //~^ ERROR cannot find function |
| 41 | + //~| NOTE not found |
| 42 | +} |
0 commit comments