From c37afcd323eba42e671dcf3430cb61912e223be1 Mon Sep 17 00:00:00 2001 From: Andy Wang Date: Thu, 22 Jun 2023 18:48:29 +0200 Subject: [PATCH 01/18] Enable zlib in LLVM on aarch64-apple-darwin --- src/bootstrap/llvm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/llvm.rs b/src/bootstrap/llvm.rs index 4752b1f7ea1e4..2cf8b22d02cce 100644 --- a/src/bootstrap/llvm.rs +++ b/src/bootstrap/llvm.rs @@ -352,7 +352,7 @@ impl Step for Llvm { // Disable zstd to avoid a dependency on libzstd.so. cfg.define("LLVM_ENABLE_ZSTD", "OFF"); - if target != "aarch64-apple-darwin" && !target.contains("windows") { + if !target.contains("windows") { cfg.define("LLVM_ENABLE_ZLIB", "ON"); } else { cfg.define("LLVM_ENABLE_ZLIB", "OFF"); From d43131b5c822f0b43e87d08aed069103c796a58e Mon Sep 17 00:00:00 2001 From: Andy Wang Date: Sat, 24 Jun 2023 19:37:00 +0200 Subject: [PATCH 02/18] Bump download-ci-llvm-stamp --- src/bootstrap/download-ci-llvm-stamp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/download-ci-llvm-stamp b/src/bootstrap/download-ci-llvm-stamp index 4111b7cc0d3f9..120b3c9c4d28a 100644 --- a/src/bootstrap/download-ci-llvm-stamp +++ b/src/bootstrap/download-ci-llvm-stamp @@ -1,4 +1,4 @@ Change this file to make users of the `download-ci-llvm` configuration download a new version of LLVM from CI, even if the LLVM submodule hasn’t changed. -Last change is for: https://github.com/rust-lang/rust/pull/96971 +Last change is for: https://github.com/rust-lang/rust/pull/112931 From 181d7b463ba690741075edd04d5cf74e037b8e23 Mon Sep 17 00:00:00 2001 From: David Wood Date: Thu, 29 Jun 2023 11:15:45 +0100 Subject: [PATCH 03/18] tests: unset `RUSTC_LOG_COLOR` Setting `RUSTC_LOG_COLOR=always` is sometimes useful if tools that one pipes `RUSTC_LOG` into support coloured output, but it makes this test fail. Signed-off-by: David Wood --- tests/ui/consts/const_in_pattern/issue-73431.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ui/consts/const_in_pattern/issue-73431.rs b/tests/ui/consts/const_in_pattern/issue-73431.rs index fa18a3af1b09f..835f502b40730 100644 --- a/tests/ui/consts/const_in_pattern/issue-73431.rs +++ b/tests/ui/consts/const_in_pattern/issue-73431.rs @@ -1,4 +1,5 @@ // run-pass +// unset-rustc-env:RUSTC_LOG_COLOR // Regression test for https://github.com/rust-lang/rust/issues/73431. From f88024627b80f07b175441eae52cf009702139de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 30 Jun 2023 00:08:38 +0200 Subject: [PATCH 04/18] CI: include workflow name in concurrency group Currently, this won't change anything, because we only have one relevant workflow (`CI`), but for future proofing we should probably include the workflow name in the concurrency group. --- .github/workflows/ci.yml | 2 +- src/ci/github-actions/ci.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff62e1ded61d0..c6af0c2ba742c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ defaults: run: shell: bash concurrency: - group: "${{ ((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.sha) || github.ref }}" + group: "${{ github.workflow }}-${{ ((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.sha) || github.ref }}" cancel-in-progress: true jobs: pr: diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml index cb12042c11739..538c503111da8 100644 --- a/src/ci/github-actions/ci.yml +++ b/src/ci/github-actions/ci.yml @@ -302,7 +302,7 @@ concurrency: # For a given workflow, if we push to the same branch, cancel all previous builds on that branch. # We add an exception for try builds (try branch) and unrolled rollup builds (try-perf), which # are all triggered on the same branch, but which should be able to run concurrently. - group: ${{ ((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.sha) || github.ref }} + group: ${{ github.workflow }}-${{ ((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.sha) || github.ref }} cancel-in-progress: true jobs: From 142075a9fb86e19de36a4583c1bdfed969cca236 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 4 Jul 2023 16:29:05 +1000 Subject: [PATCH 05/18] Make `UsageMap::get_user_items` infallible. It's nicer this way. --- compiler/rustc_monomorphize/src/collector.rs | 4 +-- .../rustc_monomorphize/src/partitioning.rs | 28 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 4a5953c11492c..f6d5f555e4147 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -231,8 +231,8 @@ impl<'tcx> UsageMap<'tcx> { assert!(self.used_map.insert(user_item, used_items).is_none()); } - pub fn get_user_items(&self, item: MonoItem<'tcx>) -> Option<&[MonoItem<'tcx>]> { - self.user_map.get(&item).map(|items| items.as_slice()) + pub fn get_user_items(&self, item: MonoItem<'tcx>) -> &[MonoItem<'tcx>] { + self.user_map.get(&item).map(|items| items.as_slice()).unwrap_or(&[]) } /// Internally iterate over all inlined items used by `item`. diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index e663f4486f7fe..14d5e0686383b 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -495,20 +495,20 @@ fn internalize_symbols<'tcx>( if !single_codegen_unit { debug_assert_eq!(mono_item_placements[item], home_cgu); - if let Some(user_items) = cx.usage_map.get_user_items(*item) { - if user_items - .iter() - .filter_map(|user_item| { - // Some user mono items might not have been - // instantiated. We can safely ignore those. - mono_item_placements.get(user_item) - }) - .any(|placement| *placement != home_cgu) - { - // Found a user from another CGU, so skip to the next item - // without marking this one as internal. - continue; - } + if cx + .usage_map + .get_user_items(*item) + .iter() + .filter_map(|user_item| { + // Some user mono items might not have been + // instantiated. We can safely ignore those. + mono_item_placements.get(user_item) + }) + .any(|placement| *placement != home_cgu) + { + // Found a user from another CGU, so skip to the next item + // without marking this one as internal. + continue; } } From 22d4c798ece4f0c9c839325fe279140565a08957 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 5 Jul 2023 07:30:43 +1000 Subject: [PATCH 06/18] Use `iter()` instead of `iter_mut()` in one place. --- compiler/rustc_monomorphize/src/partitioning.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index 14d5e0686383b..4abdce52088cf 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -460,7 +460,7 @@ fn internalize_symbols<'tcx>( let single_codegen_unit = codegen_units.len() == 1; if !single_codegen_unit { - for cgu in codegen_units.iter_mut() { + for cgu in codegen_units.iter() { for item in cgu.items().keys() { // If there is more than one codegen unit, we need to keep track // in which codegen units each monomorphization is placed. From b51169c178a535c8533d21be362c3c4e4d4f0cb7 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 5 Jul 2023 10:03:42 +1000 Subject: [PATCH 07/18] Remove the field name from `MonoItemPlacement::SingleCgu`. It's needless verbosity. --- compiler/rustc_monomorphize/src/partitioning.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index 4abdce52088cf..fc4b22285ba71 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -452,7 +452,7 @@ fn internalize_symbols<'tcx>( /// used to keep track of that. #[derive(Clone, PartialEq, Eq, Debug)] enum MonoItemPlacement { - SingleCgu { cgu_name: Symbol }, + SingleCgu(Symbol), MultipleCgus, } @@ -468,13 +468,13 @@ fn internalize_symbols<'tcx>( Entry::Occupied(e) => { let placement = e.into_mut(); debug_assert!(match *placement { - MonoItemPlacement::SingleCgu { cgu_name } => cgu_name != cgu.name(), + MonoItemPlacement::SingleCgu(cgu_name) => cgu_name != cgu.name(), MonoItemPlacement::MultipleCgus => true, }); *placement = MonoItemPlacement::MultipleCgus; } Entry::Vacant(e) => { - e.insert(MonoItemPlacement::SingleCgu { cgu_name: cgu.name() }); + e.insert(MonoItemPlacement::SingleCgu(cgu.name())); } } } @@ -484,7 +484,7 @@ fn internalize_symbols<'tcx>( // For each internalization candidates in each codegen unit, check if it is // used from outside its defining codegen unit. for cgu in codegen_units { - let home_cgu = MonoItemPlacement::SingleCgu { cgu_name: cgu.name() }; + let home_cgu = MonoItemPlacement::SingleCgu(cgu.name()); for (item, linkage_and_visibility) in cgu.items_mut() { if !internalization_candidates.contains(item) { From 3078e4d804f8ed059e3224a2b6f391928f5259e3 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 6 Jul 2023 11:07:22 +1000 Subject: [PATCH 08/18] Minor comment fix. --- compiler/rustc_monomorphize/src/partitioning.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index fc4b22285ba71..f9e73bcb6824b 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -421,9 +421,9 @@ fn merge_codegen_units<'tcx>( // zero-padded suffixes, which means they are automatically sorted by // names. The numeric suffix width depends on the number of CGUs, which // is always greater than zero: - // - [1,9] CGUS: `0`, `1`, `2`, ... - // - [10,99] CGUS: `00`, `01`, `02`, ... - // - [100,999] CGUS: `000`, `001`, `002`, ... + // - [1,9] CGUs: `0`, `1`, `2`, ... + // - [10,99] CGUs: `00`, `01`, `02`, ... + // - [100,999] CGUs: `000`, `001`, `002`, ... // - etc. // // If we didn't zero-pad the sorted-by-name order would be `XYZ-cgu.0`, From 906d2b172c936674b8fbf727c556e5b41df86ef1 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 6 Jul 2023 05:39:39 +0000 Subject: [PATCH 09/18] Structurally normalize again for byte string lit pat checking --- compiler/rustc_hir_typeck/src/pat.rs | 4 ++-- tests/ui/traits/new-solver/slice-match-byte-lit.rs | 2 +- .../ui/traits/new-solver/slice-match-byte-lit.stderr | 11 ----------- 3 files changed, 3 insertions(+), 14 deletions(-) delete mode 100644 tests/ui/traits/new-solver/slice-match-byte-lit.stderr diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 96d03b471252f..275e35d4ba538 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -394,8 +394,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut pat_ty = ty; if let hir::ExprKind::Lit(Spanned { node: ast::LitKind::ByteStr(..), .. }) = lt.kind { let expected = self.structurally_resolve_type(span, expected); - if let ty::Ref(_, inner_ty, _) = expected.kind() - && matches!(inner_ty.kind(), ty::Slice(_)) + if let ty::Ref(_, inner_ty, _) = *expected.kind() + && self.try_structurally_resolve_type(span, inner_ty).is_slice() { let tcx = self.tcx; trace!(?lt.hir_id.local_id, "polymorphic byte string lit"); diff --git a/tests/ui/traits/new-solver/slice-match-byte-lit.rs b/tests/ui/traits/new-solver/slice-match-byte-lit.rs index 5f9c0df645036..4f848062595da 100644 --- a/tests/ui/traits/new-solver/slice-match-byte-lit.rs +++ b/tests/ui/traits/new-solver/slice-match-byte-lit.rs @@ -1,5 +1,5 @@ // compile-flags: -Ztrait-solver=next -// known-bug: rust-lang/trait-system-refactor-initiative#38 +// check-pass fn test(s: &[u8]) { match &s[0..3] { diff --git a/tests/ui/traits/new-solver/slice-match-byte-lit.stderr b/tests/ui/traits/new-solver/slice-match-byte-lit.stderr deleted file mode 100644 index cd48a6d184339..0000000000000 --- a/tests/ui/traits/new-solver/slice-match-byte-lit.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0271]: type mismatch resolving `[u8; 3] <: <[u8] as Index>>::Output` - --> $DIR/slice-match-byte-lit.rs:6:9 - | -LL | match &s[0..3] { - | -------- this expression has type `&<[u8] as Index>>::Output` -LL | b"uwu" => {} - | ^^^^^^ types differ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0271`. From 284df9fc34ffb5d1e746c31902cbd1982144b45b Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 28 Jun 2023 11:31:28 -0300 Subject: [PATCH 10/18] Wrap SMIR bool and tuple into a Rigid variant --- compiler/rustc_smir/src/rustc_smir/mod.rs | 11 ++++++----- compiler/rustc_smir/src/stable_mir/ty.rs | 4 ++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index 874e34bef60f0..76cb838661817 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -7,7 +7,8 @@ //! //! For now, we are developing everything inside `rustc`, thus, we keep this module private. -use crate::stable_mir::{self, ty::TyKind, Context}; +use crate::stable_mir::ty::{RigidTy, TyKind}; +use crate::stable_mir::{self, Context}; use rustc_middle::mir; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE}; @@ -69,7 +70,7 @@ pub struct Tables<'tcx> { impl<'tcx> Tables<'tcx> { fn rustc_ty_to_ty(&mut self, ty: Ty<'tcx>) -> TyKind { match ty.kind() { - ty::Bool => TyKind::Bool, + ty::Bool => TyKind::RigidTy(RigidTy::Bool), ty::Char => todo!(), ty::Int(_) => todo!(), ty::Uint(_) => todo!(), @@ -90,9 +91,9 @@ impl<'tcx> Tables<'tcx> { ty::GeneratorWitness(_) => todo!(), ty::GeneratorWitnessMIR(_, _) => todo!(), ty::Never => todo!(), - ty::Tuple(fields) => { - TyKind::Tuple(fields.iter().map(|ty| self.intern_ty(ty)).collect()) - } + ty::Tuple(fields) => TyKind::RigidTy(RigidTy::Tuple( + fields.iter().map(|ty| self.intern_ty(ty)).collect(), + )), ty::Alias(_, _) => todo!(), ty::Param(_) => todo!(), ty::Bound(_, _) => todo!(), diff --git a/compiler/rustc_smir/src/stable_mir/ty.rs b/compiler/rustc_smir/src/stable_mir/ty.rs index f27801b0f6cae..d9d858ebe0845 100644 --- a/compiler/rustc_smir/src/stable_mir/ty.rs +++ b/compiler/rustc_smir/src/stable_mir/ty.rs @@ -10,6 +10,10 @@ impl Ty { } pub enum TyKind { + RigidTy(RigidTy), +} + +pub enum RigidTy { Bool, Tuple(Vec), } From 010ee7b0e09c0b1eb6ba7bc745693bd19c9d37e4 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 4 Jul 2023 17:36:26 +0000 Subject: [PATCH 11/18] Remove an AFIT test that isn't an AFIT test --- .../in-trait/async-associated-types2.rs | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 tests/ui/async-await/in-trait/async-associated-types2.rs diff --git a/tests/ui/async-await/in-trait/async-associated-types2.rs b/tests/ui/async-await/in-trait/async-associated-types2.rs deleted file mode 100644 index b889f616a0311..0000000000000 --- a/tests/ui/async-await/in-trait/async-associated-types2.rs +++ /dev/null @@ -1,30 +0,0 @@ -// check-pass -// edition: 2021 -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next - -#![feature(async_fn_in_trait)] -#![feature(impl_trait_in_assoc_type)] -#![allow(incomplete_features)] - -use std::future::Future; - -trait MyTrait { - type Fut<'a>: Future - where - Self: 'a; - - fn foo<'a>(&'a self) -> Self::Fut<'a>; -} - -impl MyTrait for i32 { - type Fut<'a> = impl Future + 'a - where - Self: 'a; - - fn foo<'a>(&'a self) -> Self::Fut<'a> { - async { *self } - } -} - -fn main() {} From 713f9bb5d1d1d6cb22bc668e326d1c0f0f4f815a Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 4 Jul 2023 17:54:23 +0000 Subject: [PATCH 12/18] Mark more hanging new-solver tests --- tests/ui/issues/issue-67552.rs | 1 + tests/ui/issues/issue-67552.stderr | 4 ++-- tests/ui/recursion/issue-95134.rs | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/ui/issues/issue-67552.rs b/tests/ui/issues/issue-67552.rs index ec1997ccd5d66..7336b873dd643 100644 --- a/tests/ui/issues/issue-67552.rs +++ b/tests/ui/issues/issue-67552.rs @@ -1,6 +1,7 @@ // build-fail // compile-flags: -Copt-level=0 // normalize-stderr-test: ".nll/" -> "/" +// ignore-compare-mode-next-solver (hangs) fn main() { rec(Empty); diff --git a/tests/ui/issues/issue-67552.stderr b/tests/ui/issues/issue-67552.stderr index 4746f918bf8dd..f93ed67dab244 100644 --- a/tests/ui/issues/issue-67552.stderr +++ b/tests/ui/issues/issue-67552.stderr @@ -1,11 +1,11 @@ error: reached the recursion limit while instantiating `rec::<&mut &mut &mut &mut &mut ...>` - --> $DIR/issue-67552.rs:29:9 + --> $DIR/issue-67552.rs:30:9 | LL | rec(identity(&mut it)) | ^^^^^^^^^^^^^^^^^^^^^^ | note: `rec` defined here - --> $DIR/issue-67552.rs:22:1 + --> $DIR/issue-67552.rs:23:1 | LL | / fn rec(mut it: T) LL | | where diff --git a/tests/ui/recursion/issue-95134.rs b/tests/ui/recursion/issue-95134.rs index 2f1cffa2fa907..7ee31d85c2b12 100644 --- a/tests/ui/recursion/issue-95134.rs +++ b/tests/ui/recursion/issue-95134.rs @@ -3,6 +3,7 @@ // compile-flags: -Copt-level=0 // dont-check-failure-status // dont-check-compiler-stderr +// ignore-compare-mode-next-solver (hangs) pub fn encode_num(n: u32, mut writer: Writer) -> Result<(), Writer::Error> { if n > 15 { From f55b046931cfa1b281375ff8ec4e590d8386f0c4 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 4 Jul 2023 18:49:13 +0000 Subject: [PATCH 13/18] Normalize opaques during codegen in new solver --- .../src/solve/normalize.rs | 4 +-- .../param-env-region-infer.current.stderr | 2 +- .../param-env-region-infer.next.stderr | 29 +++++++++++++++++++ tests/ui/dyn-star/param-env-region-infer.rs | 6 ++-- tests/ui/impl-trait/reveal-during-codegen.rs | 11 +++++++ 5 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 tests/ui/dyn-star/param-env-region-infer.next.stderr create mode 100644 tests/ui/impl-trait/reveal-during-codegen.rs diff --git a/compiler/rustc_trait_selection/src/solve/normalize.rs b/compiler/rustc_trait_selection/src/solve/normalize.rs index c0ee1a576e5fb..c388850d831e2 100644 --- a/compiler/rustc_trait_selection/src/solve/normalize.rs +++ b/compiler/rustc_trait_selection/src/solve/normalize.rs @@ -167,9 +167,7 @@ impl<'tcx> FallibleTypeFolder> for NormalizationFolder<'_, 'tcx> { // We don't normalize opaque types unless we have // `Reveal::All`, even if we're in the defining scope. let data = match *ty.kind() { - ty::Alias(kind, alias_ty) if kind != ty::Opaque || reveal == Reveal::UserFacing => { - alias_ty - } + ty::Alias(kind, alias_ty) if kind != ty::Opaque || reveal == Reveal::All => alias_ty, _ => return ty.try_super_fold_with(self), }; diff --git a/tests/ui/dyn-star/param-env-region-infer.current.stderr b/tests/ui/dyn-star/param-env-region-infer.current.stderr index c606a50c8a9cb..902053ecfef62 100644 --- a/tests/ui/dyn-star/param-env-region-infer.current.stderr +++ b/tests/ui/dyn-star/param-env-region-infer.current.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/param-env-region-infer.rs:16:10 + --> $DIR/param-env-region-infer.rs:18:10 | LL | t as _ | ^ cannot infer type diff --git a/tests/ui/dyn-star/param-env-region-infer.next.stderr b/tests/ui/dyn-star/param-env-region-infer.next.stderr new file mode 100644 index 0000000000000..dd724a6590829 --- /dev/null +++ b/tests/ui/dyn-star/param-env-region-infer.next.stderr @@ -0,0 +1,29 @@ +error[E0391]: cycle detected when computing type of `make_dyn_star::{opaque#0}` + --> $DIR/param-env-region-infer.rs:16:60 + | +LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...which requires type-checking `make_dyn_star`... + --> $DIR/param-env-region-infer.rs:16:1 + | +LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which requires computing layout of `make_dyn_star::{opaque#0}`... + = note: ...which requires normalizing `make_dyn_star::{opaque#0}`... + = note: ...which again requires computing type of `make_dyn_star::{opaque#0}`, completing the cycle +note: cycle used when checking item types in top-level module + --> $DIR/param-env-region-infer.rs:10:1 + | +LL | / #![feature(dyn_star, pointer_like_trait)] +LL | | #![allow(incomplete_features)] +LL | | +LL | | use std::fmt::Debug; +... | +LL | | +LL | | fn main() {} + | |____________^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/dyn-star/param-env-region-infer.rs b/tests/ui/dyn-star/param-env-region-infer.rs index 9c337e4a89bd3..537473abc3a5b 100644 --- a/tests/ui/dyn-star/param-env-region-infer.rs +++ b/tests/ui/dyn-star/param-env-region-infer.rs @@ -1,6 +1,7 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next -//[next] check-pass +// Need `-Zdeduplicate-diagnostics=yes` because the number of cycle errors +// emitted is for some horrible reason platform-specific. +//[next] compile-flags: -Ztrait-solver=next -Zdeduplicate-diagnostics=yes // incremental // checks that we don't ICE if there are region inference variables in the environment @@ -13,6 +14,7 @@ use std::fmt::Debug; use std::marker::PointerLike; fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { + //[next]~^ ERROR cycle detected when computing t as _ //[current]~^ ERROR type annotations needed } diff --git a/tests/ui/impl-trait/reveal-during-codegen.rs b/tests/ui/impl-trait/reveal-during-codegen.rs new file mode 100644 index 0000000000000..11463772eb38c --- /dev/null +++ b/tests/ui/impl-trait/reveal-during-codegen.rs @@ -0,0 +1,11 @@ +// build-pass +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + +fn test() -> Option { + Some("") +} + +fn main() { + test(); +} From 61adcaf87b605f1b2d73f62cda813329cb448807 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 5 Jul 2023 18:50:13 -0300 Subject: [PATCH 14/18] Add rustc_ty_to_ty basic tests --- compiler/rustc_smir/src/stable_mir/ty.rs | 2 ++ tests/ui-fulldeps/stable-mir/crate-info.rs | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/compiler/rustc_smir/src/stable_mir/ty.rs b/compiler/rustc_smir/src/stable_mir/ty.rs index d9d858ebe0845..86c30370ff5af 100644 --- a/compiler/rustc_smir/src/stable_mir/ty.rs +++ b/compiler/rustc_smir/src/stable_mir/ty.rs @@ -9,10 +9,12 @@ impl Ty { } } +#[derive(Clone, Debug)] pub enum TyKind { RigidTy(RigidTy), } +#[derive(Clone, Debug)] pub enum RigidTy { Bool, Tuple(Vec), diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index a3db2e9ef24c4..7cbb7898f2cae 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -7,6 +7,7 @@ // edition: 2021 #![feature(rustc_private)] +#![feature(assert_matches)] extern crate rustc_driver; extern crate rustc_hir; @@ -19,6 +20,7 @@ use rustc_hir::def::DefKind; use rustc_interface::{interface, Queries}; use rustc_middle::ty::TyCtxt; use rustc_smir::{rustc_internal, stable_mir}; +use std::assert_matches::assert_matches; use std::io::Write; const CRATE_NAME: &str = "input"; @@ -63,6 +65,18 @@ fn test_stable_mir(tcx: TyCtxt<'_>) { other => panic!("{other:?}"), } + let types = get_item(tcx, &items, (DefKind::Fn, "types")).unwrap(); + let body = types.body(); + assert_eq!(body.locals.len(), 2); + assert_matches!( + body.locals[0].kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool) + ); + assert_matches!( + body.locals[1].kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool) + ); + let drop = get_item(tcx, &items, (DefKind::Fn, "drop")).unwrap(); let body = drop.body(); assert_eq!(body.blocks.len(), 2); @@ -153,6 +167,10 @@ fn generate_input(path: &str) -> std::io::Result<()> { x_64.wrapping_add(y_64) }} + pub fn types(b: bool) -> bool {{ + b + }} + pub fn drop(_: String) {{}} pub fn assert(x: i32) -> i32 {{ From 73e816e37ce028274d603ab33d8717d35dc9e914 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 5 Jul 2023 19:01:11 -0300 Subject: [PATCH 15/18] Add Char ty to SMIR --- compiler/rustc_smir/src/rustc_smir/mod.rs | 2 +- compiler/rustc_smir/src/stable_mir/ty.rs | 1 + tests/ui-fulldeps/stable-mir/crate-info.rs | 8 ++++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index 76cb838661817..3a66eefdb7978 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -71,7 +71,7 @@ impl<'tcx> Tables<'tcx> { fn rustc_ty_to_ty(&mut self, ty: Ty<'tcx>) -> TyKind { match ty.kind() { ty::Bool => TyKind::RigidTy(RigidTy::Bool), - ty::Char => todo!(), + ty::Char => TyKind::RigidTy(RigidTy::Char), ty::Int(_) => todo!(), ty::Uint(_) => todo!(), ty::Float(_) => todo!(), diff --git a/compiler/rustc_smir/src/stable_mir/ty.rs b/compiler/rustc_smir/src/stable_mir/ty.rs index 86c30370ff5af..936fb0d3e4f82 100644 --- a/compiler/rustc_smir/src/stable_mir/ty.rs +++ b/compiler/rustc_smir/src/stable_mir/ty.rs @@ -17,5 +17,6 @@ pub enum TyKind { #[derive(Clone, Debug)] pub enum RigidTy { Bool, + Char, Tuple(Vec), } diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index 7cbb7898f2cae..e3b4f6e7df920 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -67,7 +67,7 @@ fn test_stable_mir(tcx: TyCtxt<'_>) { let types = get_item(tcx, &items, (DefKind::Fn, "types")).unwrap(); let body = types.body(); - assert_eq!(body.locals.len(), 2); + assert_eq!(body.locals.len(), 3); assert_matches!( body.locals[0].kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool) @@ -76,6 +76,10 @@ fn test_stable_mir(tcx: TyCtxt<'_>) { body.locals[1].kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool) ); + assert_matches!( + body.locals[2].kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Char) + ); let drop = get_item(tcx, &items, (DefKind::Fn, "drop")).unwrap(); let body = drop.body(); @@ -167,7 +171,7 @@ fn generate_input(path: &str) -> std::io::Result<()> { x_64.wrapping_add(y_64) }} - pub fn types(b: bool) -> bool {{ + pub fn types(b: bool, _: char) -> bool {{ b }} From 458ead41d621a6aacdf0d27169a4aa9d1ff54f98 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 5 Jul 2023 19:06:49 -0300 Subject: [PATCH 16/18] Add Int ty to SMIR --- compiler/rustc_smir/src/rustc_smir/mod.rs | 11 +++++++++-- compiler/rustc_smir/src/stable_mir/ty.rs | 11 +++++++++++ tests/ui-fulldeps/stable-mir/crate-info.rs | 8 ++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index 3a66eefdb7978..d2b13c32cc2c8 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -7,7 +7,7 @@ //! //! For now, we are developing everything inside `rustc`, thus, we keep this module private. -use crate::stable_mir::ty::{RigidTy, TyKind}; +use crate::stable_mir::ty::{IntTy, RigidTy, TyKind}; use crate::stable_mir::{self, Context}; use rustc_middle::mir; use rustc_middle::ty::{self, Ty, TyCtxt}; @@ -72,7 +72,14 @@ impl<'tcx> Tables<'tcx> { match ty.kind() { ty::Bool => TyKind::RigidTy(RigidTy::Bool), ty::Char => TyKind::RigidTy(RigidTy::Char), - ty::Int(_) => todo!(), + ty::Int(int_ty) => match int_ty { + ty::IntTy::Isize => TyKind::RigidTy(RigidTy::Int(IntTy::Isize)), + ty::IntTy::I8 => TyKind::RigidTy(RigidTy::Int(IntTy::I8)), + ty::IntTy::I16 => TyKind::RigidTy(RigidTy::Int(IntTy::I16)), + ty::IntTy::I32 => TyKind::RigidTy(RigidTy::Int(IntTy::I32)), + ty::IntTy::I64 => TyKind::RigidTy(RigidTy::Int(IntTy::I64)), + ty::IntTy::I128 => TyKind::RigidTy(RigidTy::Int(IntTy::I128)), + }, ty::Uint(_) => todo!(), ty::Float(_) => todo!(), ty::Adt(_, _) => todo!(), diff --git a/compiler/rustc_smir/src/stable_mir/ty.rs b/compiler/rustc_smir/src/stable_mir/ty.rs index 936fb0d3e4f82..f31c078b4ab1d 100644 --- a/compiler/rustc_smir/src/stable_mir/ty.rs +++ b/compiler/rustc_smir/src/stable_mir/ty.rs @@ -18,5 +18,16 @@ pub enum TyKind { pub enum RigidTy { Bool, Char, + Int(IntTy), Tuple(Vec), } + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum IntTy { + Isize, + I8, + I16, + I32, + I64, + I128, +} diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index e3b4f6e7df920..8ac32d23c6f76 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -67,7 +67,7 @@ fn test_stable_mir(tcx: TyCtxt<'_>) { let types = get_item(tcx, &items, (DefKind::Fn, "types")).unwrap(); let body = types.body(); - assert_eq!(body.locals.len(), 3); + assert_eq!(body.locals.len(), 4); assert_matches!( body.locals[0].kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool) @@ -80,6 +80,10 @@ fn test_stable_mir(tcx: TyCtxt<'_>) { body.locals[2].kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Char) ); + assert_matches!( + body.locals[3].kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Int(stable_mir::ty::IntTy::I32)) + ); let drop = get_item(tcx, &items, (DefKind::Fn, "drop")).unwrap(); let body = drop.body(); @@ -171,7 +175,7 @@ fn generate_input(path: &str) -> std::io::Result<()> { x_64.wrapping_add(y_64) }} - pub fn types(b: bool, _: char) -> bool {{ + pub fn types(b: bool, _: char, _: i32) -> bool {{ b }} From 42eccffce3e950e95d9e965d4dd58ecb44633d55 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 5 Jul 2023 19:26:52 -0300 Subject: [PATCH 17/18] Add Uint ty to SMIR --- compiler/rustc_smir/src/rustc_smir/mod.rs | 11 +++++++++-- compiler/rustc_smir/src/stable_mir/ty.rs | 11 +++++++++++ tests/ui-fulldeps/stable-mir/crate-info.rs | 8 ++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index d2b13c32cc2c8..adce55d639f73 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -7,7 +7,7 @@ //! //! For now, we are developing everything inside `rustc`, thus, we keep this module private. -use crate::stable_mir::ty::{IntTy, RigidTy, TyKind}; +use crate::stable_mir::ty::{IntTy, RigidTy, TyKind, UintTy}; use crate::stable_mir::{self, Context}; use rustc_middle::mir; use rustc_middle::ty::{self, Ty, TyCtxt}; @@ -80,7 +80,14 @@ impl<'tcx> Tables<'tcx> { ty::IntTy::I64 => TyKind::RigidTy(RigidTy::Int(IntTy::I64)), ty::IntTy::I128 => TyKind::RigidTy(RigidTy::Int(IntTy::I128)), }, - ty::Uint(_) => todo!(), + ty::Uint(uint_ty) => match uint_ty { + ty::UintTy::Usize => TyKind::RigidTy(RigidTy::Uint(stable_mir::ty::UintTy::Usize)), + ty::UintTy::U8 => TyKind::RigidTy(RigidTy::Uint(UintTy::U8)), + ty::UintTy::U16 => TyKind::RigidTy(RigidTy::Uint(UintTy::U16)), + ty::UintTy::U32 => TyKind::RigidTy(RigidTy::Uint(UintTy::U32)), + ty::UintTy::U64 => TyKind::RigidTy(RigidTy::Uint(UintTy::U64)), + ty::UintTy::U128 => TyKind::RigidTy(RigidTy::Uint(UintTy::U128)), + }, ty::Float(_) => todo!(), ty::Adt(_, _) => todo!(), ty::Foreign(_) => todo!(), diff --git a/compiler/rustc_smir/src/stable_mir/ty.rs b/compiler/rustc_smir/src/stable_mir/ty.rs index f31c078b4ab1d..2db3bdb7af162 100644 --- a/compiler/rustc_smir/src/stable_mir/ty.rs +++ b/compiler/rustc_smir/src/stable_mir/ty.rs @@ -19,6 +19,7 @@ pub enum RigidTy { Bool, Char, Int(IntTy), + Uint(UintTy), Tuple(Vec), } @@ -31,3 +32,13 @@ pub enum IntTy { I64, I128, } + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum UintTy { + Usize, + U8, + U16, + U32, + U64, + U128, +} diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index 8ac32d23c6f76..29cc6e78d8874 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -67,7 +67,7 @@ fn test_stable_mir(tcx: TyCtxt<'_>) { let types = get_item(tcx, &items, (DefKind::Fn, "types")).unwrap(); let body = types.body(); - assert_eq!(body.locals.len(), 4); + assert_eq!(body.locals.len(), 5); assert_matches!( body.locals[0].kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool) @@ -84,6 +84,10 @@ fn test_stable_mir(tcx: TyCtxt<'_>) { body.locals[3].kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Int(stable_mir::ty::IntTy::I32)) ); + assert_matches!( + body.locals[4].kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Uint(stable_mir::ty::UintTy::U64)) + ); let drop = get_item(tcx, &items, (DefKind::Fn, "drop")).unwrap(); let body = drop.body(); @@ -175,7 +179,7 @@ fn generate_input(path: &str) -> std::io::Result<()> { x_64.wrapping_add(y_64) }} - pub fn types(b: bool, _: char, _: i32) -> bool {{ + pub fn types(b: bool, _: char, _: i32, _: u64) -> bool {{ b }} From 9ca51b92d4a056d22d3b3d22e54bbb29ed205a40 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 5 Jul 2023 19:30:24 -0300 Subject: [PATCH 18/18] Add Float ty to SMIR --- compiler/rustc_smir/src/rustc_smir/mod.rs | 9 ++++++--- compiler/rustc_smir/src/stable_mir/ty.rs | 7 +++++++ tests/ui-fulldeps/stable-mir/crate-info.rs | 10 ++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index adce55d639f73..85d5bb00c4e10 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -7,7 +7,7 @@ //! //! For now, we are developing everything inside `rustc`, thus, we keep this module private. -use crate::stable_mir::ty::{IntTy, RigidTy, TyKind, UintTy}; +use crate::stable_mir::ty::{FloatTy, IntTy, RigidTy, TyKind, UintTy}; use crate::stable_mir::{self, Context}; use rustc_middle::mir; use rustc_middle::ty::{self, Ty, TyCtxt}; @@ -81,14 +81,17 @@ impl<'tcx> Tables<'tcx> { ty::IntTy::I128 => TyKind::RigidTy(RigidTy::Int(IntTy::I128)), }, ty::Uint(uint_ty) => match uint_ty { - ty::UintTy::Usize => TyKind::RigidTy(RigidTy::Uint(stable_mir::ty::UintTy::Usize)), + ty::UintTy::Usize => TyKind::RigidTy(RigidTy::Uint(UintTy::Usize)), ty::UintTy::U8 => TyKind::RigidTy(RigidTy::Uint(UintTy::U8)), ty::UintTy::U16 => TyKind::RigidTy(RigidTy::Uint(UintTy::U16)), ty::UintTy::U32 => TyKind::RigidTy(RigidTy::Uint(UintTy::U32)), ty::UintTy::U64 => TyKind::RigidTy(RigidTy::Uint(UintTy::U64)), ty::UintTy::U128 => TyKind::RigidTy(RigidTy::Uint(UintTy::U128)), }, - ty::Float(_) => todo!(), + ty::Float(float_ty) => match float_ty { + ty::FloatTy::F32 => TyKind::RigidTy(RigidTy::Float(FloatTy::F32)), + ty::FloatTy::F64 => TyKind::RigidTy(RigidTy::Float(FloatTy::F64)), + }, ty::Adt(_, _) => todo!(), ty::Foreign(_) => todo!(), ty::Str => todo!(), diff --git a/compiler/rustc_smir/src/stable_mir/ty.rs b/compiler/rustc_smir/src/stable_mir/ty.rs index 2db3bdb7af162..3181af46e9cb3 100644 --- a/compiler/rustc_smir/src/stable_mir/ty.rs +++ b/compiler/rustc_smir/src/stable_mir/ty.rs @@ -20,6 +20,7 @@ pub enum RigidTy { Char, Int(IntTy), Uint(UintTy), + Float(FloatTy), Tuple(Vec), } @@ -42,3 +43,9 @@ pub enum UintTy { U64, U128, } + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum FloatTy { + F32, + F64, +} diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index 29cc6e78d8874..3c0d684a4d7a0 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -67,7 +67,7 @@ fn test_stable_mir(tcx: TyCtxt<'_>) { let types = get_item(tcx, &items, (DefKind::Fn, "types")).unwrap(); let body = types.body(); - assert_eq!(body.locals.len(), 5); + assert_eq!(body.locals.len(), 6); assert_matches!( body.locals[0].kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool) @@ -88,6 +88,12 @@ fn test_stable_mir(tcx: TyCtxt<'_>) { body.locals[4].kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Uint(stable_mir::ty::UintTy::U64)) ); + assert_matches!( + body.locals[5].kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Float( + stable_mir::ty::FloatTy::F64 + )) + ); let drop = get_item(tcx, &items, (DefKind::Fn, "drop")).unwrap(); let body = drop.body(); @@ -179,7 +185,7 @@ fn generate_input(path: &str) -> std::io::Result<()> { x_64.wrapping_add(y_64) }} - pub fn types(b: bool, _: char, _: i32, _: u64) -> bool {{ + pub fn types(b: bool, _: char, _: i32, _: u64, _: f64) -> bool {{ b }}