about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2024-07-04Auto merge of #127127 - notriddle:notriddle/pulldown-cmark-0.11, ↵bors-5/+9
r=GuillaumeGomez rustdoc: update to pulldown-cmark 0.11 r? rustdoc This pull request updates rustdoc to the latest version of pulldown-cmark. Along with adding new markdown extensions (which this PR doesn't enable), the new pulldown-cmark version also fixes a large number of bugs. Because all text files successfully parse as markdown, these bugfixes change the output, which can break people's existing docs. A crater run, https://github.com/rust-lang/rust/pull/121659, has already been run for this change. The first commit upgrades and fixes rustdoc. The second commit adds a lint for the footnote and block quote parser changes, which break the largest numbers of docs in the Crater run. The strikethrough change was mitigated in pulldown-cmark itself. Unblocks https://github.com/rust-lang/rust-clippy/pull/12876
2024-07-03Rollup merge of #127092 - compiler-errors:rtn-dots-redux, r=estebankMatthias Krüger-0/+2
Change return-type-notation to use `(..)` Aligns the syntax with the current wording of [RFC 3654](https://github.com/rust-lang/rfcs/pull/3654). Also implements rustfmt support (along with making a match exhaustive). Tracking: * https://github.com/rust-lang/rust/issues/109417
2024-07-01Fix import suggestion error when failed not from startingyukang-1/+11
2024-06-30rustdoc: update to pulldown-cmark 0.11Michael Howell-5/+9
2024-06-28Change RTN to use .. againMichael Goulet-0/+2
2024-06-27Tighten spans for async blocksMichael Goulet-1/+1
2024-06-25resolve: Tweak some naming around import ambiguitiesVadim Petrochenkov-50/+42
2024-06-25Auto merge of #125741 - petrochenkov:atvisord, r=davidtwcobors-12/+87
ast: Standardize visiting order for attributes and node IDs This should only affect `macro_rules` scopes and order of diagnostics. Also add a deprecation lint for `macro_rules` called outside of their scope, like in https://github.com/rust-lang/rust/issues/124535.
2024-06-24resolve: Implement a lint for out-of-scope use of `macro_rules`Vadim Petrochenkov-12/+87
2024-06-24Rollup merge of #125241 - Veykril:tool-rust-analyzer, r=davidtwcoMatthias Krüger-3/+4
Add `rust_analyzer` as a predefined tool Given all the other rust-lang tools have it, I'd expect r-a to have it too. (we have a few ideas for using this https://github.com/rust-lang/rust-analyzer/issues/11556).
2024-06-21Add `rust_analyzer` as a predefined toolLukas Wirth-3/+4
2024-06-21Rollup merge of #126767 - compiler-errors:static-foreign-item, r=spastorinoMatthias Krüger-6/+1
`StaticForeignItem` and `StaticItem` are the same The struct `StaticItem` and `StaticForeignItem` are the same, so remove `StaticForeignItem`. Having them be separate is unique to `static` items -- unlike `ForeignItemKind::{Fn,TyAlias}`, which use the normal AST item. r? ``@spastorino`` or ``@oli-obk``
2024-06-20StaticForeignItem and StaticItem are the sameMichael Goulet-6/+1
2024-06-20collect attrs in const block exprbohan-0/+3
2024-06-19Rollup merge of #124135 - petrochenkov:deleglob, r=fmease许杰友 Jieyou Xu (Joe)-32/+172
delegation: Implement glob delegation Support delegating to all trait methods in one go. Overriding globs with explicit definitions is also supported. The implementation is generally based on the design from https://github.com/rust-lang/rfcs/pull/3530#issuecomment-2020869823, but unlike with list delegation in https://github.com/rust-lang/rust/pull/123413 we cannot expand glob delegation eagerly. We have to enqueue it into the queue of unexpanded macros (most other macros are processed this way too), and then a glob delegation waits in that queue until its trait path is resolved, and enough code expands to generate the identifier list produced from the glob. Glob delegation is only allowed in impls, and can only point to traits. Supporting it in other places gives very little practical benefit, but significantly raises the implementation complexity. Part of https://github.com/rust-lang/rust/issues/118212.
2024-06-18Remove redundant argument from `subdiagnostic` methodOli Scherer-58/+42
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-2/+2
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-17Rework precise capturing syntaxMichael Goulet-3/+3
2024-06-17Rollup merge of #126568 - bvanjoi:fix-126376, r=petrochenkovMatthias Krüger-9/+16
mark undetermined if target binding in current ns is not got Fixes #126376 Fixes #126389 Add a branch to handle more cases... r? `@petrochenkov`
2024-06-17Rollup merge of #125258 - compiler-errors:static-if-no-lt, r=nnethercote许杰友 Jieyou Xu (Joe)-53/+89
Resolve elided lifetimes in assoc const to static if no other lifetimes are in scope Implements the change to elided lifetime resolution in *associated consts* subject to FCP here: https://github.com/rust-lang/rust/issues/125190#issue-2301532282 Specifically, walk the enclosing lifetime ribs in an associated const, and if we find no other lifetimes, then resolve to `'static`. Also make it work for traits, but don't lint -- just give a hard error in that case.
2024-06-17mark undetermined if target binding in current ns is not gotbohan-9/+16
2024-06-15delegation: Fix hygiene for `self`Vadim Petrochenkov-20/+28
And fix diagnostics for `self` from a macro.
2024-06-14delegation: Implement glob delegationVadim Petrochenkov-43/+185
2024-06-14Resolve const lifetimes to static in trait tooMichael Goulet-22/+34
2024-06-14Resolve elided lifetimes in assoc const to static if no other lifetimes are ↵Michael Goulet-40/+64
in scope
2024-06-13Tweak output of import suggestionsEsteban Küber-7/+39
When both `std::` and `core::` items are available, only suggest the `std::` ones. We ensure that in `no_std` crates we suggest `core::` items. Ensure that the list of items suggested to be imported are always in the order of local crate items, `std`/`core` items and finally foreign crate items. Tweak wording of import suggestion: if there are multiple items but they are all of the same kind, we use the kind name and not the generic "items". Fix #83564.
2024-06-11Rollup merge of #126234 - Bryanskiy:delegation-no-entry-ice, r=petrochenkov许杰友 Jieyou Xu (Joe)-2/+5
Delegation: fix ICE on late diagnostics fixes https://github.com/rust-lang/rust/issues/124342
2024-06-11Rollup merge of #125913 - fmease:early-lints-spruce-up-some-diags, r=Nadrieril许杰友 Jieyou Xu (Joe)-8/+16
Spruce up the diagnostics of some early lints Implement the various "*(note to myself) in a follow-up PR we should turn parts of this message into a subdiagnostic (help msg or even struct sugg)*" drive-by comments I left in #124417 during my review. For context, before #124417, only a few early lints touched/decorated/customized their diagnostic because the former API made it a bit awkward. Likely because of that, things that should've been subdiagnostics were just crammed into the primary message. This PR rectifies this.
2024-06-10Delegation: fix ICE on late diagnosticsBryanskiy-2/+5
2024-06-10Elision: consider lifetimes from &T iff T has SelfAdrian Taylor-19/+45
Change the algorithm which determines whether a self lifetime can be used for return type lifetime elision, such that we consider lifetimes attached to any reference in the self type, so long as Self can be found anywhere inside the type of that reference.
2024-06-07mark binding undetermined if target name exist and not obtainedbohan-5/+5
2024-06-07Revert "Create const block DefIds in typeck instead of ast lowering"Oli Scherer-4/+12
This reverts commit ddc5f9b6c1f21da5d4596bf7980185a00984ac42.
2024-06-06Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obkbors-3/+18
Unsafe extern blocks This implements RFC 3484. Tracking issue #123743 and RFC https://github.com/rust-lang/rfcs/pull/3484 This is better reviewed commit by commit.
2024-06-05Auto merge of #126038 - matthiaskrgr:rollup-h4rm3x2, r=matthiaskrgrbors-4/+29
Rollup of 9 pull requests Successful merges: - #124840 (resolve: mark it undetermined if single import is not has any bindings) - #125622 (Winnow private method candidates instead of assuming any candidate of the right name will apply) - #125648 (Remove unused(?) `~/rustsrc` folder from docker script) - #125672 (Add more ABI test cases to miri (RFC 3391)) - #125800 (Fix `mut` static task queue in SGX target) - #125871 (Orphanck[old solver]: Consider opaque types to never cover type parameters) - #125893 (Handle all GVN binops in a single place.) - #126008 (Port `tests/run-make-fulldeps/issue-19371` to ui-fulldeps) - #126032 (Update description of the `IsTerminal` example) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-05Rollup merge of #124840 - bvanjoi:fix-124490, r=petrochenkovMatthias Krüger-4/+29
resolve: mark it undetermined if single import is not has any bindings - Fixes #124490 - Fixes #125013 This issue arises from incorrect resolution updates, for example: ```rust mod a { pub mod b { pub mod c {} } } use a::*; use b::c; use c as b; fn main() {} ``` 1. In the first loop, binding `(root, b)` is refer to `root::a::b` due to `use a::*`. 1. However, binding `(root, c)` isn't defined by `use b::c` during this stage because `use c as b` falls under the `single_imports` of `(root, b)`, where the `imported_module` hasn't been computed yet. This results in marking the `path_res` for `b` as `Indeterminate`. 2. Then, the `imported_module` for `use c as b` will be recorded. 2. In the second loop, `use b::c` will be processed again: 1. Firstly, it attempts to find the `path_res` for `(root, b)`. 2. It will iterate through the `single_imports` of `use b::c`, encounter `use c as b`, attempt to resolve `c` in `root`, and ultimately return `Err(Undetermined)`, thus passing the iterator. 3. Use the binding `(root, b)` -> `root::a::b` introduced by `use a::*` and ultimately return `root::a::b` as the `path_res` of `b`. 4. Then define the binding `(root, c)` -> `root::a::b::c`. 3. Then process `use c as b`, update the resolution for `(root, b)` to refer to `root::a::b::c`, ultimately causing inconsistency. In my view, step `2.2` has an issue where it should exit early, similar to the behavior when there's no `imported_module`. Therefore, I've added an attribute called `indeterminate` to `ImportData`. This will help us handle only those single imports that have at least one determined binding. r? ``@petrochenkov``
2024-06-05Rollup merge of #125407 - pacak:no-lending-iterators, r=pnkfelixMatthias Krüger-5/+64
Detect when user is trying to create a lending `Iterator` and give a custom explanation The scope for this diagnostic is to detect lending iterators specifically and it's main goal is to help beginners to understand that what they are trying to implement might not be possible for `Iterator` trait specifically. I ended up to changing the wording from originally proposed in the ticket because it might be misleading otherwise: `Data` might have a lifetime parameter but it can be unrelated to items user is planning to return. Fixes https://github.com/rust-lang/rust/issues/125337
2024-06-04Add safe/unsafe to static inside extern blocksSantiago Pastorino-3/+15
2024-06-04Handle safety keyword for extern block inner itemsSantiago Pastorino-3/+6
2024-06-04Rollup merge of #125795 - lucasscharenbroch:undescore-prefix-suggestion, ↵Michael Goulet-14/+24
r=compiler-errors Improve renaming suggestion for names with leading underscores Fixes #125650 Before: ``` error[E0425]: cannot find value `p` in this scope --> test.rs:2:13 | 2 | let _ = p; | ^ | help: a local variable with a similar name exists, consider renaming `_p` into `p` | 1 | fn a(p: i32) { | ~ ``` After: ``` error[E0425]: cannot find value `p` in this scope --> test.rs:2:13 | 1 | fn a(_p: i32) { | -- `_p` defined here 2 | let _ = p; | ^ | help: the leading underscore in `_p` marks it as unused, consider renaming it to `p` | 1 | fn a(p: i32) { | ~ ``` This change doesn't exactly conform to what was proposed in the issue: 1. I've kept the suggested code instead of solely replacing it with the label 2. I've removed the "...similar name exists..." message instead of relocating to the usage span 3. You could argue that it still isn't completely clear that the change is referring to the definition (not the usage), but I'm not sure how to do this without playing down the fact that the error was caused by the usage of an undefined name.
2024-06-04resolve: mark it undetermined if single import is not has any bindingsbohan-4/+29
2024-06-03Spruce up the diagnostics of some early lintsLeón Orell Valerian Liehr-8/+16
2024-05-31Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, ↵Matthias Krüger-6/+6
r=compiler-errors Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanup Rename `hir::TypeBinding` and `ast::AssocConstraint` to `AssocItemConstraint` and update all items and locals using the old terminology. Motivation: The terminology *type binding* is extremely outdated. "Type bindings" not only include constraints on associated *types* but also on associated *constants* (feature `associated_const_equality`) and on RPITITs of associated *functions* (feature `return_type_notation`). Hence the word *item* in the new name. Furthermore, the word *binding* commonly refers to a mapping from a binder/identifier to a "value" for some definition of "value". Its use in "type binding" made sense when equality constraints (e.g., `AssocTy = Ty`) were the only kind of associated item constraint. Nowadays however, we also have *associated type bounds* (e.g., `AssocTy: Bound`) for which the term *binding* doesn't make sense. --- Old terminology (HIR, rustdoc): ``` `TypeBinding`: (associated) type binding ├── `Constraint`: associated type bound └── `Equality`: (associated) equality constraint (?) ├── `Ty`: (associated) type binding └── `Const`: associated const equality (constraint) ``` Old terminology (AST, abbrev.): ``` `AssocConstraint` ├── `Bound` └── `Equality` ├── `Ty` └── `Const` ``` New terminology (AST, HIR, rustdoc): ``` `AssocItemConstraint`: associated item constraint ├── `Bound`: associated type bound └── `Equality`: associated item equality constraint OR associated item binding (for short) ├── `Ty`: associated type equality constraint OR associated type binding (for short) └── `Const`: associated const equality constraint OR associated const binding (for short) ``` r? compiler-errors
2024-05-30Improve renaming suggestion for names with leading underscoresLucas Scharenbroch-14/+24
2024-05-30Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanupLeón Orell Valerian Liehr-6/+6
2024-05-29Rollup merge of #125705 - oli-obk:const_block_ice, r=compiler-errorsMatthias Krüger-0/+5
Reintroduce name resolution check for trying to access locals from an inline const fixes #125676 I removed this without replacement in https://github.com/rust-lang/rust/pull/124650 without considering the consequences
2024-05-29Reintroduce name resolution check for trying to access locals from an inline ↵Oli Scherer-0/+5
const
2024-05-29Rollup merge of #125381 - estebank:issue-96799, r=petrochenkov许杰友 Jieyou Xu (Joe)-9/+22
Silence some resolve errors when there have been glob import errors When encountering `use foo::*;` where `foo` fails to be found, and we later encounter resolution errors, we silence those later errors. A single case of the above, for an *existing* import on a big codebase would otherwise have a huge number of knock-down spurious errors. Ideally, instead of a global flag to silence all subsequent resolve errors, we'd want to introduce an unnameable binding in the appropriate rib as a sentinel when there's a failed glob import, so when we encounter a resolve error we can search for that sentinel and if found, and only then, silence that error. The current approach is just a quick proof of concept to iterate over. Partially address #96799.
2024-05-28Silence some resolve errors when there have been glob import errorsEsteban Küber-9/+22
When encountering `use foo::*;` where `foo` fails to be found, and we later encounter resolution errors, we silence those later errors. A single case of the above, for an *existing* import on a big codebase would otherwise have a huge number of knock-down spurious errors. Ideally, instead of a global flag to silence all subsequent resolve errors, we'd want to introduce an unameable binding in the appropriate rib as a sentinel when there's a failed glob import, so when we encounter a resolve error we can search for that sentinel and if found, and only then, silence that error. The current approach is just a quick proof of concept to iterate over. Partially address #96799.
2024-05-28Create const block DefIds in typeck instead of ast loweringOli Scherer-13/+0
2024-05-24And more general errorMichael Baikov-8/+28