about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2021-07-22Add a regression testOli Scherer-0/+24
2021-07-22Make mir borrowck's use of opaque types independent of the typeck query's resultOli Scherer-174/+96
2021-07-22Auto merge of #87265 - Aaron1011:hir-wf-fn, r=estebankbors-44/+68
Support HIR wf checking for function signatures During function type-checking, we normalize any associated types in the function signature (argument types + return type), and then create WF obligations for each of the normalized types. The HIR wf code does not currently support this case, so any errors that we get have imprecise spans. This commit extends `ObligationCauseCode::WellFormed` to support recording a function parameter, allowing us to get the corresponding HIR type if an error occurs. Function typechecking is modified to pass this information during signature normalization and WF checking. The resulting code is fairly verbose, due to the fact that we can no longer normalize the entire signature with a single function call. As part of the refactoring, we now perform HIR-based WF checking for several other 'typed items' (statics, consts, and inherent impls). As a result, WF and projection errors in a function signature now have a precise span, which points directly at the responsible type. If a function signature is constructed via a macro, this will allow the error message to point at the code 'most responsible' for the error (e.g. a user-supplied macro argument).
2021-07-22Auto merge of #87250 - robojumper:87199-sized-relaxation, r=nikomatsakisbors-0/+56
Fix implicit Sized relaxation when attempting to relax other, unsupported trait Fixes #87199. Do note that this bug fix causes code like the `ref_arg::<[i32]>(&[5]);` line in the test case in combination with an affected function to no longer compile.
2021-07-22Auto merge of #87246 - rust-lang:placeholder-pretty, r=nikomatsakisbors-10/+10
When pretty printing, name placeholders as bound regions Split from #85499 When we see a placeholder that we are going to print, treat it as a bound var (and add it to a `for<...>`
2021-07-21Rollup merge of #87346 - rylev:rename-force-warn, r=nikomatsakisEric Huss-32/+32
Rename force-warns to force-warn The renames the `--force-warns` option to `--force-warn`. This mirrors other lint options like `--warn` and `--deny` which are in the singular. r? `@nikomatsakis` cc `@ehuss` - this option is being used by Cargo. How do we make sure the transition to using the new name is as smooth as possible?
2021-07-21Rollup merge of #87024 - weihanglo:issue-85494, r=ManishearthEric Huss-7/+38
rustdoc: show count of item contents when hidden Resolves #85494
2021-07-21Rollup merge of #87342 - midgleyc:add-E0757-long, r=GuillaumeGomezGuillaume Gomez-0/+1
Add long explanation for E0757 Helps with #61137
2021-07-21Rollup merge of #87321 - midgleyc:add-E0722-long, r=GuillaumeGomezGuillaume Gomez-1/+2
Add long explanation for E0722 Helps with #61137
2021-07-21Rollup merge of #87311 - oli-obk:nll_suggestion_span, r=estebankGuillaume Gomez-8/+8
Get back the more precise suggestion spans of old regionck I noticed that when you turn on nll, the structured suggestion replaces a snippet instead of appending a snippet. It seems clearer to the user to only highlight the newly added characters instead of the entire `impl Trait` (and old regionck already does it this way). r? ``@estebank``
2021-07-21Rollup merge of #87273 - fee1-dead:impl-const-impl-bounds, r=oli-obkGuillaume Gomez-0/+15
Recognize bounds on impls as const bounds r? ```@oli-obk```
2021-07-21Rollup merge of #87230 - GuillaumeGomez:docblock-table-overflow, r=notriddleGuillaume Gomez-7/+18
Fix docblock <table> overflow Before: ![Screenshot from 2021-07-18 00-05-23](https://user-images.githubusercontent.com/3050060/126050272-ce08bc5f-74ff-4135-bc12-d708d87470cc.png) After: ![Screenshot from 2021-07-18 00-03-55](https://user-images.githubusercontent.com/3050060/126050273-42f41b4d-ad57-4a87-91de-18e63f8504ec.png) cc `@SergioBenitez` r? `@notriddle`
2021-07-21Rename force-warns to force-warnRyan Levick-32/+32
2021-07-21Add long explanation for E0757Chris Midgley-0/+1
2021-07-20Add long explanation for E0722Chris Midgley-1/+2
2021-07-20Support HIR wf checking for function signaturesAaron Hill-44/+68
During function type-checking, we normalize any associated types in the function signature (argument types + return type), and then create WF obligations for each of the normalized types. The HIR wf code does not currently support this case, so any errors that we get have imprecise spans. This commit extends `ObligationCauseCode::WellFormed` to support recording a function parameter, allowing us to get the corresponding HIR type if an error occurs. Function typechecking is modified to pass this information during signature normalization and WF checking. The resulting code is fairly verbose, due to the fact that we can no longer normalize the entire signature with a single function call. As part of the refactoring, we now perform HIR-based WF checking for several other 'typed items' (statics, consts, and inherent impls). As a result, WF and projection errors in a function signature now have a precise span, which points directly at the responsible type. If a function signature is constructed via a macro, this will allow the error message to point at the code 'most responsible' for the error (e.g. a user-supplied macro argument).
2021-07-20Get back the more precise suggestion spans of old regionckOli Scherer-8/+8
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-1609/+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-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-0/+72
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-19Recognize bounds on impls as const boundsDeadbeef-0/+15
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/+10
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-12/+12
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-0/+54
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-3/+59
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-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-667/+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-18Add test to check width of item-infoGuillaume Gomez-0/+10
2021-07-18Fix implicit Sized relaxation when attempting to relax other, unsupported traitrobojumper-24/+15
2021-07-18Add test for unsupported bound relaxation with incorrect behaviorrobojumper-0/+65
2021-07-18Add invalid rust code for testGuillaume Gomez-0/+36