about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2022-06-03Conservatively report "not sure" in cfg_accessibleUrgau-1/+3
2022-06-03Use the same message as type & const generics.Camille GILLOT-51/+28
2022-06-03Reuse resolve_label to check lifetime shadowing.Camille GILLOT-40/+29
2022-06-03Do not lower generic lifetime params when AST resolution emitted an error.Camille GILLOT-0/+7
2022-06-02Stop warning against unrelated labels.Camille GILLOT-1/+0
2022-06-02Do not report mixed label/lifetime shadowing.Camille GILLOT-111/+45
2022-06-02Diagnose shadowing on AST.Camille GILLOT-325/+209
2022-06-01Rollup merge of #97264 - ↵Matthias Krüger-3/+16
TaKO8Ki:suggest-extern-crate-when-failing-to-resolve-use-crate, r=estebank Suggest `extern crate foo` when failing to resolve `use foo` closes #97095 r? ``@estebank``
2022-05-30Handle more cases in cfg_accessibleUrgau-8/+13
2022-05-25suggest `extern crate foo` when failing to resolve `use foo`Takayuki Maeda-3/+16
fix ci error
2022-05-24Rollup merge of #97240 - TaKO8Ki:improve-errors-about-typos-on-variables, ↵Yuki Okushi-7/+8
r=compiler-errors Typo suggestion for a variable with a name similar to struct fields closes #97133
2022-05-23add typo suggestions for all `AssocSuggestion` variantsTakayuki Maeda-1/+1
2022-05-23Auto merge of #97195 - notriddle:notriddle/cleanup, r=GuillaumeGomezbors-1/+1
rustdoc: shrink GenericArgs/PathSegment with boxed slices This PR also contains a few cleanup bits and pieces, but one of them is a broken intra-doc link, and the other is removing an unused Hash impl. The last commit is the one that matters.
2022-05-21Merge crate and restricted visibilitiesJacob Pratt-1/+0
2022-05-21Remove feature: `crate` visibility modifierJacob Pratt-3/+1
2022-05-21Fix broken intra-doc linkMichael Howell-1/+1
2022-05-21typo suggestion for a variable with a name similar to struct fieldsTakayuki Maeda-7/+8
2022-05-20Remove `crate` visibility usage in compilerJacob Pratt-85/+93
2022-05-20Lint single-use-lifetimes on the AST.Camille GILLOT-431/+204
2022-05-20Introduce BareFnTy::decl_span and fix generics span.Camille GILLOT-12/+3
2022-05-20Introduce LifetimeCtxt.Camille GILLOT-2/+2
2022-05-18Auto merge of #96800 - nbdd0121:const, r=nagisabors-32/+25
Permit `asm_const` and `asm_sym` to reference generic params Related #96557 These constructs will be allowed: ```rust fn foofoo<const N: usize>() {} unsafe fn foo<const N: usize>() { asm!("/* {0} */", const N); asm!("/* {0} */", const N + 1); asm!("/* {0} */", sym foofoo::<N>); } fn barbar<T>() {} unsafe fn bar<T>() { asm!("/* {0} */", const std::mem::size_of::<T>()); asm!("/* {0} */", const std::mem::size_of::<(T, T)>()); asm!("/* {0} */", sym barbar::<T>); asm!("/* {0} */", sym barbar::<(T, T)>); } ``` `@Amanieu,` I didn't switch inline asms to use `DefKind::InlineAsm`, as I see little value doing that; given that no type inference is needed, it will only make typecking slower and more complex but will have no real gains. I did switch them to follow the same code path as inline asm during symbol resolution, though. The `error: unconstrained generic constant` you mentioned in #76001 is due to the fact that `to_const` will actually add a wfness obligation to the constant, which we don't need for `asm_const`, so I have that removed. `@rustbot` label: +A-inline-assembly +F-asm
2022-05-18Rollup merge of #96651 - ken-matsui:omit-unnecessary-help-to-add-cfg-test, ↵Yuki Okushi-14/+21
r=cjgillot Omit unnecessary help to add `#[cfg(test)]` when already annotated Closes: https://github.com/rust-lang/rust/issues/96611 The related PR is: https://github.com/rust-lang/rust/pull/91770
2022-05-17Omit unnecessary help to add `#[cfg(test)]` when already annotatedKen Matsui-14/+21
2022-05-14Auto merge of #97039 - cjgillot:no-rpit-hrtb, r=jackh726bors-0/+14
Forbid nested opaque types to reference HRTB from opaque types. Avoids https://github.com/rust-lang/rust/issues/96194 Alternative to https://github.com/rust-lang/rust/pull/96970 r? `@oli-obk`
2022-05-14Forbid nested opaque types to reference HRTB from opaque types.Camille GILLOT-0/+14
2022-05-13resolve: Move collection of all `macro_rules` in the crate to rustdocVadim Petrochenkov-12/+7
2022-05-13Rollup merge of #96989 - cjgillot:defpath-use, r=davidtwcoMatthias Krüger-4/+4
Be more precise than DefPathData::Misc. This variant was used for two unrelated things. Let's make this cleaner.
2022-05-12Replace DefPathData::Misc by two appropriately-named variants.Camille GILLOT-4/+4
2022-05-12Auto merge of #95562 - lcnr:attr-no-encode, r=davidtwcobors-6/+1
don't encode only locally used attrs Part of https://github.com/rust-lang/compiler-team/issues/505. We now filter builtin attributes before encoding them in the crate metadata in case they should only be used in the local crate. To prevent accidental misuse `get_attrs` now requires the caller to state which attribute they are interested in. For places where that isn't trivially possible, I've added a method `fn get_attrs_unchecked` which I intend to remove in a followup PR. After this pull request landed, we can then slowly move all attributes to only be used in the local crate while being certain that we don't accidentally try to access them from extern crates. cc https://github.com/rust-lang/rust/pull/94963#issuecomment-1082924289
2022-05-12Auto merge of #96150 - est31:unused_macro_rules, r=petrochenkovbors-14/+109
Implement a lint to warn about unused macro rules This implements a new lint to warn about unused macro rules (arms/matchers), similar to the `unused_macros` lint added by #41907 that warns about entire macros. ```rust macro_rules! unused_empty { (hello) => { println!("Hello, world!") }; () => { println!("empty") }; //~ ERROR: 1st rule of macro `unused_empty` is never used } fn main() { unused_empty!(hello); } ``` Builds upon #96149 and #96156. Fixes #73576
2022-05-10only_local: always check for misuselcnr-6/+1
2022-05-07Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errorsbors-15/+15
Begin fixing all the broken doctests in `compiler/` Begins to fix #95994. All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are. There are also a few that I marked `ignore` that could maybe be made to work but seem less important. Each `ignore` has a rough "reason" for ignoring after it parentheses, with - `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax" - `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy. - `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR. - `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup. Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful. I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-07Permit asm_const and asm_sym to reference outer generic paramsGary Guo-32/+25
2022-05-06Rollup merge of #96557 - nbdd0121:const, r=oli-obkGuillaume Gomez-1/+8
Allow inline consts to reference generic params Tracking issue: #76001 The RFC says that inline consts cannot reference to generic parameters (for now), same as array length expressions. And expresses that it's desirable for it to reference in-scope generics, when array length expressions gain that feature as well. However it is possible to implement this for inline consts before doing this for all anon consts, because inline consts are only used as values and they won't be used in the type system. So we can have: ```rust fn foo<T>() { let x = [4i32; std::mem::size_of::<T>()]; // NOT ALLOWED (for now) let x = const { std::mem::size_of::<T>() }; // ALLOWED with this PR! let x = [4i32; const { std::mem::size_of::<T>() }]; // NOT ALLOWED (for now) } ``` This would make inline consts super useful for compile-time checks and assertions: ```rust fn assert_zst<T>() { const { assert!(std::mem::size_of::<T>() == 0) }; } ``` This would create an error during monomorphization when `assert_zst` is instantiated with non-ZST `T`s. A error during mono might sound scary, but this is exactly what a "desugared" inline const would do: ```rust fn assert_zst<T>() { struct F<T>(T); impl<T> F<T> { const V: () = assert!(std::mem::size_of::<T>() == 0); } let _ = F::<T>::V; } ``` It should also be noted that the current inline const implementation can already reference the type params via type inference, so this resolver-level restriction is not any useful either: ```rust fn foo<T>() -> usize { let (_, size): (PhantomData<T>, usize) = const { const fn my_size_of<T>() -> (PhantomData<T>, usize) { (PhantomData, std::mem::size_of::<T>()) } my_size_of() }; size } ``` ```@rustbot``` label: F-inline_const
2022-05-05Implement the unused_macro_rules lintest31-14/+109
2022-05-05Rollup merge of #96507 - TaKO8Ki:suggest-calling-associated-function, r=lcnrMatthias Krüger-34/+80
Suggest calling `Self::associated_function()` closes #96453
2022-05-05suggest calling `Self::associated_function()`Takayuki Maeda-34/+80
do not suggest when trait_ref is some Update compiler/rustc_resolve/src/late/diagnostics.rs Co-authored-by: lcnr <rust@lcnr.de> use helper struct add a test for functions with some params refactor debug log
2022-05-04Stabilize `bool::then_some`Josh Triplett-1/+0
2022-05-04Auto merge of #96353 - estebank:issue-95413, r=compiler-errorsbors-1/+18
When suggesting to import an item, also suggest changing the path if appropriate When we don't find an item we search all of them for an appropriate import and suggest `use`ing it. This is sometimes done for expressions that have paths with more than one segment. We now also suggest changing that path to work with the `use`. Fix #95413
2022-05-03Auto merge of #95380 - compiler-errors:unit-destructure-assign, r=nikomatsakisbors-7/+4
Fix unit struct/enum variant in destructuring assignment See https://github.com/rust-lang/rfcs/blob/master/text/2909-destructuring-assignment.md#guide-level-explanation, "including **unit** and tuple structs" Fixes #94319
2022-05-03Allow inline consts to reference generic paramsGary Guo-1/+8
2022-05-03Rollup merge of #96641 - oli-obk:bool_args, r=wesleywiserYuki Okushi-28/+50
Use a yes/no enum instead of a bool. The bool's meaning wasn't obvious to me at some call sites.
2022-05-03Tweak wordingEsteban Kuber-5/+4
2022-05-03When suggesting to import an item, also suggest changing the path if appropriateEsteban Küber-4/+22
When we don't find an item we search all of them for an appropriate import and suggest `use`ing it. This is sometimes done for expressions that have paths with more than one segment. We now also suggest changing that path to work with the `use`. Fix #95413
2022-05-02fix most compiler/ doctestsElliot Roberts-15/+15
2022-05-02Use a yes/no enum instead of a bool.Oli Scherer-28/+50
The bool's meaning wasn't obvious to me at some call sites.
2022-05-02Auto merge of #96431 - petrochenkov:parent, r=cjgillotbors-69/+53
rustc: Panic by default in `DefIdTree::parent` Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root. So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root. Same applies to `local_parent`/`opt_local_parent`.
2022-05-02rustc: Panic by default in `DefIdTree::parent`Vadim Petrochenkov-69/+53
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root. So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root. Same applies to `local_parent`/`opt_local_parent`.
2022-05-01Auto merge of #96521 - petrochenkov:docrules, r=notriddle,GuillaumeGomezbors-14/+19
rustdoc: Resolve doc links referring to `macro_rules` items cc https://github.com/rust-lang/rust/issues/81633 UPD: the fallback to considering *all* `macro_rules` in the crate for unresolved names is not removed in this PR, it will be removed separately and will be run through crater.