Merge pull request #1079 from teloxide/update-nightly

Update nightly
This commit is contained in:
Tima Kinsart 2024-07-04 18:03:52 +00:00 committed by GitHub
commit 2bd2035758
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 78 additions and 66 deletions

View file

@ -20,7 +20,7 @@ env:
# - crates/teloxide-core/src/codegen.rs
# - rust-toolchain.toml
# - below in the test matrix
rust_nightly: nightly-2024-03-20
rust_nightly: nightly-2024-07-03
# When updating this, also update:
# - **/README.md
# - **/src/lib.rs
@ -105,7 +105,7 @@ jobs:
toolchain: beta
features: "--features full"
- rust: nightly
toolchain: nightly-2024-03-20
toolchain: nightly-2024-07-03
features: "--features full nightly"
- rust: msrv
toolchain: 1.70.0

View file

@ -112,6 +112,9 @@ pre-release-replacements = [
{ file = "CHANGELOG.md", search = "## unreleased", replace = "## unreleased\n\n## {{version}} - {{date}}", exactly = 1 },
]
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(dep_docsrs)'] }
[[example]]
name = "self_info"
required-features = ["tokio/macros", "tokio/rt-multi-thread"]

View file

@ -23,7 +23,7 @@ use xshell::{cmd, Shell};
fn ensure_rustfmt(sh: &Shell) {
// FIXME(waffle): find a better way to set toolchain
let toolchain = "nightly-2024-03-20";
let toolchain = "nightly-2024-07-03";
let version = cmd!(sh, "rustup run {toolchain} rustfmt --version").read().unwrap_or_default();
@ -36,7 +36,7 @@ fn ensure_rustfmt(sh: &Shell) {
}
pub fn reformat(text: String) -> String {
let toolchain = "nightly-2024-03-20";
let toolchain = "nightly-2024-07-03";
let sh = Shell::new().unwrap();
ensure_rustfmt(&sh);
@ -89,7 +89,7 @@ pub fn ensure_files_contents<'a>(
err_count += 1;
let display_path = path.strip_prefix(&project_root()).unwrap_or(path);
let display_path = path.strip_prefix(project_root()).unwrap_or(path);
eprintln!(
"\n\x1b[31;1merror\x1b[0m: {} was not up-to-date, updating\n",
display_path.display()

View file

@ -1,6 +1,7 @@
use crate::codegen::schema::Type;
pub enum Convert {
#[allow(dead_code)]
Id(Type),
Into(Type),
Collect(Type),

View file

@ -361,6 +361,7 @@ impl ChatMemberKind {
/// - is the owner of the chat
/// - is an administrator in the given chat and has [`can_manage_chat`]
/// privilege.
///
/// Returns `false` otherwise.
///
/// [`can_manage_chat`]: Administrator::can_manage_chat
@ -379,6 +380,7 @@ impl ChatMemberKind {
/// - is the owner of the chat (even if the chat is not a channel)
/// - is an administrator in the given chat and has [`can_post_messages`]
/// privilege.
///
/// Returns `false` otherwise.
///
/// [`can_post_messages`]: Administrator::can_post_messages
@ -398,6 +400,7 @@ impl ChatMemberKind {
/// - is the owner of the chat (even if the chat is not a channel)
/// - is an administrator in the given chat and has the
/// [`can_edit_messages`] privilege.
///
/// Returns `false` otherwise.
///
/// [`can_edit_messages`]: Administrator::can_edit_messages
@ -416,6 +419,7 @@ impl ChatMemberKind {
/// - is the owner of the chat
/// - is an administrator in the given chat and has the
/// [`can_delete_messages`] privilege.
///
/// Returns `false` otherwise.
///
/// [`can_delete_messages`]: Administrator::can_delete_messages
@ -434,6 +438,7 @@ impl ChatMemberKind {
/// - is the owner of the chat
/// - is an administrator in the given chat and has the
/// [`can_manage_video_chats`] privilege.
///
/// Returns `false` otherwise.
///
/// [`can_manage_video_chats`]: Administrator::can_manage_video_chats
@ -454,6 +459,7 @@ impl ChatMemberKind {
/// - is the owner of the chat
/// - is an administrator in the given chat and has the
/// [`can_restrict_members`] privilege.
///
/// Returns `false` otherwise.
///
/// [`can_restrict_members`]: Administrator::can_restrict_members
@ -477,6 +483,7 @@ impl ChatMemberKind {
/// - is the owner of the chat (even if the chat is not a channel)
/// - is an administrator in the given chat and has the
/// [`can_promote_members`] privilege.
///
/// Returns `false` otherwise.
///
/// [`can_promote_members`]: Administrator::can_promote_members

View file

@ -1009,17 +1009,16 @@ mod getters {
#[must_use]
pub fn caption(&self) -> Option<&str> {
match &self.kind {
Common(MessageCommon { media_kind, .. }) => match media_kind {
MediaKind::Animation(MediaAnimation { caption, .. })
| MediaKind::Audio(MediaAudio { caption, .. })
| MediaKind::Document(MediaDocument { caption, .. })
| MediaKind::Photo(MediaPhoto { caption, .. })
| MediaKind::Video(MediaVideo { caption, .. })
| MediaKind::Voice(MediaVoice { caption, .. }) => {
caption.as_ref().map(Deref::deref)
}
_ => None,
},
Common(MessageCommon {
media_kind:
MediaKind::Animation(MediaAnimation { caption, .. })
| MediaKind::Audio(MediaAudio { caption, .. })
| MediaKind::Document(MediaDocument { caption, .. })
| MediaKind::Photo(MediaPhoto { caption, .. })
| MediaKind::Video(MediaVideo { caption, .. })
| MediaKind::Voice(MediaVoice { caption, .. }),
..
}) => caption.as_ref().map(Deref::deref),
_ => None,
}
}

View file

@ -165,6 +165,12 @@ name = "postgres"
path = "tests/postgres.rs"
required-features = ["postgres-storage-nativetls", "cbor-serializer", "bincode-serializer"]
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(CI_POSTGRES)',
'cfg(CI_REDIS)',
] }
[[example]]
name = "admin"
required-features = ["macros", "ctrlc_handler"]

View file

@ -91,8 +91,7 @@
//! several techniques:
//!
//! - **Branching:** `a.branch(b)` roughly means "try to handle an update with
//! `a`, then, if it
//! neglects the update, try `b`".
//! `a`, then, if it neglects the update, try `b`".
//! - **Pattern matching:** We also use the [`dptree::case!`] macro
//! extensively, which acts as a filter on an enumeration: if it is of a
//! certain variant, it passes the variant's payload down the handler chain;

View file

@ -44,9 +44,8 @@ impl<S> PostgresStorage<S> {
/// - database_url: full url to the postgres database, for example
/// `"postgres://postgres:password@localhost/test")`
/// - max_connections: number of connections in creating connection pool. Be
/// mindful of the connection limits for your database, each
/// connection established with the Postgres creates a new process on the
/// server side
/// mindful of the connection limits for your database, each connection
/// established with the Postgres creates a new process on the server side
/// - serializer: what [`Serializer`] will be used to encode the dialogue
/// data. Available ones are: [`Json`], [`Bincode`], [`Cbor`]
///

View file

@ -89,7 +89,7 @@ where
Box::pin(async move {
let dialogue =
self.serializer.serialize(&dialogue).map_err(RedisStorageError::SerdeError)?;
self.conn.lock().await.set::<_, Vec<u8>, _>(chat_id, dialogue).await?;
() = self.conn.lock().await.set::<_, Vec<u8>, _>(chat_id, dialogue).await?;
Ok(())
})
}

View file

@ -28,11 +28,11 @@ pub trait HandlerExt<Output> {
/// It does so by the following steps:
///
/// 1. If an incoming update has no chat ID ([`GetChatId::chat_id`] returns
/// `None`), the rest of the chain will not be executed. Otherwise, passes
/// `Dialogue::new(storage, chat_id)` forwards.
/// `None`), the rest of the chain will not be executed. Otherwise,
/// passes `Dialogue::new(storage, chat_id)` forwards.
/// 2. If [`Dialogue::get_or_default`] on the passed dialogue returns `Ok`,
/// passes the dialogue state forwards. Otherwise, logs an error and the
/// rest of the chain is not executed.
/// passes the dialogue state forwards. Otherwise, logs an error and the
/// rest of the chain is not executed.
///
/// ## Dependency requirements
///

View file

@ -81,22 +81,22 @@ pub use teloxide_macros::BotCommands;
/// ```
///
/// # Enum attributes
/// 1. `#[command(rename_rule = "rule")]`
/// Rename all commands by `rule`. Allowed rules are `lowercase`, `UPPERCASE`,
/// `PascalCase`, `camelCase`, `snake_case`, `SCREAMING_SNAKE_CASE`,
/// `kebab-case`, and `SCREAMING-KEBAB-CASE`.
/// 1. `#[command(rename_rule = "rule")]` Rename all commands by `rule`.
/// Allowed rules are `lowercase`, `UPPERCASE`, `PascalCase`, `camelCase`,
/// `snake_case`, `SCREAMING_SNAKE_CASE`, `kebab-case`, and
/// `SCREAMING-KEBAB-CASE`.
///
/// 2. `#[command(prefix = "prefix")]`
/// Change a prefix for all commands (the default is `/`).
/// 2. `#[command(prefix = "prefix")]` Change a prefix for all commands (the
/// default is `/`).
///
/// 3. `#[command(description = "description")]` and `/// description`
/// Add a summary description of commands before all commands.
/// 3. `#[command(description = "description")]` and `/// description` Add a
/// summary description of commands before all commands.
///
/// 4. `#[command(parse_with = "parser")]`
/// Change the parser of arguments. Possible values:
/// - `default` - the same as the unspecified parser. It only puts all text
/// after the first space into the first argument, which must implement
/// [`FromStr`].
/// 4. `#[command(parse_with = "parser")]` Change the parser of arguments.
/// Possible values:
/// - `default` - the same as the unspecified parser. It only puts all
/// text after the first space into the first argument, which must
/// implement [`FromStr`].
///
/// ## Example
/// ```
@ -134,9 +134,8 @@ pub use teloxide_macros::BotCommands;
/// # }
/// ```
///
/// 5. `#[command(separator = "sep")]`
/// Specify separator used by the `split` parser. It will be ignored when
/// accompanied by another type of parsers.
/// 5. `#[command(separator = "sep")]` Specify separator used by the `split`
/// parser. It will be ignored when accompanied by another type of parsers.
///
/// ## Example
/// ```
@ -154,8 +153,8 @@ pub use teloxide_macros::BotCommands;
/// # }
/// ```
///
/// 6. `#[command(command_separator = "sep")]`
/// Specify separator between command and args. Default is a space character.
/// 6. `#[command(command_separator = "sep")]` Specify separator between command
/// and args. Default is a space character.
///
/// ## Example
/// ```
@ -181,34 +180,33 @@ pub use teloxide_macros::BotCommands;
/// # Variant attributes
/// All variant attributes override the corresponding `enum` attributes.
///
/// 1. `#[command(rename_rule = "rule")]`
/// Rename one command by a rule. Allowed rules are `lowercase`, `UPPERCASE`,
/// `PascalCase`, `camelCase`, `snake_case`, `SCREAMING_SNAKE_CASE`,
/// `kebab-case`, `SCREAMING-KEBAB-CASE`.
/// 1. `#[command(rename_rule = "rule")]` Rename one command by a rule. Allowed
/// rules are `lowercase`, `UPPERCASE`, `PascalCase`, `camelCase`,
/// `snake_case`, `SCREAMING_SNAKE_CASE`, `kebab-case`,
/// `SCREAMING-KEBAB-CASE`.
///
/// 2. `#[command(rename = "name")]`
/// Rename one command to `name` (literal renaming; do not confuse with
/// `rename_rule`).
/// 2. `#[command(rename = "name")]` Rename one command to `name` (literal
/// renaming; do not confuse with `rename_rule`).
///
/// 3. `#[command(description = "description")]` and `/// description`
/// Give your command a description. It will be shown in the help message.
/// 3. `#[command(description = "description")]` and `/// description` Give
/// your command a description. It will be shown in the help message.
///
/// 4. `#[command(parse_with = "parser")]`
/// Parse arguments of one command with a given parser. `parser` must be a
/// function of the signature `fn(String) -> Result<Tuple, ParseError>`, where
/// `Tuple` corresponds to the variant's arguments.
/// 4. `#[command(parse_with = "parser")]` Parse arguments of one command with
/// a given parser. `parser` must be a function of the signature `fn(String)
/// -> Result<Tuple, ParseError>`, where `Tuple` corresponds to the
/// variant's arguments.
///
/// 5. `#[command(hide)]`
/// Hide a command from the help message. It will still be parsed.
/// 5. `#[command(hide)]` Hide a command from the help message. It will still
/// be parsed.
///
/// 6. `#[command(alias = "alias")]`
/// Add an alias to a command. It will be shown in the help message.
/// 6. `#[command(alias = "alias")]` Add an alias to a command. It will be shown
/// in the help message.
///
/// 7. `#[command(aliases = ["alias1", "alias2"])]`
/// Add multiple aliases to a command. They will be shown in the help message.
/// 7. `#[command(aliases = ["alias1", "alias2"])]` Add multiple aliases to a
/// command. They will be shown in the help message.
///
/// 8. `#[command(hide_aliases)]`
/// Hide all aliases of a command from the help message.
/// 8. `#[command(hide_aliases)]` Hide all aliases of a command from the help
/// message.
///
/// ## Example
/// ```

View file

@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2024-03-20"
channel = "nightly-2024-07-03"
components = ["rustfmt", "clippy"]
profile = "minimal"