Skip to content

Commit

Permalink
Update crates to Rust 2021
Browse files Browse the repository at this point in the history
Generate crates using Rust 2021 instead of Rust 2018
Remove use std::convert::TryFrom which is in the prelude

Closes #1332

Signed-off-by: Daniele Ahmed <[email protected]>
  • Loading branch information
Daniele Ahmed committed May 13, 2022
1 parent 4b3f9e0 commit e9066ed
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,9 @@ for chunk in byte_streams {
references = ["aws-sdk-rust#494", "aws-sdk-rust#519"]
meta = { "breaking" = true, "tada" = true, "bug" = false }
author = "Velfi"

[[smithy-rs]]
message = "Update generated crates to Rust 2021"
references = ["smithy-rs#1332"]
meta = { "breaking" = false, "tada" = false, "bug" = false }
author = "82marbag"
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ private class ServerHttpBoundProtocolTraitImplGenerator(
"""
let status = output.$memberName
.ok_or(#{ResponseRejection}::MissingHttpStatusCode)?;
let http_status: u16 = std::convert::TryFrom::<i32>::try_from(status)
let http_status: u16 = TryFrom::<i32>::try_from(status)
.map_err(|_| #{ResponseRejection}::InvalidHttpStatusCode)?;
""".trimIndent(),
*codegenScope,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class CargoTomlGenerator(
"version" to settings.moduleVersion,
"authors" to settings.moduleAuthors,
settings.moduleDescription?.let { "description" to it },
"edition" to "2018",
"edition" to "2021",
"license" to settings.license,
"repository" to settings.moduleRepository,
).toMap(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ class HttpBindingGenerator(
rustBlock("if !$safeName.is_empty()") {
rustTemplate(
"""
use std::convert::TryFrom;
let header_value = $safeName;
let header_value = http::header::HeaderValue::try_from(&*header_value).map_err(|err| {
#{build_error}::InvalidField { field: "$memberName", details: format!("`{}` cannot be used as a header value: {}", &${
Expand Down Expand Up @@ -517,7 +516,6 @@ class HttpBindingGenerator(
let header_name = http::header::HeaderName::from_str(&format!("{}{}", "${httpBinding.locationName}", &k)).map_err(|err| {
#{build_error}::InvalidField { field: "$memberName", details: format!("`{}` cannot be used as a header name: {}", k, err)}
})?;
use std::convert::TryFrom;
let header_value = ${headerFmtFun(this, target, memberShape, "v", listHeader)};
let header_value = http::header::HeaderValue::try_from(&*header_value).map_err(|err| {
#{build_error}::InvalidField {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ class XmlBindingTraitParserGenerator(
val shapeName = XmlName(xmlIndex.payloadShapeName(member))
rustTemplate(
"""
use std::convert::TryFrom;
let mut doc = #{Document}::try_from(inp)?;
##[allow(unused_mut)]
let mut decoder = doc.root_element()?;
Expand Down Expand Up @@ -190,7 +189,6 @@ class XmlBindingTraitParserGenerator(
) {
rustTemplate(
"""
use std::convert::TryFrom;
let mut doc = #{Document}::try_from(inp)?;
##[allow(unused_mut)]
Expand Down Expand Up @@ -226,7 +224,6 @@ class XmlBindingTraitParserGenerator(
if (members.isNotEmpty()) {
rustTemplate(
"""
use std::convert::TryFrom;
let mut document = #{Document}::try_from(inp)?;
##[allow(unused_mut)]
let mut error_decoder = #{xml_errors}::error_scope(&mut document)?;
Expand Down Expand Up @@ -258,7 +255,6 @@ class XmlBindingTraitParserGenerator(
) {
rustTemplate(
"""
use std::convert::TryFrom;
let mut doc = #{Document}::try_from(inp)?;
##[allow(unused_mut)]
Expand Down

0 comments on commit e9066ed

Please sign in to comment.