Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c54a2a5
Make mtime of reproducible tarball dependent on git commit
Kobzol Jun 27, 2024
e1999f9
Add support for mtime override to `generate` and `combine` rust-insta…
Kobzol Jun 29, 2024
8127461
Move -Zprint-type-sizes and -Zprint-vtable-sizes into codegen_and_bui…
bjorn3 Jun 30, 2024
61963fa
Avoid an ICE reachable through const eval shenanigans
oli-obk Jul 1, 2024
9d5da39
Revert some ICE avoiding logic that is not necessary anymore
oli-obk Jul 1, 2024
a5d3723
Prefer item-local tainting checks over global error count checks
oli-obk Jul 1, 2024
814bfe9
This check should now be unreachable
oli-obk Jul 1, 2024
bd2ff51
Move codegen_and_build_linker from Queries to Linker
bjorn3 Jun 30, 2024
ec2d1b0
Minor change
bjorn3 Jun 30, 2024
f276459
Inline Query::default()
bjorn3 Jun 30, 2024
c260d3e
Always preserve user-written comments in assembly
tgross35 Jun 21, 2024
cd70362
Rename the `asm-comments` compiler flag to `verbose-asm`
tgross35 Jun 21, 2024
b079ac7
Add documentation for -Zverbose-asm
tgross35 Jun 21, 2024
1680b79
Simplify `CfgEval`.
nnethercote Jun 27, 2024
d6c0b81
Fix a typo in a comment.
nnethercote Jun 27, 2024
f852568
Change `AttrTokenStream::to_tokenstream` to `to_token_trees`.
nnethercote Jun 27, 2024
0cfd247
Rename `TokenStream::new` argument.
nnethercote Jun 27, 2024
7416c20
Just `push` in `AttrTokenStream::to_token_trees`.
nnethercote Jun 27, 2024
36c30a9
Fix comment.
nnethercote Jul 1, 2024
2342770
Flip an if/else in `AttrTokenStream::to_attr_token_stream`.
nnethercote Jul 1, 2024
8b5a7eb
Move things around in `collect_tokens_trailing_token`.
nnethercote Jul 1, 2024
f5b2896
Move more things around in `collect_tokens_trailing_token`.
nnethercote Jul 1, 2024
3d750e2
Shrink parser positions from `usize` to `u32`.
nnethercote Jul 2, 2024
6f60156
Rename `make_token_stream`.
nnethercote Jul 2, 2024
edeebe6
Import `std::{iter,mem}`.
nnethercote Jul 2, 2024
8c353cb
Disable rmake test inaccessible-temp-dir on riscv64
Hoverbear Jun 24, 2024
8ce8c62
add test
BoxyUwU Jul 2, 2024
a21ba34
add TyCtxt::as_lang_item, use in new solver
compiler-errors Jun 30, 2024
5a83751
Make fn traits into first-class TraitSolverLangItems to avoid needing…
compiler-errors Jun 30, 2024
ecdaff2
Actually report normalization-based type errors correctly for alias-r…
compiler-errors Jun 12, 2024
48c9046
Rollup merge of #126403 - compiler-errors:better-type-errors, r=lcnr
matthiaskrgr Jul 2, 2024
0799a2c
Rollup merge of #126803 - tgross35:verbose-asm, r=Amanieu
matthiaskrgr Jul 2, 2024
1aa14d0
Rollup merge of #126917 - ferrocene:hoverbear/riscv64-inaccessible-te…
matthiaskrgr Jul 2, 2024
22d4ce4
Rollup merge of #127050 - Kobzol:reproducibility-git, r=onur-ozkan
matthiaskrgr Jul 2, 2024
26a71b9
Rollup merge of #127145 - compiler-errors:as_lang_item, r=lcnr
matthiaskrgr Jul 2, 2024
b0d8e78
Rollup merge of #127184 - bjorn3:interface_refactor2, r=Nadrieril
matthiaskrgr Jul 2, 2024
9a4e4e0
Rollup merge of #127202 - oli-obk:do_not_count_errors, r=wesleywiser
matthiaskrgr Jul 2, 2024
0108a84
Rollup merge of #127233 - nnethercote:parser-cleanups, r=petrochenkov
matthiaskrgr Jul 2, 2024
7500abf
Rollup merge of #127245 - BoxyUwU:gce_hang_test, r=Nilstrieb
matthiaskrgr Jul 2, 2024
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
Prev Previous commit
Next Next commit
Avoid an ICE reachable through const eval shenanigans
  • Loading branch information
oli-obk committed Jul 1, 2024
commit 61963fabdf2eaf9a68be970dfad7eb470a0fc0d5
9 changes: 6 additions & 3 deletions compiler/rustc_hir_typeck/src/method/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,12 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
.report_mismatched_types(&cause, method_self_ty, self_ty, terr)
.emit();
} else {
error!("{self_ty} was a subtype of {method_self_ty} but now is not?");
// This must already have errored elsewhere.
self.dcx().has_errors().unwrap();
// This has/will have errored in wfcheck, which we cannot depend on from here, as typeck on functions
// may run before wfcheck if the function is used in const eval.
self.dcx().span_delayed_bug(
cause.span(),
format!("{self_ty} was a subtype of {method_self_ty} but now is not?"),
);
}
}
}
Expand Down
29 changes: 29 additions & 0 deletions tests/ui/self/arbitrary-self-from-method-substs-ice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//! The same as the non-ICE test, but const eval will run typeck of
//! `get` before running wfcheck (as that may in itself trigger const
//! eval again, and thus cause bogus cycles). This used to ICE because
//! we asserted that an error had already been emitted.

use std::ops::Deref;

struct Foo(u32);
impl Foo {
const fn get<R: Deref<Target = Self>>(self: R) -> u32 {
//~^ ERROR: `R` cannot be used as the type of `self`
//~| ERROR destructor of `R` cannot be evaluated at compile-time
self.0
//~^ ERROR cannot borrow here, since the borrowed element may contain interior mutability
//~| ERROR cannot call non-const fn `<R as Deref>::deref` in constant function
}
}

const FOO: () = {
let foo = Foo(1);
foo.get::<&Foo>();
};

const BAR: [(); {
FOO;
0
}] = [];

fn main() {}
46 changes: 46 additions & 0 deletions tests/ui/self/arbitrary-self-from-method-substs-ice.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability
--> $DIR/arbitrary-self-from-method-substs-ice.rs:13:9
|
LL | self.0
| ^^^^
|
= note: see issue #80384 <https://github.com/rust-lang/rust/issues/80384> for more information
= help: add `#![feature(const_refs_to_cell)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0015]: cannot call non-const fn `<R as Deref>::deref` in constant functions
--> $DIR/arbitrary-self-from-method-substs-ice.rs:13:9
|
LL | self.0
| ^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
|
LL + #![feature(const_trait_impl)]
|

error[E0493]: destructor of `R` cannot be evaluated at compile-time
--> $DIR/arbitrary-self-from-method-substs-ice.rs:10:43
|
LL | const fn get<R: Deref<Target = Self>>(self: R) -> u32 {
| ^^^^ the destructor for this type cannot be evaluated in constant functions
...
LL | }
| - value is dropped here

error[E0658]: `R` cannot be used as the type of `self` without the `arbitrary_self_types` feature
--> $DIR/arbitrary-self-from-method-substs-ice.rs:10:49
|
LL | const fn get<R: Deref<Target = Self>>(self: R) -> u32 {
| ^
|
= note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information
= help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0015, E0493, E0658.
For more information about an error, try `rustc --explain E0015`.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ LL | fn get<R: Deref<Target = Self>>(self: R) -> u32 {
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)

ERROR rustc_hir_typeck::method::confirm Foo was a subtype of &Foo but now is not?
error: aborting due to 1 previous error

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