about summary refs log tree commit diff
path: root/src
AgeCommit message (Collapse)AuthorLines
2021-07-20Auto merge of #87244 - jackh726:issue-71883, r=estebankbors-7/+150
Better diagnostics with mismatched types due to implicit static lifetime Fixes #78113 I think this is my first diagnostics PR...definitely happy to hear thoughts on the direction/implementation here. I was originally just trying to solve the error above, where the lifetime on a GAT was causing a cryptic "mismatched types" error. But as I was writing this, I realized that this (unintentionally) also applied to a different case: `wf-in-foreign-fn-decls-issue-80468.rs`. I'm not sure if this diagnostic should get a new error code, or even reuse an existing one. And, there might be some ways to make this even more generalized. Also, the error is a bit more lengthy and verbose than probably needed. So thoughts there are welcome too. This PR essentially ended up adding a new nice region error pass that triggers if a type doesn't match the self type of an impl which is selected because of a predicate because of an implicit static bound on that self type. r? `@estebank`
2021-07-20Auto merge of #87224 - RalfJung:miri-ptr-oob, r=oli-obkbors-10/+25
miri: better ptr-out-of-bounds errors For offsets larger than `isize::MAX`, display them as negative offsets. r? `@oli-obk`
2021-07-20Auto merge of #87141 - spastorino:remove_impl_trait_in_bindings, r=oli-obkbors-1637/+475
Remove impl trait in bindings Closes #86729 r? `@oli-obk`
2021-07-19Better errors when we don't have implicit statics in trait objectsjackh726-7/+102
2021-07-20Auto merge of #84959 - camsteffen:lint-suggest-group, r=estebankbors-2/+12
Suggest lint groups Fixes rust-lang/rust-clippy#6986
2021-07-19Auto merge of #87284 - Aaron1011:remove-paren-special, r=petrochenkovbors-0/+19
Remove special case for `ExprKind::Paren` in `MutVisitor` The special case breaks several useful invariants (`ExpnId`s are globally unique, and never change). This special case was added back in 2016 in https://github.com/rust-lang/rust/pull/34355 r? `@petrochenkov`
2021-07-19Remove special case for `ExprKind::Paren` in `MutVisitor`Aaron Hill-0/+19
The special case breaks several useful invariants (`ExpnId`s are globally unique, and never change). This special case was added back in 2016 in https://github.com/rust-lang/rust/pull/34355
2021-07-19Better diagnostics when mismatched types due to implict static lifetimejackh726-8/+56
2021-07-19Auto merge of #87153 - ↵bors-37/+41
michaelwoerister:debuginfo-names-dyn-trait-projection-bounds, r=wesleywiser [debuginfo] Emit associated type bindings in trait object type names. This PR updates debuginfo type name generation for trait objects to include associated type bindings and auto trait bounds -- so that, for example, the debuginfo type name of `&dyn Iterator<Item=Foo>` and `&dyn Iterator<Item=Bar>` don't both map to just `&dyn Iterator` anymore. The following table shows examples of debuginfo type names before and after the PR: | type | before | after | |------|---------|-------| | `&dyn Iterator<Item=u32>>` | `&dyn Iterator` | `&dyn Iterator<Item=u32>` | | `&(dyn Iterator<Item=u32>> + Sync)` | `&dyn Iterator` | `&(dyn Iterator<Item=u32> + Sync)` | | `&(dyn SomeTrait<bool, i8, Bar=u32>> + Send)` | `&dyn SomeTrait<bool, i8>` | `&(dyn SomeTrait<bool, i8, Bar=u32>> + Send)` | For targets that need C++-like type names, we use `assoc$<Item,u32>` instead of `Item=u32`: | type | before | after | |------|---------|-------| | `&dyn Iterator<Item=u32>>` | `ref$<dyn$<Iterator> >` | `ref$<dyn$<Iterator<assoc$<Item,u32> > > >` | | `&(dyn Iterator<Item=u32>> + Sync)` | `ref$<dyn$<Iterator> >` | `ref$<dyn$<Iterator<assoc$<Item,u32> >,Sync> >` | | `&(dyn SomeTrait<bool, i8, Bar=u32>> + Send)` | `ref$<dyn$<SomeTrait<bool, i8> > >` | `ref$<dyn$<SomeTrait<bool,i8,assoc$<Bar,u32> > >,Send> >` | The PR also adds self-profiling measurements for debuginfo type name generation (re. https://github.com/rust-lang/rust/issues/86431). It looks like the compiler spends up to 0.5% of its time in that task, so the potential for optimizing it via caching seems limited. However, the perf run also shows [the biggest regression](https://perf.rust-lang.org/detailed-query.html?commit=585e91c718b0b2c5319e1fffd0ff1e62aaf7ccc2&base_commit=b9197978a90be6f7570741eabe2da175fec75375&benchmark=tokio-webpush-simple-debug&run_name=incr-unchanged) in a test case that does not even invoke the code in question. This suggests that the length of the names we generate here can affect performance by influencing how much data the linker has to copy around. Fixes https://github.com/rust-lang/rust/issues/86134.
2021-07-19Auto merge of #87225 - estebank:cleanup, r=oli-obkbors-370/+1422
Various diagnostics clean ups/tweaks * Always point at macros, including derive macros * Point at non-local items that introduce a trait requirement * On private associated item, point at definition
2021-07-19Auto merge of #87271 - flip1995:clippyup, r=Manishearthbors-298/+468
Update Clippy This is an out-of-cycle Clippy update, to fix 3 ICEs before the release (This should be merged before beta is branched): rust-lang/rust-clippy#7470 rust-lang/rust-clippy#7471 rust-lang/rust-clippy#7473 cc `@jackh726` `@JohnTitor` rust-lang/rust-clippy#7470 was caused by #86867. I saw the same ICE in the last rustup for Clippy though, so this might be a more general problem. Is there something we should check before calling `layout_of`? Should we always check for `ty.has_escaping_bound_vars()` before calling `layout_of`? Or is this overkill? r? `@Manishearth`
2021-07-19Various diagnostics clean ups/tweaksEsteban Küber-370/+1422
* Always point at macros, including derive macros * Point at non-local items that introduce a trait requirement * On private associated item, point at definition
2021-07-19[debuginfo] Adapt CDB tests after changes to whitespace usage in debuginfo ↵Michael Woerister-12/+12
type names.
2021-07-19Improve impl trait disallowed context error textSantiago Pastorino-99/+99
2021-07-19Auto merge of #86970 - inquisitivecrystal:force-warn, r=davidtwcobors-1/+73
Make `--force-warns` a normal lint level option Now that `ForceWarn` is a lint level, there's no reason `--force-warns` should be treated differently from other options that set lint levels. This merges the `ForceWarn` handling in with the other lint level command line options. It also unifies all of the relevant selection logic in `compiler/rustc_lint/src/levels.rs`, rather than having some of it weirdly elsewhere. Fixes #86958, which arose from the special-cased handling of `ForceWarn` having had an error in it.
2021-07-19Merge commit '4c41a222ca5d1325fb4b6709395bd06e766cc042' into clippyupflip1995-298/+468
2021-07-19Rollup merge of #87256 - Aaron1011:hir-wf-assoc-default, r=oli-obkGuillaume Gomez-6/+6
Extend HIR-based WF checking to associated type defaults Previously, we would only look at associated types in `impl` blocks.
2021-07-19Rollup merge of #87251 - GuillaumeGomez:item-info-width, r=notriddleGuillaume Gomez-0/+13
Fix "item info" width Fixes #87202. It now looks again like this: ![Screenshot from 2021-07-18 12-33-27](https://user-images.githubusercontent.com/3050060/126064005-013acabc-7f17-4436-8dfc-cb6b9bc24413.png) cc `@jyn514` r? `@notriddle`
2021-07-19Rollup merge of #87210 - notriddle:notriddle/rustdoc-sidebar-headers, ↵Guillaume Gomez-41/+45
r=GuillaumeGomez Rustdoc accessibility: make the sidebar headers actual headers Part of #87059 Preview it at: https://notriddle.com/notriddle-rustdoc-test/rustdoc-sidebar-header/std/index.html
2021-07-19Rollup merge of #86230 - GuillaumeGomez:nocapture, r=camelidGuillaume Gomez-1/+86
Add --nocapture option to rustdoc Fixes https://github.com/rust-lang/rust/issues/26309. Fixes #45724. Once this PR is merged, I'll send a PR to cargo to also pass `--nocapture` to rustdoc. cc `@jyn514` r? `@camelid`
2021-07-19Auto merge of #87146 - Aaron1011:better-macro-lint, r=petrochenkovbors-15/+107
Compute a better `lint_node_id` during expansion When we need to emit a lint at a macro invocation, we currently use the `NodeId` of its parent definition (e.g. the enclosing function). This means that any `#[allow]` / `#[deny]` attributes placed 'closer' to the macro (e.g. on an enclosing block or statement) will have no effect. This commit computes a better `lint_node_id` in `InvocationCollector`. When we visit/flat_map an AST node, we assign it a `NodeId` (earlier than we normally would), and store than `NodeId` in current `ExpansionData`. When we collect a macro invocation, the current `lint_node_id` gets cloned along with our `ExpansionData`, allowing it to be used if we need to emit a lint later on. This improves the handling of `#[allow]` / `#[deny]` for `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` and some `asm!`-related lints. The 'legacy derive helpers' lint retains its current behavior (I've inlined the now-removed `lint_node_id` function), since there isn't an `ExpansionData` readily available.
2021-07-19Auto merge of #86848 - notriddle:notriddle/drop-dyn, r=varkorbors-4/+60
feat(rustc_lint): add `dyn_drop` Based on the conversation in #86747. Explanation ----------- A trait object bound of the form `dyn Drop` is most likely misleading and not what the programmer intended. `Drop` bounds do not actually indicate whether a type can be trivially dropped or not, because a composite type containing `Drop` types does not necessarily implement `Drop` itself. Naïvely, one might be tempted to write a deferred drop system, to pull cleaning up memory out of a latency-sensitive code path, using `dyn Drop` trait objects. However, this breaks down e.g. when `T` is `String`, which does not implement `Drop`, but should probably be accepted. To write a trait object bound that accepts anything, use a placeholder trait with a blanket implementation. ```rust trait Placeholder {} impl<T> Placeholder for T {} fn foo(_x: Box<dyn Placeholder>) {} ```
2021-07-18Auto merge of #86950 - tmiasko:personality, r=nagisabors-0/+24
Use existing declaration of rust_eh_personality If crate declares `rust_eh_personality`, re-use existing declaration as otherwise attempts to set function attributes that follow the declaration will fail (unless it happens to have exactly the same type signature as the one predefined in the compiler). Fixes #70117. Fixes https://github.com/rust-lang/rust/pull/81469#issuecomment-809428126; probably.
2021-07-18Extend HIR-based WF checking to associated type defaultsAaron Hill-6/+6
Previously, we would only look at associated types in `impl` blocks.
2021-07-18fix(clippy): add missing allow(dyn_drop)Michael Howell-1/+1
2021-07-18Add `#![allow(dyn_drop)]` to test cases with `dyn Drop` in themMichael Howell-3/+5
These are all testing corner-cases in the compiler. Adding a new warning broke these test cases, but --cap-lints stops it from actually breaking things in production.
2021-07-18feat(rustc_lint): add `dyn_drop`Michael Howell-0/+54
Based on the conversation in #86747. Explanation ----------- A trait object bound of the form `dyn Drop` is most likely misleading and not what the programmer intended. `Drop` bounds do not actually indicate whether a type can be trivially dropped or not, because a composite type containing `Drop` types does not necessarily implement `Drop` itself. Naïvely, one might be tempted to write a deferred drop system, to pull cleaning up memory out of a latency-sensitive code path, using `dyn Drop` trait objects. However, this breaks down e.g. when `T` is `String`, which does not implement `Drop`, but should probably be accepted. To write a trait object bound that accepts anything, use a placeholder trait with a blanket implementation. ```rust trait Placeholder {} impl<T> Placeholder for T {} fn foo(_x: Box<dyn Placeholder>) {} ```
2021-07-18Remove impl_trait_in_bindings feature flagSantiago Pastorino-695/+368
2021-07-18Remove `sub_types_or_anon`Santiago Pastorino-83/+0
2021-07-18Remove impl_trait_in_bindings handling on inference error reportingSantiago Pastorino-115/+0
2021-07-18Remove impl trait bindings handling on const AST loweringSantiago Pastorino-227/+103
2021-07-18update MiriRalf Jung-9/+12
2021-07-18Add test to check width of item-infoGuillaume Gomez-0/+10
2021-07-18Fix item info displayGuillaume Gomez-0/+3
2021-07-18Add invalid rust code for testGuillaume Gomez-0/+36
2021-07-18Don't capture child process output at all when --no-capture is usedGuillaume Gomez-4/+10
2021-07-18Add doc for --nocaptureGuillaume Gomez-0/+7
2021-07-18Add test for rustdoc --nocapture optionGuillaume Gomez-0/+18
2021-07-18Add --nocapture option to rustdocGuillaume Gomez-0/+18
2021-07-18miri: better ptr-out-of-bounds errorsRalf Jung-10/+25
2021-07-18Auto merge of #87242 - JohnTitor:rollup-t9rmwpo, r=JohnTitorbors-21/+176
Rollup of 8 pull requests Successful merges: - #86763 (Add a regression test for issue-63355) - #86814 (Recover from a misplaced inner doc comment) - #86843 (Check that const parameters of trait methods have compatible types) - #86889 (rustdoc: Cleanup ExternalCrate) - #87092 (Remove nondeterminism in multiple-definitions test) - #87170 (Add diagnostic items for Clippy) - #87183 (fix typo in compile_fail doctest) - #87205 (rustc_middle: remove redundant clone) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-07-17Add tests for command line lint controlinquisitivecrystal-0/+72
2021-07-17Make `--force-warns` a normal lint level optioninquisitivecrystal-1/+1
2021-07-18Auto merge of #87071 - inquisitivecrystal:inclusive-range, r=estebankbors-0/+20
Add diagnostics for mistyped inclusive range Inclusive ranges are correctly typed as `..=`. However, it's quite easy to think of it as being like `==`, and type `..==` instead. This PR adds helpful diagnostics for this case. Resolves #86395 (there are some other cases there, but I think those should probably have separate issues). r? `@estebank`
2021-07-18Rollup merge of #87092 - ricobbe:fix-raw-dylib-multiple-definitions, ↵Yuki Okushi-0/+36
r=petrochenkov Remove nondeterminism in multiple-definitions test Compare all fields in `DllImport` when sorting to avoid nondeterminism in the error for multiple inconsistent definitions of an extern function. Restore the multiple-definitions test. Resolves #87084.
2021-07-18Rollup merge of #86889 - jyn514:crate-cleanup, r=camelidYuki Okushi-21/+14
rustdoc: Cleanup ExternalCrate - Remove unnecessary CrateNum from Cache.externs - Remove trival impl Clean for CrateNum
2021-07-18Rollup merge of #86843 - FabianWolff:issue-86820, r=lcnrYuki Okushi-0/+40
Check that const parameters of trait methods have compatible types This PR fixes #86820. The problem is that this currently passes the type checker: ```rust trait Tr { fn foo<const N: u8>(self) -> u8; } impl Tr for f32 { fn foo<const N: bool>(self) -> u8 { 42 } } ``` i.e. the type checker fails to check whether const parameters in `impl` methods have the same type as the corresponding declaration in the trait. With my changes, I get, for the above code: ``` error[E0053]: method `foo` has an incompatible const parameter type for trait --> test.rs:6:18 | 6 | fn foo<const N: bool>(self) -> u8 { 42 } | ^ | note: the const parameter `N` has type `bool`, but the declaration in trait `Tr::foo` has type `u8` --> test.rs:2:18 | 2 | fn foo<const N: u8>(self) -> u8; | ^ error: aborting due to previous error ``` This fixes #86820, where an ICE happens later on because the trait method is declared with a const parameter of type `u8`, but the `impl` uses one of type `usize`: > `expected int of size 8, but got size 1`
2021-07-18Rollup merge of #86814 - Aaron1011:inner-doc-recover, r=estebankYuki Okushi-0/+22
Recover from a misplaced inner doc comment Fixes #86781
2021-07-18Rollup merge of #86763 - JohnTitor:test-63355, r=oli-obkYuki Okushi-0/+64
Add a regression test for issue-63355 Closes #63355 r? ``@nikomatsakis``
2021-07-17Add test for `#[allow]` for warnings on attribute macroAaron Hill-0/+69