Skip to content

Issue-141806: Remove sizedness_fast_path in fulfill.rs #145492

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 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 1 addition & 5 deletions compiler/rustc_trait_selection/src/traits/fulfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ use super::{
use crate::error_reporting::InferCtxtErrorExt;
use crate::infer::{InferCtxt, TyOrConstInferVar};
use crate::solve::StalledOnCoroutines;
use crate::traits::EvaluateConstErr;
use crate::traits::normalize::normalize_with_depth_to;
use crate::traits::project::{PolyProjectionObligation, ProjectionCacheKeyExt as _};
use crate::traits::query::evaluate_obligation::InferCtxtExt;
use crate::traits::{EvaluateConstErr, sizedness_fast_path};

pub(crate) type PendingPredicateObligations<'tcx> = ThinVec<PendingPredicateObligation<'tcx>>;

Expand Down Expand Up @@ -363,10 +363,6 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {

let infcx = self.selcx.infcx;

if sizedness_fast_path(infcx.tcx, obligation.predicate, obligation.param_env) {
return ProcessResult::Changed(thin_vec![]);
}

if obligation.predicate.has_aliases() {
let mut obligations = PredicateObligations::new();
let predicate = normalize_with_depth_to(
Expand Down
1 change: 0 additions & 1 deletion tests/ui/closures/issue-78720.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
fn server() -> impl {
//~^ ERROR at least one trait must be specified
//~^^ ERROR type annotations needed
().map2(|| "")
}

Expand Down
16 changes: 5 additions & 11 deletions tests/ui/closures/issue-78720.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | fn server() -> impl {
| ^^^^

error[E0412]: cannot find type `F` in this scope
--> $DIR/issue-78720.rs:14:12
--> $DIR/issue-78720.rs:13:12
|
LL | _func: F,
| ^
Expand All @@ -22,14 +22,8 @@ help: you might be missing a type parameter
LL | struct Map2<Segment2, F> {
| +++

error[E0282]: type annotations needed
--> $DIR/issue-78720.rs:1:16
|
LL | fn server() -> impl {
| ^^^^ cannot infer type

error[E0308]: mismatched types
--> $DIR/issue-78720.rs:8:39
--> $DIR/issue-78720.rs:7:39
|
LL | fn map2<F>(self, f: F) -> Map2<F> {}
| ^^ expected `Map2<F>`, found `()`
Expand All @@ -38,7 +32,7 @@ LL | fn map2<F>(self, f: F) -> Map2<F> {}
found unit type `()`

error[E0277]: the size for values of type `Self` cannot be known at compilation time
--> $DIR/issue-78720.rs:8:16
--> $DIR/issue-78720.rs:7:16
|
LL | fn map2<F>(self, f: F) -> Map2<F> {}
| ^^^^ doesn't have a size known at compile-time
Expand All @@ -53,7 +47,7 @@ help: function arguments must have a statically known size, borrowed types alway
LL | fn map2<F>(&self, f: F) -> Map2<F> {}
| +

error: aborting due to 5 previous errors
error: aborting due to 4 previous errors

Some errors have detailed explanations: E0277, E0282, E0308, E0412.
Some errors have detailed explanations: E0277, E0308, E0412.
For more information about an error, try `rustc --explain E0277`.
2 changes: 1 addition & 1 deletion tests/ui/codegen/overflow-during-mono.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//~ ERROR overflow evaluating the requirement `for<'a> {closure@$DIR/overflow-during-mono.rs:14:41: 14:44}: FnMut(&'a _)`
//~ ERROR overflow evaluating the requirement `{closure@$DIR/overflow-during-mono.rs:14:41: 14:44}: Sized`
//@ build-fail
//@ compile-flags: -Zwrite-long-types-to-disk=yes

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/codegen/overflow-during-mono.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0275]: overflow evaluating the requirement `for<'a> {closure@$DIR/overflow-during-mono.rs:14:41: 14:44}: FnMut(&'a _)`
error[E0275]: overflow evaluating the requirement `{closure@$DIR/overflow-during-mono.rs:14:41: 14:44}: Sized`
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "64"]` attribute to your crate (`overflow_during_mono`)
= note: required for `Filter<IntoIter<i32, 11>, {[email protected]:14:41}>` to implement `Iterator`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/layout/unconstrained-param-ice-137308.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ impl<C: ?Sized> A for u8 { //~ ERROR: the type parameter `C` is not constrained

#[rustc_layout(debug)]
struct S([u8; <u8 as A>::B]);
//~^ ERROR: the type has an unknown layout
//~^ ERROR: the type `[u8; <u8 as A>::B]` has an unknown layout
2 changes: 1 addition & 1 deletion tests/ui/layout/unconstrained-param-ice-137308.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0207]: the type parameter `C` is not constrained by the impl trait, self
LL | impl<C: ?Sized> A for u8 {
| ^ unconstrained type parameter

error: the type has an unknown layout
error: the type `[u8; <u8 as A>::B]` has an unknown layout
--> $DIR/unconstrained-param-ice-137308.rs:18:1
|
LL | struct S([u8; <u8 as A>::B]);
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/nll/issue-50716.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ trait A {
type X: ?Sized;
}

fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>)
fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>) //~ ERROR: mismatched types
where
for<'b> &'b T: A,
<&'static T as A>::X: Sized
Expand Down
18 changes: 17 additions & 1 deletion tests/ui/nll/issue-50716.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
error[E0308]: mismatched types
--> $DIR/issue-50716.rs:8:27
|
LL | fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>)
| ^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
|
= note: expected trait `<<&'a T as A>::X as MetaSized>`
found trait `<<&'static T as A>::X as MetaSized>`
note: the lifetime `'a` as defined here...
--> $DIR/issue-50716.rs:8:8
|
LL | fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>)
| ^^
= note: ...does not necessarily outlive the static lifetime

error: lifetime may not live long enough
--> $DIR/issue-50716.rs:13:14
|
Expand All @@ -7,5 +22,6 @@ LL | fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>)
LL | let _x = *s;
| ^^ proving this value is `Sized` requires that `'a` must outlive `'static`

error: aborting due to 1 previous error
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
2 changes: 1 addition & 1 deletion tests/ui/recursion/issue-83150.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//~ ERROR overflow evaluating the requirement `Map<&mut std::ops::Range<u8>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>: Iterator`
//~ ERROR overflow evaluating the requirement `Map<&mut std::ops::Range<u8>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>: MetaSized`
//@ build-fail
//@ compile-flags: -Copt-level=0 -Zwrite-long-types-to-disk=yes

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/recursion/issue-83150.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LL | func(&mut iter.map(|x| x + 1))
= help: a `loop` may express intention better if this is on purpose
= note: `#[warn(unconditional_recursion)]` on by default

error[E0275]: overflow evaluating the requirement `Map<&mut std::ops::Range<u8>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>: Iterator`
error[E0275]: overflow evaluating the requirement `Map<&mut std::ops::Range<u8>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>: MetaSized`
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_83150`)
= note: required for `&mut Map<&mut Range<u8>, {[email protected]:12:24}>` to implement `Iterator`
Expand Down
10 changes: 10 additions & 0 deletions tests/ui/sized/missing-sized-not-panic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// ICE-141806
trait Trait<T> {}
fn func(x: *const dyn Trait<()>)
where
Missing: Sized, //~ ERROR E0412
{
let _x: *const dyn Trait<u8> = x as _;
}

fn main() {}
9 changes: 9 additions & 0 deletions tests/ui/sized/missing-sized-not-panic.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0412]: cannot find type `Missing` in this scope
--> $DIR/missing-sized-not-panic.rs:5:5
|
LL | Missing: Sized,
| ^^^^^^^ not found in this scope

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0412`.
2 changes: 1 addition & 1 deletion tests/ui/where-clauses/ignore-err-clauses.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::ops::Add;

fn dbl<T>(x: T) -> <T as Add>::Output
//~^ ERROR type annotations needed
where
T: Copy + Add,
UUU: Copy,
//~^ ERROR cannot find type `UUU` in this scope
{
x + x
//~^ ERROR use of moved value: `x`
}

fn main() {
Expand Down
29 changes: 6 additions & 23 deletions tests/ui/where-clauses/ignore-err-clauses.stderr
Original file line number Diff line number Diff line change
@@ -1,33 +1,16 @@
error[E0412]: cannot find type `UUU` in this scope
--> $DIR/ignore-err-clauses.rs:6:5
--> $DIR/ignore-err-clauses.rs:7:5
|
LL | UUU: Copy,
| ^^^ not found in this scope

error[E0382]: use of moved value: `x`
--> $DIR/ignore-err-clauses.rs:9:9
error[E0282]: type annotations needed
--> $DIR/ignore-err-clauses.rs:3:14
|
LL | fn dbl<T>(x: T) -> <T as Add>::Output
| - move occurs because `x` has type `T`, which does not implement the `Copy` trait
...
LL | x + x
| ----^
| | |
| | value used here after move
| `x` moved due to usage in operator
|
help: if `T` implemented `Clone`, you could clone the value
--> $DIR/ignore-err-clauses.rs:3:8
|
LL | fn dbl<T>(x: T) -> <T as Add>::Output
| ^ consider constraining this type parameter with `Clone`
...
LL | x + x
| - you could clone this value
note: calling this operator moves the left-hand side
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
| ^ cannot infer type for type parameter `T`

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0382, E0412.
For more information about an error, try `rustc --explain E0382`.
Some errors have detailed explanations: E0282, E0412.
For more information about an error, try `rustc --explain E0282`.
Loading