Skip to content

Rollup of 6 pull requests #115979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
08a997e
style-guide: Add section on bugs, and resolving bugs
joshtriplett Jul 5, 2023
8fbd78c
Detect cycle errors hidden by opaques during monomorphization
compiler-errors Sep 13, 2023
6f47a85
Use old parser if `custom_code_classes_in_docs` feature is not enabled
GuillaumeGomez Sep 18, 2023
0944860
fix mismatched symbols
cuishuang Sep 19, 2023
751ecde
rustc_target/riscv: Fix passing of transparent unions with only one n…
msizanoen1 Sep 3, 2023
4d4c13b
tests/ui/abi: Enable repr(transparent) union ABI tests on RISC-V
msizanoen1 Sep 19, 2023
494fdcd
Add new rustdoc-ui test for `custom_code_classes_in_docs` feature
GuillaumeGomez Sep 18, 2023
88b070a
Return early in `check_custom_code_classes` check if the feature is e…
GuillaumeGomez Sep 19, 2023
6bed1c6
Allow more characters in custom classes
GuillaumeGomez Sep 19, 2023
295ec09
Update tests for custom classes
GuillaumeGomez Sep 19, 2023
028c78c
explain mysterious addition in float minimum/maximum
RalfJung Sep 19, 2023
7a27acf
Rollup merge of #113383 - joshtriplett:style-bugs, r=compiler-errors
GuillaumeGomez Sep 19, 2023
edd7be5
Rollup merge of #115499 - msizanoen1:riscv-fix-transparent-union-abi,…
GuillaumeGomez Sep 19, 2023
0060db7
Rollup merge of #115801 - compiler-errors:async-cycle-mono, r=oli-obk
GuillaumeGomez Sep 19, 2023
52a0d13
Rollup merge of #115947 - GuillaumeGomez:custom_code_classes_in_docs-…
GuillaumeGomez Sep 19, 2023
c5f215a
Rollup merge of #115957 - cuishuang:master, r=GuillaumeGomez
GuillaumeGomez Sep 19, 2023
1b86218
Rollup merge of #115958 - RalfJung:mystery-plus, r=Mark-Simulacrum,no…
GuillaumeGomez Sep 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion compiler/rustc_traits/src/normalize_projection_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::query::Providers;
use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
use rustc_trait_selection::infer::InferCtxtBuilderExt;
use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt;
use rustc_trait_selection::traits::query::{
normalize::NormalizationResult, CanonicalProjectionGoal, NoSolution,
};
use rustc_trait_selection::traits::{self, ObligationCause, SelectionContext};
use rustc_trait_selection::traits::{
self, FulfillmentErrorCode, ObligationCause, SelectionContext,
};
use std::sync::atomic::Ordering;

pub(crate) fn provide(p: &mut Providers) {
Expand Down Expand Up @@ -40,6 +43,27 @@ fn normalize_projection_ty<'tcx>(
&mut obligations,
);
ocx.register_obligations(obligations);
// #112047: With projections and opaques, we are able to create opaques that
// are recursive (given some substitution of the opaque's type variables).
// In that case, we may only realize a cycle error when calling
// `normalize_erasing_regions` in mono.
if !ocx.infcx.next_trait_solver() {
let errors = ocx.select_where_possible();
if !errors.is_empty() {
// Rustdoc may attempt to normalize type alias types which are not
// well-formed. Rustdoc also normalizes types that are just not
// well-formed, since we don't do as much HIR analysis (checking
// that impl vars are constrained by the signature, for example).
if !tcx.sess.opts.actually_rustdoc {
for error in &errors {
if let FulfillmentErrorCode::CodeCycle(cycle) = &error.code {
ocx.infcx.err_ctxt().report_overflow_obligation_cycle(cycle);
}
}
}
return Err(NoSolution);
}
}
// FIXME(associated_const_equality): All users of normalize_projection_ty expected
// a type, but there is the possibility it could've been a const now. Maybe change
// it to a Term later?
Expand Down
38 changes: 38 additions & 0 deletions tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// edition: 2021
// build-fail
//~^^ ERROR overflow evaluating the requirement `<A as Second>::{opaque#0} == _`

#![feature(async_fn_in_trait)]

fn main() {
let _ = async {
A.first().await.second().await;
};
}

pub trait First {
type Second: Second;
async fn first(self) -> Self::Second;
}

struct A;

impl First for A {
type Second = A;
async fn first(self) -> Self::Second {
A
}
}

pub trait Second {
async fn second(self);
}

impl<C> Second for C
where
C: First,
{
async fn second(self) {
self.first().await.second().await;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
error[E0275]: overflow evaluating the requirement `<A as Second>::{opaque#0} == _`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0275`.
29 changes: 29 additions & 0 deletions tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// edition: 2021
// build-fail
//~^^ ERROR overflow evaluating the requirement `<() as Recur>::Recur == _`

#![feature(impl_trait_in_assoc_type)]

use core::future::Future;

trait Recur {
type Recur: Future<Output = ()>;

fn recur(self) -> Self::Recur;
}

async fn recur(t: impl Recur) {
t.recur().await;
}

impl Recur for () {
type Recur = impl Future<Output = ()>;

fn recur(self) -> Self::Recur {
async move { recur(self).await; }
}
}

fn main() {
recur(());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
error[E0275]: overflow evaluating the requirement `<() as Recur>::Recur == _`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0275`.
40 changes: 40 additions & 0 deletions tests/ui/type-alias-impl-trait/mututally-recursive-overflow.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// edition: 2021
// build-fail
//~^^ ERROR overflow evaluating the requirement `<() as B>::Assoc == _`

#![feature(rustc_attrs)]
#![feature(impl_trait_in_assoc_type)]

#[rustc_coinductive]
trait A {
type Assoc;

fn test() -> Self::Assoc;
}

#[rustc_coinductive]
trait B {
type Assoc;

fn test() -> Self::Assoc;
}

impl<T: A> B for T {
type Assoc = impl Sized;

fn test() -> <Self as B>::Assoc {
<T as A>::test()
}
}

fn main() {
<() as A>::test();
}

impl<T: B> A for T {
type Assoc = impl Sized;

fn test() -> <Self as A>::Assoc {
<T as B>::test()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
error[E0275]: overflow evaluating the requirement `<() as B>::Assoc == _`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0275`.