Skip to content

Commit

Permalink
Rollup merge of rust-lang#117449 - oli-obk:query_merge_immobile_game,…
Browse files Browse the repository at this point in the history
… r=matthewjasper

Avoid silencing relevant follow-up errors

r? ``@matthewjasper``

This PR only adds new errors to tests that are already failing and fixes one ICE.

Several tests were changed to not emit new errors. I believe all of them were faulty tests, and not explicitly testing for the code that had new errors.
  • Loading branch information
matthiaskrgr authored Jan 5, 2024
2 parents a59a980 + 594b5aa commit 7a5a540
Show file tree
Hide file tree
Showing 182 changed files with 2,686 additions and 458 deletions.
9 changes: 3 additions & 6 deletions compiler/rustc_hir_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,9 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {

// this ensures that later parts of type checking can assume that items
// have valid types and not error
// FIXME(matthewjasper) We shouldn't need to use `track_errors`.
tcx.sess.track_errors(|| {
tcx.sess.time("type_collecting", || {
tcx.hir().for_each_module(|module| tcx.ensure().collect_mod_item_types(module))
});
})?;
tcx.sess.time("type_collecting", || {
tcx.hir().for_each_module(|module| tcx.ensure().collect_mod_item_types(module))
});

if tcx.features().rustc_attrs {
tcx.sess.track_errors(|| {
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_trait_selection/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,12 @@ pub fn normalize_param_env_or_error<'tcx>(
}

fn fold_const(&mut self, c: ty::Const<'tcx>) -> ty::Const<'tcx> {
// FIXME(return_type_notation): track binders in this normalizer, as
// `ty::Const::normalize` can only work with properly preserved binders.

if c.has_escaping_bound_vars() {
return ty::Const::new_misc_error(self.0, c.ty());
}
// While it is pretty sus to be evaluating things with an empty param env, it
// should actually be okay since without `feature(generic_const_exprs)` the only
// const arguments that have a non-empty param env are array repeat counts. These
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ LL | impl<T> Windows {
note: struct defined here, with 1 generic parameter: `T`
--> $DIR/issue-109071.rs:5:8
|
LL | struct Windows<T> {}
LL | struct Windows<T> { t: T }
| ^^^^^^^ -
help: add missing generic argument
|
Expand All @@ -30,7 +30,7 @@ LL | type Item = &[T];
= help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable

error[E0223]: ambiguous associated type
--> $DIR/issue-109071.rs:15:22
--> $DIR/issue-109071.rs:16:22
|
LL | fn T() -> Option<Self::Item> {}
| ^^^^^^^^^^
Expand Down
4 changes: 3 additions & 1 deletion tests/ui/associated-inherent-types/issue-109071.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
#![cfg_attr(with_gate, feature(inherent_associated_types))]
#![cfg_attr(with_gate, allow(incomplete_features))]

struct Windows<T> {}
struct Windows<T> { t: T }

impl<T> Windows { //~ ERROR: missing generics for struct `Windows`
type Item = &[T]; //~ ERROR: `&` without an explicit lifetime name cannot be used here
//[no_gate]~^ ERROR: inherent associated types are unstable

fn next() -> Option<Self::Item> {}
//[with_gate]~^ ERROR type annotations needed
}

impl<T> Windows<T> {
fn T() -> Option<Self::Item> {}
//[no_gate]~^ ERROR: ambiguous associated type
//[with_gate]~^^ ERROR type annotations needed
}

fn main() {}
18 changes: 15 additions & 3 deletions tests/ui/associated-inherent-types/issue-109071.with_gate.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,26 @@ LL | impl<T> Windows {
note: struct defined here, with 1 generic parameter: `T`
--> $DIR/issue-109071.rs:5:8
|
LL | struct Windows<T> {}
LL | struct Windows<T> { t: T }
| ^^^^^^^ -
help: add missing generic argument
|
LL | impl<T> Windows<T> {
| +++

error: aborting due to 2 previous errors
error[E0282]: type annotations needed
--> $DIR/issue-109071.rs:11:18
|
LL | fn next() -> Option<Self::Item> {}
| ^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T`

error[E0282]: type annotations needed
--> $DIR/issue-109071.rs:16:15
|
LL | fn T() -> Option<Self::Item> {}
| ^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T`

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0107, E0637.
Some errors have detailed explanations: E0107, E0282, E0637.
For more information about an error, try `rustc --explain E0107`.
1 change: 1 addition & 0 deletions tests/ui/associated-inherent-types/issue-109299-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ impl Lexer<i32> {
}

type X = impl for<T> Fn() -> Lexer<T>::Cursor; //~ ERROR associated type `Cursor` not found for `Lexer<T>` in the current scope
//~^ ERROR: unconstrained opaque type

fn main() {}
10 changes: 9 additions & 1 deletion tests/ui/associated-inherent-types/issue-109299-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ LL | type X = impl for<T> Fn() -> Lexer<T>::Cursor;
= note: the associated type was found for
- `Lexer<i32>`

error: aborting due to 1 previous error
error: unconstrained opaque type
--> $DIR/issue-109299-1.rs:10:10
|
LL | type X = impl for<T> Fn() -> Lexer<T>::Cursor;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `X` must be used in combination with a concrete type within the same module

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0220`.
1 change: 1 addition & 0 deletions tests/ui/associated-inherent-types/issue-109768.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ impl<T> Local { //~ ERROR missing generics for struct `Local`
type AssocType3 = T; //~ ERROR inherent associated types are unstable

const WRAPPED_ASSOC_3: Wrapper<Self::AssocType3> = Wrapper();
//~^ ERROR: this struct takes 1 argument but 0 arguments were supplied
}
//~^ ERROR `main` function not found
24 changes: 20 additions & 4 deletions tests/ui/associated-inherent-types/issue-109768.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0601]: `main` function not found in crate `issue_109768`
--> $DIR/issue-109768.rs:11:2
--> $DIR/issue-109768.rs:12:2
|
LL | }
| ^ consider adding a `main` function to `$DIR/issue-109768.rs`
Expand Down Expand Up @@ -29,7 +29,23 @@ LL | type AssocType3 = T;
= note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information
= help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable

error: aborting due to 3 previous errors
error[E0061]: this struct takes 1 argument but 0 arguments were supplied
--> $DIR/issue-109768.rs:10:56
|
LL | const WRAPPED_ASSOC_3: Wrapper<Self::AssocType3> = Wrapper();
| ^^^^^^^-- an argument is missing
|
note: tuple struct defined here
--> $DIR/issue-109768.rs:3:8
|
LL | struct Wrapper<T>(T);
| ^^^^^^^
help: provide the argument
|
LL | const WRAPPED_ASSOC_3: Wrapper<Self::AssocType3> = Wrapper(/* value */);
| ~~~~~~~~~~~~~

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0107, E0601, E0658.
For more information about an error, try `rustc --explain E0107`.
Some errors have detailed explanations: E0061, E0107, E0601, E0658.
For more information about an error, try `rustc --explain E0061`.
12 changes: 12 additions & 0 deletions tests/ui/associated-type-bounds/duplicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,17 @@ where
fn FRPIT1() -> impl Iterator<Item: Copy, Item: Send> {
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
iter::empty()
//~^ ERROR type annotations needed
}
fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> {
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
iter::empty()
//~^ ERROR type annotations needed
}
fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> {
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
iter::empty()
//~^ ERROR type annotations needed
}
fn FAPIT1(_: impl Iterator<Item: Copy, Item: Send>) {}
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
Expand Down Expand Up @@ -194,12 +197,15 @@ trait TRI3<T: Iterator<Item: 'static, Item: 'static>> {}
trait TRS1: Iterator<Item: Copy, Item: Send> {}
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
trait TRS2: Iterator<Item: Copy, Item: Copy> {}
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
trait TRS3: Iterator<Item: 'static, Item: 'static> {}
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
trait TRW1<T>
where
T: Iterator<Item: Copy, Item: Send>,
Expand All @@ -223,29 +229,35 @@ where
Self: Iterator<Item: Copy, Item: Send>,
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
{
}
trait TRSW2
where
Self: Iterator<Item: Copy, Item: Copy>,
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
{
}
trait TRSW3
where
Self: Iterator<Item: 'static, Item: 'static>,
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
{
}
trait TRA1 {
type A: Iterator<Item: Copy, Item: Send>;
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR `<<Self as TRA1>::A as Iterator>::Item` cannot be sent between threads safely
//~| ERROR the trait bound `<<Self as TRA1>::A as Iterator>::Item: Copy` is not satisfied
}
trait TRA2 {
type A: Iterator<Item: Copy, Item: Copy>;
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the trait bound `<<Self as TRA2>::A as Iterator>::Item: Copy` is not satisfied
}
trait TRA3 {
type A: Iterator<Item: 'static, Item: 'static>;
Expand Down
Loading

0 comments on commit 7a5a540

Please sign in to comment.