about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2021-12-11Do not ICE when suggesting elided lifetimes on non-existent spans.Camille GILLOT-0/+5
2021-12-07Store impl_trait_fn inside OpaqueTyOrigin.Camille GILLOT-4/+11
2021-12-03Annotate `derive`d spans and move span suggestion codeEsteban Kuber-2/+2
* Annotate `derive`d spans from the user's code with the appropciate context * Add `Span::can_be_used_for_suggestion` to query if the underlying span at the users' code
2021-12-03Keep spans for generics in `#[derive(_)]` desugaringEsteban Kuber-11/+5
Keep the spans for generics coming from a `derive`d Item, so that errors and suggestions have better detail. Fix #84003.
2021-12-02Rollup merge of #91394 - Mark-Simulacrum:bump-stage0, r=pietroalbiniMatthias Krüger-1/+0
Bump stage0 compiler r? `@pietroalbini` (or anyone else)
2021-12-02Rollup merge of #91045 - mjptree:issue-90702-fix, r=petrochenkovMatthias Krüger-70/+91
Issue 90702 fix: Stop treating some crate loading failures as fatal errors Surface mulitple `extern crate` resolution errors at a time. This is achieved by creating a dummy crate, instead of aborting directly after the resolution error. The `ExternCrateError` has been added to allow propagating the resolution error from `rustc_metadata` crate to the `rustc_resolve` with a minimal public surface. The `import_extern_crate` function is a block that was factored out from `build_reduced_graph_for_item` for better organization. The only added functionality made to it where the added error handling in the `process_extern_crate` call. The remaining bits in this function are the same as before. Resolves #90702 r? `@petrochenkov`
2021-12-01Auto merge of #90446 - cjgillot:late-elided, r=jackh726bors-123/+170
Lint elided lifetimes in path during lifetime resolution. The lifetime elision lint is known to be brittle and can be redundant with later lifetime resolution errors. This PR aims to remove the redundancy by performing the lint after lifetime resolution. This PR proposes to carry the information that an elision should be linted against by using a special `LifetimeName`. I am not certain this is the best solution, but it is certainly the easiest. Fixes https://github.com/rust-lang/rust/issues/60199 Fixes https://github.com/rust-lang/rust/issues/55768 Fixes https://github.com/rust-lang/rust/issues/63110 Fixes https://github.com/rust-lang/rust/issues/71957
2021-12-01Improve suggestion for extern crate self error messageMichael-37/+21
2021-12-01Stop treating extern crate loading failures as fatal errorsMichael-12/+35
2021-12-01Factor out build reduced graph for extern crateMichael-69/+83
2021-12-01Rollup merge of #91313 - petrochenkov:cratexp, r=Aaron1011Matthias Krüger-10/+18
expand: Turn `ast::Crate` into a first class expansion target And stop creating a fake `mod` item for the crate root when expanding a crate, thus addressing FIXMEs left in https://github.com/rust-lang/rust/pull/82238, and making a step towards a proper support for crate-level macro attributes (cc #54726). I haven't added token collection support for the whole crate in this PR, maybe later. r? `@Aaron1011`
2021-12-01Rollup merge of #91404 - nnethercote:fix-bad-NodeId-limit-checking, r=dtolnayMatthias Krüger-6/+3
Fix bad `NodeId` limit checking. `Resolver::next_node_id` converts a `u32` to a `usize` (which is possibly bigger), does a checked add, and then converts the result back to a `u32`. The `usize` conversion completely subverts the checked add! This commit removes the conversion to/from `usize`.
2021-12-01Rollup merge of #91298 - FabianWolff:issue-91028-source-avail, r=cjgillotMatthias Krüger-1/+1
Improve error message for `E0659` if the source is not available Fixes #91028. The fix is similar to those in #89233 and #87088. With this change, instead of the dangling ``` note: `Option` could also refer to the enum defined here ``` I get ``` note: `Option` could also refer to an enum from prelude ``` If the standard library source code _is_ available, the output does not change.
2021-12-01Fix bad `NodeId` limit checking.Nicholas Nethercote-6/+3
`Resolver::next_node_id` converts a `u32` to a `usize` (which is possibly bigger), does a checked add, and then converts the result back to a `u32`. The `usize` conversion completely subverts the checked add! This commit removes the conversion to/from `usize`.
2021-11-30Merge Implicit and ImplicitMissing.Camille GILLOT-7/+4
2021-11-30Handle `allow(elided_lifetimes_in_paths)`.Camille GILLOT-31/+28
2021-11-30Lint elided lifetimes in path during lifetime resolution.Camille GILLOT-9/+57
2021-11-30Flatten match.Camille GILLOT-37/+41
2021-11-30Move report_elision_failure in diagnostics.rs.Camille GILLOT-82/+83
2021-11-30Apply cfg-bootstrap switchMark Rousskov-1/+0
2021-11-28Take a LocalDefId in expect_*item.Camille GILLOT-6/+6
2021-11-28expand: Turn `ast::Crate` into a first class expansion targetVadim Petrochenkov-10/+18
And stop creating a fake `mod` item for the crate root when expanding a crate.
2021-11-27Improve error message for `E0659` if the source is not availableFabian Wolff-1/+1
2021-11-25Rollup merge of #91111 - cjgillot:hir-no-lower-attrs, r=michaelwoeristerMatthias Krüger-0/+4
Do not visit attributes in `ItemLowerer`. By default, AST visitors visit expressions that appear in key-value attributes. Those expressions should not be lowered to HIR, as they do not correspond to actually compiled code. Since an attribute cannot produce meaningful HIR, just skip them altogether. Fixes https://github.com/rust-lang/rust/issues/81886 Fixes https://github.com/rust-lang/rust/issues/90873 r? `@michaelwoerister`
2021-11-25Do not visit attributes in `LateResolutionVisitor`.Camille GILLOT-0/+4
2021-11-23Rollup merge of #90856 - ↵Matthias Krüger-0/+1
ken-matsui:suggestion-to-wrap-vec-allocator-api-in-tuple, r=davidtwco Suggestion to wrap inner types using 'allocator_api' in tuple This PR provides a suggestion to wrap the inner types in tuple when being along with 'allocator_api'. Closes https://github.com/rust-lang/rust/issues/83250 ```rust fn main() { let _vec: Vec<u8, _> = vec![]; //~ ERROR use of unstable library feature 'allocator_api' } ``` ```diff error[E0658]: use of unstable library feature 'allocator_api' --> $DIR/suggest-vec-allocator-api.rs:2:23 | LL | let _vec: Vec<u8, _> = vec![]; - | ^ + | ----^ + | | + | help: consider wrapping the inner types in tuple: `(u8, _)` | = note: see issue #32838 <https://github.com/rust-lang/rust/issues/32838> for more information = help: add `#![feature(allocator_api)]` to the crate attributes to enable ```
2021-11-24Suggestion to wrap inner types using `allocator_api` in tupleKen Matsui-0/+1
2021-11-20Rollup merge of #90930 - Nilstrieb:fix-non-const-value-ice, r=estebankMatthias Krüger-2/+14
Fix `non-constant value` ICE (#90878) This also fixes the same suggestion, which was kind of broken, because it just searched for the last occurence of `const` to replace with a `let`. This works great in some cases, but when there is no const and a leading space to the file, it doesn't work and panic with overflow because it thought that it had found a const. I also changed the suggestion to only trigger if the `const` and the non-constant value are on the same line, because if they aren't, the suggestion is very likely to be wrong. Also don't trigger the suggestion if the found `const` is on line 0, because that triggers the ICE. Asking Esteban to review since he was the last one to change the relevant code. r? ``@estebank`` Fixes #90878
2021-11-20Rollup merge of #90628 - ↵Matthias Krüger-17/+33
ken-matsui:clarify-error-messages-caused-by-reexporting-pub-crate-visibility-to-outside, r=oli-obk Clarify error messages caused by re-exporting `pub(crate)` visibility to outside This PR clarifies error messages and suggestions caused by re-exporting pub(crate) visibility outside the crate. Here is a small example ([Rust Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=e2cd0bd4422d4f20e6522dcbad167d3b)): ```rust mod m { pub(crate) enum E {} } pub use m::E; fn main() {} ``` This code is compiled to: ``` error[E0365]: `E` is private, and cannot be re-exported --> prog.rs:4:9 | 4 | pub use m::E; | ^^^^ re-export of private `E` | = note: consider declaring type or module `E` with `pub` error: aborting due to previous error For more information about this error, try `rustc --explain E0365`. ``` However, enum `E` is actually public to the crate, not private totally—nevertheless, rustc treats `pub(crate)` and private visibility as the same on the error messages. They are not clear and should be segmented distinctly. By applying changes in this PR, the error message below will be the following message that would be clearer: ``` error[E0365]: `E` is only public to inside of the crate, and cannot be re-exported outside --> prog.rs:4:9 | 4 | pub use m::E; | ^^^^ re-export of crate public `E` | = note: consider declaring type or module `E` with `pub` error: aborting due to previous error For more information about this error, try `rustc --explain E0365`. ```
2021-11-20Clarify error messages caused by re-exporting `pub(crate)` visibility to outsideKen Matsui-17/+33
2021-11-18rustc: Remove `#[rustc_synthetic]`Vadim Petrochenkov-12/+8
This function parameter attribute was introduced in https://github.com/rust-lang/rust/pull/44866 as an intermediate step in implementing `impl Trait`, it's not necessary or used anywhere by itself.
2021-11-16Fix case where ICE #90878 was still triggered by a leading newlineNilstrieb-9/+7
I cannot provide a test for that thanks to tidy.
2021-11-15Fix `non-constant value` ICE (#90878)Nilstrieb-1/+15
This also fixes the same suggestion, which was kind of broken, because it just searched for the last occurence of `const` to replace with a `let`. This works great in some cases, but when there is no const and a leading space to the file, it doesn't work and panic with overflow because it thought that it had found a const. I also changed the suggestion to only trigger if the `const` and the non-constant value are on the same line, because if they aren't, the suggestion is very likely to be wrong. Also don't trigger the suggestion if the found `const` is on line 0, because that triggers the ICE.
2021-11-15Stabilize format_args_captureJosh Triplett-1/+1
Works as expected, and there are widespread reports of success with it, as well as interest in it.
2021-11-12Rollup merge of #90826 - petrochenkov:binattr, r=cjgillotMatthias Krüger-1/+1
rustc_feature: Convert `BuiltinAttribute` from tuple to a struct The tuple starts having too many fields. Noticed while reviewing https://github.com/rust-lang/rust/pull/88681.
2021-11-12rustc_feature: Convert `BuiltinAttribute` from tuple to a structVadim Petrochenkov-1/+1
2021-11-11Shorten Span of unused macro lintsMarcel Hellwig-13/+12
The span has been recuded to the actual ident, instead of linting the *whole* macro.
2021-11-09Add `ty::Visibility::is_public()`inquisitivecrystal-5/+4
2021-11-09Rollup merge of #89561 - nbdd0121:const_typeck, r=nikomatsakisMatthias Krüger-1/+2
Type inference for inline consts Fixes #78132 Fixes #78174 Fixes #81857 Fixes #89964 Perform type checking/inference of inline consts in the same context as the outer def, similar to what is currently done to closure. Doing so would require `closure_base_def_id` of the inline const to return the outer def, and since `closure_base_def_id` can be called on non-local crate (and thus have no HIR available), a new `DefKind` is created for inline consts. The type of the generated anon const can capture lifetime of outer def, so we couldn't just use the typeck result as the type of the inline const's def. Closure has a similar issue, and it uses extra type params `CK, CS, U` to capture closure kind, input/output signature and upvars. I use a similar approach for inline consts, letting it have an extra type param `R`, and then `typeof(InlineConst<[paremt generics], R>)` would just be `R`. In borrowck region requirements are also propagated to the outer MIR body just like it's currently done for closure. With this PR, inline consts in expression position are quitely usable now; however the usage in pattern position is still incomplete -- since those does not remain in the MIR borrowck couldn't verify the lifetime there. I have left an ignored test as a FIXME. Some disucssions can be found on [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/inline.20consts.20typeck). cc `````@spastorino````` `````@lcnr````` r? `````@nikomatsakis````` `````@rustbot````` label A-inference F-inline_const T-compiler
2021-11-08Rollup merge of #90652 - matthiaskrgr:unnnec_filter_map, r=jyn514Guillaume Gomez-20/+8
use filter(|x| matches!(..)) instead of filter_map(|x| match x ... => Some(xy))
2021-11-07Auto merge of #90668 - matthiaskrgr:clippy_nov7, r=jyn514bors-15/+11
more clippy fixes
2021-11-07more clippy fixesMatthias Krüger-15/+11
2021-11-07ast: Fix naming conventions in AST structuresVadim Petrochenkov-23/+18
TraitKind -> Trait TyAliasKind -> TyAlias ImplKind -> Impl FnKind -> Fn All `*Kind`s in AST are supposed to be enums. Tuple structs are converted to braced structs for the types above, and fields are reordered in syntactic order. Also, mutable AST visitor now correctly visit spans in defaultness, unsafety, impl polarity and constness.
2021-11-07Give inline const separate DefKindGary Guo-1/+2
2021-11-06Replace some uses of vec.drain(..) with vec.into_iter()The8472-5/+5
IntoIter should optimize better than Drain
2021-11-06use filter(|x| matches!(..)) instead of filter_map(|x| match x ... => Some(xy))Matthias Krüger-20/+8
2021-11-03fix messageTakayuki Maeda-1/+1
2021-11-03add a suggestion about undeclared `alloc` moduleTakayuki Maeda-9/+23
2021-10-30Rollup merge of #90202 - matthewjasper:xcrate-hygiene, r=petrochenkovGuillaume Gomez-7/+3
Improve and test cross-crate hygiene - Decode the parent expansion for traits and enums in `rustc_resolve`, this was already being used for resolution in typeck - Avoid suggesting importing names with def-site hygiene, since it's often not useful - Add more tests r? `@petrochenkov`
2021-10-28Remove `ModData` from rustc_metadataMatthew Jasper-2/+1
This avoids having to decode 2 `Lazy`s when decoding a modules exports.