diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
commit | dc0db358abe19481e475e10c32149b53370f1a1c (patch) | |
tree | ab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/idna/src | |
parent | Releasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/idna/src')
-rw-r--r-- | vendor/idna/src/lib.rs | 12 | ||||
-rw-r--r-- | vendor/idna/src/punycode.rs | 7 | ||||
-rw-r--r-- | vendor/idna/src/uts46.rs | 19 |
3 files changed, 27 insertions, 11 deletions
diff --git a/vendor/idna/src/lib.rs b/vendor/idna/src/lib.rs index 37d638741..92914f9ba 100644 --- a/vendor/idna/src/lib.rs +++ b/vendor/idna/src/lib.rs @@ -31,11 +31,23 @@ //! > This document specifies a mechanism //! > that minimizes the impact of this transition for client software, //! > allowing client software to access domains that are valid under either system. +#![no_std] + +// For forwards compatibility +#[cfg(feature = "std")] +extern crate std; + +extern crate alloc; + +#[cfg(not(feature = "alloc"))] +compile_error!("the `alloc` feature must be enabled"); #[cfg(test)] #[macro_use] extern crate assert_matches; +use alloc::string::String; + pub mod punycode; mod uts46; diff --git a/vendor/idna/src/punycode.rs b/vendor/idna/src/punycode.rs index 21955f359..faef379ca 100644 --- a/vendor/idna/src/punycode.rs +++ b/vendor/idna/src/punycode.rs @@ -13,8 +13,9 @@ //! `encode_str` and `decode_to_string` provide convenience wrappers //! that convert from and to Rust’s UTF-8 based `str` and `String` types. -use std::char; -use std::u32; +use alloc::{string::String, vec::Vec}; +use core::char; +use core::u32; // Bootstring parameters for Punycode static BASE: u32 = 36; @@ -168,7 +169,7 @@ impl Decoder { } pub(crate) struct Decode<'a> { - base: std::str::Chars<'a>, + base: core::str::Chars<'a>, pub(crate) insertions: &'a [(usize, char)], inserted: usize, position: usize, diff --git a/vendor/idna/src/uts46.rs b/vendor/idna/src/uts46.rs index ec2fd0b10..fb39c1512 100644 --- a/vendor/idna/src/uts46.rs +++ b/vendor/idna/src/uts46.rs @@ -11,7 +11,9 @@ use self::Mapping::*; use crate::punycode; -use std::{error::Error as StdError, fmt}; + +use alloc::string::String; +use core::fmt; use unicode_bidi::{bidi_class, BidiClass}; use unicode_normalization::char::is_combining_mark; use unicode_normalization::{is_nfc, UnicodeNormalization}; @@ -70,10 +72,10 @@ fn find_char(codepoint: char) -> &'static Mapping { } struct Mapper<'a> { - chars: std::str::Chars<'a>, + chars: core::str::Chars<'a>, config: Config, errors: &'a mut Errors, - slice: Option<std::str::Chars<'static>>, + slice: Option<core::str::Chars<'static>>, } impl<'a> Iterator for Mapper<'a> { @@ -274,7 +276,7 @@ fn passes_bidi(label: &str, is_bidi_domain: bool) -> bool { /// http://www.unicode.org/reports/tr46/#Validity_Criteria fn check_validity(label: &str, config: Config, errors: &mut Errors) { let first_char = label.chars().next(); - if first_char == None { + if first_char.is_none() { // Empty string, pass return; } @@ -475,7 +477,7 @@ impl Idna { /// http://www.unicode.org/reports/tr46/#ToASCII #[allow(clippy::wrong_self_convention)] - pub fn to_ascii<'a>(&'a mut self, domain: &str, out: &mut String) -> Result<(), Errors> { + pub fn to_ascii(&mut self, domain: &str, out: &mut String) -> Result<(), Errors> { let mut errors = self.to_ascii_inner(domain, out); if self.config.verify_dns_length { @@ -497,7 +499,7 @@ impl Idna { /// http://www.unicode.org/reports/tr46/#ToUnicode #[allow(clippy::wrong_self_convention)] - pub fn to_unicode<'a>(&'a mut self, domain: &str, out: &mut String) -> Result<(), Errors> { + pub fn to_unicode(&mut self, domain: &str, out: &mut String) -> Result<(), Errors> { if is_simple(domain) { out.push_str(domain); return Errors::default().into(); @@ -685,7 +687,7 @@ impl fmt::Debug for Errors { if !empty { f.write_str(", ")?; } - f.write_str(*name)?; + f.write_str(name)?; empty = false; } } @@ -708,7 +710,8 @@ impl From<Errors> for Result<(), Errors> { } } -impl StdError for Errors {} +#[cfg(feature = "std")] +impl std::error::Error for Errors {} impl fmt::Display for Errors { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |