Commit Graph

288 Commits

Author SHA1 Message Date
Sergio Benitez
83638fcee2 Remove closure borrow in 'FromForm' derive.
The codegen for field validations previously included a closure that
could potentially partially borrow a 'Copy' field of the context
structure. To prevent this, 'let'-assign the field before the closure is
created, and use the assignment inside of the closure.
2023-10-26 19:22:36 -05:00
Sergio Benitez
817648cef5 Allow 'clippy::style' warnings in attr codegen.
Furthermore, properly forward 'deprecated' items in catcher codegen.
2023-05-05 18:21:17 -07:00
Sergio Benitez
19e78eae3a Remove unnecessary 'mut' in 'uri!' impl. 2023-05-05 18:21:17 -07:00
Sergio Benitez
403604c402 Tidy custom forward status changes, update docs. 2023-05-05 18:21:17 -07:00
Benedikt Weber
1f06bb0b73 Allow status customization in 'Forward' outcomes.
Prior to this commit, all forward outcomes resulted in a 404. This
commit changes request and data guards so that they are able to provide
a `Status` on `Forward` outcomes. The router uses this status, if the
final outcome is to forward, to identify the catcher to invoke.

The net effect is that guards can now customize the status code of a
forward and thus the error catcher invoked if the final outcome of a
request is to forward.

Resolves #1560.
2023-05-05 18:21:17 -07:00
Sergio Benitez
80b7755317 Properly forward 'deprecated' items in codegen.
Resolves #2262.
2023-04-05 11:15:49 -07:00
Sergio Benitez
91f6288ea4 New version: 0.5.0-rc.3.
New contrib versions: 0.1.0-rc.3.
2023-03-23 16:56:17 -07:00
Sergio Benitez
219a8a5468 Fix a bunch of typos. 2023-03-23 16:27:08 -07:00
Sergio Benitez
66e2f9486b Update UI tests for 'FromForm' impl addition. 2023-03-23 16:26:48 -07:00
Kian-Meng Ang
06d255b52b Fix a whole bunch of typos.
Found via `codespell -L crate,ser,fo,noo,nd,cappable,pard,te,ans`.
2023-03-23 14:57:54 -07:00
Sergio Benitez
1edfa15d52 Fix several broken rustdoc links. 2023-03-23 14:57:54 -07:00
Sergio Benitez
322f88e61a Update syn, transitively, to 2.0. 2023-03-22 20:11:22 -07:00
Sergio Benitez
d628afddd0 Update UI tests for latest rustc. 2023-03-20 14:14:08 -07:00
Sergio Benitez
0c84af2ea7 Update UI test output for latest rustc. 2023-03-08 10:45:25 -08:00
Jason Hinch
910994f982 Fix Result namespacing in FromFormField derive.
Previously, if a module used or defined a type alias for Result,
FromFormField derives would fail to compile as it would use the type
alias instead of the fully qualified type.
2023-01-31 11:19:57 -08:00
Sergio Benitez
e468a98333 Update UI tests for latest stable, nightly. 2023-01-30 16:10:59 -08:00
Sergio Benitez
ca4b38c0d0 Allow UI tests to fail in CI.
This commit makes passing compile UI tests optional, allowing the CI to
succeed even when UI tests fail. This change was made because UI tests
are highly susceptible to false negatives due to benign rustc compiler
output changes. A failure resulting from such a benign change inhibits
progress in the main branch due to failing PR testing which would have
otherwise passed.
2023-01-30 16:06:18 -08:00
Sergio Benitez
162fafa0f1 Update UI tests for nightly. 2022-11-18 19:30:35 -08:00
Sergio Benitez
7e913eb8ac Report as many form errors as possible. 2022-11-12 04:11:18 -08:00
Sergio Benitez
8166ad0c7c Fix error field names in 'FromForm' derive.
Prior to this commit, the `FromForm` derive could pair the incorrect
field name with a failing validation. The bug was caused by using two
mismatched iterators in a `quote!()` invocation. Specifically, the first
iterator emitted validation calls for all fields that had validation
applied, while the second emitted field names for all fields,
irrespective of whether the field had any validation applied. The two
iterators were effectively zipped to create the final error, creating
the bug.

This commit fixes the issue by correctly matching field names with their
validators at the expense of an additional allocation, necessitated by
the `quote` crate's inability to access subfields in a repetition.

Fixes #2394.
2022-11-11 18:20:06 -08:00
Bonex
440a88ad27 Add failing form validation test cases. 2022-11-11 18:19:43 -08:00
Sergio Benitez
cd23885ee3 Update UI tests for latest nightly. 2022-11-11 18:19:33 -08:00
Sergio Benitez
f10a2d7d9c Include stable rust-src diagnostics. 2022-09-01 01:47:02 -07:00
Sergio Benitez
13732f8a6b Update UI tests for latest nightly, stable. 2022-08-31 13:52:40 -07:00
Sergio Benitez
8d8367e32b Update UI tests for latest nightly, stable. 2022-07-13 18:23:39 -07:00
pennae
7275df9fdf Make data guards eligible to be sentinels.
Prior to this commit, data guards were not being considered as eligible
to be sentinels. This commit resolves that.
2022-06-23 16:15:11 -07:00
Sergio Benitez
6e5568a155 Update UI tests for latest nightly. 2022-06-21 00:13:14 -07:00
Sergio Benitez
30b8a77fc9 Avoid dropping 'Error' inside '#[launch]' future.
Due to tokio-rs/tokio#4780, a panicking top-level future combined with
an uncooperative background task prevents runtime shutdown. To avoid
this in the case of `Rocket::launch()` returning an `Error`, which
panics on drop if it isn't inspected, we return the `Result` to the
caller (i.e., `main`) instead of the `block_on` future. This prevent the
panic from occuring inside of the `block_on` future and so the runtime
terminates even with uncooperative I/O.
2022-06-20 23:49:41 -07:00
Konrad Borowski
6f223518e4 Fix 'clippy::needless_late_init' in form codegen.
Changes codegen for '#[field(default = e)]' to resolve the
'needless_late_init' Clippy warning.
2022-05-23 16:41:10 -07:00
Sergio Benitez
d92b7249cb Update UI tests for latest stable rustc. 2022-05-19 14:16:05 -07:00
Konrad Borowski
e390423083 Enable 'cookie' 'secure' feature conditionally.
This was incorrectly enabled unconditionally in 442b668.
2022-05-18 17:29:52 -07:00
Sergio Benitez
bf2bd0e9ed Impl 'Responder' for 'Box<T: Responder + Sized>'.
In other words, allow boxing sized responders.

Resolves #1999.
2022-05-10 15:48:40 -05:00
Sergio Benitez
4dcd92837f New version: 0.5.0-rc.2.
New contrib versions: 0.1.0-rc.2.
2022-05-09 06:32:46 -05:00
Sergio Benitez
0ba56ccbb3 Revamp shutdown to recover shutdown 'Rocket'.
The core improvement is that `Rocket::launch()` now resolves to
`Ok(Rocket<Ignite>)` on nominal shutdown. Furthermore, shutdown never
terminates the running process.

Other changes directly related to shutdown:

  * Runtime worker thread names are now irrelevant to graceful shutdown.
  * `ErrorKind::Runtime` was removed; `ErrorKind::Shutdown` was added.
  * The `force` config value is only read from the default provider.
  * If `force`, Rocket's constructed async runtime is terminated.

Other related changes:

  * The exported `hyper` module docs properly reflect public re-exports.
2022-05-07 06:12:24 -05:00
Sergio Benitez
4c6c0b497c Avoid more platform dependent errors in UI tests. 2022-05-03 14:33:11 -07:00
Sergio Benitez
55ea5dfb35 Avoid platform dependent errors in UI tests. 2022-05-03 13:56:25 -07:00
Sergio Benitez
613366f4bb Fix UI tests. 2022-04-27 13:59:20 -07:00
Sergio Benitez
6bdd2f8186 Consider form parsing strategy for 'Vec', 'Map'.
Prior to this commit, 'Vec', 'HashMap', and 'BTreeMap' would parse
leniently irrespetive of the requested parsing strategy. This commit
changes their behavior so that the parsing strategy is respected.

Resolves #2131.
2022-04-21 08:17:58 -07:00
Konrad Borowski
4d258739f5 Migrate Rocket to Rust 2021 edition. 2022-04-19 18:35:38 -07:00
Sergio Benitez
bc2315943b Allow 'unused_doc_comments' on generated doctests. 2022-04-19 13:13:33 -07:00
Sergio Benitez
fc633dfcd8 Fix UI tests for latest stable, nightly. 2022-04-18 21:15:54 -07:00
Sergio Benitez
2cbaf05153 Update UI tests for latest stable. 2022-03-07 12:16:21 -08:00
Sergio Benitez
6345d2b888 Update dependencies in core to latest versions.
This updates:

 * rmp-serde to 1
 * pretty_assertions to 1
 * parking_lot to 0.12
 * tokio-util to 0.7
2022-02-16 10:26:24 -08:00
Sergio Benitez
0ba5aac53e Update codebase for latest nightly and stable. 2022-02-16 10:08:55 -08:00
Jakub Dąbek
9177b20ff1 Workaround 'rustc' bug, compiling more async code.
This commit implements a workaround for an [issue within rustc]. The
problem showed itself when using e.g. a `Vec<&str>` argument in an async
route handler (but not `&str`), which resulted in a "implementation of
`FromForm` is not general enough" error. The workaround itself works by
gathering all invocations of `FromForm`'s methods inside a block without
any `.await` points [ref].

[issue within rustc]: https://github.com/rust-lang/rust/issues/69663
[ref]: https://github.com/rust-lang/rust/issues/57478#issuecomment-501186084
2021-08-24 19:46:47 -07:00
Sergio Benitez
15e74fe184 Update UI tests for latest nightly. 2021-08-19 20:07:10 -07:00
Sergio Benitez
3616f25c0b Update 'time' to 0.3, 'cookie' to 0.16.
Also reexport 'time' from the crate root.
2021-08-19 19:49:23 -07:00
Sergio Benitez
4b272f19ba Update 'devise', fix 'Responder' derive generics. 2021-08-19 19:49:23 -07:00
Jeb Rosen
786db9b832 Update UI tests for latest nightly. 2021-08-01 12:25:12 -07:00
Jeb Rosen
5cb243fc24 Update UI tests for latest stable. 2021-08-01 12:24:49 -07:00