Skip to content

Rollup of 10 pull requests #83146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 39 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1ba71ab
Inline Attribute::has_name
tmiasko Mar 11, 2021
4943190
Validate rustc_layout_scalar_valid_range_{start,end} attributes
tmiasko Mar 11, 2021
2eeddcc
Add reproduction test
oli-obk Mar 4, 2021
7154563
Use tracing instrumentation for better bug diagnosing
oli-obk Mar 5, 2021
b42e258
Make regression test succeed as long as it ICEs
oli-obk Mar 5, 2021
7a318ae
Delete non-revision ui test output file if revisions are used
oli-obk Mar 5, 2021
375e243
Replace `type_alias_impl_trait` by `min_type_alias_impl_trait` with n…
oli-obk Mar 12, 2021
ed4c2d1
Add a test showing how `impl_trait_in_bindings` is a breaking change
oli-obk Mar 12, 2021
bc9019f
Special case type aliases from impl trait in const/static types
oli-obk Mar 12, 2021
9a36840
Only allow tait defining uses in function and method return position
oli-obk Mar 12, 2021
6fb5716
🍼 for tidy
oli-obk Mar 12, 2021
9613a88
Refactor `check_doc_attrs` body
camelid Mar 13, 2021
7189c05
Lint non-meta doc attributes
camelid Mar 13, 2021
7e972a3
Report error for each invalid nested attribute
camelid Mar 11, 2021
fe64970
Add another test case
camelid Mar 12, 2021
5134047
Add hyphen to "crate level"
camelid Mar 13, 2021
13884dc
Update `rustdoc-ui` versions of the `doc-attr` test
camelid Mar 14, 2021
e161a2f
Remove unused `opt_local_def_id_to_hir_id` function
jyn514 Mar 14, 2021
71a784d
Fix a typo in `swap_nonoverlapping_bytes`
hiyoko3m Mar 12, 2021
5ec0540
Fix a typo in thread_local_dtor.rs
hiyoko3m Mar 14, 2021
6ddd840
Minor refactoring in try_index_step
osa1 Mar 14, 2021
14038c7
Remove duplicate asserts, replace eq assert with assert_eq
osa1 Mar 14, 2021
13076f9
Tweak diagnostics
camelid Mar 14, 2021
8f40e11
Use pretty-printer instead of `span_to_snippet`
camelid Mar 14, 2021
7429c68
Don't encode file information for span with a dummy location
Aaron1011 Mar 14, 2021
f190bc4
Introduce `proc_macro_back_compat` lint, and emit for `time-macros-impl`
Aaron1011 Mar 14, 2021
4bc1434
Explain each variant of TAIT usage with examples
oli-obk Mar 15, 2021
ebe51cf
:arrow_up: rust-analyzer
lnicola Mar 15, 2021
5eae9af
Custom error on literal names from other languages
syvb Mar 15, 2021
ecd039f
Rollup merge of #82898 - oli-obk:tait_🧊, r=nikomatsakis
Dylan-DPC Mar 15, 2021
3bf9af2
Rollup merge of #82989 - Smittyvb:other-lang-literal-errors, r=varkor
Dylan-DPC Mar 15, 2021
46a3ce3
Rollup merge of #83054 - tmiasko:rustc_layout_scalar_valid_range, r=d…
Dylan-DPC Mar 15, 2021
18abf7b
Rollup merge of #83098 - camelid:more-doc-attr-check, r=davidtwco
Dylan-DPC Mar 15, 2021
d2d590a
Rollup merge of #83108 - jyn514:remove-unused, r=estebank
Dylan-DPC Mar 15, 2021
da1e67a
Rollup merge of #83110 - hyksm:fix-typo, r=jonas-schievink
Dylan-DPC Mar 15, 2021
8e73867
Rollup merge of #83113 - osa1:refactor_try_index_step, r=jonas-schievink
Dylan-DPC Mar 15, 2021
2c82116
Rollup merge of #83127 - Aaron1011:time-macros-impl-warn, r=petrochenkov
Dylan-DPC Mar 15, 2021
b70cce6
Rollup merge of #83132 - Aaron1011:fix/incr-cache-dummy, r=estebank
Dylan-DPC Mar 15, 2021
6b865da
Rollup merge of #83141 - lnicola:rust-analyzer-2021-03-15, r=jonas-sc…
Dylan-DPC Mar 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Explain each variant of TAIT usage with examples
  • Loading branch information
oli-obk committed Mar 15, 2021
commit 4bc1434c0d2414093efdf5953dfc4a056a3acfc0
45 changes: 44 additions & 1 deletion compiler/rustc_typeck/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,59 @@ pub(super) fn check_fn<'a, 'tcx>(
let declared_ret_ty = fn_sig.output();

let feature = match tcx.hir().get(fn_id) {
// TAIT usage in function return position.
// Example:
//
// ```rust
// type Foo = impl Debug;
// fn bar() -> Foo { 42 }
// ```
Node::Item(hir::Item { kind: ItemKind::Fn(..), .. }) |
// TAIT usage in associated function return position.
//
// Example with a free type alias:
//
// ```rust
// type Foo = impl Debug;
// impl SomeTrait for SomeType {
// fn bar() -> Foo { 42 }
// }
// ```
//
// Example with an associated TAIT:
//
// ```rust
// impl SomeTrait for SomeType {
// type Foo = impl Debug;
// fn bar() -> Self::Foo { 42 }
// }
// ```
Node::ImplItem(hir::ImplItem {
kind: hir::ImplItemKind::Fn(..), ..
}) => None,
// I don't know if TAIT uses in trait declarations make sense at all
// Forbid TAIT in trait declarations for now.
// Examples:
//
// ```rust
// type Foo = impl Debug;
// trait Bar {
// fn bar() -> Foo;
// }
// trait Bop {
// type Bop: PartialEq<Foo>;
// }
// ```
Node::TraitItem(hir::TraitItem {
kind: hir::TraitItemKind::Fn(..),
..
}) |
// Forbid TAIT in closure return position for now.
// Example:
//
// ```rust
// type Foo = impl Debug;
// let x = |y| -> Foo { 42 + y };
// ```
Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(..), .. }) => Some(sym::type_alias_impl_trait),
node => bug!("Item being checked wasn't a function/closure: {:?}", node),
};
Expand Down