Skip to content

Rollup of 7 pull requests #113490

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

Closed
wants to merge 25 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
28f3986
use Const::eval instead of QueryNormalize in error reporting
compiler-errors Jun 24, 2023
30c61ee
std: edit [T]::swap docs
marcospb19 Jun 26, 2023
2c33dfe
Don't sort strings right after we just sorted by types
compiler-errors Jun 27, 2023
13fcd8d
Add release notes for 1.71.0
cuviper Jun 28, 2023
281e072
Remove target feature note
cuviper Jun 29, 2023
43f4fa4
Move the TypeId change to Compatibility Notes
cuviper Jun 29, 2023
a30f797
Add a release note about recursive panics
cuviper Jun 29, 2023
76a7772
resolve typerelative ctors to adt
ericmarkmartin Jun 30, 2023
7dfb9ed
add regression test
ericmarkmartin Jul 1, 2023
b9e991a
add thir-print test
ericmarkmartin Jul 1, 2023
7bb9de8
Use consistent formatting in Readme
atouchet Jul 2, 2023
07b1912
refactor
ericmarkmartin Jul 2, 2023
afccc44
add mir dump test
ericmarkmartin Jul 5, 2023
261c023
rename constants in mir dump test
ericmarkmartin Jul 5, 2023
0ba1e0f
Fix standalone build
celinval Jun 20, 2023
a6632f1
Implement Stable for AssertMessage
celinval Jun 20, 2023
633c022
Implement a few more rvalue translation to smir
celinval Jun 13, 2023
50b4d1f
Migrate GUI colors test to original CSS color format
GuillaumeGomez Jul 8, 2023
f521d93
Rollup merge of #112717 - celinval:stable-mir-rvalue-1, r=oli-obk
matthiaskrgr Jul 8, 2023
6e20345
Rollup merge of #113005 - compiler-errors:dont-query-normalize, r=cjg…
matthiaskrgr Jul 8, 2023
f98b417
Rollup merge of #113064 - marcospb19:add-note-in-vec-swap-docs, r=Mar…
matthiaskrgr Jul 8, 2023
a0d91e8
Rollup merge of #113138 - cuviper:relnotes-1.71.0, r=Mark-Simulacrum
matthiaskrgr Jul 8, 2023
8c4a459
Rollup merge of #113217 - ericmarkmartin:lower-type-relative-ctor-to-…
matthiaskrgr Jul 8, 2023
5959038
Rollup merge of #113254 - atouchet:rd3, r=Mark-Simulacrum
matthiaskrgr Jul 8, 2023
34c6506
Rollup merge of #113482 - GuillaumeGomez:migrate-gui-test-color-20, r…
matthiaskrgr Jul 8, 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
Next Next commit
use Const::eval instead of QueryNormalize in error reporting
compiler-errors committed Jun 24, 2023
commit 28f39862a8a673d5d162121b8c432a5b82883d3d
48 changes: 23 additions & 25 deletions compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@ use crate::infer::error_reporting::{TyCategory, TypeAnnotationNeeded as ErrorCod
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use crate::infer::{self, InferCtxt};
use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
use crate::traits::query::normalize::QueryNormalizeExt as _;
use crate::traits::specialize::to_pretty_impl_header;
use crate::traits::NormalizeExt;
use on_unimplemented::{AppendConstMessage, OnUnimplementedNote, TypeErrCtxtExt as _};
@@ -31,7 +30,7 @@ use rustc_middle::traits::select::OverflowError;
use rustc_middle::traits::SelectionOutputTypeParameterMismatch;
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::fold::{TypeFolder, TypeSuperFoldable};
use rustc_middle::ty::fold::{BottomUpFolder, TypeFolder, TypeSuperFoldable};
use rustc_middle::ty::print::{with_forced_trimmed_paths, FmtPrinter, Print};
use rustc_middle::ty::{
self, SubtypePredicate, ToPolyTraitRef, ToPredicate, TraitRef, Ty, TyCtxt, TypeFoldable,
@@ -60,7 +59,7 @@ pub enum CandidateSimilarity {
Fuzzy { ignoring_lifetimes: bool },
}

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ImplCandidate<'tcx> {
pub trait_ref: ty::TraitRef<'tcx>,
pub similarity: CandidateSimilarity,
@@ -1992,7 +1991,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
// Mentioning implementers of `Copy`, `Debug` and friends is not useful.
return false;
}
let normalized_impl_candidates: Vec<_> = self
let impl_candidates: Vec<_> = self
.tcx
.all_impls(def_id)
// Ignore automatically derived impls and `!Trait` impls.
@@ -2019,7 +2018,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
}
})
.collect();
return report(normalized_impl_candidates, err);
return report(impl_candidates, err);
}

// Sort impl candidates so that ordering is consistent for UI tests.
@@ -2028,27 +2027,26 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
//
// Prefer more similar candidates first, then sort lexicographically
// by their normalized string representation.
let mut normalized_impl_candidates_and_similarities = impl_candidates
.iter()
.copied()
.map(|ImplCandidate { trait_ref, similarity }| {
// FIXME(compiler-errors): This should be using `NormalizeExt::normalize`
let normalized = self
.at(&ObligationCause::dummy(), ty::ParamEnv::empty())
.query_normalize(trait_ref)
.map_or(trait_ref, |normalized| normalized.value);
(similarity, normalized)
})
.collect::<Vec<_>>();
normalized_impl_candidates_and_similarities.sort();
normalized_impl_candidates_and_similarities.dedup();
let mut impl_candidates = impl_candidates.to_vec();
impl_candidates.sort_by_key(|cand| (cand.similarity, cand.trait_ref));
impl_candidates.dedup();

let normalized_impl_candidates = normalized_impl_candidates_and_similarities
.into_iter()
.map(|(_, normalized)| normalized)
.collect::<Vec<_>>();

report(normalized_impl_candidates, err)
report(
impl_candidates
.into_iter()
.map(|cand| {
// Fold the const so that it shows up as, e.g., `10`
// instead of `core::::array::{impl#30}::{constant#0}`.
cand.trait_ref.fold_with(&mut BottomUpFolder {
tcx: self.tcx,
ty_op: |ty| ty,
lt_op: |lt| lt,
ct_op: |ct| ct.eval(self.tcx, ty::ParamEnv::empty()),
})
})
.collect(),
err,
)
}

fn report_similar_impl_candidates_for_root_obligation(
9 changes: 9 additions & 0 deletions tests/ui/consts/missing-larger-array-impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
struct X;

// Make sure that we show the impl trait refs in the help message with
// their evaluated constants, rather than `core::::array::{impl#30}::{constant#0}`

fn main() {
<[X; 35] as Default>::default();
//~^ ERROR the trait bound `[X; 35]: Default` is not satisfied
}
20 changes: 20 additions & 0 deletions tests/ui/consts/missing-larger-array-impl.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
error[E0277]: the trait bound `[X; 35]: Default` is not satisfied
--> $DIR/missing-larger-array-impl.rs:7:5
|
LL | <[X; 35] as Default>::default();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[X; 35]`
|
= help: the following other types implement trait `Default`:
&[T]
&mut [T]
[T; 0]
[T; 10]
[T; 11]
[T; 12]
[T; 13]
[T; 14]
and 27 others

error: aborting due to previous error

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