diff options
Diffstat (limited to 'src')
15 files changed, 215 insertions, 23 deletions
diff --git a/src/doc/unstable-book/src/compiler-flags/extern-options.md b/src/doc/unstable-book/src/compiler-flags/extern-options.md new file mode 100644 index 00000000000..858eee5d2c2 --- /dev/null +++ b/src/doc/unstable-book/src/compiler-flags/extern-options.md @@ -0,0 +1,22 @@ +# `--extern` Options + +The behavior of the `--extern` flag can be modified with `noprelude`, `priv` or `nounused` options. + +This is unstable feature, so you have to provide `-Zunstable-options` to enable it. + +## Examples + +Use your own build of the `core` crate. + +`rustc main.rs -Z unstable-options --extern noprelude:core=libcore.rlib` + +To use multiple options, separate them with a comma: + +`rustc main.rs -Z unstable-options --extern noprelude,priv,nounused:mydep=mydep.rlib` + +## Options + +* `noprelude`: Do not add the crate to the external prelude. If used, it will need to be imported using `extern crate`. + This is used by the [build-std project](https://github.com/rust-lang/wg-cargo-std-aware/) to simulate compatibility with sysroot-only crates. +* `priv`: Mark the crate as a private dependency for the [`exported_private_dependencies`](../../rustc/lints/listing/warn-by-default.html#exported-private-dependencies) lint. +* `nounused`: Suppress [`unused-crate-dependencies`](../../rustc/lints/listing/allowed-by-default.html#unused-crate-dependencies) warnings for the crate. diff --git a/src/etc/cpu-usage-over-time-plot.sh b/src/etc/cpu-usage-over-time-plot.sh index 0905789079a..1c342559194 100755 --- a/src/etc/cpu-usage-over-time-plot.sh +++ b/src/etc/cpu-usage-over-time-plot.sh @@ -7,13 +7,21 @@ # commit SHA of the build you're interested in, and the second is the name of # the builder. For example: # -# ./src/etc/cpu-usage-over-time-plot.sh e699ea096fcc2fc9ce8e8bcf884e11496a31cc9f i686-mingw-1 +# ./src/etc/cpu-usage-over-time-plot.sh 7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c x86_64-gnu # # That will generate `$builder.png` in the current directory which you can open # up to see a hopefully pretty graph. # # Improvements to this script are greatly appreciated! +if [[ $# != 2 ]]; then + echo "expected 2 arguments, recieved $#" + echo "example usage: './src/etc/cpu-usage-over-time-plot.sh \ +7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c \ +x86_64-gnu'" + exit 1 +fi + set -ex bucket=rust-lang-ci2 @@ -30,7 +38,7 @@ set ylabel "CPU Usage %" set xlabel "Time" set datafile sep ',' set term png size 3000,1000 -set output "$builder.png" +set output "$builder-$commit-cpu-usage-plot.png" set grid f(x) = mean_y @@ -43,7 +51,9 @@ set ytics 10 set boxwidth 0.5 plot \\ - mean_y with lines linetype 1 linecolor rgb "#ff0000" title "average", \\ - "cpu-$builder.csv" using 1:(100-\$2) with points pointtype 7 pointsize 0.4 title "$builder", \\ - "" using 1:(100-\$2) smooth bezier linewidth 3 title "bezier" + mean_y with lines linetype 1 linecolor rgb "#ff0000" title "average", "cpu-$builder.csv" \\ + using 1:(100-\$2) with points pointtype 7 pointsize 0.4 title "$builder", "" \\ + using 1:(100-\$2) smooth bezier linewidth 3 title "bezier" EOF + +rm "cpu-$builder.csv" diff --git a/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr b/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr index bd8c8a4414c..fbd76a64c1e 100644 --- a/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr +++ b/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr @@ -6,6 +6,9 @@ LL | fn bar() -> impl Bar { ... LL | fn baz() -> impl Bar<Item = i32> { | ^^^^^^^^^^^^^^^^^^^^ expected associated type, found `i32` +LL | +LL | bar() + | ----- return type was inferred to be `impl Bar` here | = note: expected associated type `<impl Bar as Foo>::Item` found type `i32` diff --git a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr index cbe4a4ac0d6..cbc7b93f3a9 100644 --- a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr +++ b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr @@ -3,6 +3,9 @@ error[E0277]: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied | LL | fn rawr() -> impl Trait { | ^^^^^^^^^^ the trait `Trait` is not implemented for `Uwu<10_u32, 12_u32>` +LL | +LL | Uwu::<10, 12> + | ------------- return type was inferred to be `Uwu<10_u32, 12_u32>` here | = help: the trait `Trait` is implemented for `Uwu<N>` @@ -11,6 +14,9 @@ error[E0277]: the trait bound `u32: Traitor<N>` is not satisfied | LL | fn uwu<const N: u8>() -> impl Traitor<N> { | ^^^^^^^^^^^^^^^ the trait `Traitor<N>` is not implemented for `u32` +LL | +LL | 1_u32 + | ----- return type was inferred to be `u32` here | = help: the following other types implement trait `Traitor<N, M>`: <u32 as Traitor<N, 2_u8>> @@ -21,6 +27,9 @@ error[E0277]: the trait bound `u64: Traitor` is not satisfied | LL | fn owo() -> impl Traitor { | ^^^^^^^^^^^^ the trait `Traitor` is not implemented for `u64` +LL | +LL | 1_u64 + | ----- return type was inferred to be `u64` here | = help: the following other types implement trait `Traitor<N, M>`: <u32 as Traitor<N, 2_u8>> diff --git a/src/test/ui/impl-trait/bound-normalization-fail.stderr b/src/test/ui/impl-trait/bound-normalization-fail.stderr index eac7e6b315e..bd8d3d3d24e 100644 --- a/src/test/ui/impl-trait/bound-normalization-fail.stderr +++ b/src/test/ui/impl-trait/bound-normalization-fail.stderr @@ -3,6 +3,9 @@ error[E0271]: type mismatch resolving `<Foo<()> as FooLike>::Output == <T as imp | LL | fn foo_fail<T: Trait>() -> impl FooLike<Output = T::Assoc> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Foo<()> as FooLike>::Output == <T as impl_trait::Trait>::Assoc` +LL | +LL | Foo(()) + | ------- return type was inferred to be `Foo<()>` here | note: expected this to be `()` --> $DIR/bound-normalization-fail.rs:14:19 @@ -27,6 +30,9 @@ error[E0271]: type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lif | LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lifetimes::Trait<'static>>::Assoc` +... +LL | Foo(()) + | ------- return type was inferred to be `Foo<()>` here | note: expected this to be `()` --> $DIR/bound-normalization-fail.rs:14:19 diff --git a/src/test/ui/issues-71798.stderr b/src/test/ui/issues-71798.stderr index ab72c3e41af..829d0a02ec9 100644 --- a/src/test/ui/issues-71798.stderr +++ b/src/test/ui/issues-71798.stderr @@ -9,6 +9,9 @@ error[E0277]: `u32` is not a future | LL | fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `u32` is not a future +LL | +LL | *x + | -- return type was inferred to be `u32` here | = help: the trait `Future` is not implemented for `u32` = note: u32 must be a future or must implement `IntoFuture` to be awaited diff --git a/src/test/ui/trait-bounds/issue-93008.rs b/src/test/ui/trait-bounds/issue-93008.rs index 1b010566cbc..f4d21a160b6 100644 --- a/src/test/ui/trait-bounds/issue-93008.rs +++ b/src/test/ui/trait-bounds/issue-93008.rs @@ -1,10 +1,15 @@ -// compile-flags: -Zmir-opt-level=4 +// build-pass +// compile-flags: -Zmir-opt-level=3 --crate-type=lib -pub fn bar<T>(s: &'static mut ()) +#![feature(trivial_bounds)] +#![allow(trivial_bounds)] + +trait Foo { + fn test(self); +} +fn baz<T>() where - &'static mut (): Clone, //~ ERROR the trait bound + &'static str: Foo, { - <&'static mut () as Clone>::clone(&s); + "Foo".test() } - -fn main() {} diff --git a/src/test/ui/trait-bounds/issue-93008.stderr b/src/test/ui/trait-bounds/issue-93008.stderr deleted file mode 100644 index 10f80f8de0c..00000000000 --- a/src/test/ui/trait-bounds/issue-93008.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0277]: the trait bound `&'static mut (): Clone` is not satisfied - --> $DIR/issue-93008.rs:5:5 - | -LL | &'static mut (): Clone, - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `&'static mut ()` - | - = help: see issue #48214 - = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/trait-bounds/issue-94680.rs b/src/test/ui/trait-bounds/issue-94680.rs new file mode 100644 index 00000000000..58e892079e6 --- /dev/null +++ b/src/test/ui/trait-bounds/issue-94680.rs @@ -0,0 +1,14 @@ +// check-pass + +fn main() { + println!("{:?}", { + type T = (); + + pub fn cloneit(it: &'_ mut T) -> (&'_ mut T, &'_ mut T) + where + for<'any> &'any mut T: Clone, + { + (it.clone(), it) + } + }); +} diff --git a/src/test/ui/trait-bounds/issue-94999.rs b/src/test/ui/trait-bounds/issue-94999.rs new file mode 100644 index 00000000000..e131902346f --- /dev/null +++ b/src/test/ui/trait-bounds/issue-94999.rs @@ -0,0 +1,34 @@ +// check-pass + +trait Identity<Q> { + type T; +} + +impl<Q, T> Identity<Q> for T { + type T = T; +} + +trait Holds { + type Q; +} + +struct S; +struct X(S); + +struct XHelper; + +impl Holds for X { + type Q = XHelper; +} + +impl<Q> Clone for X +where + <S as Identity<Q>>::T: Clone, + X: Holds<Q = Q>, +{ + fn clone(&self) -> Self { + Self(self.0.clone()) + } +} + +fn main() {} diff --git a/src/test/ui/trait-bounds/issue-95640.rs b/src/test/ui/trait-bounds/issue-95640.rs new file mode 100644 index 00000000000..e4e998b5d0b --- /dev/null +++ b/src/test/ui/trait-bounds/issue-95640.rs @@ -0,0 +1,31 @@ +// build-pass +// compile-flags:-Zmir-opt-level=3 + +struct D; + +trait Tr { + type It; + fn foo(self) -> Option<Self::It>; +} + +impl<'a> Tr for &'a D { + type It = (); + fn foo(self) -> Option<()> { + None + } +} + +fn run<F>(f: F) +where + for<'a> &'a D: Tr, + F: Fn(<&D as Tr>::It), +{ + let d = &D; + while let Some(i) = d.foo() { + f(i); + } +} + +fn main() { + run(|_| {}); +} diff --git a/src/test/ui/trait-bounds/select-param-env-instead-of-blanket.rs b/src/test/ui/trait-bounds/select-param-env-instead-of-blanket.rs new file mode 100644 index 00000000000..288b2098b4c --- /dev/null +++ b/src/test/ui/trait-bounds/select-param-env-instead-of-blanket.rs @@ -0,0 +1,43 @@ +// known-bug +// build-fail +// failure-status: 101 +// compile-flags:--crate-type=lib -Zmir-opt-level=3 +// rustc-env:RUST_BACKTRACE=0 + +// normalize-stderr-test "thread 'rustc' panicked.*" -> "thread 'rustc' panicked" +// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> "" +// normalize-stderr-test "error: internal compiler error.*" -> "error: internal compiler error" +// normalize-stderr-test "encountered.*with incompatible types:" "encountered ... with incompatible types:" +// normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> "" +// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" +// normalize-stderr-test "note: compiler flags.*\n\n" -> "" +// normalize-stderr-test "note: rustc.*running on.*\n\n" -> "" +// normalize-stderr-test "query stack during panic:\n" -> "" +// normalize-stderr-test "we're just showing a limited slice of the query stack\n" -> "" +// normalize-stderr-test "end of query stack\n" -> "" +// normalize-stderr-test "#.*\n" -> "" + +// This is a known bug that @compiler-errors tried to fix in #94238, +// but the solution was probably not correct. + +pub trait Factory<T> { + type Item; +} + +pub struct IntFactory; + +impl<T> Factory<T> for IntFactory { + type Item = usize; +} + +pub fn foo<T>() +where + IntFactory: Factory<T>, +{ + let mut x: <IntFactory as Factory<T>>::Item = bar::<T>(); +} + +#[inline] +pub fn bar<T>() -> <IntFactory as Factory<T>>::Item { + 0usize +} diff --git a/src/test/ui/trait-bounds/select-param-env-instead-of-blanket.stderr b/src/test/ui/trait-bounds/select-param-env-instead-of-blanket.stderr new file mode 100644 index 00000000000..56cc5c93c96 --- /dev/null +++ b/src/test/ui/trait-bounds/select-param-env-instead-of-blanket.stderr @@ -0,0 +1,18 @@ +error: internal compiler error + +error: internal compiler error + encountered ... with incompatible types: + left-hand side has type: <IntFactory as Factory<T>>::Item + right-hand side has type: usize + --> $DIR/select-param-env-instead-of-blanket.rs:42:5 + | +LL | let mut x: <IntFactory as Factory<T>>::Item = bar::<T>(); + | ---------- in this inlined function call +... +LL | 0usize + | ^^^^^^ + | + = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:128:36 + +thread 'rustc' panicked + diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference.stderr b/src/test/ui/type-alias-impl-trait/nested-tait-inference.stderr index f98da9f7f92..62db019ed6a 100644 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference.stderr +++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference.stderr @@ -3,6 +3,9 @@ error[E0277]: the trait bound `(): Foo<FooX>` is not satisfied | LL | fn foo() -> impl Foo<FooX> { | ^^^^^^^^^^^^^^ the trait `Foo<FooX>` is not implemented for `()` +... +LL | () + | -- return type was inferred to be `()` here | = help: the trait `Foo<()>` is implemented for `()` diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr index 54f571ad3e3..f4d96038d91 100644 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr +++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr @@ -3,6 +3,9 @@ error[E0277]: the trait bound `(): Foo<FooX>` is not satisfied | LL | fn foo() -> impl Foo<FooX> { | ^^^^^^^^^^^^^^ the trait `Foo<FooX>` is not implemented for `()` +LL | +LL | () + | -- return type was inferred to be `()` here | = help: the following other types implement trait `Foo<A>`: <() as Foo<()>> |
