std::time::Duration::new can panic. There is no alternative non-panicing constructor.
Check the panic condition beforehand and return an error instead of panicing.
Fixes#1933
Both of these modules are doc(hidden) and commented "Not public API",
but incorrect downstream code sometimes still references them. Naming
the module __private will make it more likely to be noticed in code
review.
This test has multiple #[ignore] attributes in some configurations.
$ cargo +beta check --test expandtest
warning: unused attribute
--> test_suite/tests/expandtest.rs:2:29
|
2 | #[cfg_attr(not(expandtest), ignore)]
| ^^^^^^
|
= note: `#[warn(unused_attributes)]` on by default
When building with beta and older rustc:
error: unknown lint: `mixed_script_confusables`
--> test_suite/tests/test_gen.rs:7:10
|
7 | #![allow(mixed_script_confusables, clippy::trivially_copy_pass_by_ref)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> test_suite/tests/test_gen.rs:5:9
|
5 | #![deny(warnings)]
| ^^^^^^^^
= note: `#[deny(unknown_lints)]` implied by `#[deny(warnings)]`
error: The usage of Script Group `Greek` in this crate consists solely of mixed script confusables
--> test_suite/tests/test_gen.rs:269:9
|
269 | σ: f64,
| ^
|
note: the lint level is defined here
--> test_suite/tests/test_gen.rs:5:9
|
5 | #![deny(warnings)]
| ^^^^^^^^
= note: `#[deny(mixed_script_confusables)]` implied by `#[deny(warnings)]`
= note: The usage includes 'σ' (U+03C3).
= note: Please recheck to make sure their usages are indeed what you want.
* Deserialize adjacently tagged newtype variants with optional content as None instead of erroring when content field is missing
* refactor to remove duplicate code and remove panic
These hit a strange error in our Emscripten builder in Travis as well as
locally through cargo web:
ERROR: failed to execute cargo: Resource temporarily unavailable (os error 11)
Without this:
error: failed to select a version for `serde_test_suite`.
... required by package `serde_test_suite-tests v0.0.0`
versions that meet the requirements `= 0.0.0` are: 0.0.0
the package `serde_test_suite-tests` depends on `serde_test_suite`, with features: `serde` but `serde_test_suite` does not have these features.
failed to select a version for `serde_test_suite` which could resolve this conflict
Seems like a Cargo bug -- I will minimize and report.
Also changed the generated code to have at least one thing refer to the
path directly, rather than via `use` -- This shows that the impl *can*
work without `use`, but doesn't actually do all the work to remove the
`use` lines unless we decide we need this feature to work on the 2015
edition
This is intended to be used by other crates which provide their own proc
macros and use serde internally. Today there's no consistent way to put
`#[derive(Deserialize)]` on a struct that consistently works, since
crates may be using either `features = ["derive"]` or relying on
`serde_derive` separately.
Even if we assume that everyone is using `features = ["derive"]`,
without this commit, any crate which generates
`#[derive(serde::Deserialize)]` forces its consumers to put `serde` in
their `Cargo.toml`, even if they aren't otherwise using serde for
anything.
Examples of crates which suffer from this in the real world are
tower-web and swirl.
With this feature, it's expected that these crates would have `pub
extern crate serde;` in some accessible path, and add
`#[serde(serde_path = "that_crate::wherever::serde")]` anywhere they
place serde's derives. Those crates would also have to derive
`that_crate::whatever::serde::Deserialize`, or `use` the macros
explicitly beforehand.
The test for this is a little funky, as it's testing this in a way that
is not the intended use case, or even one we want to support. It has its
own module which re-exports all of serde, but defines its own
`Serialize` and `Deserialize` traits. We then test that we generated
impls for those traits, instead of serde's. The only other way to test
this would be to create a new test crate which does not depend on serde,
but instead depends on `serde_derive` and a third crate which publicly
re-exports serde. This feels like way too much overhead for a single
test case, hence the funky test given.
I didn't see anywhere in this repo to document this attribute, so I
assume the docs will have to be done as a separate PR to a separate
repo.
Fixes#1487