1
Fork 0

Auto merge of #123098 - matthiaskrgr:rollup-39v4rf3, r=matthiaskrgr

Rollup of 10 pull requests

Successful merges:

 - #122766 (store segment and module in `UnresolvedImportError`)
 - #122996 (simplify_branches: add comment)
 - #123047 (triagebot: Add notification of 2024 issues)
 - #123066 (CFI: (actually) check that methods are object-safe before projecting their receivers to `dyn Trait` in CFI)
 - #123067 (match lowering: consistently merge simple or-patterns)
 - #123069 (Revert `cargo update` changes and bump `download-artifact` to v4)
 - #123070 (Add my former address to .mailmap)
 - #123086 (Fix doc link to BufWriter in std::fs::File documentation)
 - #123090 (Remove `CacheSelector` trait now that we can use GATs)
 - #123091 (Delegation: fix ICE on wrong `self` resolution)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-03-26 17:44:57 +00:00
commit 3b370cf46a
22 changed files with 393 additions and 184 deletions

View file

@ -6,8 +6,6 @@ on:
schedule:
# Run weekly
- cron: '0 0 * * Sun'
# Re-bump deps every 4 hours
- cron: '0 */4 * * *'
workflow_dispatch:
# Needed so we can run it manually
permissions:
@ -42,7 +40,7 @@ jobs:
# Exit with error if open and S-waiting-on-bors
if [[ "$STATE" == "OPEN" && "$WAITING_ON_BORS" == "true" ]]; then
gh run cancel ${{ github.run_id }}
exit 1
fi
update:
@ -65,10 +63,7 @@ jobs:
- name: cargo update
# Remove first line that always just says "Updating crates.io index"
# If there are no changes, cancel the job here
run: |
cargo update 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
git status --porcelain | grep -q Cargo.lock || gh run cancel ${{ github.run_id }}
run: cargo update 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
- name: upload Cargo.lock artifact for use in PR
uses: actions/upload-artifact@v4
with:
@ -95,11 +90,11 @@ jobs:
uses: actions/checkout@v4
- name: download Cargo.lock from update job
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: Cargo-lock
- name: download cargo-update log from update job
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: cargo-updates
@ -134,14 +129,14 @@ jobs:
# Exit with error if PR is closed
STATE=$(gh pr view cargo_update --repo $GITHUB_REPOSITORY --json state --jq '.state')
if [[ "$STATE" != "OPEN" ]]; then
gh run cancel ${{ github.run_id }}
exit 1
fi
gh pr edit cargo_update --title "${PR_TITLE}" --body-file body.md --repo $GITHUB_REPOSITORY
- name: open new pull request
# Only run if there wasn't an existing PR and if this is the weekly run
if: steps.edit.outcome != 'success' && github.event.schedule == '0 0 * * Sun'
# Only run if there wasn't an existing PR
if: steps.edit.outcome != 'success'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr create --title "${PR_TITLE}" --body-file body.md --repo $GITHUB_REPOSITORY

View file

@ -324,6 +324,7 @@ Katze <binary@benary.org>
Keegan McAllister <mcallister.keegan@gmail.com> <kmcallister@mozilla.com>
Kerem Kat <keremkat@gmail.com>
Kevin Butler <haqkrs@gmail.com>
Kevin Reid <kpreid@switchb.org> <kpreid@google.com>
Kevin Jiang <kwj2104@columbia.edu>
Kornel Lesiński <kornel@geekhood.net>
Krishna Sai Veera Reddy <veerareddy@email.arizona.edu>

View file

@ -9,8 +9,7 @@ use crate::ty::{self, Ty, TyCtxt};
use crate::ty::{GenericArg, GenericArgsRef};
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalModDefId, ModDefId, LOCAL_CRATE};
use rustc_hir::hir_id::{HirId, OwnerId};
use rustc_query_system::query::DefIdCacheSelector;
use rustc_query_system::query::{DefaultCacheSelector, SingleCacheSelector, VecCacheSelector};
use rustc_query_system::query::{DefIdCache, DefaultCache, SingleCache, VecCache};
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
use rustc_target::abi;
@ -22,7 +21,7 @@ pub struct LocalCrate;
/// The `Key` trait controls what types can legally be used as the key
/// for a query.
pub trait Key: Sized {
// N.B. Most of the keys down below have `type CacheSelector = DefaultCacheSelector<Self>;`,
// N.B. Most of the keys down below have `type Cache<V> = DefaultCache<Self, V>;`,
// it would be reasonable to use associated type defaults, to remove the duplication...
//
// ...But r-a doesn't support them yet and using a default here causes r-a to not infer
@ -30,7 +29,7 @@ pub trait Key: Sized {
// type defaults, please restrain from using them here <3
//
// r-a issue: <https://github.com/rust-lang/rust-analyzer/issues/13693>
type CacheSelector;
type Cache<V>;
/// In the event that a cycle occurs, if no explicit span has been
/// given for a query with key `self`, what span should we use?
@ -56,7 +55,7 @@ pub trait AsLocalKey: Key {
}
impl Key for () {
type CacheSelector = SingleCacheSelector;
type Cache<V> = SingleCache<V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -64,7 +63,7 @@ impl Key for () {
}
impl<'tcx> Key for ty::InstanceDef<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.def_id())
@ -81,7 +80,7 @@ impl<'tcx> AsLocalKey for ty::InstanceDef<'tcx> {
}
impl<'tcx> Key for ty::Instance<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.def_id())
@ -89,7 +88,7 @@ impl<'tcx> Key for ty::Instance<'tcx> {
}
impl<'tcx> Key for mir::interpret::GlobalId<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.instance.default_span(tcx)
@ -97,7 +96,7 @@ impl<'tcx> Key for mir::interpret::GlobalId<'tcx> {
}
impl<'tcx> Key for (Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -105,7 +104,7 @@ impl<'tcx> Key for (Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>) {
}
impl<'tcx> Key for mir::interpret::LitToConstInput<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -113,7 +112,7 @@ impl<'tcx> Key for mir::interpret::LitToConstInput<'tcx> {
}
impl Key for CrateNum {
type CacheSelector = VecCacheSelector<Self>;
type Cache<V> = VecCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -130,7 +129,7 @@ impl AsLocalKey for CrateNum {
}
impl Key for OwnerId {
type CacheSelector = VecCacheSelector<Self>;
type Cache<V> = VecCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.to_def_id().default_span(tcx)
@ -142,7 +141,7 @@ impl Key for OwnerId {
}
impl Key for LocalDefId {
type CacheSelector = VecCacheSelector<Self>;
type Cache<V> = VecCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.to_def_id().default_span(tcx)
@ -154,7 +153,7 @@ impl Key for LocalDefId {
}
impl Key for DefId {
type CacheSelector = DefIdCacheSelector;
type Cache<V> = DefIdCache<V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(*self)
@ -176,7 +175,7 @@ impl AsLocalKey for DefId {
}
impl Key for LocalModDefId {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(*self)
@ -189,7 +188,7 @@ impl Key for LocalModDefId {
}
impl Key for ModDefId {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(*self)
@ -211,7 +210,7 @@ impl AsLocalKey for ModDefId {
}
impl Key for SimplifiedType {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -219,7 +218,7 @@ impl Key for SimplifiedType {
}
impl Key for (DefId, DefId) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.1.default_span(tcx)
@ -227,7 +226,7 @@ impl Key for (DefId, DefId) {
}
impl<'tcx> Key for (ty::Instance<'tcx>, LocalDefId) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
@ -235,7 +234,7 @@ impl<'tcx> Key for (ty::Instance<'tcx>, LocalDefId) {
}
impl Key for (DefId, LocalDefId) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.1.default_span(tcx)
@ -243,7 +242,7 @@ impl Key for (DefId, LocalDefId) {
}
impl Key for (LocalDefId, DefId) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
@ -251,7 +250,7 @@ impl Key for (LocalDefId, DefId) {
}
impl Key for (LocalDefId, LocalDefId) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
@ -259,7 +258,7 @@ impl Key for (LocalDefId, LocalDefId) {
}
impl Key for (DefId, Ident) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.0)
@ -272,7 +271,7 @@ impl Key for (DefId, Ident) {
}
impl Key for (LocalDefId, LocalDefId, Ident) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.1.default_span(tcx)
@ -280,7 +279,7 @@ impl Key for (LocalDefId, LocalDefId, Ident) {
}
impl Key for (CrateNum, DefId) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.1.default_span(tcx)
@ -297,7 +296,7 @@ impl AsLocalKey for (CrateNum, DefId) {
}
impl Key for (CrateNum, SimplifiedType) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -314,7 +313,7 @@ impl AsLocalKey for (CrateNum, SimplifiedType) {
}
impl Key for (DefId, SimplifiedType) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
@ -322,7 +321,7 @@ impl Key for (DefId, SimplifiedType) {
}
impl<'tcx> Key for GenericArgsRef<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -330,7 +329,7 @@ impl<'tcx> Key for GenericArgsRef<'tcx> {
}
impl<'tcx> Key for (DefId, GenericArgsRef<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
@ -338,7 +337,7 @@ impl<'tcx> Key for (DefId, GenericArgsRef<'tcx>) {
}
impl<'tcx> Key for (ty::UnevaluatedConst<'tcx>, ty::UnevaluatedConst<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
(self.0).def.default_span(tcx)
@ -346,7 +345,7 @@ impl<'tcx> Key for (ty::UnevaluatedConst<'tcx>, ty::UnevaluatedConst<'tcx>) {
}
impl<'tcx> Key for (LocalDefId, DefId, GenericArgsRef<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
@ -354,7 +353,7 @@ impl<'tcx> Key for (LocalDefId, DefId, GenericArgsRef<'tcx>) {
}
impl<'tcx> Key for (ty::ParamEnv<'tcx>, ty::TraitRef<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.1.def_id)
@ -362,7 +361,7 @@ impl<'tcx> Key for (ty::ParamEnv<'tcx>, ty::TraitRef<'tcx>) {
}
impl<'tcx> Key for ty::PolyTraitRef<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.def_id())
@ -370,7 +369,7 @@ impl<'tcx> Key for ty::PolyTraitRef<'tcx> {
}
impl<'tcx> Key for ty::PolyExistentialTraitRef<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.def_id())
@ -378,7 +377,7 @@ impl<'tcx> Key for ty::PolyExistentialTraitRef<'tcx> {
}
impl<'tcx> Key for (ty::PolyTraitRef<'tcx>, ty::PolyTraitRef<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.0.def_id())
@ -386,7 +385,7 @@ impl<'tcx> Key for (ty::PolyTraitRef<'tcx>, ty::PolyTraitRef<'tcx>) {
}
impl<'tcx> Key for GenericArg<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -394,7 +393,7 @@ impl<'tcx> Key for GenericArg<'tcx> {
}
impl<'tcx> Key for ty::Const<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -402,7 +401,7 @@ impl<'tcx> Key for ty::Const<'tcx> {
}
impl<'tcx> Key for Ty<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -418,7 +417,7 @@ impl<'tcx> Key for Ty<'tcx> {
}
impl<'tcx> Key for TyAndLayout<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -426,7 +425,7 @@ impl<'tcx> Key for TyAndLayout<'tcx> {
}
impl<'tcx> Key for (Ty<'tcx>, Ty<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -434,7 +433,7 @@ impl<'tcx> Key for (Ty<'tcx>, Ty<'tcx>) {
}
impl<'tcx> Key for &'tcx ty::List<ty::Clause<'tcx>> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -442,7 +441,7 @@ impl<'tcx> Key for &'tcx ty::List<ty::Clause<'tcx>> {
}
impl<'tcx> Key for ty::ParamEnv<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -450,7 +449,7 @@ impl<'tcx> Key for ty::ParamEnv<'tcx> {
}
impl<'tcx, T: Key> Key for ty::ParamEnvAnd<'tcx, T> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.value.default_span(tcx)
@ -462,7 +461,7 @@ impl<'tcx, T: Key> Key for ty::ParamEnvAnd<'tcx, T> {
}
impl Key for Symbol {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -470,7 +469,7 @@ impl Key for Symbol {
}
impl Key for Option<Symbol> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -480,7 +479,7 @@ impl Key for Option<Symbol> {
/// Canonical query goals correspond to abstract trait operations that
/// are not tied to any crate in particular.
impl<'tcx, T: Clone> Key for Canonical<'tcx, T> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -488,7 +487,7 @@ impl<'tcx, T: Clone> Key for Canonical<'tcx, T> {
}
impl Key for (Symbol, u32, u32) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -496,7 +495,7 @@ impl Key for (Symbol, u32, u32) {
}
impl<'tcx> Key for (DefId, Ty<'tcx>, GenericArgsRef<'tcx>, ty::ParamEnv<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -504,7 +503,7 @@ impl<'tcx> Key for (DefId, Ty<'tcx>, GenericArgsRef<'tcx>, ty::ParamEnv<'tcx>) {
}
impl<'tcx> Key for (Ty<'tcx>, abi::VariantIdx) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -512,7 +511,7 @@ impl<'tcx> Key for (Ty<'tcx>, abi::VariantIdx) {
}
impl<'tcx> Key for (ty::Predicate<'tcx>, traits::WellFormedLoc) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -520,7 +519,7 @@ impl<'tcx> Key for (ty::Predicate<'tcx>, traits::WellFormedLoc) {
}
impl<'tcx> Key for (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -528,7 +527,7 @@ impl<'tcx> Key for (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>) {
}
impl<'tcx> Key for (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
@ -536,7 +535,7 @@ impl<'tcx> Key for (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>) {
}
impl<'tcx> Key for (Ty<'tcx>, ty::ValTree<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -544,7 +543,7 @@ impl<'tcx> Key for (Ty<'tcx>, ty::ValTree<'tcx>) {
}
impl Key for HirId {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.hir().span(*self)
@ -557,7 +556,7 @@ impl Key for HirId {
}
impl<'tcx> Key for (ValidityRequirement, ty::ParamEnvAnd<'tcx, Ty<'tcx>>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
// Just forward to `Ty<'tcx>`

View file

@ -73,7 +73,7 @@ use rustc_hir::lang_items::{LangItem, LanguageItems};
use rustc_hir::{Crate, ItemLocalId, ItemLocalMap, TraitCandidate};
use rustc_index::IndexVec;
use rustc_query_system::ich::StableHashingContext;
use rustc_query_system::query::{try_get_cached, CacheSelector, QueryCache, QueryMode, QueryState};
use rustc_query_system::query::{try_get_cached, QueryCache, QueryMode, QueryState};
use rustc_session::config::{EntryFnType, OptLevel, OutputFilenames, SymbolManglingVersion};
use rustc_session::cstore::{CrateDepKind, CrateSource};
use rustc_session::cstore::{ExternCrate, ForeignModule, LinkagePreference, NativeLib};

View file

@ -336,9 +336,7 @@ macro_rules! define_callbacks {
))
}
pub type Storage<'tcx> = <
<$($K)* as keys::Key>::CacheSelector as CacheSelector<'tcx, Erase<$V>>
>::Cache;
pub type Storage<'tcx> = <$($K)* as keys::Key>::Cache<Erase<$V>>;
// Ensure that keys grow no larger than 64 bytes
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]

View file

@ -1006,6 +1006,10 @@ struct Candidate<'pat, 'tcx> {
/// If the candidate matches, bindings and ascriptions must be established.
extra_data: PatternExtraData<'tcx>,
/// If we filled `self.subcandidate`, we store here the span of the or-pattern they came from.
// Invariant: it is `None` iff `subcandidates.is_empty()`.
or_span: Option<Span>,
/// The block before the `bindings` have been established.
pre_binding_block: Option<BasicBlock>,
/// The pre-binding block of the next candidate.
@ -1028,6 +1032,7 @@ impl<'tcx, 'pat> Candidate<'pat, 'tcx> {
extra_data: flat_pat.extra_data,
has_guard,
subcandidates: Vec::new(),
or_span: None,
otherwise_block: None,
pre_binding_block: None,
next_candidate_pre_binding_block: None,
@ -1277,7 +1282,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
//
// only generates a single switch.
candidate.subcandidates = self.create_or_subcandidates(pats, candidate.has_guard);
candidate.match_pairs.pop();
let first_match_pair = candidate.match_pairs.pop().unwrap();
candidate.or_span = Some(first_match_pair.pattern.span);
split_or_candidate = true;
}
}
@ -1287,8 +1293,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// At least one of the candidates has been split into subcandidates.
// We need to change the candidate list to include those.
let mut new_candidates = Vec::new();
for candidate in candidates {
for candidate in candidates.iter_mut() {
candidate.visit_leaves(|leaf_candidate| new_candidates.push(leaf_candidate));
}
self.match_simplified_candidates(
@ -1298,6 +1303,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
otherwise_block,
&mut *new_candidates,
);
for candidate in candidates {
self.merge_trivial_subcandidates(candidate);
}
} else {
self.match_simplified_candidates(
span,
@ -1531,16 +1540,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
&mut or_candidate_refs,
);
candidate.subcandidates = or_candidates;
self.merge_trivial_subcandidates(candidate, self.source_info(or_span));
candidate.or_span = Some(or_span);
self.merge_trivial_subcandidates(candidate);
}
/// Try to merge all of the subcandidates of the given candidate into one.
/// This avoids exponentially large CFGs in cases like `(1 | 2, 3 | 4, ...)`.
fn merge_trivial_subcandidates(
&mut self,
candidate: &mut Candidate<'_, 'tcx>,
source_info: SourceInfo,
) {
fn merge_trivial_subcandidates(&mut self, candidate: &mut Candidate<'_, 'tcx>) {
if candidate.subcandidates.is_empty() || candidate.has_guard {
// FIXME(or_patterns; matthewjasper) Don't give up if we have a guard.
return;
@ -1550,7 +1556,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// Not `Iterator::all` because we don't want to short-circuit.
for subcandidate in &mut candidate.subcandidates {
self.merge_trivial_subcandidates(subcandidate, source_info);
self.merge_trivial_subcandidates(subcandidate);
// FIXME(or_patterns; matthewjasper) Try to be more aggressive here.
can_merge &=
@ -1559,6 +1565,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
if can_merge {
let any_matches = self.cfg.start_new_block();
let or_span = candidate.or_span.take().unwrap();
let source_info = self.source_info(or_span);
for subcandidate in mem::take(&mut candidate.subcandidates) {
let or_block = subcandidate.pre_binding_block.unwrap();
self.cfg.goto(or_block, source_info, any_matches);

View file

@ -82,7 +82,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
&*candidate.match_pairs
{
candidate.subcandidates = self.create_or_subcandidates(pats, has_guard);
candidate.match_pairs.pop();
let first_match_pair = candidate.match_pairs.pop().unwrap();
candidate.or_span = Some(first_match_pair.pattern.span);
}
candidate
})

View file

@ -19,6 +19,7 @@ impl<'tcx> MirPass<'tcx> for SimplifyConstCondition {
let param_env = tcx.param_env_reveal_all_normalized(body.source.def_id());
'blocks: for block in body.basic_blocks_mut() {
for stmt in block.statements.iter_mut() {
// Simplify `assume` of a known value: either a NOP or unreachable.
if let StatementKind::Intrinsic(box ref intrinsic) = stmt.kind
&& let NonDivergingIntrinsic::Assume(discr) = intrinsic
&& let Operand::Constant(ref c) = discr

View file

@ -9,13 +9,6 @@ use rustc_span::def_id::DefId;
use rustc_span::def_id::DefIndex;
use std::fmt::Debug;
use std::hash::Hash;
use std::marker::PhantomData;
pub trait CacheSelector<'tcx, V> {
type Cache
where
V: Copy;
}
pub trait QueryCache: Sized {
type Key: Hash + Eq + Copy + Debug;
@ -29,14 +22,6 @@ pub trait QueryCache: Sized {
fn iter(&self, f: &mut dyn FnMut(&Self::Key, &Self::Value, DepNodeIndex));
}
pub struct DefaultCacheSelector<K>(PhantomData<K>);
impl<'tcx, K: Eq + Hash, V: 'tcx> CacheSelector<'tcx, V> for DefaultCacheSelector<K> {
type Cache = DefaultCache<K, V>
where
V: Copy;
}
pub struct DefaultCache<K, V> {
cache: Sharded<FxHashMap<K, (V, DepNodeIndex)>>,
}
@ -81,14 +66,6 @@ where
}
}
pub struct SingleCacheSelector;
impl<'tcx, V: 'tcx> CacheSelector<'tcx, V> for SingleCacheSelector {
type Cache = SingleCache<V>
where
V: Copy;
}
pub struct SingleCache<V> {
cache: OnceLock<(V, DepNodeIndex)>,
}
@ -123,14 +100,6 @@ where
}
}
pub struct VecCacheSelector<K>(PhantomData<K>);
impl<'tcx, K: Idx, V: 'tcx> CacheSelector<'tcx, V> for VecCacheSelector<K> {
type Cache = VecCache<K, V>
where
V: Copy;
}
pub struct VecCache<K: Idx, V> {
cache: Sharded<IndexVec<K, Option<(V, DepNodeIndex)>>>,
}
@ -174,14 +143,6 @@ where
}
}
pub struct DefIdCacheSelector;
impl<'tcx, V: 'tcx> CacheSelector<'tcx, V> for DefIdCacheSelector {
type Cache = DefIdCache<V>
where
V: Copy;
}
pub struct DefIdCache<V> {
/// Stores the local DefIds in a dense map. Local queries are much more often dense, so this is
/// a win over hashing query keys at marginal memory cost (~5% at most) compared to FxHashMap.

View file

@ -9,10 +9,7 @@ pub use self::job::{
};
mod caches;
pub use self::caches::{
CacheSelector, DefIdCacheSelector, DefaultCacheSelector, QueryCache, SingleCacheSelector,
VecCacheSelector,
};
pub use self::caches::{DefIdCache, DefaultCache, QueryCache, SingleCache, VecCache};
mod config;
pub use self::config::{HashResult, QueryConfig};

View file

@ -19,6 +19,7 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::intern::Interned;
use rustc_errors::{codes::*, pluralize, struct_span_code_err, Applicability, MultiSpan};
use rustc_hir::def::{self, DefKind, PartialRes};
use rustc_hir::def_id::DefId;
use rustc_middle::metadata::ModChild;
use rustc_middle::metadata::Reexport;
use rustc_middle::span_bug;
@ -250,6 +251,9 @@ struct UnresolvedImportError {
note: Option<String>,
suggestion: Option<Suggestion>,
candidates: Option<Vec<ImportSuggestion>>,
segment: Option<Symbol>,
/// comes from `PathRes::Failed { module }`
module: Option<DefId>,
}
// Reexports of the form `pub use foo as bar;` where `foo` is `extern crate foo;`
@ -579,16 +583,18 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
&import.kind,
import.span,
);
let err = UnresolvedImportError {
span: import.span,
label: None,
note: None,
suggestion: None,
candidates: None,
};
// FIXME: there should be a better way of doing this than
// formatting this as a string then checking for `::`
if path.contains("::") {
let err = UnresolvedImportError {
span: import.span,
label: None,
note: None,
suggestion: None,
candidates: None,
segment: None,
module: None,
};
errors.push((*import, err))
}
}
@ -738,15 +744,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}
}
match &import.kind {
ImportKind::Single { source, .. } => {
if let Some(ModuleOrUniformRoot::Module(module)) = import.imported_module.get()
&& let Some(module) = module.opt_def_id()
{
self.find_cfg_stripped(&mut diag, &source.name, module)
}
}
_ => {}
if matches!(import.kind, ImportKind::Single { .. })
&& let Some(segment) = err.segment
&& let Some(module) = err.module
{
self.find_cfg_stripped(&mut diag, &segment, module)
}
}
@ -916,10 +918,17 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
span,
label,
suggestion,
module,
segment_name,
..
} => {
if no_ambiguity {
assert!(import.imported_module.get().is_none());
let module = if let Some(ModuleOrUniformRoot::Module(m)) = module {
m.opt_def_id()
} else {
None
};
let err = match self.make_path_suggestion(
span,
import.module_path.clone(),
@ -935,6 +944,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
Applicability::MaybeIncorrect,
)),
candidates: None,
segment: Some(segment_name),
module,
},
None => UnresolvedImportError {
span,
@ -942,6 +953,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
note: None,
suggestion,
candidates: None,
segment: Some(segment_name),
module,
},
};
return Some(err);
@ -990,6 +1003,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
note: None,
suggestion: None,
candidates: None,
segment: None,
module: None,
});
}
}
@ -1199,6 +1214,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
} else {
None
},
module: import.imported_module.get().and_then(|module| {
if let ModuleOrUniformRoot::Module(m) = module {
m.opt_def_id()
} else {
None
}
}),
segment: Some(ident.name),
})
} else {
// `resolve_ident_in_module` reported a privacy error.

View file

@ -2531,7 +2531,17 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
}
ItemKind::Delegation(ref delegation) => {
self.resolve_delegation(delegation);
let span = delegation.path.segments.last().unwrap().ident.span;
self.with_generic_param_rib(
&[],
RibKind::Item(HasGenericParams::Yes(span), def_kind),
LifetimeRibKind::Generics {
binder: item.id,
kind: LifetimeBinderKind::Function,
span,
},
|this| this.resolve_delegation(delegation),
);
}
ItemKind::ExternCrate(..) => {}
@ -2819,7 +2829,16 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
walk_assoc_item(self, generics, LifetimeBinderKind::Function, item);
}
AssocItemKind::Delegation(delegation) => {
self.resolve_delegation(delegation);
self.with_generic_param_rib(
&[],
RibKind::AssocItem,
LifetimeRibKind::Generics {
binder: item.id,
kind: LifetimeBinderKind::Function,
span: delegation.path.segments.last().unwrap().ident.span,
},
|this| this.resolve_delegation(delegation),
);
}
AssocItemKind::Type(box TyAlias { generics, .. }) => self
.with_lifetime_rib(LifetimeRibKind::AnonymousReportError, |this| {
@ -3069,16 +3088,28 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
}
AssocItemKind::Delegation(box delegation) => {
debug!("resolve_implementation AssocItemKind::Delegation");
self.check_trait_item(
item.id,
item.ident,
&item.kind,
ValueNS,
item.span,
seen_trait_items,
|i, s, c| MethodNotMemberOfTrait(i, s, c),
self.with_generic_param_rib(
&[],
RibKind::AssocItem,
LifetimeRibKind::Generics {
binder: item.id,
kind: LifetimeBinderKind::Function,
span: delegation.path.segments.last().unwrap().ident.span,
},
|this| {
this.check_trait_item(
item.id,
item.ident,
&item.kind,
ValueNS,
item.span,
seen_trait_items,
|i, s, c| MethodNotMemberOfTrait(i, s, c),
);
this.resolve_delegation(delegation)
},
);
self.resolve_delegation(delegation);
}
AssocItemKind::MacCall(_) => {
panic!("unexpanded macro in resolve!")

View file

@ -415,6 +415,19 @@ enum PathResult<'a> {
label: String,
suggestion: Option<Suggestion>,
is_error_from_last_segment: bool,
/// The final module being resolved, for instance:
///
/// ```compile_fail
/// mod a {
/// mod b {
/// mod c {}
/// }
/// }
///
/// use a::not_exist::c;
/// ```
///
/// In this case, `module` will point to `a`.
module: Option<ModuleOrUniformRoot<'a>>,
/// The segment name of target
segment_name: Symbol,

View file

@ -1124,7 +1124,10 @@ pub fn typeid_for_instance<'tcx>(
.trait_item_def_id
.expect("Part of a trait implementation, but not linked to the def_id?");
let trait_method = tcx.associated_item(method_id);
if traits::is_vtable_safe_method(tcx, trait_ref.skip_binder().def_id, trait_method) {
let trait_id = trait_ref.skip_binder().def_id;
if traits::is_vtable_safe_method(tcx, trait_id, trait_method)
&& tcx.object_safety_violations(trait_id).is_empty()
{
// Trait methods will have a Self polymorphic parameter, where the concreteized
// implementatation will not. We need to walk back to the more general trait method
let trait_ref = tcx.instantiate_and_normalize_erasing_regions(
@ -1152,8 +1155,8 @@ pub fn typeid_for_instance<'tcx>(
let fn_abi = tcx
.fn_abi_of_instance(tcx.param_env(instance.def_id()).and((instance, ty::List::empty())))
.unwrap_or_else(|instance| {
bug!("typeid_for_instance: couldn't get fn_abi of instance {:?}", instance)
.unwrap_or_else(|error| {
bug!("typeid_for_instance: couldn't get fn_abi of instance {instance:?}: {error:?}")
});
typeid_for_fnabi(tcx, fn_abi, options)
@ -1182,6 +1185,7 @@ fn strip_receiver_auto<'tcx>(
tcx.mk_args_trait(new_rcvr, args.into_iter().skip(1))
}
#[instrument(skip(tcx), ret)]
fn trait_object_ty<'tcx>(tcx: TyCtxt<'tcx>, poly_trait_ref: ty::PolyTraitRef<'tcx>) -> Ty<'tcx> {
assert!(!poly_trait_ref.has_non_region_param());
let principal_pred = poly_trait_ref.map_bound(|trait_ref| {
@ -1199,6 +1203,7 @@ fn trait_object_ty<'tcx>(tcx: TyCtxt<'tcx>, poly_trait_ref: ty::PolyTraitRef<'tc
ty::ParamEnv::reveal_all(),
alias_ty.to_ty(tcx),
);
debug!("Resolved {:?} -> {resolved}", alias_ty.to_ty(tcx));
ty::ExistentialPredicate::Projection(ty::ExistentialProjection {
def_id: assoc_ty.def_id,
args: ty::ExistentialTraitRef::erase_self_ty(tcx, super_trait_ref).args,

View file

@ -97,7 +97,7 @@ use crate::time::SystemTime;
/// have been opened for asynchronous I/O (e.g. by using `FILE_FLAG_OVERLAPPED`).
///
/// [`BufReader`]: io::BufReader
/// [`BufWriter`]: io::BufReader
/// [`BufWriter`]: io::BufWriter
/// [`sync_all`]: File::sync_all
/// [`write`]: File::write
/// [`read`]: File::read

View file

@ -26,18 +26,20 @@
_3 = _1;
_2 = move _3 as [u32; 4] (Transmute);
StorageDead(_3);
switchInt(_2[0 of 4]) -> [0: bb1, otherwise: bb6];
switchInt(_2[0 of 4]) -> [0: bb1, otherwise: bb4];
}
bb1: {
switchInt(_2[1 of 4]) -> [0: bb2, otherwise: bb6];
switchInt(_2[1 of 4]) -> [0: bb2, otherwise: bb4];
}
bb2: {
switchInt(_2[2 of 4]) -> [0: bb4, 4294901760: bb5, otherwise: bb6];
switchInt(_2[2 of 4]) -> [0: bb3, 4294901760: bb3, otherwise: bb4];
}
bb3: {
StorageLive(_4);
_4 = _2[3 of 4];
StorageLive(_5);
StorageLive(_6);
_6 = _4;
@ -46,27 +48,15 @@
_0 = Option::<[u8; 4]>::Some(move _5);
StorageDead(_5);
StorageDead(_4);
goto -> bb7;
goto -> bb5;
}
bb4: {
StorageLive(_4);
_4 = _2[3 of 4];
goto -> bb3;
_0 = Option::<[u8; 4]>::None;
goto -> bb5;
}
bb5: {
StorageLive(_4);
_4 = _2[3 of 4];
goto -> bb3;
}
bb6: {
_0 = Option::<[u8; 4]>::None;
goto -> bb7;
}
bb7: {
StorageDead(_2);
return;
}

View file

@ -4,8 +4,12 @@ pub mod inner {
//~^ NOTE found an item that was configured out
#[cfg(FALSE)]
pub mod doesnt_exist { //~ NOTE found an item that was configured out
pub mod doesnt_exist {
//~^ NOTE found an item that was configured out
//~| NOTE found an item that was configured out
//~| NOTE found an item that was configured out
pub fn hello() {}
pub mod hi {}
}
pub mod wrong {
@ -20,6 +24,15 @@ pub mod inner {
}
}
mod placeholder {
use super::inner::doesnt_exist;
//~^ ERROR unresolved import `super::inner::doesnt_exist`
//~| NOTE no `doesnt_exist` in `inner`
use super::inner::doesnt_exist::hi;
//~^ ERROR unresolved import `super::inner::doesnt_exist`
//~| NOTE could not find `doesnt_exist` in `inner`
}
#[cfg(i_dont_exist_and_you_can_do_nothing_about_it)]
pub fn vanished() {}

View file

@ -1,5 +1,29 @@
error[E0432]: unresolved import `super::inner::doesnt_exist`
--> $DIR/diagnostics-same-crate.rs:28:9
|
LL | use super::inner::doesnt_exist;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `doesnt_exist` in `inner`
|
note: found an item that was configured out
--> $DIR/diagnostics-same-crate.rs:7:13
|
LL | pub mod doesnt_exist {
| ^^^^^^^^^^^^
error[E0432]: unresolved import `super::inner::doesnt_exist`
--> $DIR/diagnostics-same-crate.rs:31:23
|
LL | use super::inner::doesnt_exist::hi;
| ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner`
|
note: found an item that was configured out
--> $DIR/diagnostics-same-crate.rs:7:13
|
LL | pub mod doesnt_exist {
| ^^^^^^^^^^^^
error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner`
--> $DIR/diagnostics-same-crate.rs:37:12
--> $DIR/diagnostics-same-crate.rs:50:12
|
LL | inner::doesnt_exist::hello();
| ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner`
@ -11,7 +35,7 @@ LL | pub mod doesnt_exist {
| ^^^^^^^^^^^^
error[E0425]: cannot find function `uwu` in module `inner`
--> $DIR/diagnostics-same-crate.rs:32:12
--> $DIR/diagnostics-same-crate.rs:45:12
|
LL | inner::uwu();
| ^^^ not found in `inner`
@ -23,31 +47,31 @@ LL | pub fn uwu() {}
| ^^^
error[E0425]: cannot find function `meow` in module `inner::right`
--> $DIR/diagnostics-same-crate.rs:41:19
--> $DIR/diagnostics-same-crate.rs:54:19
|
LL | inner::right::meow();
| ^^^^ not found in `inner::right`
|
note: found an item that was configured out
--> $DIR/diagnostics-same-crate.rs:18:16
--> $DIR/diagnostics-same-crate.rs:22:16
|
LL | pub fn meow() {}
| ^^^^
= note: the item is gated behind the `what-a-cool-feature` feature
error[E0425]: cannot find function `uwu` in this scope
--> $DIR/diagnostics-same-crate.rs:28:5
--> $DIR/diagnostics-same-crate.rs:41:5
|
LL | uwu();
| ^^^ not found in this scope
error[E0425]: cannot find function `vanished` in this scope
--> $DIR/diagnostics-same-crate.rs:48:5
--> $DIR/diagnostics-same-crate.rs:61:5
|
LL | vanished();
| ^^^^^^^^ not found in this scope
error: aborting due to 5 previous errors
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0425, E0433.
Some errors have detailed explanations: E0425, E0432, E0433.
For more information about an error, try `rustc --explain E0425`.

View file

@ -0,0 +1,38 @@
#![feature(fn_delegation)]
#![allow(incomplete_features)]
trait Trait {
fn static_method(x: i32) -> i32 { x }
}
struct F;
struct S(F);
impl Trait for S {}
fn foo(x: i32) -> i32 { x }
fn bar<T: Default>(_: T) {
reuse Trait::static_method {
//~^ ERROR delegation with early bound generics is not supported yet
//~| ERROR mismatched types
let _ = T::Default();
//~^ ERROR can't use generic parameters from outer item
}
}
fn main() {
let y = 0;
reuse <S as Trait>::static_method {
let x = y;
//~^ ERROR can't capture dynamic environment in a fn item
foo(self);
let reuse_ptr: fn(i32) -> i32 = static_method;
reuse_ptr(0)
}
self.0;
//~^ ERROR expected value, found module `self`
let z = x;
//~^ ERROR cannot find value `x` in this scope
}

View file

@ -0,0 +1,65 @@
error[E0401]: can't use generic parameters from outer item
--> $DIR/target-expr.rs:19:17
|
LL | fn bar<T: Default>(_: T) {
| - type parameter from outer item
LL | reuse Trait::static_method {
| - help: try introducing a local generic parameter here: `T,`
...
LL | let _ = T::Default();
| ^^^^^^^^^^ use of generic parameter from outer item
error[E0434]: can't capture dynamic environment in a fn item
--> $DIR/target-expr.rs:27:17
|
LL | let x = y;
| ^
|
= help: use the `|| { ... }` closure form instead
error[E0424]: expected value, found module `self`
--> $DIR/target-expr.rs:34:5
|
LL | fn main() {
| ---- this function can't have a `self` parameter
...
LL | self.0;
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
error[E0425]: cannot find value `x` in this scope
--> $DIR/target-expr.rs:36:13
|
LL | let z = x;
| ^
|
help: the binding `x` is available in a different scope in the same function
--> $DIR/target-expr.rs:27:13
|
LL | let x = y;
| ^
error: delegation with early bound generics is not supported yet
--> $DIR/target-expr.rs:16:18
|
LL | fn static_method(x: i32) -> i32 { x }
| ------------------------------- callee defined here
...
LL | reuse Trait::static_method {
| ^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/target-expr.rs:16:32
|
LL | reuse Trait::static_method {
| ________________________________^
LL | |
LL | |
LL | | let _ = T::Default();
LL | |
LL | | }
| |_____^ expected `i32`, found `()`
error: aborting due to 6 previous errors
Some errors have detailed explanations: E0308, E0401, E0424, E0425, E0434.
For more information about an error, try `rustc --explain E0308`.

View file

@ -0,0 +1,38 @@
// Regression test for issue 123053, where associated types with lifetimes caused generation of the
// trait object type to fail, causing an ICE.
//
//@ needs-sanitizer-cfi
//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi --edition=2021
//@ no-prefer-dynamic
//@ only-x86_64-unknown-linux-gnu
//@ build-pass
trait Iterable {
type Item<'a>
where
Self: 'a;
type Iter<'a>: Iterator<Item = Self::Item<'a>>
where
Self: 'a;
fn iter<'a>(&'a self) -> Self::Iter<'a>;
}
impl<T> Iterable for [T] {
type Item<'a> = <std::slice::Iter<'a, T> as Iterator>::Item where T: 'a;
type Iter<'a> = std::slice::Iter<'a, T> where T: 'a;
fn iter<'a>(&'a self) -> Self::Iter<'a> {
self.iter()
}
}
fn get_first<'a, I: Iterable + ?Sized>(it: &'a I) -> Option<I::Item<'a>> {
it.iter().next()
}
fn main() {
let v = vec![1, 2, 3];
assert_eq!(Some(&1), get_first(&*v));
}

View file

@ -424,7 +424,15 @@ message_on_reopen = "Issue #{number} has been reopened. Pinging @*T-types*."
[notify-zulip."A-edition-2021"]
required_labels = ["C-bug"]
zulip_stream = 268952 # #edition 2021
zulip_stream = 268952 # #edition
topic = "Edition Bugs"
message_on_add = """\
Issue #{number} "{title}" has been added (previous edition 2021).
"""
[notify-zulip."A-edition-2024"]
required_labels = ["C-bug"]
zulip_stream = 268952 # #edition
topic = "Edition Bugs"
message_on_add = """\
Issue #{number} "{title}" has been added.