diff --git a/compiler/rustc_hir_typeck/src/intrinsicck.rs b/compiler/rustc_hir_typeck/src/intrinsicck.rs index 3c5eafd94848..362c07431e0a 100644 --- a/compiler/rustc_hir_typeck/src/intrinsicck.rs +++ b/compiler/rustc_hir_typeck/src/intrinsicck.rs @@ -82,8 +82,17 @@ pub fn check_transmute(&self, from: Ty<'tcx>, to: Ty<'tcx>, hir_id: HirId) { // Try to display a sensible error with as much information as possible. let skeleton_string = |ty: Ty<'tcx>, sk| match sk { - Ok(SizeSkeleton::Known(size)) => format!("{} bits", size.bits()), Ok(SizeSkeleton::Pointer { tail, .. }) => format!("pointer to `{tail}`"), + Ok(SizeSkeleton::Known(size)) => { + if let Some(v) = u128::from(size.bytes()).checked_mul(8) { + format!("{} bits", v) + } else { + // `u128` should definitely be able to hold the size of different architectures + // larger sizes should be reported as error `are too big for the current architecture` + // otherwise we have a bug somewhere + bug!("{:?} overflow for u128", size) + } + } Ok(SizeSkeleton::Generic(size)) => { if let Some(size) = size.try_eval_target_usize(tcx, self.param_env) { format!("{size} bytes") diff --git a/compiler/rustc_hir_typeck/src/writeback.rs b/compiler/rustc_hir_typeck/src/writeback.rs index a395858262f0..29abe921bbdc 100644 --- a/compiler/rustc_hir_typeck/src/writeback.rs +++ b/compiler/rustc_hir_typeck/src/writeback.rs @@ -136,7 +136,10 @@ fn tcx(&self) -> TyCtxt<'tcx> { fn write_ty_to_typeck_results(&mut self, hir_id: hir::HirId, ty: Ty<'tcx>) { debug!("write_ty_to_typeck_results({:?}, {:?})", hir_id, ty); - assert!(!ty.has_infer() && !ty.has_placeholders() && !ty.has_free_regions()); + assert!( + !ty.has_infer() && !ty.has_placeholders() && !ty.has_free_regions(), + "{ty} can't be put into typeck results" + ); self.typeck_results.node_types_mut().insert(hir_id, ty); } @@ -803,7 +806,11 @@ fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { // We must normalize erasing regions here, since later lints // expect that types that show up in the typeck are fully // normalized. - self.fcx.tcx.try_normalize_erasing_regions(self.fcx.param_env, t).unwrap_or(t) + if let Ok(t) = self.fcx.tcx.try_normalize_erasing_regions(self.fcx.param_env, t) { + t + } else { + EraseEarlyRegions { tcx: self.fcx.tcx }.fold_ty(t) + } } Ok(t) => { // Do not anonymize late-bound regions diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 7f944fb57459..47d8e5993fd8 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -338,7 +338,21 @@ pub(crate) fn try_define( } else { resolution.binding = Some(nonglob_binding); } - resolution.shadowed_glob = Some(glob_binding); + + if let Some(old_binding) = resolution.shadowed_glob { + assert!(old_binding.is_glob_import()); + if glob_binding.res() != old_binding.res() { + resolution.shadowed_glob = Some(this.ambiguity( + AmbiguityKind::GlobVsGlob, + old_binding, + glob_binding, + )); + } else if !old_binding.vis.is_at_least(binding.vis, this.tcx) { + resolution.shadowed_glob = Some(glob_binding); + } + } else { + resolution.shadowed_glob = Some(glob_binding); + } } (false, false) => { return Err(old_binding); diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index f205ff15ec3d..5bd9389a400a 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1940,8 +1940,6 @@ fn dont_escape(c: u8) -> bool { // While the same is not true for hashes, rustdoc only needs to be // consistent with itself when encoding them. st += "+"; - } else if b == b'%' { - st += "%%"; } else { write!(st, "%{:02X}", b).unwrap(); } diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 984358396ab2..1ccfca8d0d5f 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -386,6 +386,35 @@ function initSearch(rawSearchIndex) { if (query.literalSearch && parserState.totalElems - parserState.genericsElems > 0) { throw ["You cannot have more than one element if you use quotes"]; } + const typeFilter = parserState.typeFilter; + parserState.typeFilter = null; + if (name === "!") { + if (typeFilter !== null && typeFilter !== "primitive") { + throw [ + "Invalid search type: primitive never type ", + "!", + " and ", + typeFilter, + " both specified", + ]; + } + if (generics.length !== 0) { + throw [ + "Never type ", + "!", + " does not accept generic parameters", + ]; + } + return { + name: "never", + id: -1, + fullPath: ["never"], + pathWithoutLast: [], + pathLast: "never", + generics: [], + typeFilter: "primitive", + }; + } const pathSegments = name.split("::"); if (pathSegments.length > 1) { for (let i = 0, len = pathSegments.length; i < len; ++i) { @@ -399,6 +428,13 @@ function initSearch(rawSearchIndex) { } throw ["Unexpected ", "::::"]; } + + if (pathSegment === "!") { + pathSegments[i] = "never"; + if (i !== 0) { + throw ["Never type ", "!", " is not associated item"]; + } + } } } // In case we only have something like `
`, there is no name.
@@ -409,8 +445,6 @@ function initSearch(rawSearchIndex) {
if (isInGenerics) {
parserState.genericsElems += 1;
}
- const typeFilter = parserState.typeFilter;
- parserState.typeFilter = null;
return {
name: name,
id: -1,
@@ -459,10 +493,11 @@ function initSearch(rawSearchIndex) {
break;
}
if (foundExclamation !== -1) {
- if (start <= (end - 2)) {
+ if (foundExclamation !== start &&
+ isIdentCharacter(parserState.userQuery[foundExclamation - 1])
+ ) {
throw ["Cannot have associated items in macros"];
} else {
- // if start == end - 1, we got the never type
// while the never type has no associated macros, we still
// can parse a path like that
foundExclamation = -1;
@@ -478,7 +513,10 @@ function initSearch(rawSearchIndex) {
end = parserState.pos;
}
// if start == end - 1, we got the never type
- if (foundExclamation !== -1 && start <= (end - 2)) {
+ if (foundExclamation !== -1 &&
+ foundExclamation !== start &&
+ isIdentCharacter(parserState.userQuery[foundExclamation - 1])
+ ) {
if (parserState.typeFilter === null) {
parserState.typeFilter = "macro";
} else if (parserState.typeFilter !== "macro") {
diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs
index 5c6a94877884..55bf38110a6d 100644
--- a/src/tools/tidy/src/ui_tests.rs
+++ b/src/tools/tidy/src/ui_tests.rs
@@ -10,7 +10,7 @@
const ENTRY_LIMIT: usize = 900;
// FIXME: The following limits should be reduced eventually.
-const ISSUES_ENTRY_LIMIT: usize = 1898;
+const ISSUES_ENTRY_LIMIT: usize = 1896;
const ROOT_ENTRY_LIMIT: usize = 870;
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
diff --git a/tests/rustdoc-js-std/never.js b/tests/rustdoc-js-std/never.js
index ed3776b3c2ae..27d415b5e486 100644
--- a/tests/rustdoc-js-std/never.js
+++ b/tests/rustdoc-js-std/never.js
@@ -1,6 +1,14 @@
-const EXPECTED = {
- 'query': '!',
- 'others': [
- { 'path': 'std', 'name': 'never' },
- ],
-};
+const EXPECTED = [
+ {
+ 'query': '!',
+ 'others': [
+ { 'path': 'std', 'name': 'never' },
+ ],
+ },
+ {
+ 'query': '!::clone',
+ 'others': [
+ { 'path': 'std::never', 'name': 'clone' },
+ ],
+ },
+];
diff --git a/tests/rustdoc-js-std/parser-errors.js b/tests/rustdoc-js-std/parser-errors.js
index aa8ee86d6724..af7f63f99cbd 100644
--- a/tests/rustdoc-js-std/parser-errors.js
+++ b/tests/rustdoc-js-std/parser-errors.js
@@ -359,6 +359,15 @@ const PARSED = [
userQuery: "mod:a!",
error: 'Invalid search type: macro `!` and `mod` both specified',
},
+ {
+ query: "mod:!",
+ elems: [],
+ foundElems: 0,
+ original: "mod:!",
+ returned: [],
+ userQuery: "mod:!",
+ error: 'Invalid search type: primitive never type `!` and `mod` both specified',
+ },
{
query: "a!::a",
elems: [],
diff --git a/tests/rustdoc-js-std/parser-ident.js b/tests/rustdoc-js-std/parser-ident.js
index d9ee5fb564b6..f65a7ce6692b 100644
--- a/tests/rustdoc-js-std/parser-ident.js
+++ b/tests/rustdoc-js-std/parser-ident.js
@@ -8,11 +8,12 @@ const PARSED = [
pathLast: "r",
generics: [
{
- name: "!",
- fullPath: ["!"],
+ name: "never",
+ fullPath: ["never"],
pathWithoutLast: [],
- pathLast: "!",
+ pathLast: "never",
generics: [],
+ typeFilter: 15,
},
],
typeFilter: -1,
@@ -26,12 +27,12 @@ const PARSED = [
{
query: "!",
elems: [{
- name: "!",
- fullPath: ["!"],
+ name: "never",
+ fullPath: ["never"],
pathWithoutLast: [],
- pathLast: "!",
+ pathLast: "never",
generics: [],
- typeFilter: -1,
+ typeFilter: 15,
}],
foundElems: 1,
original: "!",
@@ -64,12 +65,21 @@ const PARSED = [
userQuery: "a!::b",
error: "Cannot have associated items in macros",
},
+ {
+ query: "!