From 60c5b73b6da149f5365f526d5d213e6cad94cd39 Mon Sep 17 00:00:00 2001 From: beetrees Date: Sat, 18 May 2024 16:25:55 +0100 Subject: [PATCH 1/4] Add `#[inline]` to float `Debug` fallback used by `cfg(no_fp_fmt_parse)` (cherry picked from commit 827711d0879dabfc9df4cb6a76d2925391e61423) --- library/core/src/fmt/nofloat.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/core/src/fmt/nofloat.rs b/library/core/src/fmt/nofloat.rs index a36e7efcd95c7..6b07236f1da12 100644 --- a/library/core/src/fmt/nofloat.rs +++ b/library/core/src/fmt/nofloat.rs @@ -4,6 +4,7 @@ macro_rules! floating { ($ty:ident) => { #[stable(feature = "rust1", since = "1.0.0")] impl Debug for $ty { + #[inline] fn fmt(&self, _fmt: &mut Formatter<'_>) -> Result { panic!("floating point support is turned off"); } From 66bac3a967650401f4ff2b5b320f69cf430b23b2 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 11 Apr 2024 14:23:25 -0400 Subject: [PATCH 2/4] Add v0 symbol mangling for `f16` and `f128` As discussed at , use the crate encoding to represent new primitives. (cherry picked from commit 809b84edba988408071630b1e89a8c06be07aeed) --- compiler/rustc_symbol_mangling/src/v0.rs | 5 ++--- src/doc/rustc/src/symbol-mangling/v0.md | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index 58b67c77a6150..ada2f54a19a94 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -318,11 +318,10 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> { ty::Uint(UintTy::U64) => "y", ty::Uint(UintTy::U128) => "o", ty::Uint(UintTy::Usize) => "j", - // FIXME(f16_f128): update these once `rustc-demangle` supports the new types - ty::Float(FloatTy::F16) => unimplemented!("f16_f128"), + ty::Float(FloatTy::F16) => "C3f16", ty::Float(FloatTy::F32) => "f", ty::Float(FloatTy::F64) => "d", - ty::Float(FloatTy::F128) => unimplemented!("f16_f128"), + ty::Float(FloatTy::F128) => "C4f128", ty::Never => "z", // Placeholders (should be demangled as `_`). diff --git a/src/doc/rustc/src/symbol-mangling/v0.md b/src/doc/rustc/src/symbol-mangling/v0.md index 61f747fac837c..763694a9fdac8 100644 --- a/src/doc/rustc/src/symbol-mangling/v0.md +++ b/src/doc/rustc/src/symbol-mangling/v0.md @@ -739,6 +739,8 @@ The type encodings based on the initial tag character are: * `z` — `!` * `p` — [placeholder] `_` +Remaining primitives are encoded as a crate production, e.g. `C4f128`. + * `A` — An [array][reference-array] `[T; N]`. > array-type → `A` *[type]* *[const]* From 7e941a7c10fed496749ca20ca5af61791389474f Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 17 May 2024 11:14:36 -0400 Subject: [PATCH 3/4] Only make GAT ambiguous in match_projection_projections considering shallow resolvability (cherry picked from commit fa829feb2f7a3fee5890f3acf57b66029b123d18) --- .../src/traits/select/mod.rs | 12 +++++++++++- .../guide-inference-in-gat-arg-deeper.rs | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/ui/generic-associated-types/guide-inference-in-gat-arg-deeper.rs diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index fc12fed353738..49102e19a6f05 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -1777,9 +1777,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // If this type is a GAT, and of the GAT args resolve to something new, // that means that we must have newly inferred something about the GAT. // We should give up in that case. + // FIXME(generic-associated-types): This only detects one layer of inference, + // which is probably not what we actually want, but fixing it causes some ambiguity: + // . if !generics.params.is_empty() && obligation.predicate.args[generics.parent_count..].iter().any(|&p| { - p.has_non_region_infer() && self.infcx.resolve_vars_if_possible(p) != p + p.has_non_region_infer() + && match p.unpack() { + ty::GenericArgKind::Const(ct) => { + self.infcx.shallow_resolve_const(ct) != ct + } + ty::GenericArgKind::Type(ty) => self.infcx.shallow_resolve(ty) != ty, + ty::GenericArgKind::Lifetime(_) => false, + } }) { ProjectionMatchesProjection::Ambiguous diff --git a/tests/ui/generic-associated-types/guide-inference-in-gat-arg-deeper.rs b/tests/ui/generic-associated-types/guide-inference-in-gat-arg-deeper.rs new file mode 100644 index 0000000000000..96a0f2f40bf49 --- /dev/null +++ b/tests/ui/generic-associated-types/guide-inference-in-gat-arg-deeper.rs @@ -0,0 +1,19 @@ +// Fix for . +//@ check-pass + +trait Tr { + type Gat; +} + +struct W(T); + +fn foo() where for<'a> &'a T: Tr> = i32> { + let x: <&T as Tr>::Gat> = 1i32; + // Previously, `match_projection_projections` only checked that + // `shallow_resolve(W) = W`. This won't prevent *all* inference guidance + // from projection predicates in the environment, just ones that guide the + // outermost type of each GAT constructor. This is definitely wrong, but there is + // code that relies on it in the wild :/ +} + +fn main() {} From 16f4a2b2f96967d6f5c5512d5cc561a066883546 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sun, 19 May 2024 18:24:30 +0200 Subject: [PATCH 4/4] Update to LLVM 18.1.6 (cherry picked from commit e57f9ac3a04848da107047238d33528956121e03) --- .gitmodules | 2 +- src/llvm-project | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 802d61eea293b..75faaba71517b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -33,7 +33,7 @@ [submodule "src/llvm-project"] path = src/llvm-project url = https://github.com/rust-lang/llvm-project.git - branch = rustc/18.0-2024-02-13 + branch = rustc/18.1-2024-05-19 shallow = true [submodule "src/doc/embedded-book"] path = src/doc/embedded-book diff --git a/src/llvm-project b/src/llvm-project index 5399a24c66cb6..b31c30a9bb4db 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 5399a24c66cb6164cf32280e7d300488c90d5765 +Subproject commit b31c30a9bb4dbbd13c359d0e2bea7f65d20adf3f