summary refs log tree commit diff
path: root/compiler/rustc_span/src
AgeCommit message (Collapse)AuthorLines
2021-11-25Rollup merge of #91096 - compiler-errors:elaborate_opaque_trait, r=estebankMatthias Krüger-0/+1
Print associated types on opaque `impl Trait` types This PR generalizes #91021, printing associated types for all opaque `impl Trait` types instead of just special-casing for future. before: ``` error[E0271]: type mismatch resolving `<impl Iterator as Iterator>::Item == u32` ``` after: ``` error[E0271]: type mismatch resolving `<impl Iterator<Item = usize> as Iterator>::Item == u32` ``` --- Questions: 1. I'm kinda lost in binders hell with this one. Is all of the `rebind`ing necessary? 2. Is there a map collection type that will give me a stable iteration order? Doesn't seem like TraitRef is Ord, so I can't just sort later.. 3. I removed the logic that suppresses printing generator projection types. It creates outputs like this [gist](https://gist.github.com/compiler-errors/d6f12fb30079feb1ad1d5f1ab39a3a8d). Should I put that back? 4. I also added spaces between traits, `impl A+B` -> `impl A + B`. I quite like this change, but is there a good reason to keep it like that? r? ````@estebank````
2021-11-24Rollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelidGuillaume Gomez-0/+1
Create rustdoc_internals feature gate As suggested by ``@camelid`` [here](https://github.com/rust-lang/rust/pull/90398#issuecomment-955093851), since `doc_keyword` and `doc_primitive` aren't meant to be stabilized, we could put them behind a same feature flag. This is pretty much what it would look like (needs to update the tests too). The tracking issue is https://github.com/rust-lang/rust/issues/90418. What do you think ``@rust-lang/rustdoc`` ?
2021-11-24Create rustdoc_internals feature gateGuillaume Gomez-0/+1
2021-11-23Add generator lang-itemMichael Goulet-0/+1
2021-11-23Rollup merge of #91140 - nbdd0121:const_typeck, r=oli-obkMatthias Krüger-0/+1
Split inline const to two feature gates and mark expression position inline const complete This PR splits inline const in pattern position into its own `#![feature(inline_const_pat)]` feature gate, and make the usage in expression position complete. I think I have resolved most outstanding issues related to `inline_const` with #89561 and other PRs. The only thing left that I am aware of is #90150 and the lack of lifetime checks when inline const is used in pattern position (FIXME in #89561). Implementation-wise when used in pattern position it has to be lowered during MIR building while in expression position it's evaluated only when monomorphizing (just like normal consts), so it makes some sense to separate it into two feature gates so one can progress without being blocked by another. ``@rustbot`` label: T-compiler F-inline_const
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-22Split inline const to two feature gatesGary Guo-0/+1
2021-11-21Simplify for loop desugarCameron Steffen-11/+3
2021-11-20Rollup merge of #90930 - Nilstrieb:fix-non-const-value-ice, r=estebankMatthias Krüger-0/+1
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 #90575 - m-ou-se:compatible-variant-improvements, r=estebankMatthias Krüger-7/+12
Improve suggestions for compatible variants on type mismatch. Fixes #90553. Before: ![image](https://user-images.githubusercontent.com/783247/140385675-6ff41090-eca2-41bc-b161-99c5dabfec61.png) After: ![image](https://user-images.githubusercontent.com/783247/140385748-20cf26b5-ea96-4e56-8af2-5fe1ab16fd3b.png) r? `````@estebank`````
2021-11-18rustc: Remove `#[rustc_synthetic]`Vadim Petrochenkov-1/+0
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-16Add SourceMap::indentation_before.Mara Bos-7/+12
2021-11-15Fix `non-constant value` ICE (#90878)Nilstrieb-0/+1
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-09Auto merge of #90485 - camsteffen:fmt-args-less-bind, r=m-ou-sebors-0/+1
Don't destructure args tuple in format_args! This allows Clippy to parse the HIR more simply since `arg0` is changed to `_args.0`. (cc rust-lang/rust-clippy#7843). From rustc's perspective, I think this is something between a lateral move and a tiny improvement since there are fewer bindings. r? `@m-ou-se`
2021-11-07Auto merge of #90668 - matthiaskrgr:clippy_nov7, r=jyn514bors-10/+5
more clippy fixes
2021-11-07more clippy fixesMatthias Krüger-10/+5
2021-11-07Auto merge of #90348 - Amanieu:asm_feature_gates, r=joshtriplettbors-0/+3
Add features gates for experimental asm features This PR splits off parts of `asm!` into separate features because they are not ready for stabilization. Specifically this adds: - `asm_const` for `const` operands. - `asm_sym` for `sym` operands. - `asm_experimental_arch` for architectures other than x86, x86_64, arm, aarch64 and riscv. r? `@nagisa`
2021-11-07Add features gates for experimental asm featuresAmanieu d'Antras-0/+3
2021-11-06Don't destructure args tuple in format_args!Cameron Steffen-0/+1
2021-11-03Remove `MaybeMutBorrowedLocals`Tomasz Miąsko-1/+0
2021-11-02Split doc_cfg and doc_auto_cfg featuresGuillaume Gomez-0/+1
2021-10-30Rollup merge of #90202 - matthewjasper:xcrate-hygiene, r=petrochenkovGuillaume Gomez-1/+1
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-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-2/+0
2021-10-27Auto merge of #89652 - rcvalle:rust-cfi, r=nagisabors-0/+1
Add LLVM CFI support to the Rust compiler This PR adds LLVM Control Flow Integrity (CFI) support to the Rust compiler. It initially provides forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their number of arguments. Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by defining and using compatible type identifiers (see Type metadata in the design document in the tracking issue #89653). LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto). Thank you, `@eddyb` and `@pcc,` for all the help!
2021-10-25Add LLVM CFI support to the Rust compilerRamon de C Valle-0/+1
This commit adds LLVM Control Flow Integrity (CFI) support to the Rust compiler. It initially provides forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their number of arguments. Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by defining and using compatible type identifiers (see Type metadata in the design document in the tracking issue #89653). LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto).
2021-10-24Rollup merge of #89558 - lcnr:query-stable-lint, r=estebankMatthias Krüger-0/+2
Add rustc lint, warning when iterating over hashmaps r? rust-lang/wg-incr-comp
2021-10-23Auto merge of #90104 - spastorino:coherence-for-negative-trait, r=nikomatsakisbors-0/+1
Implement coherence checks for negative trait impls The main purpose of this PR is to be able to [move Error trait to core](https://github.com/rust-lang/project-error-handling/issues/3). This feature is necessary to handle the following from impl on box. ```rust impl From<&str> for Box<dyn Error> { ... } ``` Without having negative traits affect coherence moving the error trait into `core` and moving that `From` impl to `alloc` will cause the from impl to no longer compiler because of a potential future incompatibility. The compiler indicates that `&str` _could_ introduce an `Error` impl in the future, and thus prevents the `From` impl in `alloc` that would cause overlap with `From<E: Error> for Box<dyn Error>`. Adding `impl !Error for &str {}` with the negative trait coherence feature will disable this error by encoding a stability guarantee that `&str` will never implement `Error`, making the `From` impl compile. We would have this in `alloc`: ```rust impl From<&str> for Box<dyn Error> {} // A impl<E> From<E> for Box<dyn Error> where E: Error {} // B ``` and this in `core`: ```rust trait Error {} impl !Error for &str {} ``` r? `@nikomatsakis` This PR was built on top of `@yaahc` PR #85764. Language team proposal: to https://github.com/rust-lang/lang-team/issues/96
2021-10-23Rollup merge of #89730 - crlf0710:type_changing_feature, r=jackh726Matthias Krüger-0/+1
add feature flag for `type_changing_struct_update` This implements the PR0 part of the mentoring notes within #86618. overrides the previous inactive #86646 pr. r? ```@nikomatsakis```
2021-10-22Add rustc_strict_coherence attribute and use it to check overlapSantiago Pastorino-0/+1
2021-10-22add feature flag for `type_changing_struct_update`Charles Lew-0/+1
2021-10-21Don't suggest importing items with hygienic namesMatthew Jasper-1/+1
This will potentially hide a few correct suggestions, but importing these items from another module is not generally possible.
2021-10-20Rollup merge of #88860 - nbdd0121:panic, r=m-ou-seYuki Okushi-1/+0
Deduplicate panic_fmt std's begin_panic_fmt and core's panic_fmt are duplicates. Merge them to declutter code and remove a lang item.
2021-10-19Deduplicate panic_fmtGary Guo-1/+0
std's begin_panic_fmt and core's panic_fmt are duplicates. Merge them to declutter code and remove a lang item.
2021-10-19Rollup merge of #89956 - JohnTitor:suggest-case-insensitive-match-names, ↵Matthias Krüger-28/+18
r=estebank Suggest a case insensitive match name regardless of levenshtein distance Fixes #86170 Currently, `find_best_match_for_name` only returns a case insensitive match name depending on a Levenshtein distance. It's a bit unfortunate that that hides some suggestions for typos like `Bar` -> `BAR`. That idea is from https://github.com/rust-lang/rust/pull/46347#discussion_r153701834, but I think it still makes some sense to show a candidate when we find a case insensitive match name as it's more like a typo. Skipped the `candidate != lookup` check because the current (i.e, `levenshtein_match`) returns the exact same `Symbol` anyway but it doesn't seem to confuse anything on UI tests. r? ``@estebank``
2021-10-17rustc_span: `Ident::invalid` -> `Ident::empty`Vadim Petrochenkov-1/+1
The equivalent for `Symbol`s was renamed some time ago (`kw::Invalid` -> `kw::Empty`), and it makes sense to do the same thing for `Ident`s.
2021-10-17Suggest a case insensitive match name regardless of levenshtein distanceYuki Okushi-28/+18
2021-10-15allow `potential_query_instability` everywherelcnr-0/+1
2021-10-15add a `rustc::query_stability` lintlcnr-0/+1
2021-10-15Guess semicolon span for macro statementsCameron Steffen-0/+38
2021-10-14Auto merge of #89247 - fee1-dead:const-eval-select, r=oli-obkbors-0/+3
Add `const_eval_select` intrinsic Adds an intrinsic that calls a given function when evaluated at compiler time, but generates a call to another function when called at runtime. See https://github.com/rust-lang/const-eval/issues/7 for previous discussion. r? `@oli-obk.`
2021-10-12Add const_eval_select intrinsicDeadbeef-0/+3
2021-10-11Add enum_intrinsics_non_enums lintFlying-Toast-0/+1
2021-10-08Add feature gate to non_exhaustive_omitted_patterns lintDevin Ragotzy-0/+1
Actually add the feature to the lints ui test Add tracking issue to the feature declaration Rename feature gate to non_exhaustive_omitted_patterns_lint Add more omitted_patterns lint feature gate
2021-10-07Rollup merge of #89622 - m-ou-se:debug-assert-2021, r=estebankJubilee-0/+1
Use correct edition for panic in [debug_]assert!(). See https://github.com/rust-lang/rust/issues/88638#issuecomment-915472783
2021-10-07Use correct edition for panic in [debug_]assert!() etc.Mara Bos-0/+1
2021-10-05Allow adding a set of cfg's to hide from being implicitly doc(cfg)'dWim Looman-0/+2
By adding #![doc(cfg_hide(foobar))] to the crate attributes the cfg #[cfg(foobar)] (and _only_ that _exact_ cfg) will not be implicitly treated as a doc(cfg) to render a message in the documentation.
2021-10-03Auto merge of #88175 - camsteffen:let-desugar-span, r=Manishearthbors-0/+2
Add expansion to while desugar spans In the same vein as #88163, this reverts a change in Clippy behavior as a result of #80357 (and reverts some `#[allow]`s): This changes `clippy::blocks_in_if_conditions` to not fire on `while` loops. Though we might actually want Clippy to lint those cases, we should introduce the change purposefully, with tests, and possibly under a different lint name. The actual change here is to add a desugaring expansion to the spans when lowering a `while` loop. r? `@Manishearth`
2021-10-02Make diangostic item names consistentCameron Steffen-15/+8
2021-10-02Add desugaring mark to while loopCameron Steffen-0/+2