Skip to content
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

Rollup of 9 pull requests #129772

Closed
wants to merge 163 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
163 commits
Select commit Hold shift + click to select a range
c1245e1
Add new assist toggle_macro_delimiter
alibektas Aug 1, 2024
662f02f
Make toggle_macro_delimiters work only for macro_calls
alibektas Aug 2, 2024
aa6e8d3
Allow declaring cfg groups in rust-project.json, to help sharing comm…
ChayimFriedman2 Aug 11, 2024
5e058db
docs: Add a doc comment for OpQueue
Wilfred Aug 13, 2024
54ecca0
Auto merge of #17885 - Wilfred:op_queue_docs, r=lnicola
bors Aug 14, 2024
4a14155
Be more resilient to bad language item definitions in binop inference
lnicola Aug 14, 2024
e2f2e73
Auto merge of #17891 - lnicola:binop-bad-lang-items, r=flodiebold
bors Aug 14, 2024
81b68b2
fix: Panic while canonicalizing erroneous projection type
ShoyuVanilla Aug 14, 2024
89cd585
Auto merge of #17882 - ShoyuVanilla:issue-17866, r=lnicola
bors Aug 14, 2024
b0183f8
fix: Panic while displaying associated function with a type annotation
ShoyuVanilla Aug 14, 2024
e20180d
Auto merge of #17893 - ShoyuVanilla:issue-17871, r=flodiebold
bors Aug 15, 2024
6ed283b
rustdoc-json: Add test for `Self` type
aDotInTheVoid Aug 15, 2024
a783e30
internal: Properly check the edition for edition dependent syntax kinds
Veykril Aug 15, 2024
a594a2d
Auto merge of #17896 - Veykril:editioned-syntax-kinds, r=Veykril
bors Aug 15, 2024
bf4d31d
Add scip/lsif flag to exclude vendored libaries
darichey Aug 15, 2024
23c8dcd
Allow flycheck process to exit gracefully
tmandry Aug 15, 2024
642a0f8
Replace once_cell with std's recently stabilized OnceCell/Lock and La…
ChayimFriedman2 Aug 16, 2024
0cbf6a7
Test for word boundary in `FindUsages`
ChayimFriedman2 Aug 16, 2024
b68992a
Auto merge of #17907 - ChayimFriedman2:no-once_cell, r=Veykril
bors Aug 16, 2024
95f5e4b
Auto merge of #17908 - ChayimFriedman2:usages-word-boundaries, r=Veykril
bors Aug 16, 2024
fdd5294
Auto merge of #17903 - tmandry:graceful-exit, r=Veykril
bors Aug 16, 2024
4ca597a
implement basic inferring of lifetimes
dfireBird Jun 29, 2024
2071778
Auto merge of #17595 - dfireBird:infer-lt, r=flodiebold
bors Aug 16, 2024
3d6129d
Properly account for editions in names
ChayimFriedman2 Aug 15, 2024
6908451
Auto merge of #17905 - ChayimFriedman2:edition-dependent-raw-keyword,…
bors Aug 16, 2024
995a014
Auto merge of #17900 - darichey:exclude-vendored-libraries, r=davidba…
bors Aug 16, 2024
6fc487d
Remove rust-analyzer.workspace.discoverProjectRunner
darichey Aug 16, 2024
01245bd
Auto merge of #17909 - darichey:remove-discoverProjectRunner, r=lnicola
bors Aug 16, 2024
d3fa5e9
Pin `rowan` to `0.15.15`
ShoyuVanilla Aug 17, 2024
d2d41b4
Auto merge of #17917 - ShoyuVanilla:pin-rowan, r=lnicola
bors Aug 17, 2024
c4b8c65
fix: Wrong BoundVar index when lowering impl trait parameter of paren…
ShoyuVanilla Aug 17, 2024
eb12861
Auto merge of #17916 - ShoyuVanilla:issue-17711, r=Veykril
bors Aug 17, 2024
d0ce97f
feat: Make rust-analyzer work partially when missing an internet conn…
Veykril Aug 17, 2024
324cf83
Adress new clippy::large_enum_variant diagnostics
Veykril Aug 17, 2024
51e3775
Auto merge of #17915 - Veykril:offline-no-deps, r=Veykril
bors Aug 17, 2024
74db4d3
Include generics when lowering extern type
darichey Aug 18, 2024
2c18533
Auto merge of #17925 - darichey:issue-17767, r=Veykril
bors Aug 19, 2024
1bfb362
chore(config): remove `invocationLocation` in favor of `invocationStr…
Tyrubias Aug 14, 2024
85f6d15
Auto merge of #17888 - Tyrubias:remove-invocation-location, r=Veykril
bors Aug 19, 2024
036affc
fix: keep comments in convert_while_to_loop
roife Aug 19, 2024
05f5c77
Auto merge of #17928 - roife:fix-issue-17869, r=Veykril
bors Aug 19, 2024
b2062ea
Improve documentation for `InvocationStrategy`
Veykril Aug 19, 2024
f17e9a0
Auto merge of #17929 - Veykril:invocation-loc-docs, r=Veykril
bors Aug 19, 2024
bd6ea75
Remove the ability to configure the user config path
Veykril Aug 19, 2024
879fa66
Allow user config to not exist
Veykril Aug 19, 2024
ea12d79
fix: Panic when a TAIT exists in a RPIT
ShoyuVanilla Aug 18, 2024
f9c0c8a
Auto merge of #17924 - ShoyuVanilla:issue-17921, r=Veykril
bors Aug 19, 2024
f25cb80
ServerStatusParams should consider 'prime caches' in quiescent status
Wilfred Aug 13, 2024
df6ce96
Auto merge of #17886 - Wilfred:prime_caches_quiescent, r=Veykril
bors Aug 19, 2024
a7d15a8
fix: Fix panics for semantic highlighting at startup
Veykril Aug 20, 2024
a9e3555
Auto merge of #17932 - Veykril:default-reply-lat-sensitive, r=Veykril
bors Aug 20, 2024
a42c732
Define workspace level configs.
alibektas Aug 16, 2024
8e31598
Next up : generating configs for workspace level configs
alibektas Aug 16, 2024
1b2eaa5
Old configs are back
alibektas Aug 17, 2024
085aac3
Auto merge of #17930 - Veykril:config-user-config, r=alibektas
bors Aug 20, 2024
9cb66c2
Auto merge of #17913 - alibektas:ratoml_improvements, r=alibektas
bors Aug 20, 2024
94f206a
Run flycheck only on crate if target is binary.
alibektas Aug 20, 2024
3f89eeb
internal: Implement `module_path` macro
Veykril Aug 21, 2024
db2e8e1
fix: Wrong `Sized` predicate for `generic_predicates_for_param`
ShoyuVanilla Aug 21, 2024
614fb24
Auto merge of #17939 - ShoyuVanilla:maybe-sized-fix, r=Veykril
bors Aug 22, 2024
f845536
Remove DescendPreference::SameText
Veykril Aug 22, 2024
d893dcc
Drop MacroInputKind
Veykril Aug 22, 2024
aeb9c7b
Implement floating point casts in const eval
HKalbasi Aug 22, 2024
1179cbb
Remove DescendPreference::SameKind
Veykril Aug 22, 2024
8e82e44
Fully remove old macro descension API
Veykril Aug 22, 2024
4d61444
Rename macro descension functions
Veykril Aug 22, 2024
d79999a
Thread file id through descension API for semantic highlighting
Veykril Aug 22, 2024
b0e7ef4
Sort hover results by relevance
Veykril Aug 22, 2024
f9db48f
Consider interleaving hover kinds
Veykril Aug 22, 2024
06228b9
Auto merge of #17942 - HKalbasi:fp-const-eval, r=HKalbasi
bors Aug 22, 2024
71c7cea
Fix sorting order for tokens in hover
Veykril Aug 22, 2024
81a9956
Auto merge of #17898 - Veykril:descend-2.0, r=Veykril
bors Aug 22, 2024
0a27711
Improve proc-macro panic message and workspace loading failure diagno…
Veykril Aug 22, 2024
1b0e158
Auto merge of #17943 - Veykril:diags, r=Veykril
bors Aug 22, 2024
f65d605
When descending into macros in search, first check if there is a need…
ChayimFriedman2 Aug 16, 2024
a57def2
Speed up search for short associated functions, especially very commo…
ChayimFriedman2 Aug 18, 2024
a44152a
Add cov_marks to test #17927
ChayimFriedman2 Aug 22, 2024
0251cfa
Apply changes
alibektas Aug 22, 2024
b88a4f0
Auto merge of #17912 - alibektas:cargo_check_on_binary, r=Veykril
bors Aug 23, 2024
916c559
Remove incorrect FIXME comment
Veykril Aug 23, 2024
39cc5b6
Auto merge of #17927 - ChayimFriedman2:speedup-new-usages, r=Veykril
bors Aug 23, 2024
ac912c7
Auto merge of #17936 - Veykril:module_path, r=Veykril
bors Aug 23, 2024
5f7489a
internal: Don't requery crates_for for flycheck when crates are known
Veykril Aug 23, 2024
e030cf0
Auto merge of #17946 - Veykril:flycheck-crates-for, r=Veykril
bors Aug 23, 2024
3a097e1
Auto merge of #17857 - ChayimFriedman2:rust-project-cfg-group, r=Veykril
bors Aug 23, 2024
eb896a5
fix: Wrong `Self: Sized` predicate for trait assoc items
ShoyuVanilla Aug 23, 2024
3bd42d3
Auto merge of #17948 - ShoyuVanilla:parent-self-sized, r=Veykril
bors Aug 23, 2024
bdbc057
Include buildfile path in watcher list
Wilfred Aug 23, 2024
a074e1a
Auto merge of #17949 - Wilfred:include_build_file_in_watchers, r=lnicola
bors Aug 24, 2024
12faedd
Fix few bugs in closure capture computation, and add tests
ChayimFriedman2 Aug 24, 2024
77ab568
Preserve all spans for closure captures, not just one
ChayimFriedman2 Aug 24, 2024
cf243e5
Add `gen` modifier to functions
ChayimFriedman2 Aug 22, 2024
1e0df17
Handle associated types that are lang items
ChayimFriedman2 Aug 22, 2024
2c6a521
Provide `Future::Output` and `Iterator` lang items
ChayimFriedman2 Aug 22, 2024
737a969
Add helper methods to retrieve `Future::Output` and `Iterator::Item`
ChayimFriedman2 Aug 22, 2024
7339337
Modify `hacks::parse_expr_from_str()` to take an edition too
ChayimFriedman2 Aug 22, 2024
6340522
Provide `impl From<ast::TypeOrConstParam> for ast::GenericParam`
ChayimFriedman2 Aug 22, 2024
becfc5a
Impl PartialEq and Eq for `IndentLevel`
ChayimFriedman2 Aug 22, 2024
7bd3ca1
Don't enable the search fast path for short associated functions when…
ChayimFriedman2 Aug 25, 2024
cba00a8
Auto merge of #17955 - ChayimFriedman2:fix-fast-search-with-scope, r=…
bors Aug 25, 2024
d9d8d94
fix: Fix metadata retrying eating original errors
Veykril Aug 25, 2024
c223013
Auto merge of #17956 - Veykril:metadata-err, r=Veykril
bors Aug 25, 2024
606401f
fix: Fix trait method completions not acknowledging Deref impls
Veykril Aug 25, 2024
bdee5c9
Auto merge of #17958 - Veykril:deref-chain-method-completions, r=Veykril
bors Aug 25, 2024
2703ea1
fix: add extra_test_bin_args to test explorer test runner
Aug 25, 2024
98e23d3
internal: Don't allocate autoderef steps when not needed
Veykril Aug 25, 2024
31a532a
Auto merge of #17961 - Veykril:autoderef-alloc, r=Veykril
bors Aug 25, 2024
e0b1719
Auto merge of #17960 - duncanawoods:master, r=HKalbasi
bors Aug 25, 2024
326a1c6
Fix Return Type Syntax to include `..` (i.e. `method(..)` and not `me…
ChayimFriedman2 Aug 25, 2024
a3f1196
Auto merge of #17962 - ChayimFriedman2:update-rtn, r=Veykril
bors Aug 26, 2024
239dc5d
Auto merge of #17941 - ChayimFriedman2:pre-closure-to-fn, r=Veykril
bors Aug 26, 2024
9dad25a
Show and render error lifetime args as `'_`
avrong Aug 26, 2024
9d4fdc0
Show lifetime args if there are only error ones
avrong Aug 26, 2024
05e6fb6
Auto merge of #17963 - avrong:avrong/error-lifetimes, r=Veykril
bors Aug 26, 2024
65e9f8b
Fix "Unwrap block" assist with block modifiers
ChayimFriedman2 Aug 26, 2024
c61f85b
Don't make pattern nonterminals match statement nonterminals
compiler-errors Jan 22, 2024
0763a3a
Bump backtrace to rust-lang/backtrace@fc37b22
workingjubilee Aug 27, 2024
65d25fe
Revert "feat: Implement `module_path` macro"
Veykril Aug 27, 2024
f0bfd43
Auto merge of #17972 - rust-lang:revert-17936-module_path, r=Veykril
bors Aug 27, 2024
6593688
Auto merge of #17970 - ChayimFriedman2:unwrap-unsafe-block, r=Veykril
bors Aug 27, 2024
df4580b
Expand proc-macros in workspace root, not package root
Veykril Aug 27, 2024
b592256
Drop Apache license appendices
lnicola Aug 27, 2024
e4c404e
Auto merge of #17973 - Veykril:proc-macro-curr-dir, r=Veykril
bors Aug 27, 2024
2dce250
Auto merge of #17974 - lnicola:rm-apache-appendix, r=lnicola
bors Aug 27, 2024
c9a3b02
Fix tests
Veykril Aug 27, 2024
199c01d
Auto merge of #17757 - alibektas:toggle_macro_delimiters, r=Veykril
bors Aug 27, 2024
34e50f5
Create an assist to convert closure to freestanding fn
ChayimFriedman2 Aug 22, 2024
51055f7
Fix cwd used for proc macro expansion
lnicola Aug 28, 2024
248a557
Auto merge of #17981 - lnicola:proc-macro-cwd, r=Veykril
bors Aug 28, 2024
ae6f8a7
allow BufReader::peek to be called on unsized types
lolbinarycat Aug 28, 2024
4880eee
Fix name resolution of shadowed builtin macro
ChayimFriedman2 Aug 28, 2024
2a7ec0b
Consider all expressions that autoderef in "Extract variable", not ju…
ChayimFriedman2 Aug 28, 2024
fe5f91e
Don't add reference when it isn't needed for the "Extract variable" a…
ChayimFriedman2 Aug 28, 2024
5aefe78
internal: Avoid newlines in fetch workspace errors
Wilfred Aug 28, 2024
3ff3d39
Also handle deref expressions in "Extract variable"
ChayimFriedman2 Aug 28, 2024
b3fcd8e
Consider field attributes when converting from tuple to named struct …
ChayimFriedman2 Aug 28, 2024
c2c1bd0
Fix incorrect symbol definitions in SCIP output
darichey Aug 28, 2024
9200452
Stop using ty::GenericPredicates for non-predicates_of queries
compiler-errors Aug 29, 2024
3a14e30
Auto merge of #17992 - Wilfred:newlines_in_logs, r=Veykril
bors Aug 29, 2024
14ec120
fix: Fix proc-macro server crashing when parsing a non-lexable string…
Veykril Aug 29, 2024
03d6745
fix: Fix TokenStream::to_string implementation dropping quotation marks
Veykril Aug 29, 2024
266bb1f
Auto merge of #17994 - Veykril:proc-macro-srv-from-str-panic, r=Veykril
bors Aug 29, 2024
2ec71c8
Preparing for merge from rust-lang/rust
lnicola Aug 29, 2024
26888c3
Merge from rust-lang/rust
lnicola Aug 29, 2024
f05888d
Auto merge of #17995 - lnicola:sync-from-rust, r=lnicola
bors Aug 29, 2024
b195ff3
Auto merge of #17940 - ChayimFriedman2:closure-to-fn, r=Veykril
bors Aug 29, 2024
e0625d5
Auto merge of #17988 - darichey:fix-scip-def, r=Veykril
bors Aug 29, 2024
b6d0fd0
Auto merge of #17987 - ChayimFriedman2:column-macro, r=Veykril
bors Aug 29, 2024
cd377d9
Auto merge of #17991 - ChayimFriedman2:extract-variable-ref, r=Veykril
bors Aug 29, 2024
34e7e79
Auto merge of #17993 - ChayimFriedman2:convert-to-tuple-attrs, r=Veykril
bors Aug 29, 2024
de34a91
interpret/visitor: make memory order iteration slightly more efficient
RalfJung Aug 29, 2024
8c798c8
Simplify some extern providers
compiler-errors Aug 29, 2024
518b41c
Try latest backtrace
workingjubilee Aug 29, 2024
fa4f892
Remove `Option<!>` return types.
nnethercote Aug 29, 2024
0f29560
Rollup merge of #120221 - compiler-errors:statements-are-not-patterns…
workingjubilee Aug 30, 2024
e411e44
Rollup merge of #129123 - aDotInTheVoid:rustdoc-json-self, r=fmease
workingjubilee Aug 30, 2024
19ccc23
Rollup merge of #129642 - workingjubilee:bump-backtrace-fc37b22, r=wo…
workingjubilee Aug 30, 2024
e3aec4f
Rollup merge of #129675 - lolbinarycat:bufreader_peek_unsized, r=work…
workingjubilee Aug 30, 2024
f88a091
Rollup merge of #129723 - compiler-errors:extern-providers, r=lcnr
workingjubilee Aug 30, 2024
8d3be01
Rollup merge of #129724 - nnethercote:rm-Option-bang, r=fee1-dead
workingjubilee Aug 30, 2024
2baed45
Rollup merge of #129725 - compiler-errors:predicates-of, r=fmease
workingjubilee Aug 30, 2024
a9531e3
Rollup merge of #129733 - lnicola:sync-from-ra, r=lnicola
workingjubilee Aug 30, 2024
1b5c216
Rollup merge of #129751 - RalfJung:interpret-visit-field-order, r=com…
workingjubilee Aug 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
57 changes: 36 additions & 21 deletions compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,9 @@ impl Token {
}

/// Returns `true` if the token can appear at the start of an expression.
///
/// **NB**: Take care when modifying this function, since it will change
/// the stable set of tokens that are allowed to match an expr nonterminal.
pub fn can_begin_expr(&self) -> bool {
match self.uninterpolate().kind {
Ident(name, is_raw) =>
Expand All @@ -504,34 +507,46 @@ impl Token {
PathSep | // global path
Lifetime(..) | // labeled loop
Pound => true, // expression attributes
Interpolated(ref nt) => matches!(&**nt, NtLiteral(..) |
NtExpr(..) |
NtBlock(..) |
NtPath(..)),
Interpolated(ref nt) =>
matches!(&**nt,
NtBlock(..) |
NtExpr(..) |
NtLiteral(..) |
NtPath(..)
),
_ => false,
}
}

/// Returns `true` if the token can appear at the start of a pattern.
///
/// Shamelessly borrowed from `can_begin_expr`, only used for diagnostics right now.
pub fn can_begin_pattern(&self) -> bool {
match self.uninterpolate().kind {
Ident(name, is_raw) =>
ident_can_begin_expr(name, self.span, is_raw), // value name or keyword
| OpenDelim(Delimiter::Bracket | Delimiter::Parenthesis) // tuple or array
| Literal(..) // literal
| BinOp(Minus) // unary minus
| BinOp(And) // reference
| AndAnd // double reference
// DotDotDot is no longer supported
| DotDot | DotDotDot | DotDotEq // ranges
| Lt | BinOp(Shl) // associated path
| PathSep => true, // global path
Interpolated(ref nt) => matches!(&**nt, NtLiteral(..) |
NtPat(..) |
NtBlock(..) |
NtPath(..)),
pub fn can_begin_pattern(&self, pat_kind: NtPatKind) -> bool {
match &self.uninterpolate().kind {
// box, ref, mut, and other identifiers (can stricten)
Ident(..) | NtIdent(..) |
OpenDelim(Delimiter::Parenthesis) | // tuple pattern
OpenDelim(Delimiter::Bracket) | // slice pattern
BinOp(And) | // reference
BinOp(Minus) | // negative literal
AndAnd | // double reference
Literal(_) | // literal
DotDot | // range pattern (future compat)
DotDotDot | // range pattern (future compat)
PathSep | // path
Lt | // path (UFCS constant)
BinOp(Shl) => true, // path (double UFCS)
// leading vert `|` or-pattern
BinOp(Or) => matches!(pat_kind, PatWithOr),
Interpolated(nt) =>
matches!(&**nt,
| NtExpr(..)
| NtLiteral(..)
| NtMeta(..)
| NtPat(..)
| NtPath(..)
| NtTy(..)
),
_ => false,
}
}
Expand Down
19 changes: 10 additions & 9 deletions compiler/rustc_const_eval/src/interpret/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized {
}

/// This function provides the chance to reorder the order in which fields are visited for
/// `FieldsShape::Aggregate`: The order of fields will be
/// `(0..num_fields).map(aggregate_field_order)`.
/// `FieldsShape::Aggregate`.
///
/// The default means we iterate in source declaration order; alternative this can do an inverse
/// lookup in `memory_index` to use memory field order instead.
/// The default means we iterate in source declaration order; alternatively this can do some
/// work with `memory_index` to iterate in memory order.
#[inline(always)]
fn aggregate_field_order(_memory_index: &IndexVec<FieldIdx, u32>, idx: usize) -> usize {
idx
fn aggregate_field_iter(
memory_index: &IndexVec<FieldIdx, u32>,
) -> impl Iterator<Item = FieldIdx> + 'static {
memory_index.indices()
}

// Recursive actions, ready to be overloaded.
Expand Down Expand Up @@ -172,9 +173,9 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized {
&FieldsShape::Union(fields) => {
self.visit_union(v, fields)?;
}
FieldsShape::Arbitrary { offsets, memory_index } => {
for idx in 0..offsets.len() {
let idx = Self::aggregate_field_order(memory_index, idx);
FieldsShape::Arbitrary { memory_index, .. } => {
for idx in Self::aggregate_field_iter(memory_index) {
let idx = idx.as_usize();
let field = self.ecx().project_field(v, idx)?;
self.visit_field(v, idx, &field)?;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
span: Span,
def_id: LocalDefId,
assoc_name: Ident,
) -> ty::GenericPredicates<'tcx> {
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
self.tcx.at(span).type_param_predicates((self.item_def_id, def_id, assoc_name))
}

Expand Down
59 changes: 29 additions & 30 deletions compiler/rustc_hir_analysis/src/collect/predicates_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,24 +580,24 @@ pub(super) fn explicit_predicates_of<'tcx>(
/// Ensures that the super-predicates of the trait with a `DefId`
/// of `trait_def_id` are lowered and stored. This also ensures that
/// the transitive super-predicates are lowered.
pub(super) fn explicit_super_predicates_of(
tcx: TyCtxt<'_>,
pub(super) fn explicit_super_predicates_of<'tcx>(
tcx: TyCtxt<'tcx>,
trait_def_id: LocalDefId,
) -> ty::GenericPredicates<'_> {
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
implied_predicates_with_filter(tcx, trait_def_id.to_def_id(), PredicateFilter::SelfOnly)
}

pub(super) fn explicit_supertraits_containing_assoc_item(
tcx: TyCtxt<'_>,
pub(super) fn explicit_supertraits_containing_assoc_item<'tcx>(
tcx: TyCtxt<'tcx>,
(trait_def_id, assoc_name): (DefId, Ident),
) -> ty::GenericPredicates<'_> {
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
implied_predicates_with_filter(tcx, trait_def_id, PredicateFilter::SelfThatDefines(assoc_name))
}

pub(super) fn explicit_implied_predicates_of(
tcx: TyCtxt<'_>,
pub(super) fn explicit_implied_predicates_of<'tcx>(
tcx: TyCtxt<'tcx>,
trait_def_id: LocalDefId,
) -> ty::GenericPredicates<'_> {
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
implied_predicates_with_filter(
tcx,
trait_def_id.to_def_id(),
Expand All @@ -612,11 +612,11 @@ pub(super) fn explicit_implied_predicates_of(
/// Ensures that the super-predicates of the trait with a `DefId`
/// of `trait_def_id` are lowered and stored. This also ensures that
/// the transitive super-predicates are lowered.
pub(super) fn implied_predicates_with_filter(
tcx: TyCtxt<'_>,
pub(super) fn implied_predicates_with_filter<'tcx>(
tcx: TyCtxt<'tcx>,
trait_def_id: DefId,
filter: PredicateFilter,
) -> ty::GenericPredicates<'_> {
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
let Some(trait_def_id) = trait_def_id.as_local() else {
// if `assoc_name` is None, then the query should've been redirected to an
// external provider
Expand Down Expand Up @@ -679,20 +679,16 @@ pub(super) fn implied_predicates_with_filter(
_ => {}
}

ty::GenericPredicates {
parent: None,
predicates: implied_bounds,
effects_min_tys: ty::List::empty(),
}
ty::EarlyBinder::bind(implied_bounds)
}

/// Returns the predicates defined on `item_def_id` of the form
/// `X: Foo` where `X` is the type parameter `def_id`.
#[instrument(level = "trace", skip(tcx))]
pub(super) fn type_param_predicates(
tcx: TyCtxt<'_>,
pub(super) fn type_param_predicates<'tcx>(
tcx: TyCtxt<'tcx>,
(item_def_id, def_id, assoc_name): (LocalDefId, LocalDefId, Ident),
) -> ty::GenericPredicates<'_> {
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
use rustc_hir::*;
use rustc_middle::ty::Ty;

Expand All @@ -713,18 +709,20 @@ pub(super) fn type_param_predicates(
tcx.generics_of(item_def_id).parent.map(|def_id| def_id.expect_local())
};

let mut result = parent
.map(|parent| {
let icx = ItemCtxt::new(tcx, parent);
icx.probe_ty_param_bounds(DUMMY_SP, def_id, assoc_name)
})
.unwrap_or_default();
let result = if let Some(parent) = parent {
let icx = ItemCtxt::new(tcx, parent);
icx.probe_ty_param_bounds(DUMMY_SP, def_id, assoc_name)
} else {
ty::EarlyBinder::bind(&[] as &[_])
};
let mut extend = None;

let item_hir_id = tcx.local_def_id_to_hir_id(item_def_id);

let hir_node = tcx.hir_node(item_hir_id);
let Some(hir_generics) = hir_node.generics() else { return result };
let Some(hir_generics) = hir_node.generics() else {
return result;
};
if let Node::Item(item) = hir_node
&& let ItemKind::Trait(..) = item.kind
// Implied `Self: Trait` and supertrait bounds.
Expand All @@ -748,9 +746,10 @@ pub(super) fn type_param_predicates(
_ => false,
}),
);
result.predicates =
tcx.arena.alloc_from_iter(result.predicates.iter().copied().chain(extra_predicates));
result

ty::EarlyBinder::bind(
tcx.arena.alloc_from_iter(result.skip_binder().iter().copied().chain(extra_predicates)),
)
}

impl<'tcx> ItemCtxt<'tcx> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1761,7 +1761,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
break Some((bound_vars.into_iter().collect(), assoc_item));
}
let predicates = tcx.explicit_supertraits_containing_assoc_item((def_id, assoc_name));
let obligations = predicates.predicates.iter().filter_map(|&(pred, _)| {
let obligations = predicates.iter_identity_copied().filter_map(|(pred, _)| {
let bound_predicate = pred.kind();
match bound_predicate.skip_binder() {
ty::ClauseKind::Trait(data) => {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub trait HirTyLowerer<'tcx> {
span: Span,
def_id: LocalDefId,
assoc_name: Ident,
) -> ty::GenericPredicates<'tcx>;
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]>;

/// Lower an associated type to a projection.
///
Expand Down Expand Up @@ -831,13 +831,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
debug!(?ty_param_def_id, ?assoc_name, ?span);
let tcx = self.tcx();

let predicates = &self.probe_ty_param_bounds(span, ty_param_def_id, assoc_name).predicates;
let predicates = &self.probe_ty_param_bounds(span, ty_param_def_id, assoc_name);
debug!("predicates={:#?}", predicates);

self.probe_single_bound_for_assoc_item(
|| {
let trait_refs = predicates
.iter()
.iter_identity_copied()
.filter_map(|(p, _)| Some(p.as_trait_clause()?.map_bound(|t| t.trait_ref)));
traits::transitive_bounds_that_define_assoc_item(tcx, trait_refs, assoc_name)
},
Expand Down
25 changes: 11 additions & 14 deletions compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,27 +263,24 @@ impl<'tcx> HirTyLowerer<'tcx> for FnCtxt<'_, 'tcx> {
_: Span,
def_id: LocalDefId,
_: Ident,
) -> ty::GenericPredicates<'tcx> {
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
let tcx = self.tcx;
let item_def_id = tcx.hir().ty_param_owner(def_id);
let generics = tcx.generics_of(item_def_id);
let index = generics.param_def_id_to_index[&def_id.to_def_id()];
// HACK(eddyb) should get the original `Span`.
let span = tcx.def_span(def_id);
ty::GenericPredicates {
parent: None,
predicates: tcx.arena.alloc_from_iter(
self.param_env.caller_bounds().iter().filter_map(|predicate| {
match predicate.kind().skip_binder() {
ty::ClauseKind::Trait(data) if data.self_ty().is_param(index) => {
Some((predicate, span))
}
_ => None,

ty::EarlyBinder::bind(tcx.arena.alloc_from_iter(
self.param_env.caller_bounds().iter().filter_map(|predicate| {
match predicate.kind().skip_binder() {
ty::ClauseKind::Trait(data) if data.self_ty().is_param(index) => {
Some((predicate, span))
}
}),
),
effects_min_tys: ty::List::empty(),
}
_ => None,
}
}),
))
}

fn lower_assoc_ty(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/traits/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub fn transitive_bounds_that_define_assoc_item<'tcx>(

stack.extend(
tcx.explicit_supertraits_containing_assoc_item((trait_ref.def_id(), assoc_name))
.instantiate_own_identity()
.iter_identity_copied()
.map(|(clause, _)| clause.instantiate_supertrait(tcx, trait_ref))
.filter_map(|clause| clause.as_trait_clause())
// FIXME: Negative supertraits are elaborated here lol
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_lint/src/multiple_supertrait_upcastable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ impl<'tcx> LateLintPass<'tcx> for MultipleSupertraitUpcastable {
let direct_super_traits_iter = cx
.tcx
.explicit_super_predicates_of(def_id)
.predicates
.into_iter()
.iter_identity_copied()
.filter_map(|(pred, _)| pred.as_trait_clause());
if direct_super_traits_iter.count() > 1 {
cx.emit_span_lint(
Expand Down
32 changes: 0 additions & 32 deletions compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1070,34 +1070,6 @@ impl<'a> CrateMetadataRef<'a> {
)
}

fn get_explicit_item_bounds<'tcx>(
self,
index: DefIndex,
tcx: TyCtxt<'tcx>,
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
let lazy = self.root.tables.explicit_item_bounds.get(self, index);
let output = if lazy.is_default() {
&mut []
} else {
tcx.arena.alloc_from_iter(lazy.decode((self, tcx)))
};
ty::EarlyBinder::bind(&*output)
}

fn get_explicit_item_super_predicates<'tcx>(
self,
index: DefIndex,
tcx: TyCtxt<'tcx>,
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
let lazy = self.root.tables.explicit_item_super_predicates.get(self, index);
let output = if lazy.is_default() {
&mut []
} else {
tcx.arena.alloc_from_iter(lazy.decode((self, tcx)))
};
ty::EarlyBinder::bind(&*output)
}

fn get_variant(
self,
kind: DefKind,
Expand Down Expand Up @@ -1323,10 +1295,6 @@ impl<'a> CrateMetadataRef<'a> {
self.root.tables.optimized_mir.get(self, id).is_some()
}

fn cross_crate_inlinable(self, id: DefIndex) -> bool {
self.root.tables.cross_crate_inlinable.get(self, id)
}

fn get_fn_has_self_parameter(self, id: DefIndex, sess: &'a Session) -> bool {
self.root
.tables
Expand Down
Loading
Loading