Auto merge of #109769 - JohnTitor:rollup-7n2bnpg, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #106985 (Enhanced doucmentation of binary search methods for `slice` and `VecDeque` for unsorted instances)
 - #109509 (compiletest: Don't allow tests with overlapping prefix names)
 - #109719 (RELEASES: Add "Only support Android NDK 25 or newer" to 1.68.0)
 - #109748 (Don't ICE on `DiscriminantKind` projection in new solver)
 - #109749 (Canonicalize float var as float in new solver)
 - #109761 (Drop binutils on powerpc-unknown-freebsd)
 - #109766 (Fix title for openharmony.md)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2023-03-30 12:44:25 +00:00
commit 516a6d3202
20 changed files with 160 additions and 44 deletions

View File

@ -94,6 +94,7 @@ Misc
Compatibility Notes
-------------------
- [Only support Android NDK 25 or newer](https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25.html)
- [Add `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` to future-incompat report](https://github.com/rust-lang/rust/pull/103418/)
- [Only specify `--target` by default for `-Zgcc-ld=lld` on wasm](https://github.com/rust-lang/rust/pull/101792/)
- [Bump `IMPLIED_BOUNDS_ENTAILMENT` to Deny + ReportNow](https://github.com/rust-lang/rust/pull/106465/)

View File

@ -291,7 +291,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
if nt != t {
return self.fold_ty(nt);
} else {
CanonicalVarKind::Ty(CanonicalTyVarKind::Int)
CanonicalVarKind::Ty(CanonicalTyVarKind::Float)
}
}
ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {

View File

@ -344,10 +344,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
LangItem::Sized,
[ty::GenericArg::from(goal.predicate.self_ty())],
));
ecx.add_goal(goal.with(tcx, sized_predicate));
ecx.eq(goal.param_env, goal.predicate.term, tcx.types.unit.into())?;
return ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
tcx.types.unit
}
ty::Adt(def, substs) if def.is_struct() => {
@ -483,9 +481,49 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
ecx: &mut EvalCtxt<'_, 'tcx>,
goal: Goal<'tcx, Self>,
) -> QueryResult<'tcx> {
let discriminant = goal.predicate.self_ty().discriminant_ty(ecx.tcx());
let self_ty = goal.predicate.self_ty();
let discriminant_ty = match *self_ty.kind() {
ty::Bool
| ty::Char
| ty::Int(..)
| ty::Uint(..)
| ty::Float(..)
| ty::Array(..)
| ty::RawPtr(..)
| ty::Ref(..)
| ty::FnDef(..)
| ty::FnPtr(..)
| ty::Closure(..)
| ty::Infer(ty::IntVar(..) | ty::FloatVar(..))
| ty::Generator(..)
| ty::GeneratorWitness(..)
| ty::GeneratorWitnessMIR(..)
| ty::Never
| ty::Foreign(..)
| ty::Adt(_, _)
| ty::Str
| ty::Slice(_)
| ty::Dynamic(_, _, _)
| ty::Tuple(_)
| ty::Error(_) => self_ty.discriminant_ty(ecx.tcx()),
// We do not call `Ty::discriminant_ty` on alias, param, or placeholder
// types, which return `<self_ty as DiscriminantKind>::Discriminant`
// (or ICE in the case of placeholders). Projecting a type to itself
// is never really productive.
ty::Alias(_, _) | ty::Param(_) | ty::Placeholder(..) => {
return Err(NoSolution);
}
ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_))
| ty::Bound(..) => bug!(
"unexpected self ty `{:?}` when normalizing `<T as DiscriminantKind>::Discriminant`",
goal.predicate.self_ty()
),
};
ecx.probe(|ecx| {
ecx.eq(goal.param_env, goal.predicate.term, discriminant.into())?;
ecx.eq(goal.param_env, goal.predicate.term, discriminant_ty.into())?;
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
})
}

View File

@ -2394,7 +2394,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
}
/// Binary searches this `VecDeque` for a given element.
/// This behaves similarly to [`contains`] if this `VecDeque` is sorted.
/// If the `VecDeque` is not sorted, the returned result is unspecified and
/// meaningless.
///
/// If the value is found then [`Result::Ok`] is returned, containing the
/// index of the matching element. If there are multiple matches, then any
@ -2404,7 +2405,6 @@ impl<T, A: Allocator> VecDeque<T, A> {
///
/// See also [`binary_search_by`], [`binary_search_by_key`], and [`partition_point`].
///
/// [`contains`]: VecDeque::contains
/// [`binary_search_by`]: VecDeque::binary_search_by
/// [`binary_search_by_key`]: VecDeque::binary_search_by_key
/// [`partition_point`]: VecDeque::partition_point
@ -2450,12 +2450,13 @@ impl<T, A: Allocator> VecDeque<T, A> {
}
/// Binary searches this `VecDeque` with a comparator function.
/// This behaves similarly to [`contains`] if this `VecDeque` is sorted.
///
/// The comparator function should implement an order consistent
/// with the sort order of the deque, returning an order code that
/// indicates whether its argument is `Less`, `Equal` or `Greater`
/// than the desired target.
/// The comparator function should return an order code that indicates
/// whether its argument is `Less`, `Equal` or `Greater` the desired
/// target.
/// If the `VecDeque` is not sorted or if the comparator function does not
/// implement an order consistent with the sort order of the underlying
/// `VecDeque`, the returned result is unspecified and meaningless.
///
/// If the value is found then [`Result::Ok`] is returned, containing the
/// index of the matching element. If there are multiple matches, then any
@ -2465,7 +2466,6 @@ impl<T, A: Allocator> VecDeque<T, A> {
///
/// See also [`binary_search`], [`binary_search_by_key`], and [`partition_point`].
///
/// [`contains`]: VecDeque::contains
/// [`binary_search`]: VecDeque::binary_search
/// [`binary_search_by_key`]: VecDeque::binary_search_by_key
/// [`partition_point`]: VecDeque::partition_point
@ -2505,10 +2505,11 @@ impl<T, A: Allocator> VecDeque<T, A> {
}
/// Binary searches this `VecDeque` with a key extraction function.
/// This behaves similarly to [`contains`] if this `VecDeque` is sorted.
///
/// Assumes that the deque is sorted by the key, for instance with
/// [`make_contiguous().sort_by_key()`] using the same key extraction function.
/// If the deque is not sorted by the key, the returned result is
/// unspecified and meaningless.
///
/// If the value is found then [`Result::Ok`] is returned, containing the
/// index of the matching element. If there are multiple matches, then any
@ -2518,7 +2519,6 @@ impl<T, A: Allocator> VecDeque<T, A> {
///
/// See also [`binary_search`], [`binary_search_by`], and [`partition_point`].
///
/// [`contains`]: VecDeque::contains
/// [`make_contiguous().sort_by_key()`]: VecDeque::make_contiguous
/// [`binary_search`]: VecDeque::binary_search
/// [`binary_search_by`]: VecDeque::binary_search_by

View File

@ -2387,7 +2387,8 @@ impl<T> [T] {
}
/// Binary searches this slice for a given element.
/// This behaves similarly to [`contains`] if this slice is sorted.
/// If the slice is not sorted, the returned result is unspecified and
/// meaningless.
///
/// If the value is found then [`Result::Ok`] is returned, containing the
/// index of the matching element. If there are multiple matches, then any
@ -2399,7 +2400,6 @@ impl<T> [T] {
///
/// See also [`binary_search_by`], [`binary_search_by_key`], and [`partition_point`].
///
/// [`contains`]: slice::contains
/// [`binary_search_by`]: slice::binary_search_by
/// [`binary_search_by_key`]: slice::binary_search_by_key
/// [`partition_point`]: slice::partition_point
@ -2462,12 +2462,13 @@ impl<T> [T] {
}
/// Binary searches this slice with a comparator function.
/// This behaves similarly to [`contains`] if this slice is sorted.
///
/// The comparator function should implement an order consistent
/// with the sort order of the underlying slice, returning an
/// order code that indicates whether its argument is `Less`,
/// `Equal` or `Greater` the desired target.
/// The comparator function should return an order code that indicates
/// whether its argument is `Less`, `Equal` or `Greater` the desired
/// target.
/// If the slice is not sorted or if the comparator function does not
/// implement an order consistent with the sort order of the underlying
/// slice, the returned result is unspecified and meaningless.
///
/// If the value is found then [`Result::Ok`] is returned, containing the
/// index of the matching element. If there are multiple matches, then any
@ -2479,7 +2480,6 @@ impl<T> [T] {
///
/// See also [`binary_search`], [`binary_search_by_key`], and [`partition_point`].
///
/// [`contains`]: slice::contains
/// [`binary_search`]: slice::binary_search
/// [`binary_search_by_key`]: slice::binary_search_by_key
/// [`partition_point`]: slice::partition_point
@ -2548,10 +2548,11 @@ impl<T> [T] {
}
/// Binary searches this slice with a key extraction function.
/// This behaves similarly to [`contains`] if this slice is sorted.
///
/// Assumes that the slice is sorted by the key, for instance with
/// [`sort_by_key`] using the same key extraction function.
/// If the slice is not sorted by the key, the returned result is
/// unspecified and meaningless.
///
/// If the value is found then [`Result::Ok`] is returned, containing the
/// index of the matching element. If there are multiple matches, then any
@ -2563,7 +2564,6 @@ impl<T> [T] {
///
/// See also [`binary_search`], [`binary_search_by`], and [`partition_point`].
///
/// [`contains`]: slice::contains
/// [`sort_by_key`]: slice::sort_by_key
/// [`binary_search`]: slice::binary_search
/// [`binary_search_by`]: slice::binary_search_by

View File

@ -434,11 +434,6 @@ impl Step for Llvm {
}
}
// Workaround for ppc32 lld limitation
if target == "powerpc-unknown-freebsd" {
ldflags.exe.push(" -fuse-ld=bfd");
}
// https://llvm.org/docs/HowToCrossCompileLLVM.html
if target != builder.config.build {
let LlvmResult { llvm_config, .. } =

View File

@ -1,4 +1,4 @@
# `*-linux-ohos*`
# `*-unknown-linux-ohos`
**Tier: 3**

View File

@ -12,6 +12,7 @@ use build_helper::git::{get_git_modified_files, get_git_untracked_files};
use core::panic;
use getopts::Options;
use lazycell::LazyCell;
use std::collections::BTreeSet;
use std::ffi::OsString;
use std::fs;
use std::io::{self, ErrorKind};
@ -409,7 +410,9 @@ pub fn run_tests(config: Config) {
let mut tests = Vec::new();
for c in &configs {
make_tests(c, &mut tests);
let mut found_paths = BTreeSet::new();
make_tests(c, &mut tests, &mut found_paths);
check_overlapping_tests(&found_paths);
}
tests.sort_by(|a, b| a.desc.name.as_slice().cmp(&b.desc.name.as_slice()));
@ -535,7 +538,11 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
}
}
pub fn make_tests(config: &Config, tests: &mut Vec<test::TestDescAndFn>) {
pub fn make_tests(
config: &Config,
tests: &mut Vec<test::TestDescAndFn>,
found_paths: &mut BTreeSet<PathBuf>,
) {
debug!("making tests from {:?}", config.src_base.display());
let inputs = common_inputs_stamp(config);
let modified_tests = modified_tests(config, &config.src_base).unwrap_or_else(|err| {
@ -547,6 +554,7 @@ pub fn make_tests(config: &Config, tests: &mut Vec<test::TestDescAndFn>) {
&PathBuf::new(),
&inputs,
tests,
found_paths,
&modified_tests,
)
.unwrap_or_else(|_| panic!("Could not read tests from {}", config.src_base.display()));
@ -617,6 +625,7 @@ fn collect_tests_from_dir(
relative_dir_path: &Path,
inputs: &Stamp,
tests: &mut Vec<test::TestDescAndFn>,
found_paths: &mut BTreeSet<PathBuf>,
modified_tests: &Vec<PathBuf>,
) -> io::Result<()> {
// Ignore directories that contain a file named `compiletest-ignore-dir`.
@ -650,6 +659,8 @@ fn collect_tests_from_dir(
let file_name = file.file_name();
if is_test(&file_name) && (!config.only_modified || modified_tests.contains(&file_path)) {
debug!("found test file: {:?}", file_path.display());
let rel_test_path = relative_dir_path.join(file_path.file_stem().unwrap());
found_paths.insert(rel_test_path);
let paths =
TestPaths { file: file_path, relative_dir: relative_dir_path.to_path_buf() };
@ -664,6 +675,7 @@ fn collect_tests_from_dir(
&relative_file_path,
inputs,
tests,
found_paths,
modified_tests,
)?;
}
@ -1079,3 +1091,24 @@ fn extract_lldb_version(full_version_line: &str) -> Option<(u32, bool)> {
fn not_a_digit(c: char) -> bool {
!c.is_digit(10)
}
fn check_overlapping_tests(found_paths: &BTreeSet<PathBuf>) {
let mut collisions = Vec::new();
for path in found_paths {
for ancestor in path.ancestors().skip(1) {
if found_paths.contains(ancestor) {
collisions.push((path, ancestor.clone()));
}
}
}
if !collisions.is_empty() {
let collisions: String = collisions
.into_iter()
.map(|(path, check_parent)| format!("test {path:?} clashes with {check_parent:?}\n"))
.collect();
panic!(
"{collisions}\n\
Tests cannot have overlapping names. Make sure they use unique prefixes."
);
}
}

View File

@ -0,0 +1,8 @@
// compile-flags: -Ztrait-solver=next
// check-pass
fn foo(x: f64) {
let y = x + 1.0;
}
fn main() {}

View File

@ -0,0 +1,8 @@
// compile-flags: -Ztrait-solver=next
// check-pass
fn foo<T>(x: T) {
std::mem::discriminant(&x);
}
fn main() {}

View File

@ -7,17 +7,15 @@ use std::ptr::{DynMetadata, Pointee};
trait Trait<U> {}
struct MyDst<T: ?Sized>(T);
fn works<T>() {
let _: <T as Pointee>::Metadata = ();
let _: <[T] as Pointee>::Metadata = 1_usize;
let _: <str as Pointee>::Metadata = 1_usize;
let _: <dyn Trait<T> as Pointee>::Metadata = give::<DynMetadata<dyn Trait<T>>>();
let _: <MyDst<T> as Pointee>::Metadata = ();
let _: <((((([u8],),),),),) as Pointee>::Metadata = 1_usize;
}
fn meta_is<T: Pointee<Metadata = U> + ?Sized, U>() {}
fn give<U>() -> U {
loop {}
fn works<T>() {
meta_is::<T, ()>();
meta_is::<[T], usize>();
meta_is::<str, usize>();
meta_is::<dyn Trait<T>, DynMetadata<dyn Trait<T>>>();
meta_is::<MyDst<T>, ()>();
meta_is::<((((([u8],),),),),), usize>();
}
fn main() {}

View File

@ -0,0 +1,18 @@
// compile-flags: -Ztrait-solver=next
// Check that `<T::Assoc as DiscriminantKind>::Discriminant` doesn't normalize
// to itself and cause overflow/ambiguity.
trait Foo {
type Assoc;
}
trait Bar {}
fn needs_bar(_: impl Bar) {}
fn foo<T: Foo>(x: T::Assoc) {
needs_bar(std::mem::discriminant(&x));
//~^ ERROR the trait bound `Discriminant<<T as Foo>::Assoc>: Bar` is not satisfied
}
fn main() {}

View File

@ -0,0 +1,17 @@
error[E0277]: the trait bound `Discriminant<<T as Foo>::Assoc>: Bar` is not satisfied
--> $DIR/projection-discr-kind.rs:14:15
|
LL | needs_bar(std::mem::discriminant(&x));
| --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `Discriminant<<T as Foo>::Assoc>`
| |
| required by a bound introduced by this call
|
note: required by a bound in `needs_bar`
--> $DIR/projection-discr-kind.rs:11:22
|
LL | fn needs_bar(_: impl Bar) {}
| ^^^ required by this bound in `needs_bar`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.